A music analysis tool to compare your music taste with your friends.
- Node.js v.18.13.0+ (Has not been tested with any other version yet)
- Clone this repo, or download it
- Open a terminal and navigate to the project root directory
- Run the command
npm install
- Duplicate the file called
sample.envand rename one of them to.env - Fill in the values for the environment variables
- Open a terminal and navigate to the project root directory
Now you have two options, developer mode or production mode.
To run the API in developer mode:
- Run the command
npm run compilerto open a TypeScript compiler in "watch mode" to continuously compile changes in the source code on every save. - Run the command
npm run devStartto start a server with Nodemon on your local machine which refreshes on every change in the compiled. It will be hosted on the port specified by thePORTenvironment variable. If noPORTenvironment variable is provided, it defaults to port 4000.
To run the API in production mode:
- Run the command
npm run compileto compile the TypeScript source code into executable JavaScript code. - Run the command
npm run startto start a server on your local machine using Node.js
There are many automated tests, both unit tests and integration tests. To run the entire test suite, run the command npm run test.
There are some requirements for the integration tests to work. A test.env file must be added to the /tests/ folder. To do this:
- Duplicate the file
/tests/sample.test.env - Rename the duplicated file to
test.env, keeping it in the/tests/folder - Fill in the required environment variable values. More on which variable are required below
For the database tests and the database driver tests, these will both require a valid MongoDB database is running. Provide the connection URL and test database name in the environments variables.
For the API endpoint tests, a valid access token from Spotify is required. The recommended way to get one is to manually get one using your browser while the API is running in development mode:
- With the API running on your local machine, paste the URL
http://localhost:<PORT>/auth/loginand make sure to replace<PORT>with the port the API server is running on - Copy the link that is provided in the browser from visiting that URL and paste it into your browser search bar
- Login in with your Spotify credentials and accept their terms
- Copy the access token that is provided in your browser
- Paste the access token in your
/tests/test.envfile afterSPOTIFY_API_ACCESS_TOKEN=Bearer. Make sure that the "Bearer" text is still there and that there is a space between "Bearer" and the access code you just pasted
There are also test runner groups available, which are used to specify a certain type of tests to run. Here is a list of the current groups:
- database
- model
- integration
- unit
- service
Readme Template