ocr-document-backend/src/health/health.controller.ts
Hasta Ragil Saputra 0456cd57f4 feat: update boilerplate
add swagger
add correlation id
add health check for internet connectivity and database
update to latest nestjs version
remove clutter from http log
2022-06-24 17:13:05 +07:00

33 lines
662 B
TypeScript

import { Controller, Get } from '@nestjs/common';
import {
HealthCheck,
HealthCheckService,
HttpHealthIndicator,
TypeOrmHealthIndicator,
} from '@nestjs/terminus';
@Controller('health')
export class HealthController {
constructor(
private health: HealthCheckService,
private http: HttpHealthIndicator,
private db: TypeOrmHealthIndicator,
) {}
@Get()
@HealthCheck()
check() {
return this.health.check([
() => {
return this.http.pingCheck(
'internet-connectivity',
'https://www.google.com',
);
},
() => {
return this.db.pingCheck('database');
},
]);
}
}