50 lines
1.8 KiB
TypeScript
50 lines
1.8 KiB
TypeScript
import { Module } from '@nestjs/common';
|
|
import { ConfigModule } from '@nestjs/config';
|
|
import { AdModule } from './modules/ad/ad.module';
|
|
import { EventEmitterModule } from '@nestjs/event-emitter';
|
|
import { RequestContextModule } from 'nestjs-request-context';
|
|
import { MessagerModule } from '@modules/messager/messager.module';
|
|
import { HealthModule, HealthRepositoryPort } from '@mobicoop/health-module';
|
|
import { AD_REPOSITORY } from '@modules/ad/ad.di-tokens';
|
|
import { MESSAGE_PUBLISHER } from '@modules/messager/messager.di-tokens';
|
|
import { HealthModuleOptions } from '@mobicoop/health-module/dist/core/domain/types/health.types';
|
|
import { MessagePublisherPort } from '@mobicoop/ddd-library';
|
|
import { GeographyModule } from '@modules/geography/geography.module';
|
|
import producerServicesConfig from './config/producer-services.config';
|
|
import {
|
|
HEALTH_AD_REPOSITORY,
|
|
HEALTH_CRITICAL_LOGGING_KEY,
|
|
SERVICE_NAME,
|
|
} from './app.constants';
|
|
|
|
@Module({
|
|
imports: [
|
|
ConfigModule.forRoot({ isGlobal: true, load: [producerServicesConfig] }),
|
|
EventEmitterModule.forRoot(),
|
|
RequestContextModule,
|
|
HealthModule.forRootAsync({
|
|
imports: [AdModule, MessagerModule],
|
|
inject: [AD_REPOSITORY, MESSAGE_PUBLISHER],
|
|
useFactory: async (
|
|
adRepository: HealthRepositoryPort,
|
|
messagePublisher: MessagePublisherPort,
|
|
): Promise<HealthModuleOptions> => ({
|
|
serviceName: SERVICE_NAME,
|
|
criticalLoggingKey: HEALTH_CRITICAL_LOGGING_KEY,
|
|
checkRepositories: [
|
|
{
|
|
name: HEALTH_AD_REPOSITORY,
|
|
repository: adRepository,
|
|
},
|
|
],
|
|
messagePublisher,
|
|
}),
|
|
}),
|
|
AdModule,
|
|
GeographyModule,
|
|
MessagerModule,
|
|
],
|
|
exports: [AdModule, GeographyModule, MessagerModule],
|
|
})
|
|
export class AppModule {}
|