This is an application where you can post and get music recommendations. It has a scoring system so you can vote for your favorite songs.
- NodeJS
- ExpressJS
- nodemon
- pg
- dotenv
- cors
- Jest
- prettier
- eslint
- Clone this repo
git clone https://github.com/Deltinha/sing-me-a-song.git
- Install dependencies
npm install
- Navigate to the repository folder and run the following commands to create a database
sudo -u postgres createdb -T template0 sing_me_a_song
sudo -u postgres psql sing_me_a_song < 'dump.sql'
- Create a new file called
.env
in the root folder using.env-example
as template. Feed the newly created file with the info of your database. - To run in development mode
npm run dev
POST /recommendations
You can insert a recommendation by using this endpoint. The body contents should be a JSON object following the example below.
{
"name": "Maroon 5 - Memories",
"youtubeLink": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
}
POST /recommendations/:id/upvote
You can increase a recommendation's score using this endpoint.
POST /recommendations/:id/downvote
You can decrease a recommendation's score using this endpoint.
GET /recommendations/random
You can get a single random recommendation by using this endpoint.
{
"id": 15,
"name": "Olivia Rodrigo - good 4 u",
"youtubeLink": "https://www.youtube.com/watch?v=Yb6dZ1IFlKc",
"score": 25
}
GET /recommendations/top/:amount
You can get the top recommendations by using this endpoint.
[
{
"id": 10,
"name": "Maroon 5 - Memories",
"youtubeLink": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
"score": 32
},
{
"id": 15,
"name": "Olivia Rodrigo - good 4 u",
"youtubeLink": "https://www.youtube.com/watch?v=Yb6dZ1IFlKc",
"score": 25
},
...
]