add swagger add correlation id add health check for internet connectivity and database update to latest nestjs version remove clutter from http log
33 lines
662 B
TypeScript
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');
|
|
},
|
|
]);
|
|
}
|
|
}
|