import { applyDecorators, UseGuards } from '@nestjs/common';
import { ApiHeader, ApiUnauthorizedResponse } from '@nestjs/swagger';
import { ApiKeyGuard } from '../guards/api-key.guard';
import { API_KEY_HEADER, DEPARTMENT_CODE_HEADER } from '../constants';

export function ApiKeyAuth(): ReturnType<typeof applyDecorators> {
  return applyDecorators(
    UseGuards(ApiKeyGuard),
    ApiHeader({
      name: API_KEY_HEADER,
      description: 'Department API Key',
      required: true,
    }),
    ApiHeader({
      name: DEPARTMENT_CODE_HEADER,
      description: 'Department Code (e.g., FIRE_DEPT)',
      required: true,
    }),
    ApiUnauthorizedResponse({ description: 'Invalid or missing API key' }),
  );
}
