
Interceptro을 전역으로 쓰고 싶다면 APP.module에서 APP_INTERCEPTO 를 호출하고
provider에 전역으로 써줄 interceptor을 써주면 된다.
(모든 모듈에서 직접 인터셉터를 설정할 수 있습니다)
import { Module } from '@nestjs/common';
import { APP_INTERCEPTOR } from '@nestjs/core';
@Module({
providers: [
{
provide: APP_INTERCEPTOR,
useClass: LoggingInterceptor,
},
],
})
export class AppModule {}

cats.controller.ts
CatsController에 있는 모든 핸들러에 interceptor이 적용되게 끔 해주는 것이다
@UseInterceptors(new LoggingInterceptor())
export class CatsController {}
'TypeScript' 카테고리의 다른 글
Password validation (0) | 2023.12.25 |
---|---|
Everyday Types (0) | 2023.12.20 |
자동 재시작 & 자동 컴파일 .js생성 (1) | 2023.12.02 |