- Node.js with Express.js
- Knex.js for ORM
- Jest.js for Testing
Adding a Favorite to a Playlist
Play is an API for favoriting songs based off of the Musixmatch API providing many different endpoints.
This API is JSON 1.0
compliant and only accepts x-www-form-urlencoded JSON bodies
and query parameters
npm install
npm install -g knex
Development db Setup:
psql -c 'create database play_dev;' -U postgres
Test db Setup:
psql -c 'create database play_test;' -U postgres
Development Migrations / Seeds:
knex migrate:latest
knex seed:run
Testing Migrations
knex migrate:latest --env test
npm test
npm start
Development:
http://localhost:3000/api/v1/
Production:
https://play-play-dc.herokuapp.com/api/v1/
POST /favorites
Required Request Body
Ex: { title: "We Will Rock You", artistName: "Queen" }
Example Response
Status: 201
{
"id": 1,
"title": "We Will Rock You",
"artistName": "Queen"
"genre": "Rock",
"rating": 88
}
GET /favorites
Example Response
Status: 200
[
{
"id": 1,
"title": "We Will Rock You",
"artistName": "Queen"
"genre": "Rock",
"rating": 88
},
{
"id": 2,
"title": "Careless Whisper",
"artistName": "George Michael"
"genre": "Pop",
"rating": 93
},
]
GET /favorites/:id
Example Response
Status: 200
{
"id": 1,
"title": "We Will Rock You",
"artistName": "Queen"
"genre": "Rock",
"rating": 88
}
DELETE /favorites/:id
Example Response
Status 204
POST /playlists
Required Request Body
Ex: { title: "Cleaning House" }
Example Response
Status: 201
{
"id": 1,
"title": "Cleaning House",
"createdAt": 2019-11-26T16:03:43+00:00,
"updatedAt": 2019-11-26T16:03:43+00:00
}
GET /playlists
Example Response
Status: 200
[
{
"id": 1,
"title": "yolo",
"createdAt": "2020-02-12T15:26:09.179Z",
"updatedAt": "2020-02-12T15:26:09.179Z",
"favorites": [
{
"id": 1,
"title": "We Will Rock You",
"artistName": "Queen",
"genre": "Rock",
"rating": 88
},
{
"id": 2,
"title": "Careless Whisper",
"artistName": "George Michael",
"genre": "Unknown",
"rating": 93
}
],
"songCount": 2,
"songAvgRating": 90.5
},
{
"id": 2,
"title": "new jams",
"createdAt": "2020-02-13T03:09:18.605Z",
"updatedAt": "2020-02-13T03:09:18.605Z",
"favorites": [],
"songCount": 0,
"songAvgRating": 0
}
]
PUT /playlists/:id
Required Request Body
Available Params: title
Ex:
{
title: "My Jams"
}
Example Response
Status: 201
{
"id": 2,
"title": "My Jams",
"createdAt": 2019-11-26T16:03:43+00:00,
"updatedAt": 2019-11-26T16:03:43+00:00
}
DELETE /playlists/:id
Example Response
Status 204
POST /playlists/:playlistId/favorites/:favoriteId
Example Response
Status: 201
{
"Success": "{Song Title} has been added to {Playlist Title}!"
}
GET /playlists/:playlistId/favorites
Example Response
Status: 200
{
"id": 1,
"title": "Cleaning House",
"createdAt": "2019-11-26T16:03:43+00:00",
"updatedAt": "2019-11-26T16:03:43+00:00",
"favorites" : [
{
"id": 1,
"title": "We Will Rock You",
"artistName": "Queen"
"genre": "Rock",
"rating": 25
},
{
"id": 4,
"title": "Back In Black",
"artistName": "AC/DC"
"genre": "Rock",
"rating": 30
}
],
"songCount": 2,
"songAvgRating": 27.5
}
DELETE /playlists/:playlistId/favorites/:favoriteId
Example Response
Status 204