Well-structured backends separate concerns: routers define URLs, controllers translate HTTP to application calls, services own data access, and middleware handles cross-cutting behavior (validation, 404, errors). Study these patterns to keep files small, testable, and aligned with REST conventions.

Query and route parameters — Lesson overview

Chegg Skills Lesson 5 (Node and Express): read three request inputs—path params, query string, and body—and use each in the right place in controllers and services.
Learn: Lesson 5 in the Node and Express unit introduces the three ways HTTP sends data into your API. Route parameters identify which resource (req.params). Query parameters optional filters (req.query). The body carries JSON on POST/PUT (req.body). Controllers read all three; routers only declare path parameter names in the URL pattern.

Course example

// Path parameter (router defines :userId)
// GET /users/42        ->  req.params.userId === "42"

// Query string (optional filters)
// GET /pastes?sort=desc&limit=5  ->  req.query.sort, req.query.limit

// JSON body (POST/PUT, needs express.json())
// POST /users  body: { "username": "ada" }  ->  req.body.username

Additional references & examples

← All Query and route parameters · Server Architecture / Routes