Skip to content
Snippets Groups Projects
Commit b715868c authored by Lukáš Kratochvíl's avatar Lukáš Kratochvíl
Browse files

feat: app uses prisma client exception filter

parent 6ba1be14
No related branches found
No related tags found
No related merge requests found
import { NestFactory } from '@nestjs/core'; import { HttpAdapterHost, NestFactory } from '@nestjs/core';
import { ConfigService } from '@nestjs/config'; import { ConfigService } from '@nestjs/config';
import { AppModule } from './app.module'; import { AppModule } from './app.module';
import { ValidationPipe } from '@nestjs/common'; import { ValidationPipe } from '@nestjs/common';
...@@ -7,6 +7,7 @@ import { ...@@ -7,6 +7,7 @@ import {
SwaggerCustomOptions, SwaggerCustomOptions,
SwaggerModule, SwaggerModule,
} from '@nestjs/swagger'; } from '@nestjs/swagger';
import { PrismaClientExceptionFilter } from './prisma/prisma-client-exception.filter';
async function bootstrap(): Promise<void> { async function bootstrap(): Promise<void> {
const app = await NestFactory.create(AppModule); const app = await NestFactory.create(AppModule);
...@@ -18,6 +19,9 @@ async function bootstrap(): Promise<void> { ...@@ -18,6 +19,9 @@ async function bootstrap(): Promise<void> {
}), }),
); );
const { httpAdapter } = app.get(HttpAdapterHost);
app.useGlobalFilters(new PrismaClientExceptionFilter(httpAdapter));
const swaggerDocConfig = new DocumentBuilder() const swaggerDocConfig = new DocumentBuilder()
.setTitle('Movie Base API') .setTitle('Movie Base API')
.setVersion('1.0') .setVersion('1.0')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment