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
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user