import { Controller, Get } from '@nestjs/common';
import { ApiTags, ApiOperation } from '@nestjs/swagger';
import { RelayService } from '../relay/relay.service';

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

  @Get()
  @ApiOperation({ summary: '健康检查（含 Relayer 钱包余额）' })
  async check() {
    const balance = await this.relay.getRelayerBalance();
    const balanceGnx = Number(BigInt(balance)) / 1e18;
    return {
      status: balanceGnx > 10000 ? 'healthy' : 'warning',
      relayerBalanceGnx: balanceGnx,
      threshold: 10000,
      timestamp: new Date().toISOString(),
    };
  }
}
