Kind: Interface
Source: packages/core/router/interfaces/route-path-metadata.interface.ts
Part of: Core
RoutePathMetadata aggregates all path and versioning inputs needed to construct a controller route. The router uses it to combine global, module, controller, and method paths while applying controller- or method-level API versioning configuration.
Properties
| Property | Type |
|---|---|
ctrlPath | string |
methodPath | string |
globalPrefix | string |
modulePath | string |
controllerVersion | VersionValue |
methodVersion | VersionValue |
versioningOptions | VersioningOptions |
Diagram
mermaidgraph LR GP[globalPrefix] --> RP[RoutePathMetadata] MP[modulePath] --> RP CP[ctrlPath] --> RP MTP[methodPath] --> RP CV[controllerVersion] --> RP MV[methodVersion] --> RP VO[versioningOptions] --> RP RP --> URL[Resolved Route URL]
Usage
tsimport { VersioningType } from '@nestjs/common';
import { RoutePathMetadata } from '@nestjs/core/router/interfaces/route-path-metadata.interface';
const routeMetadata: RoutePathMetadata = {
globalPrefix: 'api',
modulePath: 'users',
ctrlPath: 'profiles',
methodPath: ':id',
controllerVersion: '1',
methodVersion: '2',
versioningOptions: {
type: VersioningType.URI,
},
};
// Used internally to resolve a route such as:
// /api/v2/users/profiles/:id
AI Coding Instructions
- Preserve each path segment separately; route composition should be handled by the router rather than manual string concatenation.
- Treat
methodVersionas the more specific version value when method- and controller-level versions both exist. - Ensure
versioningOptionsmatches the application's configured versioning strategy, such asURI,HEADER, orMEDIA_TYPE. - Avoid including leading or trailing slash assumptions in consumers; normalize paths when constructing the final route.
How it works
RoutePathMetadata
RoutePathMetadata is an exported TypeScript interface that groups optional path fragments and API-versioning metadata used while constructing and registering HTTP route paths. It declares no methods or runtime logic; all seven properties are optional. [route-path-metadata.interface.ts:4-39]
Relationships
- IMPORTS →
VersioningOptions - IMPORTS →
VersionValue
Was this page helpful?