mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-26 08:14:55 +00:00
38 lines
948 B
TypeScript
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),
|
|
]);
|
|
}
|
|
}
|