import { Controller, Get } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { HealthCheck, HealthCheckService, TypeOrmHealthIndicator, DiskHealthIndicator, MemoryHealthIndicator, HttpHealthIndicator, } from '@nestjs/terminus'; @ApiTags('Health Module') @Controller('health') export class HealthController { constructor( private health: HealthCheckService, private db: TypeOrmHealthIndicator, private memory: MemoryHealthIndicator, private disk: DiskHealthIndicator, private http: HttpHealthIndicator, ) {} @Get() @HealthCheck() check() { return this.health.check([ () => this.db.pingCheck('database'), () => this.disk.checkStorage('disk', { thresholdPercent: 0.9, path: '/', }), () => this.memory.checkHeap('memory_heap', 300 * 1024 * 1024), () => this.http.pingCheck('tuya', process.env.TUYA_EU_URL), ]); } }