2022-12-13 12:39:06 +00:00
|
|
|
import { Module } from '@nestjs/common';
|
2023-06-02 13:56:23 +00:00
|
|
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
2023-03-31 08:33:59 +00:00
|
|
|
import { UserModule } from './modules/user/user.module';
|
2023-06-02 13:56:23 +00:00
|
|
|
import {
|
|
|
|
ConfigurationModule,
|
|
|
|
ConfigurationModuleOptions,
|
|
|
|
} from '@mobicoop/configuration-module';
|
|
|
|
import {
|
2023-07-20 15:22:31 +00:00
|
|
|
HealthModule,
|
|
|
|
HealthModuleOptions,
|
|
|
|
HealthRepositoryPort,
|
|
|
|
} from '@mobicoop/health-module';
|
|
|
|
import { MessagerModule } from './modules/messager/messager.module';
|
|
|
|
import { USER_REPOSITORY } from './modules/user/user.di-tokens';
|
|
|
|
import { MESSAGE_PUBLISHER } from './modules/messager/messager.di-tokens';
|
|
|
|
import { MessagePublisherPort } from '@mobicoop/ddd-library';
|
2022-12-13 12:39:06 +00:00
|
|
|
|
|
|
|
@Module({
|
2022-12-14 10:37:13 +00:00
|
|
|
imports: [
|
|
|
|
ConfigModule.forRoot({ isGlobal: true }),
|
2023-07-20 15:22:31 +00:00
|
|
|
ConfigurationModule.forRootAsync({
|
|
|
|
imports: [ConfigModule],
|
|
|
|
inject: [ConfigService],
|
|
|
|
useFactory: async (
|
|
|
|
configService: ConfigService,
|
|
|
|
): Promise<ConfigurationModuleOptions> => ({
|
|
|
|
domain: configService.get<string>('SERVICE_CONFIGURATION_DOMAIN'),
|
|
|
|
messageBroker: {
|
2023-06-02 13:56:23 +00:00
|
|
|
uri: configService.get<string>('MESSAGE_BROKER_URI'),
|
|
|
|
exchange: configService.get<string>('MESSAGE_BROKER_EXCHANGE'),
|
2023-07-20 15:22:31 +00:00
|
|
|
},
|
|
|
|
redis: {
|
|
|
|
host: configService.get<string>('REDIS_HOST'),
|
|
|
|
password: configService.get<string>('REDIS_PASSWORD'),
|
|
|
|
port: configService.get<number>('REDIS_PORT'),
|
|
|
|
},
|
|
|
|
setConfigurationBrokerQueue: 'user-configuration-create-update',
|
|
|
|
deleteConfigurationQueue: 'user-configuration-delete',
|
|
|
|
propagateConfigurationQueue: 'user-configuration-propagate',
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
HealthModule.forRootAsync({
|
|
|
|
imports: [UserModule, MessagerModule],
|
|
|
|
inject: [USER_REPOSITORY, MESSAGE_PUBLISHER],
|
|
|
|
useFactory: async (
|
|
|
|
userRepository: HealthRepositoryPort,
|
|
|
|
messagePublisher: MessagePublisherPort,
|
|
|
|
): Promise<HealthModuleOptions> => ({
|
|
|
|
serviceName: 'user',
|
|
|
|
criticalLoggingKey: 'logging.user.health.crit',
|
|
|
|
checkRepositories: [
|
|
|
|
{
|
|
|
|
name: 'UserRepository',
|
|
|
|
repository: userRepository,
|
2023-06-02 13:56:23 +00:00
|
|
|
},
|
2023-07-20 15:22:31 +00:00
|
|
|
],
|
|
|
|
messagePublisher,
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
UserModule,
|
|
|
|
MessagerModule,
|
2022-12-14 10:37:13 +00:00
|
|
|
],
|
2023-07-20 15:22:31 +00:00
|
|
|
exports: [UserModule, MessagerModule],
|
2022-12-13 12:39:06 +00:00
|
|
|
})
|
|
|
|
export class AppModule {}
|