커스텀 데코레이터 & 인터셉터
커스텀 데코레이터
// decorators/current-user.decorator.ts
import {
createParamDecorator,
ExecutionContext
} from '@nestjs/common'
export const CurrentUser = createParamDecorator(
(data : any, context : ExecutionContext) => {
return 'hi there!'
}
)//users.controller.ts
import { CurrentUser } from './decorators/current-user.decorator'
@Get('/whoami')
whoAmI(@CurrentUser() user : string) {
return user;
}인터셉터
인터셉터를 의존성 주입과 연결하기
전역 인터셉터
Last updated