44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import { Module } from '@nestjs/common';
|
|
import { TerminusModule } from '@nestjs/terminus';
|
|
import { HttpModule } from '@nestjs/axios';
|
|
import { HealthController } from './health.controller';
|
|
import { TypeOrmHealthIndicator } from './indicators/typeorm.health';
|
|
import { DbPoolStatsIndicator } from './indicators/db-pool-stats.health';
|
|
import { ConfigModule } from '@nestjs/config';
|
|
import { PrometheusModule } from '@willsoto/nestjs-prometheus';
|
|
import { metricProviders } from './metrics/metrics.config';
|
|
import { CustomMetricsService } from './metrics/custom.metrics';
|
|
import { MetricsInterceptor } from './metrics/metrics.interceptor';
|
|
import { HealthAlertService } from './alert/health-alert.service';
|
|
import { APP_INTERCEPTOR } from '@nestjs/core';
|
|
|
|
@Module({
|
|
imports: [
|
|
TerminusModule,
|
|
HttpModule,
|
|
ConfigModule,
|
|
PrometheusModule.register({
|
|
path: '/metrics',
|
|
defaultMetrics: {
|
|
enabled: true,
|
|
},
|
|
}),
|
|
],
|
|
controllers: [HealthController],
|
|
providers: [
|
|
TypeOrmHealthIndicator,
|
|
DbPoolStatsIndicator,
|
|
CustomMetricsService,
|
|
HealthAlertService,
|
|
{
|
|
provide: APP_INTERCEPTOR,
|
|
useClass: MetricsInterceptor,
|
|
},
|
|
...metricProviders,
|
|
],
|
|
exports: [
|
|
CustomMetricsService,
|
|
HealthAlertService,
|
|
],
|
|
})
|
|
export class HealthModule {}
|