ad/src/app.module.ts

70 lines
2.3 KiB
TypeScript
Raw Normal View History

2023-05-03 11:43:21 +00:00
import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
2023-05-04 08:05:23 +00:00
import { HealthModule } from './modules/health/health.module';
import { AdModule } from './modules/ad/ad.module';
import { AutomapperModule } from '@automapper/nestjs';
import { classes } from '@automapper/classes';
import {
MessageBrokerModule,
MessageBrokerModuleOptions,
} from '@mobicoop/message-broker-module';
import {
ConfigurationModule,
ConfigurationModuleOptions,
} from '@mobicoop/configuration-module';
2023-05-03 11:43:21 +00:00
@Module({
imports: [
ConfigModule.forRoot({ isGlobal: true }),
AutomapperModule.forRoot({ strategyInitializer: classes() }),
MessageBrokerModule.forRootAsync(
{
imports: [ConfigModule],
inject: [ConfigService],
useFactory: async (
configService: ConfigService,
): Promise<MessageBrokerModuleOptions> => ({
uri: configService.get<string>('MESSAGE_BROKER_URI'),
exchange: configService.get<string>('MESSAGE_BROKER_EXCHANGE'),
}),
},
false,
),
ConfigurationModule.forRootAsync(
{
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'),
},
setConfigurationBrokerRoutingKeys: [
'configuration.create',
'configuration.update',
],
deleteConfigurationRoutingKey: 'configuration.delete',
propagateConfigurationRoutingKey: 'configuration.propagate',
setConfigurationBrokerQueue: 'ad-configuration-create-update',
deleteConfigurationQueue: 'ad-configuration-delete',
propagateConfigurationQueue: 'ad-configuration-propagate',
}),
},
true,
),
2023-05-04 08:05:23 +00:00
HealthModule,
AdModule,
],
2023-05-03 11:43:21 +00:00
controllers: [],
providers: [],
})
export class AppModule {}