import { Injectable, UnauthorizedException } from '@nestjs/common'; import { PassportStrategy } from '@nestjs/passport'; import { Strategy } from 'passport-http-bearer'; import { AuthService } from './auth.service'; @Injectable() export class HttpStrategy extends PassportStrategy(Strategy) { constructor(private readonly authService: AuthService) { super(); } public validate(token: string): string { if (!this.authService.validateToken(token)) { throw new UnauthorizedException(); } return token; } }