Spaces:
Runtime error
Runtime error
| import { | |
| ValidationPipe, | |
| VersioningType, | |
| VERSION_NEUTRAL, | |
| } from '@nestjs/common'; | |
| import { NestFactory } from '@nestjs/core'; | |
| import { ConfigService } from '@nestjs/config'; | |
| import helmet from 'helmet'; | |
| import { AppModule } from './app.module'; | |
| import { PrismaService } from './shared/modules/prisma/prisma.service'; | |
| import { setupSwagger } from './swagger-setup'; | |
| import * as bodyParser from 'body-parser'; | |
| async function bootstrap() { | |
| const app = await NestFactory.create(AppModule, { cors: true }); | |
| const configService = app.get(ConfigService); | |
| const prismaService = app.get(PrismaService); | |
| await prismaService.enableShutdownHooks(app); | |
| app.use(bodyParser.json({ limit: '50mb' })); | |
| app.use(bodyParser.urlencoded({ limit: '50mb', extended: true })); | |
| app.enableVersioning({ | |
| type: VersioningType.URI, | |
| defaultVersion: VERSION_NEUTRAL, | |
| }); | |
| app.useGlobalPipes( | |
| new ValidationPipe({ | |
| whitelist: true, | |
| transform: true, | |
| }), | |
| ); | |
| if (process.env.NODE_ENV === 'production') { | |
| app.use(helmet()); | |
| } | |
| setupSwagger(app); | |
| app.enableCors({ | |
| origin: configService.get('CORS_ORIGIN') || '*', | |
| credentials: true, | |
| }); | |
| const port = process.env.PORT || 3000; | |
| await app.listen(port); | |
| console.log(`π Application is running on: http://localhost:${port}`); | |
| console.log(`π Swagger documentation: http://localhost:${port}/api`); | |
| } | |
| bootstrap(); | |