feat: enable Swagger for beta environments and add /docs route alias
This commit is contained in:
17
src/main.ts
17
src/main.ts
@@ -69,8 +69,11 @@ async function bootstrap() {
|
|||||||
// Global interceptors
|
// Global interceptors
|
||||||
app.useGlobalInterceptors(new TransformInterceptor());
|
app.useGlobalInterceptors(new TransformInterceptor());
|
||||||
|
|
||||||
// Swagger documentation (only in development)
|
// Swagger documentation — enabled when NODE_ENV !== 'production' OR SWAGGER_ENABLED=true.
|
||||||
if (appEnv !== 'production') {
|
// 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()
|
const config = new DocumentBuilder()
|
||||||
.setTitle('Real Estate Agent Platform API')
|
.setTitle('Real Estate Agent Platform API')
|
||||||
.setDescription('API documentation for the Real Estate Agent Platform')
|
.setDescription('API documentation for the Real Estate Agent Platform')
|
||||||
@@ -93,13 +96,15 @@ async function bootstrap() {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
const document = SwaggerModule.createDocument(app, config);
|
const document = SwaggerModule.createDocument(app, config);
|
||||||
|
// Mount at both /api/docs (existing) and /docs (cleaner subdomain URL).
|
||||||
SwaggerModule.setup('api/docs', app, document, {
|
SwaggerModule.setup('api/docs', app, document, {
|
||||||
swaggerOptions: {
|
swaggerOptions: { persistAuthorization: true },
|
||||||
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
|
// Socket.IO Redis adapter for cross-instance event broadcasting
|
||||||
|
|||||||
Reference in New Issue
Block a user