Skip to content

alect47/Playlist

Repository files navigation

Playlist

Contributors:

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.

Areas of focus:

  • 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.

Tech Stack

Local Setup

Before cloning the repository:

To get set up:

  • git clone [email protected]: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/

Set up your local database

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.

Migrations

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

Set up your test database

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 your tests

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.

Running in Postman

In Postman, append the url to expose the below endpoints or click the Run in Postman button.

Endpoints

  1. POST /api/v1/favorites Run in Postman
  2. GET /api/v1/favorites Run in Postman
  3. GET /api/v1/favorites/:id Run in Postman
  4. DELETE /api/v1/favorites Run in Postman
  5. POST /api/v1/playlists Run in Postman
  6. GET /api/v1/playlists Run in Postman
  7. PUT /api/v1/playlists/:id Run in Postman
  8. DELETE /api/v1/playlists/:id Run in Postman
  9. POST /api/v1/playlists/:id/favorites/:favorite_id Run in Postman
  10. GET /api/v1/playlists/:id/favorites Run in Postman
  11. DELETE /api/v1/playlists/:id/favorites/:favorite_id Run in Postman

Song Endpoints

Run in Postman

body:
{
  "song_title": "We Will Rock You",
  "artist": "Queen",
}

Expected Successful Response:

status: 201
body:
{
  "id": 1,
  "title": "We Will Rock You",
  "artistName": "Queen"
  "genre": "Rock",
  "rating": 88
}

Run in Postman

Expected Successful Response:

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

Run in Postman

Expected Successful Response:

{
  "id": 1,
  "title": "We Will Rock You",
  "artistName": "Queen"
  "genre": "Rock",
  "rating": 88
}

Run in Postman

Expected Successful Response:

status code 204

Playlist Endpoints

Run in Postman

body:
{
  "title": "Cleaning House"
}

Expected Successful Response:

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,
}

Run in Postman

Expected Successful Response:

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
  },
]

Run in Postman

body:
{
  "title": "Updated Title"
}

Expected Successful Response:

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
  }

Run in Postman

Expected Successful Response:

status: 204

Playlist-Songs Endpoints

Run in Postman

Expected Successful Response:

status: 201
body:
"Success": "We Will Rock You has been added to Cleaning House!"

Run in Postman

Expected Successful Response:

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
}

Run in Postman

Expected Successful Response:

status: 204

Database Schema

db_diagram.png

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages