FIX: hide internal endpoints

This commit is contained in:
Gabriel Rosa
2023-02-15 13:13:43 -03:00
parent 99288fa805
commit 6a14c2b459
24 changed files with 3864 additions and 4612 deletions
+18 -2
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,9 +24,20 @@ 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);
}
@@ -56,9 +67,14 @@ function configureSwagger(app: INestApplication) {
const document = SwaggerModule.createDocument(app, config);
let swaggerJsonFile = 'docsfera.external.json';
if (process.env.INTERNAL_SWAGGER === 'true') {
swaggerJsonFile = 'docsfera.json';
}
if (process.env.ENV === 'local') SwaggerModule.setup('api', app, document);
writeFileSync(
'docsfera.json',
swaggerJsonFile,
JSON.stringify(
{
service: '${DOCS_API_TOKEN}',