Code Monkey home page Code Monkey logo

play_play_express's Introduction

Play Play

Build Status

Table of Contents

Introduction

Intial Setup

Follow the following steps to setup application locally. Setup time is 5-10 minutes.

Installing necessary dependencies

The easiest way to get started is to run the following command. This will pull down any necessary dependencies that your app will require.

npm install

Set up your local database

You’ll need to figure out a name for your database. We suggest calling it something like play_play_express_dev.

You will also need to update the development section of the knexfile with the database name.

To get things set up, you’ll need to access your Postgres instance by typing in psql into your terminal. Once there, you can create your database by running the comment CREATE DATABASE PUT_DATABASE_NAME_HERE_dev;.

Migrations

Once you have your database setup, you’ll need to run some migrations (if you have any). You can do this by running the following command:

knex migrate:latest

Instructions to create database, run migrations, and seed:

psql
CREATE DATABASE DATABASE_NAME_dev;
\q

knex migrate:latest
knex seed:run

Adding Environment Keys

Enviroment keys are required to use the Google Geocoding and DarkSky Service.

Obtain a Musix Match API key

Create an .env file in the root of the dictory

In the .env file, add the following information:

MUSIX_MATCH_API_KEY= your_musix_match_api_key

Add the .env to your .gitignore to avoid the file being pushed to GitHub

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

You will also need to update the test section of the knexfile with the test database name.

How to Run Tests

Running tests are simple and require you to run the following command below:

npm test

How to Use

We recommend using Postman to hit endpoints.

Endpoints

Root

Production address

https://play-play-express.herokuapp.com/

Local address

http://localhost:3000/

Get All Favorite Tracks

Returns all favorite tracks from the database

GET /api/v1/favorites

If successful, application will respond with status code 200 and JSON with array of tracks.

Run in Postman

Sample Successful Response:

[
    {
        "id": 1,
        "title": "Bailamos",
        "artistName": "Enrique Iglesias",
        "genre": "Pop",
        "rating": 88
    },
    {
        "id": 2,
        "title": "The Chain",
        "artistName": "Fleetwood Mac",
        "genre": "Rock",
        "rating": 52
    }
]

Get a Single Favorite Track

Returns a single favorite track from the database

GET /api/v1/favorites/:id

:id: id of desired favorite track

If successful, application will respond with status code 200 and JSON of requested track.

Run in Postman

Sample Successful Response:

[
    {
        "id": 2,
        "title": "The Chain",
        "artistName": "Fleetwood Mac",
        "genre": "Rock",
        "rating": 52
    }
]

Delete a Single Favorite Track

Delete a single favorite track from the database

DELETE /api/v1/favorites/:id

:id: id of the track to be deleted

If successful, application will respond with 201 status.

Run in Postman

Add a New Single Favorite Track

Add a new favorite track. The track title must be included in the POST request body. Including the track's artist is optional.

POST /api/v1/favorites

title: title of the desired track artist: (optional) artist of the desired track

If successful, application will respond with 201 status and return JSON of newly posted favorite track.

Run in Postman

Sample Successful Response:

[
    {
        "id": 19,
        "title": "Stronger",
        "artistName": "Kelly Clarkson",
        "genre": "Electronic",
        "rating": 30
    }
]

Get All Playlists

Returns all playlists from the database

GET /api/v1/playlists

If successful, application will respond with status code 200 and JSON with array of playlists.

Run in Postman

Sample Successful Response:

[
    {
        "id": 1,
        "title": "90s Guilty Pleasure",
        "songCount": 1,
        "songAvgRating": 88,
        "favorites": [
            {
                "id": 1,
                "title": "Bailamos",
                "artistName": "Enrique Iglesias",
                "genre": "Pop",
                "rating": 88
            }
        ],
        "updated_at": "2019-12-11T19:40:01.088Z",
        "created_at": "2019-12-11T19:40:01.088Z"
    },
    {
        "id": 2,
        "title": "Party Mix",
        "songCount": 0,
        "songAvgRating": 0,
        "favorites": [],
        "updated_at": "2019-12-11T19:40:01.088Z",
        "created_at": "2019-12-11T19:40:01.088Z"
    }
]

Add a New Single Playlist

Add a new playlist. A unique playlist title must be included in the POST request body.

POST /api/v1/playlists

title: title of playlist

If successful, application will respond with 201 status and return JSON of newly posted playlist record.

Run in Postman

Sample Successful Response:

[
    {
        "id": 17,
        "title": "Electronic Dance Music Playlist",
        "created_at": "2019-12-12T21:42:11.346Z",
        "updated_at": "2019-12-12T21:42:11.346Z"
    }
]

Update a Single Playlist

Update a playlist. To update a playlist title, a unique playlist title must be included in the POST request body.

PUT /api/v1/playlists/:id

title: title of playlist

If successful, application will respond with 201 status and return JSON of newly updated playlist record.

Run in Postman

Sample Successful Response:

[
    {
        "id": 2,
        "title": "Classical Playlist",
        "created_at": "2019-12-11T19:40:01.088Z",
        "updated_at": "2019-12-11T19:40:01.088Z"
    }
]

Delete a Single Playlist

Delete a single playlist from the database

DELETE /api/v1/playlists/:id

:id: id of the track to be deleted

If successful, application will respond with 201 status.

Run in Postman

Get a Single Playlist with Favorites

Returns a playlist with it associated favorite tracks from the database

GET /api/v1/playlists/:id/favorites

:id: id of desired favorite track

If successful, application will respond with status code 200 and JSON of requested playlists with associated favorite tracks.

Run in Postman

Sample Successful Response:

{
    "id": 1,
    "title": "90s Guilty Pleasure",
    "songCount": 1,
    "songAvgRating": 88,
    "favorites": [
        {
            "id": 1,
            "title": "Bailamos",
            "artistName": "Enrique Iglesias",
            "genre": "Pop",
            "rating": 88
        }
    ],
    "updated_at": "2019-12-11T19:40:01.088Z",
    "created_at": "2019-12-11T19:40:01.088Z"
}

Add a Single Favorite to a Playlist

Add a favorite track to a playlist. A playlist id and favorite id must be included in the POST request URI.

POST /api/v1/playlists/:playlist_id/favorites/:favorite_id

playlist_id: id of playlist favorite_id: id of favorite

If successful, application will respond with 201 status and return message indicating that the favorite track has been added to the playlist.

Run in Postman

Sample Successful Response:

{
    "Success": "Bailamos has been added to 90s Guilty Pleasure!"
}

Delete a Single Favorite from a Playlist

Delete a favorite track from a playlist. A playlist id and favorite id must be included in the DELETE request URI.

DELETE /api/v1/playlists/:playlist_id/favroites/:favorite_id

playlist_id: id of playlist favorite_id: id of favorite

If successful, application will respond with 201 status.

Run in Postman

Schema Design

image

Tech Stack List

Core Contributors

View LinkedIn

View LinkedIn

play_play_express's People

Contributors

mackhalliday avatar joshsherwood1 avatar iandouglas avatar corywest avatar dionew1 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.