65 lines
1.9 KiB
TypeScript
65 lines
1.9 KiB
TypeScript
import { NestFactory } from '@nestjs/core';
|
|
import { AppModule } from './app.module';
|
|
import { ValidationPipe } from '@nestjs/common';
|
|
import { GlobalExceptionFilter } from './helpers/exception.filter';
|
|
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
|
|
|
|
async function bootstrap() {
|
|
const app = await NestFactory.create(AppModule);
|
|
app.enableCors();
|
|
|
|
app.useGlobalPipes(
|
|
new ValidationPipe({
|
|
transform: true,
|
|
}),
|
|
);
|
|
|
|
app.useGlobalFilters(new GlobalExceptionFilter());
|
|
|
|
const config = new DocumentBuilder()
|
|
.setTitle('Documentacion de la api de carga masiva de CEDETEC')
|
|
.setDescription(
|
|
'El objetivo es mejorar la gestion interna y la integridad de los datos',
|
|
)
|
|
.setVersion('1.0')
|
|
.addBearerAuth(
|
|
{
|
|
type: 'http',
|
|
scheme: 'bearer',
|
|
bearerFormat: 'JWT',
|
|
name: 'Authorization',
|
|
in: 'header',
|
|
},
|
|
'bearer', // nombre del security definition
|
|
)
|
|
.build();
|
|
// .addServer(process.env.SWAGGER_SERVER_URL) // descomentar parael servidor de acatlan
|
|
|
|
const document = SwaggerModule.createDocument(app, config);
|
|
|
|
SwaggerModule.setup('documentation', app, document);
|
|
|
|
const port = process.env.API_PORT || 4000;
|
|
await app.listen(port, '0.0.0.0');
|
|
|
|
console.log(
|
|
`[main] Aplicación iniciada en el puerto ${port} a las ${new Date().toISOString()}`,
|
|
);
|
|
console.log(
|
|
`\n\x1b[36m=========================================================\x1b[0m`,
|
|
);
|
|
console.log(`\x1b[36m SISTEMA DE CARGA MASIVA - API\x1b[0m`);
|
|
console.log(
|
|
`\x1b[36m=========================================================\x1b[0m`,
|
|
);
|
|
console.log(`\x1b[32m✅ API corriendo en:\x1b[0m http://localhost:${port}`);
|
|
console.log(
|
|
`\x1b[32m✅ Documentación disponible en:\x1b[0m http://localhost:${port}/documentation`,
|
|
);
|
|
|
|
console.log(
|
|
`\x1b[36m=========================================================\x1b[0m\n`,
|
|
);
|
|
}
|
|
bootstrap();
|