From e371930d79686a571782fcaff89063494a6900ea Mon Sep 17 00:00:00 2001 From: temiport25 Date: Mon, 22 Jun 2026 11:44:15 +0100 Subject: [PATCH] feat(versioning): enable URI-based API versioning with v1 default prefix Closes #454 --- meridian-api/src/main.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/meridian-api/src/main.ts b/meridian-api/src/main.ts index 4b377e17..1a0a6425 100644 --- a/meridian-api/src/main.ts +++ b/meridian-api/src/main.ts @@ -1,6 +1,6 @@ import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; -import { ValidationPipe } from '@nestjs/common'; +import { ValidationPipe, VersioningType } from '@nestjs/common'; import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; import helmet from 'helmet'; import { DataResponseInterceptor } from './common/interceptors/data-response.interceptor'; @@ -44,6 +44,16 @@ async function bootstrap() { credentials: true, }); + // Enable URI-based API versioning (issue #454). + // All existing routes remain accessible at their current paths. + // New routes should declare a @Version('1') decorator and be mounted + // under /api/v1/... for forward compatibility. + app.enableVersioning({ + type: VersioningType.URI, + prefix: 'v', + defaultVersion: '1', + }); + // Set global validation pipes. The custom `exceptionFactory` reshapes // class-validator's flat `message: string[]` response into a structured // `{ errors: [{ field, message, constraint }] }` shape that the frontend