A paired project completed in 10 days in Module 4 of Backend Engineering at Turing School of Software and Design.
This Express app consumes MusixMatch API and exposes endpoints that return song data and playlist data. The data format adheres to project specs provided by our instructors for each sprint.
- Create an Express API given specified endpoints and response formats
- Testing using Jest, with coverage at or above 95%
- Continuous integration using Travis CI
- Project management using GitHub Projects
- Advanced git workflow using development, staging and production environments
- Agile workflow - building project in sprints, daily standups, writing detailed user stories
- Deploying to staging and production environments each feature only after it was fully tested and functional in development.
- Migrations for many to many database relationship using Knex. Please see database schema design below.
Before cloning the repository:
- You will need to register and get an API key from Musix Match
- Download Postman
To get set up:
git clone git@github.com:alect47/Playlist.git
npm install
to install necessary dependencies- Add
.env
file in the root directory and add your API keys:MUSIXMATCH_API_KEY=<your Musix Match API Key>
To run the server: npm start
- Local server:
http://localhost:3000
- Production site:
https://playlist-express.herokuapp.com/
You’ll need to figure out a name for your database. We suggest calling it something like playlist_dev
and playlist_test
for testing.
We also suggest using Postico to track the changes to your database, you can also edit your tables in Postico.
To get things set up, you’ll need to access your PostgreSQL instance by typing in psql
into your terminal. Once there, you can create your database. Instructions to create database:
psql
CREATE DATABASE DATABASE_NAME_dev;
\q
Now you have a database for your test and development environments.
Once you have your database setup, you’ll need to run some migrations. You can do this by running the following command:
knex migrate:latest
for development
Most of the setup is going to be same as the one you did before. You’ll notice one small difference with setting the environment flag to test
.
psql
CREATE DATABASE DATABASE_NAME_test;
\q
knex migrate:latest --env test
Running tests are simple and require you to run the following command below:
npm test
When the tests have completed, you’ll get a read out of how things panned out.
In Postman, append the url to expose the below endpoints or click the Run in Postman
button.
- POST /api/v1/favorites
- GET /api/v1/favorites
- GET /api/v1/favorites/:id
- DELETE /api/v1/favorites
- POST /api/v1/playlists
- GET /api/v1/playlists
- PUT /api/v1/playlists/:id
- DELETE /api/v1/playlists/:id
- POST /api/v1/playlists/:id/favorites/:favorite_id
- GET /api/v1/playlists/:id/favorites
- DELETE /api/v1/playlists/:id/favorites/:favorite_id
body:
{
"song_title": "We Will Rock You",
"artist": "Queen",
}
status: 201
body:
{
"id": 1,
"title": "We Will Rock You",
"artistName": "Queen"
"genre": "Rock",
"rating": 88
}
[
{
"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
},
]
{
"id": 1,
"title": "We Will Rock You",
"artistName": "Queen"
"genre": "Rock",
"rating": 88
}
status code 204
body:
{
"title": "Cleaning House"
}
status: 201
body:
{
"id": 1,
"title": "Cleaning House",
"created_at": 2019-11-26T16:03:43+00:00,
"updated_at": 2019-11-26T16:03:43+00:00,
}
status: 200
body:
[
{
"id": 1,
"title": "Cleaning House",
"created_at": 2019-11-26T16:03:43+00:00,
"updated_at": 2019-11-26T16:03:43+00:00
},
{
"id": 2,
"title": "Running Mix",
"created_at": 2019-11-26T16:03:43+00:00,
"updated_at": 2019-11-26T16:03:43+00:00
},
]
body:
{
"title": "Updated Title"
}
status: 200
body:
{
"id": 1,
"title": "Updated Title",
"created_at": 2019-11-26T16:03:43+00:00,
"updated_at": 2019-11-26T16:03:43+00:00
}
status: 204
status: 201
body:
"Success": "We Will Rock You has been added to Cleaning House!"
status: 200
body:
{
"id": 1,
"title": "Cleaning House",
"songCount": 2,
"songAvgRating": 27.5,
"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
}
],
"created_at": 2019-11-26T16:03:43+00:00,
"updated_at": 2019-11-26T16:03:43+00:00
}
status: 204