thaisealves / sing-me-a-song

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sing Me a Song

Description

Microphone
The purpose of this project is to use unit, integration and end to end tests on an already working application. The tests where done with Jest and Cypress. The original project is a plataform to put songs recommendations by their YouTube links.

Built With

Typescript PostgreSQL Node.js Express.js Prisma

Features:

  • Post a recommendation on the plataform
  • Upvote and downvote a recommendation
  • Get the last 10 recommendations added
  • Get the top 10 recommendations added
  • Get a random recommendation from the app

References

Post a recommendation

To post a recommendation by the back-end:

POST /recommendations

Request:

Body Type Description
name string Required and Unique. The name of the song you're recommending
youtubeLink string Required. YouTube link from the song


Upvote

Getting a upvote for the recommendation

POST /recommendations/:id/upvote

Request:

Params Description
id Required. Id from the recommendation you want to upvote


Downvote

Getting a downvote for the recommendation

POST /recommendations/:id/downvote

Request:

Params Description
id Required. Id from the recommendation you want to downvote


Get last 10 recommendations

Seeing the last 10 added recommendations

GET /recommendations

Response:

[
  {
    "id": 2,
    "name": "Love on the Brain",
    "youtubeLink": "https://www.youtube.com/watch?v=QMP-o8WXSPM&ab_channel=Rihanna-Topic",
    "score": 100
  },
  {
    "id": 1,
    "name": "Chitãozinho E Xororó - Evidências",
    "youtubeLink": "https://www.youtube.com/watch?v=ePjtnSPFWK8&ab_channel=CHXVEVO",
    "score": 245
  }
]


Get top recommendations

Seeing the most scored recommendations.

GET /recommendations/top/:amount

Request:

Params Description
amount Required. Amount of recommendations to be shown

Response:

[
  {
    "id": 1,
    "name": "Chitãozinho E Xororó - Evidências",
    "youtubeLink": "https://www.youtube.com/watch?v=ePjtnSPFWK8&ab_channel=CHXVEVO",
    "score": 245
  },
  {
    "id": 2,
    "name": "Love on the Brain",
    "youtubeLink": "https://www.youtube.com/watch?v=QMP-o8WXSPM&ab_channel=Rihanna-Topic",
    "score": 100
  }
]


Get recommendation by ID

Seeing one recommendation that was required by ID.

GET /recommendations/:id

Request:

Params Description
id Required. ID of recommendations to be shown

Response:

{
  "id": 1,
  "name": "Chitãozinho E Xororó - Evidências",
  "youtubeLink": "https://www.youtube.com/watch?v=ePjtnSPFWK8&ab_channel=CHXVEVO",
  "score": 245
}


Get a random recommendation from the application

Seeing one recommendation that the application will choose.

GET /recommendations/random

Response:

{
  "id": 1,
  "name": "Chitãozinho E Xororó - Evidências",
  "youtubeLink": "https://www.youtube.com/watch?v=ePjtnSPFWK8&ab_channel=CHXVEVO",
  "score": 245
}


Starting the application for tests:

Clone application to machine

git clone git@github.com:thaisealves/sing-me-a-song.git

Run back end

npm run dev

Run front end

npm start

Open cypress, on front end

npx cypress open

Run integration tests, on back end

npm test

Run unit tests, on back end

npm run test:unit

Obs.: All the tests are setted to the .env.test file, so it has to be created. If trying to run on .env, you have to create a database by prisma:

npx prisma migrate dev

About


Languages

Language:TypeScript 47.7%Language:JavaScript 46.5%Language:HTML 3.2%Language:CSS 2.5%Language:Shell 0.1%