import { CanActivate , ExecutionContext , Injectable } from '@nestjs/common' ; import { Observable } from 'rxjs' ; import { ADMIN_RANK } from '../constant/User' ; import { Auth } from '../interface/Auth' ; @ Injectable ( ) export class AdminGuard implements CanActivate { canActivate ( context ) { const req = context . switchToHttp ( ) . getRequest ( ) ; const auth = req . headers . auth ; return ( auth && auth . rank ) >= ADMIN_RANK ; } }