Skip to content

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

Notifications You must be signed in to change notification settings

Lucas-zz/Sing_Me_A_Song_Back

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

36 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Have you ever asked someone for a music recommendation?

Status: Finished

About β€’ How It Works β€’ Pre-requisites β€’ Tech Stack β€’ How to contribute β€’ Author

About

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 πŸ™‚ .


How It Works

POST /recommendations

POST /recommendations

Expected Body

{
  "name": String, required,
  "youtubeLink": String, must be a valid youtube link, required,
}

Possible Response Status

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

POST /recommendations/:id/upvote

Expected Body

None

Possible Response Status

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

POST /recommendations/:id/downvote

Expected Body

None

Possible Response Status

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

GET recommendations/random

Expect to receive

// 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 )
}

Possible Response Status

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

GET recommendations/top/:amount

Expect to receive

[
  {
    "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
  }
]

Possible Response Status

400: 'Invalid amount';
200: 'Object with expected body'
404: 'No recommendations yet';
500: 'Error on Recommendations: Unable to get top recommendations - (error message here)'

Pre-requisites

Before you begin, you will need to have the following tools installed on your machine: Git, Node.js, VSCode.

Initial configs

// 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


Testing

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

Tech Stack

The following tools were used in the construction of the project-api:

Server (NodeJS)

See the file package.json

Utilities


How to contribute

  1. Fork the project.
  2. Create a new branch with your changes: git checkout -b feat/myFeatureName
  3. For each feature implemented, make a commit specifying what was done
  4. Submit your changes: git push -u origin feat/myFeatureName

Author


Lucas Azzolini Vieira

About

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published