Skip to content

Latest commit

 

History

History
287 lines (184 loc) · 6.04 KB

README.md

File metadata and controls

287 lines (184 loc) · 6.04 KB

Music Library

A music library API created following a CRUD REST API technology using Node.js, Express, Mocha-Chai, Postman and pgAdmin.

Concepts covered

  • Database design and migration
  • PostgreSQL
  • Building databases in a Docker container
  • Creating API using CRUD (Create, Read, Update and Delete) operations on databases
  • Using Postman to manage API requests
  • Integration testing using Mocha, Chai and SuperTest
  • Use of Dotenv to store sensitive information
  • Use of Nodemon to automatically restart the node application when code changes
  • Github Actions for automated testing

Getting started

Fork and clone the repo, and run the following commands. Use Postman and pgAdmin to check if the CRUD operations are working.

npm test  # to test the codes
npm start # to start the app at http://localhost:3000

API documentation can be accessed at: http://localhost:3000/api-docs/ .

Screenshot of Swagger API doc of Musci Library


API end points

Artist

POST /artists (add a new artist)

Parameters and body content

Parameters Body content
None name [string], genre [string]

Responses

code description
201 successful operation
GET /artists (find all artists)

Parameters and body content

None

Responses

code description
200 successful operation
GET /artists/{id} (find an artist by ID)

Parameters and body content

Parameters Body content
artistId None

Responses

code description
200 successful operation
404 aritst not found
PUT /artists/{id} (replace an artist with updated record)

Parameters and body content

Parameters Body content
artistId name[string], genre[string]

Responses

code description
200 successful operation
404 aritst not found
PATCH /artists/{id} (update an aritst's record)

Parameters and body content

Parameters Body content
artistId name[string], genre[string]

Responses

code description
200 successful operation
404 aritst not found
DELETE /artists/{id} (delete an artist)

Parameters and body content

Parameters Body content
artistId None

Responses

code description
200 successful operation
404 aritst not found

Album

POST /artists/{id}/albums (add a new album associated to an artist)

Parameters and body content

Parameters Body content
artistId name [string], year [integer]

Responses

code description
201 successful operation
GET /albums (find all albums)

Parameters and body content

None

Responses

code description
200 successful operation
GET /albums/{id} (find an album by ID)

Parameters and body content

Parameters Body content
albumId None

Responses

code description
200 successful operation
404 album not found
PUT /albums/{id} (replace an album with updated record)

Parameters and body content

Parameters Body content
albumId name[string], year[integer]

Responses

code description
200 successful operation
404 album not found
PATCH /albums/{id} (update an album's record)

Parameters and body content

Parameters Body content
albumId name[string], year[integer]

Responses

code description
200 successful operation
404 album not found
DELETE /albums/{id} (delete an album)

Parameters and body content

Parameters Body content
albumId None

Responses

code description
200 successful operation
404 album not found

Models

Artists
column data type
id integer (PK)
name string
genre string
Albums
column data type
id integer (PK)
name string
year integer
artistId integer (FK)

Author

👤 HJ Kang