import { Controller, Get, UseGuards } from '@nestjs/common'
import { JwtAuthGuard } from '../auth/jwt-auth.guard.js'
import { HealthService } from './health.service.js'

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

  // Public liveness probe — used by infra (Docker / k8s) to know the
  // platform-api process is alive. Intentionally not behind auth.
  @Get()
  check() {
    return {
      status: 'ok',
      service: 'dezky-platform-api',
      timestamp: new Date().toISOString(),
    }
  }

  // Aggregated probes of every neighbouring service in the stack. Behind
  // JwtAuthGuard because we don't want this read by random unauthenticated
  // clients — it leaks the topology of the deployment.
  @Get('platform')
  @UseGuards(JwtAuthGuard)
  async platform() {
    return this.health.probeAll()
  }
}
