Kind: Interface
Source: packages/common/interfaces/middleware/middleware-configuration.interface.ts
Part of: Common
RouteInfo describes a single route targeted by middleware configuration. It combines the route path, HTTP request method, and API version so middleware can be applied to the correct endpoint variant.
Properties
| Property | Type |
|---|---|
path | string |
method | RequestMethod |
version | VersionValue |
Diagram
mermaidgraph LR Middleware[Middleware Configuration] --> RouteInfo RouteInfo --> Path[path: string] RouteInfo --> Method[method: RequestMethod] RouteInfo --> Version[version: VersionValue] RouteInfo --> TargetRoute[Versioned HTTP Route]
Usage
tsimport { RequestMethod } from '@nestjs/common';
import type { RouteInfo } from './middleware-configuration.interface';
const protectedRoute: RouteInfo = {
path: 'users/:id',
method: RequestMethod.GET,
version: '1',
};
// Example: register middleware for a specific versioned endpoint.
consumer
.apply(AuthMiddleware)
.forRoutes(protectedRoute);
AI Coding Instructions
- Provide all three fields when creating a
RouteInfo:path,method, andversion. - Use
RequestMethodenum values instead of raw HTTP method strings such as'GET'. - Keep
pathconsistent with the application's route definitions, including parameter segments like:id. - Set
versionto the sameVersionValueused by the controller or route being targeted. - Use
RouteInfowhen middleware must apply to a specific method and API version rather than an entire controller.
Used by
5 references from 5 files. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.
Imported by (5)
MiddlewareBuilder—packages/core/middleware/builder.ts:17handler—packages/core/middleware/middleware-module.ts:287RouteInfoPathExtractor—packages/core/middleware/route-info-path-extractor.ts:16modulesContainer—packages/core/middleware/routes-mapper.ts:148anonymousMiddleware—packages/core/middleware/utils.ts:77
Was this page helpful?