NestJS Custom Param decorators

오픈소스·2023년 1월 15일
0

NestJS Boilerplate

목록 보기
8/16
post-thumbnail

https://github.com/youngkiu/nestjs-kakaologin/blob/1b4439012ec78997039efdc7379ece712f6d8a14/src/user/user.decorator.ts

import { createParamDecorator, ExecutionContext } from '@nestjs/common';

export const User = createParamDecorator(
  (data: unknown, ctx: ExecutionContext) => {
    const request = ctx.switchToHttp().getRequest();
    return request.user;
  },
);

https://github.com/youngkiu/nestjs-kakaologin/blob/1b4439012ec78997039efdc7379ece712f6d8a14/src/auth-kakao/auth-kakao.controller.ts#L19

  kakaoLoginCallback(@User() user) {
    const {
      profile: { id, username },
      token: { accessToken, refreshToken },
    } = user;

0개의 댓글