질문&답변
Exception Filter와 관련하여 질문있습니다.
아래와 같이 작성했습니다. // main.ts import { NestFactory } from ' @nestjs/core '; import { AppModule } from ' ./app.module '; import { SwaggerModule , DocumentBuilder } from ' @nestjs/swagger '; import { HttpExceptionFilter } from ' ./common/exception-filter/http-exception.filter '; import { HttpException , ValidationPipe } from ' @nestjs/common '; declare const module : any ; async function bootstrap () { const app = await NestFactory . create ( AppModule ) ; const PORT = process . env . PORT || 3000 ; const config = new DocumentBuilder () . setTitle ( ' Sleact API ' ) . setDescription ( ' Sleact 개발을 위한 API 문서입니다. ' ) . setVersion ( ' 1.0 ' ) . addCookieAuth ( ' connect.sid ' ) . build () ; const document = SwaggerModule . createDocument ( app , config ) ; SwaggerModule . setup ( ' api ' , app , document ) ; app . useGlobalPipes ( new ValidationPipe ( { whitelist : true , forbidNonWhitelisted : true , transform : true , } ) , ) ; app . useGlobalFilters ( new HttpExceptionFilter ()) ; app . use ( ( req , res , next ) => { throw new HttpException ( ' 미들웨어 에러 테스트 ' , 400 ) ; next () ; } ) ; await app . listen ( PORT ) ; console . log ( ` ${ PORT } 번 포트에서 서버 실행 중 ✅ ` ) ; if ( module . hot ) { module . hot . accept () ; module . hot . dispose ( () => app . close ()) ; } } bootstrap () ; 혹시 main.ts의 코드 순서도 라이프 사이클과 동일하게 맞춰줘야 하는건가요!?
- 좋아요수
- 0
- 댓글수
- 2
- 조회수
- 502





