Middleware — Basics · Express

Express is a chain of functions, and a route is only the last link. Write middleware that numbers every request, logs each one with its final status, and guards two routes with an API key, and see why the order they are mounted in decides what happens.

What you will learn

Read the theory for Middleware

All Basics lessons

All Express courses

loading types…

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')