Kind: Constant
Source: packages/common/interfaces/version-options.interface.ts
Part of: Common
Indicates that this will work for any version passed in the request, or no version.
VERSION_NEUTRAL is a versioning constant that marks a route or controller as compatible with every API version. It allows an endpoint to handle requests regardless of whether a version is specified in the request, providing a fallback for version-neutral functionality.
Definition
tsSymbol('VERSION_NEUTRAL')
Value
tsSymbol('VERSION_NEUTRAL')
Diagram
mermaidgraph LR Request[Incoming Request] --> VersionCheck{Version specified?} VersionCheck -->|Yes| VersionedRoute[Version-specific Route] VersionCheck -->|No or Any Version| NeutralRoute[VERSION_NEUTRAL Route] NeutralRoute --> Handler[Route Handler]
Usage
tsimport { Controller, Get, VERSION_NEUTRAL } from '@nestjs/common';
@Controller({
path: 'health',
version: VERSION_NEUTRAL,
})
export class HealthController {
@Get()
check() {
return { status: 'ok' };
}
}
AI Coding Instructions
- Use
VERSION_NEUTRALfor endpoints that must remain accessible across all API versions, such as health checks or shared metadata routes. - Apply it through controller or route version metadata where Nest versioning is enabled.
- Do not use it for endpoints whose response contract changes between API versions.
- Ensure version-neutral routes do not conflict with version-specific routes using the same HTTP method and path.
- Test requests both with and without version information to confirm the route is resolved as expected.
Used by
7 references from 7 files. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.
Imported by (7)
RoutePathFactory—packages/core/router/route-path-factory.ts:18VersionNeutralMiddlewareController—integration/versioning/src/neutral-middleware.controller.ts:3VersionNeutralController—integration/versioning/src/neutral.controller.ts:3modulesContainer—packages/core/middleware/routes-mapper.ts:148MODULE_INIT_MESSAGE—packages/core/helpers/messages.ts:7ExpressAdapter—packages/platform-express/adapters/express-adapter.ts:51FastifyAdapter—packages/platform-fastify/adapters/fastify-adapter.ts:124
Was this page helpful?