Skip to content

Instantly share code, notes, and snippets.

@jhon0010
Created August 19, 2020 14:48
Show Gist options
  • Save jhon0010/3b2fa18dd268bd21bfc384c18dbf52b4 to your computer and use it in GitHub Desktop.
Save jhon0010/3b2fa18dd268bd21bfc384c18dbf52b4 to your computer and use it in GitHub Desktop.
import { createParamDecorator, ExecutionContext } from '@nestjs/common';
import { GqlExecutionContext } from '@nestjs/graphql';
export const CurrentUserToken = createParamDecorator((data, context: ExecutionContext) => {
const ctx = GqlExecutionContext.create(context).getContext();
const authHeader: string = ctx.headers.authorization;
return authHeader.replace('Bearer ', '');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment