import { ExtractJwt , Strategy } from 'passport-jwt' ; import { PassportStrategy } from '@nestjs/passport' ; import { Injectable } from '@nestjs/common' ; import { ConfigurationService } from '../../configuration/configuration.service' ; @ Injectable ( ) export class JwtStrategy extends PassportStrategy ( Strategy ) { constructor ( private configService ) { super ( { jwtFromRequest : ExtractJwt . fromAuthHeaderAsBearerToken ( ) , ignoreExpiration : true , secretOrKey : configService . get ( 'JWT_SECRET' ) , } ) ; } async validate ( payload ) { return { userId : payload . sub } ; } }