/sing-me-a-song-api

An api made for you to recommend songs and receive recommendations

Primary LanguageHTML

Sing Me A Song API 🎶

An api made for you to recommend songs and receive recommendations

Documentation 🧾

Get recommendation

GET /recommendations/random

Possible responses

- 200: Success

What you will receive from this route

{
  "id": recommendationId,
  "name": recommendationName,
  "youtube_link": recommendationLink,
  "score": recommendationScore
}

if you get nothing from this request with a 200 status, it is because there is no music registered yet


Get top songs

GET /recommendations/top/:amount

Possible response status

- 400: You have sent a invalid amount
- 200: Success

What you will receive from this route

[
  {
    "id": recommendationId,
    "name": recommendationName,
    "youtube_link": recommendationLink,
    "score": recommendationScore
  },
]

Recommend song

POST /recommendations

Expected body

{
  name: String, at least 2 characters, 
  youtube_link: String, must be a valid youtube link
}

Possible response status

- 400: You have sent a invalid body, check your params
- 409: This music name or link is already been recommended
- 201: Success

Upvote song

POST /recommendations/:recommendation_id/upvote

Possible response status

- 400: You have sent a invalid id
- 404: The recommendation does not exist
- 204: Success

Downvote song

POST /recommendations/:recommendation_id/downvote

Possible response status

- 400: You have sent a invalid id
- 404: The recommendation does not exist
- 204: Success

How to run in your machine 🖥️

git clone https://github.com/victordurco/sing-me-a-song-api
cd sing-me-a-song-api
npm i 

Create a .env.dev file and fill it using your environment variables following the .env.dev.example

In your terminal

sudo su postgres
psql
CREATE DATABASE sing_me_a_song
\c sing_me_a_song

Copy everything in the DUMP.sql file and paste on the terminal
You can not exit the postgres admin, and run

npm run start:dev

How to run the tests in your machine 🖥️

Create a .env.test file and fill it using your environment variables following the .env.test.example file

In your terminal

sudo su postgres
psql
CREATE DATABASE sing_me_a_song_test;
\c sing_me_a_song_test

Copy everything in the DUMP.sql file and paste on the terminal

You can not exit the postgres admin, and run

npm run test

Deployment 🚀

You can interact with the server running on this link


Tech Stack 🧮

javascript postgres nodejs npm jest expressjs eslinter