Note: The
middlewaresfolder is purely an organizational grouping. It contains NestJS Guards, Interceptors, and Filters — each with distinct roles in the request lifecycle. The choice to group them under a single folder was made solely for project organization purposes.
Request → Guards → Interceptors (before) → Handler → Interceptors (after) → Filters (on error) → Response
| Type | Purpose | When Runs |
|---|---|---|
| Guards | Authorization, access control | Before handler |
| Interceptors | Transform request/response, logging, tracing | Before & after handler |
| Filters | Error handling, exception formatting | On exceptions |
| Guide | Implementation | Description |
|---|---|---|
| Authorization Guard | authorization.guard.ts | RBAC permission checking via @Permission decorator |
| Guide | Implementation | Description |
|---|---|---|
| Tracing Interceptor | tracing.interceptor.ts | Distributed tracing with OpenTelemetry, auto traceid propagation |
| HTTP Logger Interceptor | http-logger.interceptor.ts | TraceId generation and context assignment for logs |
| Metrics Interceptor | metrics.interceptor.ts | HTTP metrics collection for Prometheus/Grafana |
| Request Timeout Interceptor | request-timeout.interceptor.ts | Per-route timeout control |
| Exception Handler Interceptor | exception-handler.interceptor.ts | Error catching and tracing finalization |
| Guide | Implementation | Description |
|---|---|---|
| Exception Handler Filter | exception-handler.filter.ts | Standardizes and sanitizes all API error responses |
| Guide | Implementation | Description |
|---|---|---|
| Authentication Middleware | authentication.middleware.ts | JWT token validation and user injection |