import { HttpAdapterHost, NestFactory } from '@nestjs/core' import { ValidationPipe } from '@nestjs/common' import { ConfigService } from '@nestjs/config' import { PrismaClientExceptionFilter, PrismaService } from 'nestjs-prisma' import { AppModule } from './app.module' async function bootstrap() { const app = await NestFactory.create(AppModule) // Validation app.useGlobalPipes(new ValidationPipe({ whitelist: true })) // enable shutdown hook const prismaService = app.get(PrismaService) await prismaService.enableShutdownHooks(app) // Prisma Client Exception Filter for unhandled exceptions const { httpAdapter } = app.get(HttpAdapterHost) app.useGlobalFilters(new PrismaClientExceptionFilter(httpAdapter)) const configService = app.get(ConfigService) const PORT = configService.get('PORT', 12400) await app.listen(PORT) } bootstrap()