Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
IkeHunter authored Oct 2, 2024
2 parents c0e643e + 5b52906 commit 0c90728
Show file tree
Hide file tree
Showing 7 changed files with 214 additions and 107 deletions.
81 changes: 51 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,73 +22,94 @@ This project has two Github pages this is designated for the Backend Development

## Project Install One-Liner

Copy this command to quickly get started. Must have docker, docker-compose, and git installed.
Copy and paste the following command into your terminal to clone the repository and get the server up and running.

This assumes you have **Docker**, **Docker Compose**, and **Git** installed.

```sh
git clone git@github.com:ufosc/Jukebox-Server.git && cd Jukebox-Server && cp sample.env .env && docker-compose up --build
```

## Getting started

Use the following commands to download the project locally and get it running with nodemon.
Follow these steps to download the project locally and get it running with nodemon.

1. Clone the repository:

```sh
git clone <git url>
git clone https://github.com/ufosc/Jukebox-Server.git
cd Jukebox-Server
```

2. Set up the environment:

```sh
cp sample.env .env
```

3. Build and run the Docker containers:

```sh
docker-compose build
docker-compose up
```

We use docker compose to easily connect to databases and other container images. It could alternatively be run using `npm run dev`; however, this is not guaranteed to always work.
We use Docker Compose to manage the server and its dependencies, including databases and other containers. While you can run the server using `npm run dev`, Docker Compose provides more reliability.

Once the server is running, visit <https://localhost:8000/login> to authenticate with Spotify.

## Technology Stack (with documentation link)

| Use | Tech |
| ---------------------- | ------------------------------------------------------------------------------------------- |
| Language | [TypeScript](https://www.typescriptlang.org/docs/handbook/typescript-from-scratch.html) |
| Backend Runtime | [Node.js](https://nodejs.dev/en/learn/) |
| Backend Framework | [Express.js](https://expressjs.com/en/4x/api.html#express) |
| SQL Database | [Postgres](https://node-postgres.com/) |
| Unit Tests | [Mocha](https://semaphoreci.com/community/tutorials/getting-started-with-node-js-and-mocha) |
| Auto Documentation | [Swagger](https://swagger.io/docs/specification/about/) |
| Infrastructure as Code | [Terraform](#) |
| Hosting | [AWS](#) |
| Containerization | [Docker](https://docs.docker.com/get-started/) |
| Use | Tech |
| ---------------------- | --------------------------------------------------------------------------------------- |
| Language | [TypeScript](https://www.typescriptlang.org/docs/handbook/typescript-from-scratch.html) |
| Backend Runtime | [Node.js](https://nodejs.dev/en/learn/) |
| Backend Framework | [Express.js](https://expressjs.com/en/4x/api.html#express) |
| SQL Database | [Postgres](https://node-postgres.com/) |
| Unit Tests | [Jest](https://jestjs.io/docs/getting-started) |
| Auto Documentation | [Swagger](https://swagger.io/docs/specification/about/) |
| Infrastructure as Code | [Terraform](https://developer.hashicorp.com/terraform/docs) |
| Hosting | [AWS](https://docs.aws.amazon.com/) |
| Containerization | [Docker](https://docs.docker.com/get-started/) |

## Workflow

To start with, look over the issues list and either pick out a task from there, or you can plan out your own idea. After that, clone the main branch onto you local system and get the server up and running using the commands above.
1. Start by reviewing the [issues list](https://github.com/ufosc/Jukebox-Server/issues) and pick a task or propose a new feature.

Once you have the server up and running, create a feature branch and start coding!
2. Clone the main branch onto your local system:

```sh
git checkout -b feature/something-brilliant
git clone git@github.com:ufosc/Jukebox-Server.git && cd Jukebox-Server && cp sample.env .env && docker-compose up --build
```

Remember, branches need to be focused on specific and full-working features. These features can be small, like adding some documentation, or large, like adding advanced authentication.
3. Create a feature branch:

After you are finished with the feature, make sure you have written at least 3 unit tests, otherwise the pull request might not be accepted. Ideally, you should write tests before making the new feature to follow with the TDD paradigm, but this takes a bit of practice.
Include Link/Example to TDD Paradigm here.
```sh
git checkout -b feature/[insert name here]
```

After you are satisfied, push your branch to GitHub and submit a pull request for you new branch.
_Ensure your branch focuses on a specific, fully working feature e.g. documentation, implementing new authentication logic. [Read more about feature branch workflow here](https://craftquest.io/guides/git/git-workflows/feature-branch-workflow)._

The pull request will then be tested by a maintainer, and merged into the main branch.
Before submitting a pull request, write at least three unit tests. If possible, follow the Test-Driven Development (TDD) paradigm, which involves writing tests before coding the feature itself. [Learn more about TDD here](https://www.browserstack.com/guide/what-is-test-driven-development).

4. Push your feature branch and submit a pull request (PR). Your PR will be reviewed and tested by a maintainer before merging.

## Testing

When creating unit tests please use Mocha Formatting. REMEMBER TO HAVE AT LEAST 3 UNIT TESTS.
var expect = require("chai").expect;
var converter = require("../app/converter");
describe("JukeboxTest", function() {
// specification code
// Play from this specific playlist, source from another artist, etc.
We use Jest for unit testing. **At least 3 unit tests** must accompany any new feature.

Example of Jest Formatting:

```
const converter = require('../app/converter');
// Example test
test('Jukebox Unit Test', () => {
expect(converter.convertPlaylist('playlist-id')).toBe('expected-output');
});
```

Running the following command will run Mocha, which will look for files inside the `/test` directory.
To run the tests, use the following command. This will execute Jest, which will look for test files inside the `/test` directory:

```sh
docker-compose run --rm api sh -c "npm test"
Expand Down
2 changes: 1 addition & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const config = {
// coverageDirectory: "coverage",

// An array of regexp pattern strings used to skip coverage collection
coveragePathIgnorePatterns: ['/node_modules/', '/build/', 'docs/', 'index.ts', 'config/', 'lib/', 'types/'],
coveragePathIgnorePatterns: ['/node_modules/', '/build/', 'docs/', 'index.ts', 'config/', 'lib/', 'types/', '_deprecated/'],

// Indicates which provider should be used to instrument code for coverage
coverageProvider: 'v8',
Expand Down
11 changes: 9 additions & 2 deletions server/docs/swagger.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BASE_URL } from 'server/config'
import type { IGroup, IGroupFields } from 'server/models'
import type { IGroup, IGroupFields, IUser } from 'server/models'
import { ResponseCodes, formatJsonResponse } from 'server/utils'
import swaggerAutogen from 'swagger-autogen'

Expand Down Expand Up @@ -44,7 +44,14 @@ const doc = {
},
definitions: {
IGroupFields: { name: '', ownerId: '' } as IGroupFields,
IGroup: { id: '', name: '', ownerId: '' } as IGroup
IGroup: { id: '', name: '', ownerId: '' } as IGroup,
IUser: new class implements IUser {
id: string = 'some-id'
email: string = 'user@example.com'
firstName?: string | undefined
lastName?: string | undefined
image?: string | undefined
}()
}
}
const generateResponseDocs = () => {
Expand Down
Loading

0 comments on commit 0c90728

Please sign in to comment.