Middleware — Basics · NestJS

Write a middleware class that records every request to the cats routes and nothing else, and apply it from the module with configure().

What you will learn

Read the theory for Middleware

All Basics lessons

All NestJS courses

loading types…

What you'll learn

  • Write middleware as an @Injectable() class implementing NestMiddleware, with a service injected
  • Apply middleware from a module's configure() with MiddlewareConsumer, to a controller's routes only
  • Explain why middleware must call next() or end the response, and what it cannot know about the handler