feat(health): add health checks to server api

This commit is contained in:
Amruth Pillai
2022-03-10 09:25:15 +01:00
parent 8f48f5fcd6
commit eca80a1663
12 changed files with 114 additions and 26 deletions

View File

@ -0,0 +1,21 @@
import { Controller, Get } from '@nestjs/common';
import { HealthCheck, HealthCheckService, HttpHealthIndicator, TypeOrmHealthIndicator } from '@nestjs/terminus';
@Controller('health')
export class HealthController {
constructor(
private health: HealthCheckService,
private db: TypeOrmHealthIndicator,
private http: HttpHealthIndicator
) {}
@Get()
@HealthCheck()
check() {
return this.health.check([
() => this.db.pingCheck('database'),
() => this.http.pingCheck('app', 'https://rxresu.me'),
() => this.http.pingCheck('docs', 'https://beta.rxresu.me'),
]);
}
}