Files
cargaMasiva_api/src/main.ts
T

76 lines
2.1 KiB
TypeScript
Raw Normal View History

2025-09-02 13:58:37 -06:00
import * as crypto from "crypto";
2025-09-03 12:34:31 -06:00
//(global as any).crypto = crypto;
2025-09-02 13:58:37 -06:00
2025-06-11 10:46:45 -06:00
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';
2025-06-11 10:46:45 -06:00
2025-09-02 13:58:37 -06:00
2025-06-11 10:46:45 -06:00
async function bootstrap() {
const app = await NestFactory.create(AppModule);
2025-09-12 12:51:32 -06:00
app.enableCors({
origin: [process.env.FRONTEND_URL], // solo frontend permitido
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
credentials: true,
});
app.useGlobalPipes(
new ValidationPipe({
transform: true,
}),
);
2025-09-12 12:50:57 -06:00
app.useGlobalFilters(new GlobalExceptionFilter());
2025-09-12 12:50:57 -06:00
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
2025-09-12 12:50:57 -06:00
const document = SwaggerModule.createDocument(app, config);
2025-09-12 12:50:57 -06:00
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}`);
2025-09-12 12:50:57 -06:00
console.log(
`\x1b[32m✅ Documentación disponible en:\x1b[0m http://localhost:${port}/documentation`,
);
console.log(
`\x1b[36m=========================================================\x1b[0m\n`,
);
2025-06-11 10:46:45 -06:00
}
bootstrap();