You’ve finished the course. You can now design a REST API’s resources and routes, and build it with Express 5: create, read, update and delete through route parameters and query strings, with the data saved safely to a JSON file.
Dev’s Desk, Request by Request
The ticket desk that replaced Dev’s clipboard answers every request the same way. Express finds the first route that matches, and your handler answers once, with the status you chose. Here’s how the finished desk answers the requests the course built it for:
| Request | Answer |
|---|---|
GET /tickets?status=waiting&category=electrical |
200 OK and a page with Priya’s toaster only |
GET /tickets/99 |
404 Not Found, code ticket_not_found |
POST /tickets with Rosa’s radio |
201 Created with a Location header |
PATCH /tickets/1 with {"status":"on-bench"} |
200 OK, Priya’s toaster on the bench |
PATCH /tickets/4 with {"status":"waiting"}, Joe’s fixed stool |
409 Conflict, code ticket_closed |
DELETE /tickets/<id>, Rosa’s radio |
204 No Content |
GET /volunteers?speciality=bikes |
200 OK and a page with Lucía only |
Each resource has its own router. The tickets router is mounted at /tickets and the volunteers router at /volunteers, so each router’s paths are relative to its mount path.