improvement: error handeling structure changed and unified all across the app. user no longer sees inappropriate messages.
This commit is contained in:
@@ -4,6 +4,10 @@ import { AppModule } from './app.module';
|
||||
import { ValidationPipe } from '@nestjs/common';
|
||||
import cookieParser from 'cookie-parser'; // 👈 Change this line!
|
||||
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
||||
import {
|
||||
HttpExceptionFilter,
|
||||
validationExceptionFactory,
|
||||
} from './common/errors';
|
||||
|
||||
// At the VERY TOP of main.ts, before anything else
|
||||
const originalConsoleLog = console.log;
|
||||
@@ -21,11 +25,14 @@ console.log = (...args) => {
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
|
||||
app.useGlobalFilters(new HttpExceptionFilter());
|
||||
|
||||
// Global pipes
|
||||
app.useGlobalPipes(new ValidationPipe({
|
||||
whitelist: true,
|
||||
forbidNonWhitelisted: true,
|
||||
transform: true,
|
||||
exceptionFactory: validationExceptionFactory,
|
||||
}));
|
||||
|
||||
// Cookie parser - this is correct for Express
|
||||
|
||||
Reference in New Issue
Block a user