import { Controller, Get, UseGuards, HttpStatus, HttpException } from "@nestjs/common"; import { Throttle } from "@nestjs/throttler"; import { HealthService, ReadinessResult } from "./health.service"; import { OrchestratorThrottlerGuard } from "../../common/guards/throttler.guard"; /** * Health check controller for orchestrator service * * Rate limits: * - Health endpoints: 200 requests/minute (higher for monitoring) */ @Controller("health") @UseGuards(OrchestratorThrottlerGuard) export class HealthController { constructor(private readonly healthService: HealthService) {} @Get() @Throttle({ status: { limit: 200, ttl: 60000 } }) check(): { status: string; uptime: number; timestamp: string } { return { status: "healthy", uptime: this.healthService.getUptime(), timestamp: new Date().toISOString(), }; } @Get("ready") @Throttle({ status: { limit: 200, ttl: 60000 } }) async ready(): Promise { const result = await this.healthService.isReady(); if (!result.ready) { throw new HttpException(result, HttpStatus.SERVICE_UNAVAILABLE); } return result; } }