TASK: You are a Software Engineer for a movie theater company, and your team is tasked with creating an API that can work with and serve data on our database through an application server. We will be testing our API endpoints using Postman, so no UI code is needed for now.
Your main task is creating the API! We will be working with Express to create
Routers for Users
and Shows
. We have a seed file that contains a list of
users and shows to add to the database. We will need to include that seed file
in our main server. While we don’t have a front-end, we will be using Postman to
interact with our API.
We’ll have 2 Express Routers:
Users
Shows
As a user, I want to keep track of the shows I have watched, so that I can satisfy my urge to list things
- Install the following npm packages:
- sqlite3
- sequelize
- express
- nodemon
Once everything is installed, you can run npm run seed
to reset and fill your
database with initial seed data. You can run this command at any time to reset
the database to the initial seed data.
- Create a file for your server and initialize it on port
3000
using Express.
Create the route handlers for the project, per these definitions:
Users
GET
all usersGET
one user (user id inreq.params
)GET
all shows watched by a user (user id inreq.params
)PUT
associate a user with a show they have watched
Shows
GET
all showsGET
one show (show id inreq.params
)GET
all users who watched a showPUT
update theavailable
property of a showDELETE
a showGET
shows of a particular genre (genre inreq.params
)
Make sure to include your routers in a directory named routes
- Test your endpoints using Postman
git add .
,git commit -m “somemessage”
andgit push
so we can see your work.