Build HTTP APIs with routing, middleware, validation, controllers, and error handling.
Lessons
Group method handlers for one path using app.route().
Chaining Routes with route() is easiest to learn by reading the example, changing it, and observing the result.
// routes/lessons.js
import { Router } from 'express';
const router = Router();
router.route('/')
.get((req, res) => res.json({ lessons: [] }))
.post((req, res) => res.status(201).json({ created: true }));
export default router;
// app.js
import express from 'express';
import lessons from './routes/lessons.js';
const app = express();
app.use('/api/lessons', lessons); // mount the router
app.listen(3000);Practice the Chaining Routes with route() example in a small scratch file, then explain what changed and why.