

Category · Node.js
Your own REST API in an evening
Routes and parameters, middleware, validation, error handling, project structure, working with the database, protected routes, tests, and getting ready for production. The practice is real req/res handlers.
9 lessons94 min
To the first lessonCheatsheet nowTopics, each as its own lesson

01Routes, req, and resDemoA route is a method + a path + a function. req is what came in, res is what goes out.
11 min
02MiddlewareA pipeline of functions before the handler: logging, auth, body parsing.
11 min
03Validating inputDon't trust the request body. Check shape, types, and limits, and only then write to the database.
11 min
04Error handlingOne error handler for the whole app and no stack traces leaking out.
10 min
05Project structureRoutes apart, logic apart, database apart. Then the code is testable.
9 min
06Async handlers and the databaseThe handler awaits the database. Express 5 delivers the error to the error handler by itself.
11 min
07Protected routes and rolesOne middleware finds out who came, the next decides whether they're allowed.
11 min
08API tests with supertestSend a real HTTP request into the app and check the response.
10 min
09Production: helmet, limits, logsWhat to add to an API before opening it to the world.
10 min0/9 topics open. This is the course intro, not the whole course on one page.