import { CanActivate, Injectable, NotFoundException } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';

@Injectable()
export class AuditEventsFeatureGuard implements CanActivate {
  constructor(private readonly configService: ConfigService) {}

  canActivate(): boolean {
    const enabled = this.configService.get<boolean>('AUDIT_EVENTS_ENABLED');
    if (enabled === false) {
      throw new NotFoundException('Audit events are disabled');
    }

    return true;
  }
}
