import { Controller, Get } from '@nestjs/common';
import { HealthCheckService } from '../services/health-check.service';

@Controller('health')
export class HealthController {
  constructor(private healthCheckService: HealthCheckService) {}

  /**
   * Simple health check endpoint for load balancers
   * GET /health
   */
  @Get()
  async checkHealth(): Promise<{ status: string }> {
    const isHealthy = await this.healthCheckService.isHealthy();
    return {
      status: isHealthy ? 'ok' : 'error',
    };
  }

  /**
   * Detailed health status with service information
   * GET /health/status
   */
  @Get('status')
  async getStatus() {
    return await this.healthCheckService.getHealthStatus();
  }

  /**
   * Detailed metrics for monitoring dashboards
   * GET /health/metrics
   */
  @Get('metrics')
  async getMetrics() {
    return await this.healthCheckService.getDetailedMetrics();
  }
}
