This is the documentation for the REST API about TV shows.
sample.env
for .env
with the values:
PORT=8080
MONGO_URL='mongodb://localhost:27017/tvshow-db'
NODE_ENV='development'
Then, run:
npm install
💡 At this point, make sure
MONGO
is running on your local machine
To start the project run:
npm run start
To work on the project and have it listen for changes:
npm run dev
Show
data model:
{
title: "The Simpsons",
creator: "Matt Groening",
launched: 1989,
genre: "comedy",
image: "https://ychef.files.bbci.co.uk/976x549/p02fc1jw.jpg",
description: "The series is a satirical depiction of American life, epitomized by the Simpson family, which consists of Homer, Marge, Bart, Lisa, and Maggie. The show is set in the fictional town of Springfield and parodies American culture and society, television, and the human condition."
}
Method | Endpoint | Req.body |
---|---|---|
GET | /shows | |
GET | /shows/:id | |
POST | /shows | { title, creator, launched, genre, image, description } |
PUT | /shows/:id | { title, creator, launched, genre, image, description } |
DELETE | /shows/:id |
- Create the
model
for the show - In the
db/seed.js
file, create an array of 3-4 shows and complete the code for the seed. Afterwards, runnpm run seed
and seed the database - Create a
shows.js
file in the folder /routes. Remember to import it on theapp.js
- One by one, create the routes according to the endpoints shown above. Before moving to the next one, test it on Postman to make sure it works as expected.
💡 Remember the HTTP Status codes on each one of the responses:
HTTP response status code | Meaning |
---|---|
200 | OK - successful |
201 | Created success |
204 | Resource updated successfully |
404 | Not found |
500 | Server error |