29 lines
807 B
TypeScript
29 lines
807 B
TypeScript
import { RepositoriesHealthIndicatorUseCase } from '@modules/health/core/application/usecases/repositories.health-indicator.usecase';
|
|
import { Controller, Get } from '@nestjs/common';
|
|
import {
|
|
HealthCheckService,
|
|
HealthCheck,
|
|
HealthCheckResult,
|
|
} from '@nestjs/terminus';
|
|
|
|
@Controller('health')
|
|
export class HealthHttpController {
|
|
constructor(
|
|
private readonly repositoriesHealthIndicatorUseCase: RepositoriesHealthIndicatorUseCase,
|
|
private readonly healthCheckService: HealthCheckService,
|
|
) {}
|
|
|
|
@Get()
|
|
@HealthCheck()
|
|
async check(): Promise<HealthCheckResult> {
|
|
try {
|
|
return await this.healthCheckService.check([
|
|
async () =>
|
|
this.repositoriesHealthIndicatorUseCase.isHealthy('repositories'),
|
|
]);
|
|
} catch (error) {
|
|
throw error;
|
|
}
|
|
}
|
|
}
|