Files
backend/src/health/controllers/health.controller.ts
hannathkadher 0749fab633 health check
2025-04-23 17:31:16 +04:00

38 lines
948 B
TypeScript

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),
]);
}
}