From b082d5d3a229e89d355ee6d669e02326225abcbc Mon Sep 17 00:00:00 2001 From: pradeepkumar Date: Wed, 29 Apr 2026 18:24:56 +0530 Subject: [PATCH] feat: enable Swagger for beta environments and add /docs route alias --- src/main.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main.ts b/src/main.ts index 74123d2..de7a95a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -69,8 +69,11 @@ async function bootstrap() { // Global interceptors app.useGlobalInterceptors(new TransformInterceptor()); - // Swagger documentation (only in development) - if (appEnv !== 'production') { + // Swagger documentation — enabled when NODE_ENV !== 'production' OR SWAGGER_ENABLED=true. + // Lets us turn it on for beta (NODE_ENV=production) without exposing it in real prod. + const swaggerEnabled = appEnv !== 'production' || process.env.SWAGGER_ENABLED === 'true'; + + if (swaggerEnabled) { const config = new DocumentBuilder() .setTitle('Real Estate Agent Platform API') .setDescription('API documentation for the Real Estate Agent Platform') @@ -93,13 +96,15 @@ async function bootstrap() { .build(); const document = SwaggerModule.createDocument(app, config); + // Mount at both /api/docs (existing) and /docs (cleaner subdomain URL). SwaggerModule.setup('api/docs', app, document, { - swaggerOptions: { - persistAuthorization: true, - }, + swaggerOptions: { persistAuthorization: true }, + }); + SwaggerModule.setup('docs', app, document, { + swaggerOptions: { persistAuthorization: true }, }); - logger.log(`Swagger documentation available at http://localhost:${port}/api/docs`); + logger.log(`Swagger documentation available at /api/docs and /docs`); } // Socket.IO Redis adapter for cross-instance event broadcasting