file module import { ExecutionContext , Injectable } from '@nestjs/common' ; import { AuthGuard } from '@nestjs/passport' ; import { HttpUnauthorizedError } from '../../../common/errors/unauthorized.error' ; class classdesc example UseGuards @ Injectable ( ) export class HumanizedJwtAuthGuard extends AuthGuard ( 'jwt' ) { canActivate ( context ) { return super . canActivate ( context ) ; } function description handleRequest ( error , authInfo , errInfo ) { const okToken = ! ! authInfo ; const noToken = ! authInfo && errInfo && errInfo . message === 'No auth token' ; if ( ! error && ( okToken || noToken ) ) { return authInfo ; } else { throw error || new HttpUnauthorizedError ( undefined , errInfo && errInfo . message ) ; } } }