Middleware is a function that runs before the route handler, with access to the request and response objects — the same concept as Express middleware. NestJS also has guards, interceptors, pipes, and filters, each running at a specific point in the request lifecycle with a distinct purpose. Knowing which to use is key.
Middleware — runs first, has req/res
()
{
() {
.();
();
}
}
{
() {
consumer.().();
}
}
