feat: initial API Ubigeo Peru - INEI 2025 + países del mundo
This commit is contained in:
46
src/main.ts
Normal file
46
src/main.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { ValidationPipe } from '@nestjs/common';
|
||||
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
||||
import * as helmet from 'helmet';
|
||||
import { AppModule } from './app.module';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
|
||||
app.setGlobalPrefix('api/v1');
|
||||
|
||||
app.enableCors({ origin: '*' });
|
||||
|
||||
app.use(helmet.default());
|
||||
|
||||
app.useGlobalPipes(
|
||||
new ValidationPipe({
|
||||
whitelist: true,
|
||||
forbidNonWhitelisted: false,
|
||||
transform: true,
|
||||
transformOptions: { enableImplicitConversion: true },
|
||||
}),
|
||||
);
|
||||
|
||||
const config = new DocumentBuilder()
|
||||
.setTitle('API Ubigeo Peru')
|
||||
.setDescription(
|
||||
'API de ubicaciones geográficas del Perú (departamentos, provincias, distritos) y países del mundo. Fuente: INEI 2025.',
|
||||
)
|
||||
.setVersion('1.0')
|
||||
.addTag('ubigeo', 'Departamentos, provincias y distritos del Perú')
|
||||
.addTag('paises', 'Países del mundo')
|
||||
.addTag('health', 'Estado del servicio')
|
||||
.build();
|
||||
|
||||
const document = SwaggerModule.createDocument(app, config);
|
||||
SwaggerModule.setup('api/docs', app, document, {
|
||||
swaggerOptions: { persistAuthorization: true },
|
||||
});
|
||||
|
||||
const port = process.env.PORT ?? 3200;
|
||||
await app.listen(port);
|
||||
console.log(`API Ubigeo corriendo en: http://localhost:${port}/api/v1`);
|
||||
console.log(`Swagger docs: http://localhost:${port}/api/docs`);
|
||||
}
|
||||
bootstrap();
|
||||
Reference in New Issue
Block a user