NestModule is the interface that any NestJS module using middleware must implement. It requires a configure(consumer: MiddlewareConsumer) method where middleware is applied to routes.
export class AppModule implements NestModule {
configure(consumer: MiddlewareConsumer) {
consumer.apply(LoggerMiddleware).forRoutes('cats');
}
}The configure() method can be async for asynchronous middleware setup. Middleware is distinct from module configuration in @Module() — it cannot be declared in the decorator metadata and must use this interface.