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-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,
|
|
|
|
exchange: configService.get<string>(
|
|
|
|
'MESSAGE_BROKER_EXCHANGE',
|
|
|
|
) as string,
|
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
|
|
|
},
|
|
|
|
setConfigurationBrokerQueue: 'matcher-configuration-create-update',
|
|
|
|
deleteConfigurationQueue: 'matcher-configuration-delete',
|
|
|
|
propagateConfigurationQueue: 'matcher-configuration-propagate',
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
HealthModule.forRootAsync({
|
|
|
|
imports: [AdModule, MessagerModule],
|
|
|
|
inject: [AD_REPOSITORY, MESSAGE_PUBLISHER],
|
|
|
|
useFactory: async (
|
|
|
|
adRepository: HealthRepositoryPort,
|
|
|
|
messagePublisher: MessagePublisherPort,
|
|
|
|
): Promise<HealthModuleOptions> => ({
|
|
|
|
serviceName: 'matcher',
|
|
|
|
criticalLoggingKey: 'logging.matcher.health.crit',
|
|
|
|
checkRepositories: [
|
|
|
|
{
|
|
|
|
name: 'AdRepository',
|
|
|
|
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 {}
|