import { PassportStrategy } from '@nestjs/passport';
import { ExtractJwt, Strategy } from 'passport-jwt';

export class JwtStrategy extends PassportStrategy(Strategy) {
  constructor() {
    super({
      jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
      secretOrKey: 'isuru-chandika-rathnayaka',
    });
  }

  async validate(payload: any) {
    return {
      idUser: payload.sub,
      Name: payload.Name,
    };
  }
}
