import { Controller, Get } from '@nestjs/common';
import { ApiOkResponse, ApiTags } from '@nestjs/swagger';
import type { HealthResponse } from '@ali-ismail/contracts';
import { HealthService } from './health.service';
import { Public } from './common/public.decorator';

@ApiTags('health')
@Controller('health')
export class HealthController {
  constructor(private readonly healthService: HealthService) {}

  @Public()
  @Get()
  @ApiOkResponse({ description: 'Service health' })
  getHealth(): HealthResponse {
    return this.healthService.getHealth();
  }

  /** Readiness: process is up AND the database answers within a bounded time. */
  @Public()
  @Get('ready')
  @ApiOkResponse({ description: 'Readiness including database connectivity' })
  async getReadiness() {
    return this.healthService.getReadiness();
  }
}