import { Injectable , CanActivate , ExecutionContext } from '@nestjs/common' ; import { Observable } from 'rxjs' ; import { Request } from 'express' ; import { ConfigurationService } from '../../configuration/configuration.service' ; @ Injectable ( ) export class UserResourceOrAdminsecretGuard implements CanActivate { constructor ( private configService ) { } canActivate ( context ) { const request = context . switchToHttp ( ) . getRequest ( ) ; const adminSecret = request . headers [ 'x-admin-secret' ] ; const isAdminRequest = adminSecret === this . configService . get ( 'ADMIN_SECRET' ) ; if ( isAdminRequest ) { return true ; } } }