mirror of
https://github.com/dadosfera/maestro.git
synced 2026-09-27 16:14:48 +00:00
50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
if (process.env.ENV !== 'local') require('elastic-apm-node/start');
|
|
import { NestFactory } from '@nestjs/core';
|
|
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
|
import helmet from 'helmet';
|
|
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
|
|
|
import { AppModule } from './app.module';
|
|
import { writeFileSync } from 'fs';
|
|
async function bootstrap() {
|
|
DadosferaLogger.setupLogger({
|
|
serviceName: 'maestro',
|
|
serviceEnvironment: process.env.ENV,
|
|
});
|
|
const logger = new DadosferaLogger();
|
|
|
|
const app = await NestFactory.create(AppModule, {
|
|
logger,
|
|
cors: {
|
|
origin: '*',
|
|
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
|
|
preflightContinue: false,
|
|
optionsSuccessStatus: 204,
|
|
},
|
|
});
|
|
|
|
app.use(helmet());
|
|
|
|
const date = new Date();
|
|
|
|
const config = new DocumentBuilder()
|
|
.setTitle('Maestro')
|
|
.setDescription('Documentation for Maestro gateway')
|
|
.setVersion(
|
|
`${date.getDate()}.${
|
|
date.getMonth() + 1
|
|
}.${date.getFullYear()} - ${date.getHours()}:${date.getMinutes()}`,
|
|
)
|
|
.addBearerAuth()
|
|
.build();
|
|
|
|
const document = SwaggerModule.createDocument(app, config);
|
|
|
|
if (process.env.ENV === 'local') SwaggerModule.setup('api', app, document);
|
|
|
|
await writeFileSync('swagger.txt', JSON.stringify(JSON.stringify(document)));
|
|
|
|
await app.listen(3333);
|
|
}
|
|
bootstrap();
|