In this project I was given the task of doing the unit tests, integration and e2e
Sing me a song is an application for anonymous song recommendation. The more people like a recommendation, the more likely it is to be recommended to others.
- unitary (backEnd)
- integration (backEnd)
- e2e (frontEnd)
POST /recommendations
Params | Type | Description |
---|---|---|
name |
string |
Required |
youtubeLink |
string |
Required, youtube link |
Status code | Cause |
---|---|
400 |
Request in wrong format |
409 |
try to register with an name already registered |
POST /recommendations/:id/upvote
Status code | Cause |
---|---|
404 |
id not found |
If the score falls below -5, the recommendation should be deleted.
POST /recommendations/:id/downvote
Status code | Cause |
---|---|
404 |
id not found |
GET /recommendations
[
{
"id": 1,
"name": "Chitãozinho E Xororó - Evidências",
"youtubeLink": "https://www.youtube.com/watch?v=ePjtnSPFWK8&ab_channel=CHXVEVO",
"score": 245
}
]
GET /recommendations/:id
Status code | Cause |
---|---|
404 |
id not found |
{
"id": 1,
"name": "Chitãozinho E Xororó - Evidências",
"youtubeLink": "https://www.youtube.com/watch?v=ePjtnSPFWK8&ab_channel=CHXVEVO",
"score": 245
}
- 70% of the times they hit this route: a song with a score greater than 10 should be randomly recommended
- 30% of the times they hit this route: a song with a score between -5 and 10 (inclusive), should be randomly recommended
- If there are only songs with a score above 10 or only below/equal to 10, 100% of the time any song must be drawn
- If there is no song registered, status 404 must be returned
GET /recommendations/random
{
"id": 1,
"name": "Chitãozinho E Xororó - Evidências",
"youtubeLink": "https://www.youtube.com/watch?v=ePjtnSPFWK8&ab_channel=CHXVEVO",
"score": 245
},
- Lists the songs with the most points and their score. Top x songs are returned (parameter :amount of the route), ordered by score (highest first)
GET /recommendations/top/:amount
[
{
"id": 150,
"name": "Chitãozinho E Xororó - Evidências",
"youtubeLink": "https://www.youtube.com/watch?v=ePjtnSPFWK8&ab_channel=CHXVEVO",
"score": 245
},
{
"id": 12,
"name": "Falamansa - Xote dos Milagres",
"youtubeLink": "https://www.youtube.com/watch?v=ePjtnSPFWK8&ab_channel=CHXVEVO",
"score": 112
},
...
]
To run this project, you will need to add the following environment variables to your .env file
DATABASE_URL = postgres://UserName:Password@Hostname:5432/DatabaseName
PORT = number #recommended:5000
NODE_ENV = string #TEST if it is a dev environment
Clone the project
git clone https://github.com/ThVinicius/sing_me_a_song_backEnd.git
Go to the project directory
cd sing_me_a_song_backEnd
Install dependencies
npm install
Create database
npx prisma migrate dev
Start the server
npm run start
Run tests
npm test
- Vinicius Pacheco is a student at Driven Education and is putting effort into it to switch careers. Nowadays he works with Engineering,
looking forward to become a Dev.