38 lines
1.3 KiB
TypeScript
38 lines
1.3 KiB
TypeScript
import { NestFactory } from '@nestjs/core';
|
|
import { ValidationPipe, Logger } from '@nestjs/common';
|
|
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
|
|
import { NestExpressApplication } from '@nestjs/platform-express';
|
|
import { join } from 'path';
|
|
import { AppModule } from './app.module';
|
|
|
|
async function bootstrap() {
|
|
const app = await NestFactory.create<NestExpressApplication>(AppModule);
|
|
const logger = new Logger('Bootstrap');
|
|
|
|
app.enableCors({
|
|
origin: ['http://localhost:3000', 'http://localhost:5173', 'https://app.prosapp.co'],
|
|
methods: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'],
|
|
credentials: true,
|
|
});
|
|
|
|
app.setGlobalPrefix('api/v1');
|
|
app.useGlobalPipes(new ValidationPipe({ whitelist: true, transform: true }));
|
|
|
|
app.useStaticAssets(join(__dirname, '..', 'uploads'), { prefix: '/uploads' });
|
|
|
|
const config = new DocumentBuilder()
|
|
.setTitle('ProsApp API')
|
|
.setDescription('API de ProsApp - Migración Firebase a PostgreSQL')
|
|
.setVersion('1.0')
|
|
.addBearerAuth()
|
|
.build();
|
|
const document = SwaggerModule.createDocument(app, config);
|
|
SwaggerModule.setup('docs', app, document);
|
|
|
|
const port = process.env.PORT || 3000;
|
|
await app.listen(port);
|
|
logger.log(`API corriendo en http://localhost:${port}`);
|
|
logger.log(`Swagger en http://localhost:${port}/docs`);
|
|
}
|
|
bootstrap();
|