Skip to content

Module Recap

Module 03 covered Express: creating servers, routing, HTTP methods, route parameters, query strings, and the full request/response API. You now have the tools to build any REST API.

Express abstracts Node’s http module. It adds routing, middleware, and a clean API on top of raw HTTP. express() creates an app; app.listen(port) starts it.

HTTP methods carry semantic meaning. GET reads, POST creates, PATCH updates, DELETE removes. RESTful conventions — plural nouns for collections, /:id for single resources — make APIs intuitive.

Route parameters identify resources; query strings shape responses. req.params.id reads /posts/42. req.query.sort reads ?sort=newest. Always parse strings to the right types.

The req and res objects are rich. req.body holds the parsed request body (after express.json()). req.headers has all request headers. res.status(code).json(data) sends a response with the right status.

The Bulletin API’s routes follow the RESTful pattern you learned:

POST /auth/register → req.body: { username, password }
POST /auth/login → req.body: { username, password }
GET /posts → req.query: { sort?, page?, limit? }
GET /posts/:id → req.params: { id }
POST /posts → req.body: { title, body }
DELETE /posts/:id → req.params: { id }, Authorization header
GET /posts/:id/comments → req.params: { id }
POST /posts/:id/comments → req.params: { id }, req.body: { body }
POST /posts/:id/upvote → req.params: { id }, Authorization header
GET /users/:id → req.params: { id }

Every route in Bulletin uses exactly the concepts from this module.

TermWhat it means
ExpressMinimal web framework for Node.js — routing + middleware on top of http
Route handler(req, res) => {} — handles a specific method + path combination
req.paramsDynamic URL segments — always strings
req.queryQuery string values — always strings
req.bodyParsed request body — requires express.json() middleware
req.headersHTTP request headers — lowercase keys
res.json(data)Sends JSON response with correct Content-Type
res.status(code)Sets the HTTP status code
RESTful conventionPlural noun + HTTP method + optional /:id for resource routing

Module 04 — Middleware and API Structure →

Module 04 introduces middleware — the functions that run between a request arriving and your route handler executing. You’ll learn the middleware pipeline, add body parsing, logging, and CORS, write your own custom middleware, organize routes with Express Router, and build a centralized error handling layer. This is what turns a simple script into a production-ready API structure.