FIX: add multiple servers

This commit is contained in:
Gabriel Rosa
2023-02-15 13:14:53 -03:00
parent 6a14c2b459
commit 87882b5afc
2 changed files with 23 additions and 19 deletions
+14 -1
View File
@@ -1669,7 +1669,20 @@
"contact": {}
},
"tags": [],
"servers": [],
"servers": [
{
"url": "https://maestro.stg.dadosfera.ai",
"description": "Ambiente STG"
},
{
"url": "https://maestro-2.stg.dadosfera.ai",
"description": "Ambiente STG2"
},
{
"url": "https://maestro.dadosfera.ai",
"description": "Ambiente PRD"
}
],
"components": {
"securitySchemes": {
"access-token": {
+9 -18
View File
@@ -14,7 +14,7 @@ async function bootstrap() {
serviceEnvironment: process.env.ENV,
});
const logger = new DadosferaLogger();
process.env.INTERNAL_SWAGGER = 'true';
const app = await NestFactory.create(AppModule, {
logger,
cors: {
@@ -24,21 +24,8 @@ async function bootstrap() {
optionsSuccessStatus: 204,
},
});
process.env.INTERNAL_SWAGGER = 'true';
const app2 = await NestFactory.create(AppModule, {
logger,
cors: {
origin: '*',
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
preflightContinue: false,
optionsSuccessStatus: 204,
},
});
app.use(helmet());
configureSwagger(app);
// configureSwagger(app2);
await app.listen(3333);
}
@@ -63,14 +50,18 @@ function configureSwagger(app: INestApplication) {
in: 'header',
})
.setDescription('This is the Maestro API')
.addServer('https://maestro.stg.dadosfera.ai', 'Ambiente STG')
.addServer('https://maestro-2.stg.dadosfera.ai', 'Ambiente STG2')
.addServer('https://maestro.dadosfera.ai', 'Ambiente PRD')
.build();
const document = SwaggerModule.createDocument(app, config);
let swaggerJsonFile = 'docsfera.external.json';
if (process.env.INTERNAL_SWAGGER === 'true') {
swaggerJsonFile = 'docsfera.json';
}
const swaggerJsonFile =
process.env.INTERNAL_SWAGGER === 'true'
? 'docsfera.json'
: 'docsfera.external.json';
if (process.env.ENV === 'local') SwaggerModule.setup('api', app, document);
writeFileSync(