import { HealthModule, HealthModuleOptions, HealthRepositoryPort, } from '@mobicoop/health-module'; import { MessagerModule } from '@modules/messager/messager.module'; import { Module } from '@nestjs/common'; import { ConfigModule } from '@nestjs/config'; import { HEALTH_CONFIGURATION_REPOSITORY, HEALTH_CRITICAL_LOGGING_KEY, SERVICE_NAME, } from './app.constants'; import { MessagePublisherPort } from '@mobicoop/ddd-library'; import { MESSAGE_PUBLISHER } from '@modules/messager/messager.di-tokens'; import { CONFIGURATION_REPOSITORY } from '@modules/configuration/configuration.di-tokens'; import { ConfigurationModule } from '@modules/configuration/configuration.module'; import { EventEmitterModule } from '@nestjs/event-emitter'; @Module({ imports: [ ConfigModule.forRoot({ isGlobal: true }), EventEmitterModule.forRoot(), HealthModule.forRootAsync({ imports: [ConfigurationModule, MessagerModule], inject: [CONFIGURATION_REPOSITORY, MESSAGE_PUBLISHER], useFactory: async ( configurationRepository: HealthRepositoryPort, messagePublisher: MessagePublisherPort, ): Promise => ({ serviceName: SERVICE_NAME, criticalLoggingKey: HEALTH_CRITICAL_LOGGING_KEY, checkRepositories: [ { name: HEALTH_CONFIGURATION_REPOSITORY, repository: configurationRepository, }, ], messagePublisher, }), }), ConfigurationModule, MessagerModule, ], exports: [ConfigurationModule, MessagerModule], }) export class AppModule {}