85 lines
2.8 KiB
TypeScript
85 lines
2.8 KiB
TypeScript
import { Module } from '@nestjs/common';
|
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
import { UserModule } from './modules/user/user.module';
|
|
import {
|
|
ConfigurationModule,
|
|
ConfigurationModuleOptions,
|
|
} from '@mobicoop/configuration-module';
|
|
import {
|
|
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';
|
|
import { EventEmitterModule } from '@nestjs/event-emitter';
|
|
import {
|
|
HEALTH_CRITICAL_LOGGING_KEY,
|
|
HEALTH_USER_REPOSITORY,
|
|
SERVICE_CONFIGURATION_DELETE_QUEUE,
|
|
SERVICE_CONFIGURATION_PROPAGATE_QUEUE,
|
|
SERVICE_CONFIGURATION_SET_QUEUE,
|
|
SERVICE_NAME,
|
|
} from './app.constants';
|
|
|
|
@Module({
|
|
imports: [
|
|
ConfigModule.forRoot({ isGlobal: true }),
|
|
EventEmitterModule.forRoot(),
|
|
ConfigurationModule.forRootAsync({
|
|
imports: [ConfigModule],
|
|
inject: [ConfigService],
|
|
useFactory: async (
|
|
configService: ConfigService,
|
|
): Promise<ConfigurationModuleOptions> => ({
|
|
domain: configService.get<string>(
|
|
'SERVICE_CONFIGURATION_DOMAIN',
|
|
) as string,
|
|
messageBroker: {
|
|
uri: configService.get<string>('MESSAGE_BROKER_URI') as string,
|
|
exchange: {
|
|
name: configService.get<string>(
|
|
'MESSAGE_BROKER_EXCHANGE',
|
|
) as string,
|
|
durable: configService.get<boolean>(
|
|
'MESSAGE_BROKER_EXCHANGE',
|
|
) as boolean,
|
|
},
|
|
},
|
|
redis: {
|
|
host: configService.get<string>('REDIS_HOST') as string,
|
|
password: configService.get<string>('REDIS_PASSWORD'),
|
|
port: configService.get<number>('REDIS_PORT') as number,
|
|
},
|
|
setConfigurationQueue: SERVICE_CONFIGURATION_SET_QUEUE,
|
|
deleteConfigurationQueue: SERVICE_CONFIGURATION_DELETE_QUEUE,
|
|
propagateConfigurationQueue: SERVICE_CONFIGURATION_PROPAGATE_QUEUE,
|
|
}),
|
|
}),
|
|
HealthModule.forRootAsync({
|
|
imports: [UserModule, MessagerModule],
|
|
inject: [USER_REPOSITORY, MESSAGE_PUBLISHER],
|
|
useFactory: async (
|
|
userRepository: HealthRepositoryPort,
|
|
messagePublisher: MessagePublisherPort,
|
|
): Promise<HealthModuleOptions> => ({
|
|
serviceName: SERVICE_NAME,
|
|
criticalLoggingKey: HEALTH_CRITICAL_LOGGING_KEY,
|
|
checkRepositories: [
|
|
{
|
|
name: HEALTH_USER_REPOSITORY,
|
|
repository: userRepository,
|
|
},
|
|
],
|
|
messagePublisher,
|
|
}),
|
|
}),
|
|
UserModule,
|
|
MessagerModule,
|
|
],
|
|
exports: [UserModule, MessagerModule],
|
|
})
|
|
export class AppModule {}
|