nest-project/src/main.ts

19 lines
599 B
TypeScript
Raw Normal View History

2023-02-15 19:12:21 +08:00
import { HttpAdapterHost, NestFactory } from '@nestjs/core'
import { PrismaClientExceptionFilter, PrismaService } from 'nestjs-prisma'
import { AppModule } from './app.module'
2023-02-15 16:49:40 +08:00
async function bootstrap() {
const app = await NestFactory.create(AppModule)
2023-02-15 19:12:21 +08:00
// 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))
await app.listen(3000)
2023-02-15 16:49:40 +08:00
}
bootstrap()