matcher/src/app.module.ts

69 lines
2.5 KiB
TypeScript
Raw Normal View History

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,
ConfigurationModule.forRootAsync({
2023-08-16 10:28:20 +00:00
imports: [ConfigModule],
inject: [ConfigService],
useFactory: async (
configService: ConfigService,
): Promise<ConfigurationModuleOptions> => ({
domain: configService.get<string>('SERVICE_CONFIGURATION_DOMAIN'),
messageBroker: {
uri: configService.get<string>('MESSAGE_BROKER_URI'),
exchange: configService.get<string>('MESSAGE_BROKER_EXCHANGE'),
},
redis: {
host: configService.get<string>('REDIS_HOST'),
password: configService.get<string>('REDIS_PASSWORD'),
port: configService.get<number>('REDIS_PORT'),
},
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-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-16 10:28:20 +00:00
exports: [AdModule, MessagerModule],
2023-04-06 09:12:49 +00:00
})
export class AppModule {}