Spaces:
Runtime error
Runtime error
File size: 1,414 Bytes
52c09c2 4acc19f 61d4c9c 4acc19f 52c09c2 4acc19f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | 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();
|