2023-10-19 15:16:05 +00:00
|
|
|
import {
|
|
|
|
HealthModule,
|
|
|
|
HealthModuleOptions,
|
|
|
|
HealthRepositoryPort,
|
|
|
|
} from '@mobicoop/health-module';
|
|
|
|
import { MessagerModule } from '@modules/messager/messager.module';
|
2023-01-25 09:50:05 +00:00
|
|
|
import { Module } from '@nestjs/common';
|
2023-01-25 14:16:13 +00:00
|
|
|
import { ConfigModule } from '@nestjs/config';
|
2023-10-19 15:16:05 +00:00
|
|
|
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';
|
2023-01-25 09:50:05 +00:00
|
|
|
|
|
|
|
@Module({
|
2023-01-25 14:16:13 +00:00
|
|
|
imports: [
|
|
|
|
ConfigModule.forRoot({ isGlobal: true }),
|
2023-10-19 15:16:05 +00:00
|
|
|
EventEmitterModule.forRoot(),
|
|
|
|
HealthModule.forRootAsync({
|
|
|
|
imports: [ConfigurationModule, MessagerModule],
|
|
|
|
inject: [CONFIGURATION_REPOSITORY, MESSAGE_PUBLISHER],
|
|
|
|
useFactory: async (
|
|
|
|
configurationRepository: HealthRepositoryPort,
|
|
|
|
messagePublisher: MessagePublisherPort,
|
|
|
|
): Promise<HealthModuleOptions> => ({
|
|
|
|
serviceName: SERVICE_NAME,
|
|
|
|
criticalLoggingKey: HEALTH_CRITICAL_LOGGING_KEY,
|
|
|
|
checkRepositories: [
|
|
|
|
{
|
|
|
|
name: HEALTH_CONFIGURATION_REPOSITORY,
|
|
|
|
repository: configurationRepository,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
messagePublisher,
|
|
|
|
}),
|
|
|
|
}),
|
2023-01-25 14:16:13 +00:00
|
|
|
ConfigurationModule,
|
2023-10-19 15:16:05 +00:00
|
|
|
MessagerModule,
|
2023-01-25 14:16:13 +00:00
|
|
|
],
|
2023-10-19 15:16:05 +00:00
|
|
|
exports: [ConfigurationModule, MessagerModule],
|
2023-01-25 09:50:05 +00:00
|
|
|
})
|
|
|
|
export class AppModule {}
|