인프런 커뮤니티 질문&답변

rhkdtjd_12님의 프로필 이미지

작성한 질문수

[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core

Exception Filter 적용하기

gateway level에서 filter도 잘 작동합니다!

24.01.21 16:44 작성

·

221

0

@UsePipes(
  new ValidationPipe({
    transform: true,
    transformOptions: {
      enableImplicitConversion: true,
    },
    whitelist: true,
    forbidNonWhitelisted: true,
  }),
)
@UseFilters(SocketCatchHttpExceptionFilter)
@WebSocketGateway({
  // ws://localhost:3000/chats
  namespace: 'chats',
})
export class ChatsGateway implements OnGatewayConnection {
  constructor(
    private readonly chatsService: ChatsService,
    private readonly messagesService: ChatsMessagesService,
  ) {}
...
}

각각의 메소드마다 넣어주는것보다 나은것 같아서 공유 해보아요!

답변 1

0

코드팩토리님의 프로필 이미지
코드팩토리
지식공유자

2024. 01. 21. 22:52

안녕하세요!

공유 감사합니다!