import * as path from 'path' ; require ( 'dotenv' ) . config ( { path : path . resolve ( process . cwd ( ) , 'apps/bootcamp-api/.env' ) } ) ; import { ExtractJwt , Strategy } from 'passport-jwt' ; import { PassportStrategy } from '@nestjs/passport' ; import { Injectable } from '@nestjs/common' ; @ Injectable ( ) export class JwtStrategy extends PassportStrategy ( Strategy ) { constructor ( ) { super ( { jwtFromRequest : ExtractJwt . fromAuthHeaderAsBearerToken ( ) , ignoreExpiration : false , secretOrKey : process . env . JWT_SECRET , } ) ; } async validate ( payload ) { const tempPayload = { ... payload , userId : payload . sub } ; const { exp , iat , sub , ... tempPayload2 } = tempPayload ; return tempPayload2 ; } }