2023-04-06 09:12:49 +00:00
|
|
|
import { Module } from '@nestjs/common';
|
2023-08-16 10:28:20 +00:00
|
|
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
2023-05-02 15:26:04 +00:00
|
|
|
import { AdModule } from './modules/ad/ad.module';
|
2023-08-16 10:28:20 +00:00
|
|
|
import {
|
|
|
|
ConfigurationModule,
|
|
|
|
ConfigurationModuleOptions,
|
|
|
|
} from '@mobicoop/configuration-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';
|
2023-08-18 10:47:51 +00:00
|
|
|
import { GeographyModule } from '@modules/geography/geography.module';
|
2023-10-18 08:21:43 +00:00
|
|
|
import {
|
|
|
|
HEALTH_AD_REPOSITORY,
|
|
|
|
HEALTH_CRITICAL_LOGGING_KEY,
|
|
|
|
SERVICE_CONFIGURATION_DELETE_QUEUE,
|
|
|
|
SERVICE_CONFIGURATION_PROPAGATE_QUEUE,
|
|
|
|
SERVICE_CONFIGURATION_SET_QUEUE,
|
|
|
|
SERVICE_NAME,
|
|
|
|
} from './app.constants';
|
2023-04-06 09:12:49 +00:00
|
|
|
|
|
|
|
@Module({
|
|
|
|
imports: [
|
|
|
|
ConfigModule.forRoot({ isGlobal: true }),
|
2023-08-16 10:28:20 +00:00
|
|
|
EventEmitterModule.forRoot(),
|
|
|
|
RequestContextModule,
|
2023-05-30 09:41:30 +00:00
|
|
|
ConfigurationModule.forRootAsync({
|
2023-08-16 10:28:20 +00:00
|
|
|
imports: [ConfigModule],
|
|
|
|
inject: [ConfigService],
|
|
|
|
useFactory: async (
|
|
|
|
configService: ConfigService,
|
|
|
|
): Promise<ConfigurationModuleOptions> => ({
|
2023-08-25 14:01:19 +00:00
|
|
|
domain: configService.get<string>(
|
|
|
|
'SERVICE_CONFIGURATION_DOMAIN',
|
|
|
|
) as string,
|
2023-08-16 10:28:20 +00:00
|
|
|
messageBroker: {
|
2023-08-25 14:01:19 +00:00
|
|
|
uri: configService.get<string>('MESSAGE_BROKER_URI') as string,
|
2023-10-18 08:21:43 +00:00
|
|
|
exchange: {
|
|
|
|
name: configService.get<string>(
|
|
|
|
'MESSAGE_BROKER_EXCHANGE',
|
|
|
|
) as string,
|
|
|
|
durable: configService.get<boolean>(
|
|
|
|
'MESSAGE_BROKER_EXCHANGE_DURABILITY',
|
|
|
|
) as boolean,
|
|
|
|
},
|
2023-08-16 10:28:20 +00:00
|
|
|
},
|
|
|
|
redis: {
|
2023-08-25 14:01:19 +00:00
|
|
|
host: configService.get<string>('REDIS_HOST') as string,
|
2023-08-16 10:28:20 +00:00
|
|
|
password: configService.get<string>('REDIS_PASSWORD'),
|
2023-08-25 14:01:19 +00:00
|
|
|
port: configService.get<number>('REDIS_PORT') as number,
|
2023-08-16 10:28:20 +00:00
|
|
|
},
|
2023-10-18 08:21:43 +00:00
|
|
|
setConfigurationQueue: SERVICE_CONFIGURATION_SET_QUEUE,
|
|
|
|
deleteConfigurationQueue: SERVICE_CONFIGURATION_DELETE_QUEUE,
|
|
|
|
propagateConfigurationQueue: SERVICE_CONFIGURATION_PROPAGATE_QUEUE,
|
2023-08-16 10:28:20 +00:00
|
|
|
}),
|
|
|
|
}),
|
|
|
|
HealthModule.forRootAsync({
|
|
|
|
imports: [AdModule, MessagerModule],
|
|
|
|
inject: [AD_REPOSITORY, MESSAGE_PUBLISHER],
|
|
|
|
useFactory: async (
|
|
|
|
adRepository: HealthRepositoryPort,
|
|
|
|
messagePublisher: MessagePublisherPort,
|
|
|
|
): Promise<HealthModuleOptions> => ({
|
2023-10-18 08:21:43 +00:00
|
|
|
serviceName: SERVICE_NAME,
|
|
|
|
criticalLoggingKey: HEALTH_CRITICAL_LOGGING_KEY,
|
2023-08-16 10:28:20 +00:00
|
|
|
checkRepositories: [
|
|
|
|
{
|
2023-10-18 08:21:43 +00:00
|
|
|
name: HEALTH_AD_REPOSITORY,
|
2023-08-16 10:28:20 +00:00
|
|
|
repository: adRepository,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
messagePublisher,
|
|
|
|
}),
|
2023-05-30 09:41:30 +00:00
|
|
|
}),
|
2023-04-24 14:44:52 +00:00
|
|
|
AdModule,
|
2023-08-18 10:47:51 +00:00
|
|
|
GeographyModule,
|
2023-08-16 10:28:20 +00:00
|
|
|
MessagerModule,
|
2023-04-06 09:12:49 +00:00
|
|
|
],
|
2023-08-18 14:50:55 +00:00
|
|
|
exports: [AdModule, GeographyModule, MessagerModule],
|
2023-04-06 09:12:49 +00:00
|
|
|
})
|
|
|
|
export class AppModule {}
|