Skip to content

cjkelling/play

 
 

Repository files navigation

Play

Build Status

Core Contributors

Tech Stack

  • Node.js with Express.js
  • Knex.js for ORM
  • Jest.js for Testing

Jump-To

Setup

Running Tests

Running the Application

Documentation

Favorites

Favoriting Songs

Viewing all Songs

Viewing Specific Song

Deleting Specific Song

Playlists

Creating Playlists

Viewing all Playlists

Updating Playlists

Deleting Playlists

Favorites in Playlists

Adding a Favorite to a Playlist

Viewing Favorites in Playlists

Removing a Favorite to a Playlist

Description

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

Setup

Installing necessary dependencies

npm install
npm install -g knex

Set up databases

Development db Setup:
psql -c 'create database play_dev;' -U postgres

Test db Setup:
psql -c 'create database play_test;' -U postgres

Schema

Schema

Migrations

Development Migrations / Seeds:
knex migrate:latest
knex seed:run

Testing Migrations
knex migrate:latest --env test

Running Tests

npm test

Running the Application

npm start

Documentation

All endpoints go off of:

Development:
http://localhost:3000/api/v1/

Production:
https://play-play-dc.herokuapp.com/api/v1/

Favorites

Favoriting a Song

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
}

Viewing all favorited songs

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

Viewing specific favorited song

GET /favorites/:id

Example Response

Status: 200

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

Deleting specific favorited song

DELETE /favorites/:id

Example Response

Status 204

Playlists

Create a Playlist

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
}

Viewing all Playlists

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

Updating a Playlist

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 a Playlist

DELETE /playlists/:id

Example Response

Status 204

Favorites in Playlists

Add to Playlist

POST /playlists/:playlistId/favorites/:favoriteId

Example Response

Status: 201

{
  "Success": "{Song Title} has been added to {Playlist Title}!"
}

Viewing Favorites in a Playlist

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
}

Remove from Playlist

DELETE /playlists/:playlistId/favorites/:favoriteId

Example Response

Status 204

Back to Top

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 99.2%
  • Other 0.8%