@Injectable()
export class ApiKeyAuth implements CanActivate {
canActivate(
context: ExecutionContext,
): boolean | Promise<boolean> | Observable<boolean> {
const request = context.switchToHttp().getRequest();
const token = request.originalUrl.split('/')[2];
if (token == process.env.API_KEY) {
(request.headers['api-key'] as any) = token;
return true;
} else return false;
}
}