Middleware Basics
Middleware is (req, res, next) => {}. It can log, parse JSON, check auth, then call next(). Order matters.
- express.json() parses JSON bodies.
- Stop the chain by sending a response.
- Shared logic belongs in middleware or helpers.
console.log("middleware-next");
After you read this chapter, use Write (when available) and Quiz on this page to lock it in.