Skip to content

NatanBrito/sing-me-a-song

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Sing me a song

Built With


Description

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.


Features

  • Create a recommendation music
  • Upvote and downvote each music
  • Get a random music
  • Get a specific top musics based in number of votes

API Reference

RECOMMENDATIONS

Create a recommendation

POST /recommendation

Request:

Body Type Description
name string Required. recommendation name
youtubeLink string Required. recommendation url

youtubeLinkRegex = /^(https?\:\/\/)?(www\.youtube\.com|youtu\.?be)\/.+$/;

Get recommendations

GET /recommendations

Response:

[
  {
    "id": 3,
    "name": "Numb",
    "youtubeLink": "https://www.youtube.com/watch?v=mRXKnG2eugU",
    "score": 0
  },
  {
    "id": 2,
    "name": "Feels Like Home (Radio Edit)",
    "youtubeLink": "https://www.youtube.com/watch?v=5CY1vbxP4Jo",
    "score": 0
  },
  {
    "id": 1,
    "name": "All That Really Matters",
    "youtubeLink": "https://www.youtube.com/watch?v=3gxxW5NqICc",
    "score": 0
  }
]

Get a recommendation by id

GET /recommendations/:id

Request:

Params Type Description
id number Required.

Response:

{
  "id": 1,
  "name": "All That Really Matters",
  "youtubeLink": "https://www.youtube.com/watch?v=3gxxW5NqICc",
  "score": 0
}

Post a upvote for a recommendation

POST /recommendations/:id/upvote

Request:

Params Type Description
id number Required.

Post a downvote for a recommendation

POST /recommendations/:id/downvote

Request:

Params Type Description
id number Required.

Get a top musics recommendations - based in amount params - with decreasing score

GET /recommendations/top/:amount

Request:

Params Type Description
amount number Required.

example = /recommendations/top/2

Response:

[
  {
    "id": 1,
    "name": "All That Really Matters",
    "youtubeLink": "https://www.youtube.com/watch?v=3gxxW5NqICc",
    "score": 1
  },
  {
    "id": 2,
    "name": "Feels Like Home (Radio Edit)",
    "youtubeLink": "https://www.youtube.com/watch?v=5CY1vbxP4Jo",
    "score": 0
  }
]

Get a random recommendation music

POST /recommendations/random

Response:

{
  "id": 1,
  "name": "All That Really Matters",
  "youtubeLink": "https://www.youtube.com/watch?v=3gxxW5NqICc",
  "score": 1
}

Environment Variables

To run this project, you will need to add the following environment variables to your .env file

Back-end .env file

DATABASE_URL = postgres://UserName:Password@Hostname:5432/DatabaseName?schema=public

PORT = number #recommended:5000

NODE_ENV=development

Back-end .env.test file

DATABASE_URL = postgres://UserName:Password@Hostname:5432/DatabaseName-tests?schema=public

PORT = number #recommended:5000

NODE_ENV=test

Front-end .env file

REACT_APP_API_BASE_URL=http://


Run Locally

Clone the project

  git clone https://github.com/thalesgomest/sing-me-a-song.git

Go to the project directory

  cd sing-me-a-song/

Install dependencies

  npm install

Start the server

  npm run start

Tests Back-end

Integration and unitary tests

Go to the back-end project directory

  cd sing-me-a-song/back-end

Install dependencies

  npm install

Install prisma database

  npx prisma migrate dev

For run only integration tests

  npm run test:integration

For run only unitary tests

  npm run test:unit

For run both tests: unitary and integration

  npm run test

Tests Front-end

E2E tests with cypress

Go to the back-end project directory and up the server

  cd sing-me-a-song/back-end
  npm run dev

Go to the front-end project directory

  cd sing-me-a-song/front-end

Install dependencies

  npm install

Up the front-end application

  npm start

Open cypress graphic interface

  npx cypress open

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 47.9%
  • JavaScript 43.9%
  • HTML 4.4%
  • CSS 3.4%
  • Shell 0.4%