Files
main.tsmain
What you'll learn
- Write middleware with (req, res, next), and pass the request on with next() or answer it instead
- Mount middleware for the whole app with app.use() or for one route in its argument list, in the order it should run
- Share a value with later handlers through res.locals, and act after the response with res.on('finish')
Press Run tests to start the app. Its log appears here.Graded endpoints
No key needed to read, and the first request gets the first id
The key check answers before the handler runs; the id is still set, because that middleware came first
Only the one key opens the route
The check calls next(), and the handler runs
The same check guards the DELETE route
Through the check, and the cat is gone
Through the check again, to the handler's own 404
Tom and Luna, and the eighth id
A value set by middleware, read by the handler for the same request
Every request so far, each with the status it finally got, recorded after its response finished