add health service

This commit is contained in:
sbriat
2023-03-31 11:03:21 +02:00
parent 17f40e73fb
commit 39805b009d
5 changed files with 342 additions and 34 deletions

View File

@@ -1,9 +1,14 @@
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { LoggerModule } from './modules/logger.module';
import { HealthModule } from './modules/health/adapters/primaries/health.module';
@Module({
imports: [ConfigModule.forRoot({ isGlobal: true }), LoggerModule],
imports: [
ConfigModule.forRoot({ isGlobal: true }),
LoggerModule,
HealthModule,
],
controllers: [],
providers: [],
})

View File

@@ -0,0 +1,22 @@
import { Controller, Get } from '@nestjs/common';
import {
HealthCheckService,
HttpHealthIndicator,
HealthCheck,
} from '@nestjs/terminus';
@Controller('health')
export class HealthController {
constructor(
private health: HealthCheckService,
private http: HttpHealthIndicator,
) {}
@Get()
@HealthCheck()
check() {
return this.health.check([
() => this.http.pingCheck('google.fr', 'https://google.fr'),
]);
}
}

View File

@@ -0,0 +1,10 @@
import { Module } from '@nestjs/common';
import { TerminusModule } from '@nestjs/terminus';
import { HttpModule } from '@nestjs/axios';
import { HealthController } from './health.controller';
@Module({
imports: [TerminusModule, HttpModule],
controllers: [HealthController],
})
export class HealthModule {}