import { Controller , Get } from '@nestjs/common' ; import { ApiOperation } from '@nestjs/swagger' ; import { DiskHealthIndicator , HealthCheck , HealthCheckService , HttpHealthIndicator , MemoryHealthIndicator , TypeOrmHealthIndicator , } from '@nestjs/terminus' ; import { Allow } from './auth' ; import { KubernetesHealthIndicator } from './project' ; @ Controller ( 'health' ) export class HealthController { constructor ( private readonly health , private readonly dns , private readonly db , private readonly memory , private readonly disk , private readonly kubernetes ) { } @ ApiOperation ( { summary : 'Readiness prod' } ) @ Allow ( ) @ Get ( '/ready' ) @ HealthCheck ( ) readiness ( ) { return this . health . check ( [ async ( ) => this . memory . checkHeap ( 'memory_heap' , 200 * 1024 * 1024 ) , async ( ) => this . memory . checkRSS ( 'memory_rss' , 3000 * 1024 * 1024 ) , async ( ) => this . dns . pingCheck ( 'weather' , 'https://samples.openweathermap.org' ) , async ( ) => this . kubernetes . isHealthy ( 'kubernetes' ) , ] ) ; } @ ApiOperation ( { summary : 'Liveness prob' } ) @ Allow ( ) @ Get ( '/live' ) @ HealthCheck ( ) liveness ( ) { return this . health . check ( [ async ( ) => this . db . pingCheck ( 'database' , { timeout : 300 } ) ] ) ; } }