Created
August 19, 2020 14:48
-
-
Save jhon0010/3b2fa18dd268bd21bfc384c18dbf52b4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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