π΅ Sing Me A Song API
About β’ How It Works β’ Pre-requisites β’ Tech Stack β’ How to contribute β’ Author
Sing Me A Song is an API for anonymous song recommendation. The more people like a recommendation, the more likely it is to be recommended to others π .
POST /recommendations
{
"name": String, required,
"youtubeLink": String, must be a valid youtube link, required,
}
422: 'The request body contains invalid elements';
201: 'Successfully created!';
409: 'Recommendations names must be unique';
500: 'Error on Recommendations: Unable to post recommendation - (error message here)'
POST /recommendations/:id/upvote
None
400: 'Id is invalid';
200: 'Successfully updated! +1';
404: 'Recommendation not found';
500: 'Error on Recommendations: Unable to update recommendation - (error message here)'
POST /recommendations/:id/downvote
None
400: 'Id is invalid';
200: 'Successfully updated! -1';
404: 'Recommendation not found';
500: 'Error on Recommendations: Unable to update recommendation - (error message here)'
GET recommendations/random
// 70% chance
{
"id": 1,
"name": "The Trail - The Witcher 3 Trailer Music",
"youtubeLink": "https://www.youtube.com/watch?v=s3L0_ez0Dg4",
"score": Good score ( > 10 )
}
// 30% chance
{
"id": 1,
"name": "Toss A Coin to Your Witcher",
"youtubeLink": "https://www.youtube.com/watch?v=waMkFIzvDpE",
"score": Bad score ( <= 10 )
}
400: 'Id is invalid';
200: 'Object with expected body'
404: 'No recommendations yet';
500: 'Error on Recommendations: Unable to get recommendation - (error message here)'
GET recommendations/top/:amount
[
{
"id": 1,
"name": "The Trail - The Witcher 3 Trailer Music",
"youtubeLink": "https://www.youtube.com/watch?v=s3L0_ez0Dg4",
"score": 0
},
{
"id": 2,
"name": "Toss A Coin to Your Witcher",
"youtubeLink": "https://www.youtube.com/watch?v=waMkFIzvDpE",
"score": 0
},
{
"id": 3,
"name": "Netflix The Witcher - Full Original Soundtrack",
"youtubeLink": "https://www.youtube.com/watch?v=uv54ec8Pg1k",
"score": 0
}
]
400: 'Invalid amount';
200: 'Object with expected body'
404: 'No recommendations yet';
500: 'Error on Recommendations: Unable to get top recommendations - (error message here)'
Before you begin, you will need to have the following tools installed on your machine: Git, Node.js, VSCode.
// Clone this repository
$ git clone git@github.com:Lucas-zz/Sing_Me_A_Song_Back.git
// Access the project folder cmd/terminal
$ cd Sing_Me_A_Song_Back
// Install the dependencies
$ npm install
// Create a .env file and fill it using your environment variables following the .env.example
// Create the Database (designed with Prisma)
$ npx prisma migrate dev
// Run the application in development mode
$ npm run dev
// The server will start at port of your choice, as determined by the .env file
You can find the .env.example here
To run the integration and unit tests, some minor configurations will need to be done first
// Create a .env.test file and fill it using your environment variables following the .env.test.example
// Create a new database made for testing
$ npx dotenv -e .env.test prisma migrate dev
// Populate the test database with the seed
$ npm run seed
// Run the application in the test mode
$ npm run dev:test
// Run the automated tests
$ npm run test
You can find the .env.test.example here
The following tools were used in the construction of the project-api:
Server (NodeJS)
See the file package.json
Utilities
- Editor: Visual Studio Code
- API Test: Jest
- Front Test: Cypress
- Fork the project.
- Create a new branch with your changes:
git checkout -b feat/myFeatureName
- For each feature implemented, make a commit specifying what was done
- Submit your changes:
git push -u origin feat/myFeatureName