👉 Create a REST API using the user JSON data found in data/users.json
. Your API must be RESTful with all CRUD routes (create, read, update, delete).
Operation | Path | Response body shape |
---|---|---|
Get all users | /api/users |
{ success: true, payload: array of user objects } |
Get user by id | /api/users/:id |
{ success: true, payload: user object } |
Create new user | /api/users |
{ success: true, payload: newly created user object } |
Update user by id | /api/users/:id |
{ success: true, payload: new user object (after replacement) } |
Delete user by id | /api/users/:id |
{ success: true, payload: deleted user } |
Remember to break down the task and tackle it step by step.
- Start by looking at the data and familiarizing yourself with how it's structured.
- Make a plan for each CRUD route, and break down the logic in that plan until you can't break it down anymore!
- Code each route handler in the
app.js
file. - Code each helper function in the
users.js
file.- Test each route with Postman or Thunder Client as you finish it before you move on to the next one!
- Add, commit, and push after you complete each route/helper function.
⭐ If you've finished everything above and have time left over, keep developing! Think through what ideas you can come up with to improve functionality.
This can include:
- Implementing the correct HTTP response status code
- Making a front end to consume and display your data
- Additional routes that include searching the data using query strings
- Implementing middleware (start with a simple logger, and then explore what else you can add)