import { Module } from '@nestjs/common'; import { CqrsModule } from '@nestjs/cqrs'; import { DatabaseModule } from '../database/database.module'; import { AuthenticationController } from './adapters/primaries/authentication.controller'; import { CreateAuthenticationUseCase } from './domain/usecases/create-authentication.usecase'; import { ValidateAuthenticationUseCase } from './domain/usecases/validate-authentication.usecase'; import { AuthenticationProfile } from './mappers/authentication.profile'; import { AuthenticationRepository } from './adapters/secondaries/authentication.repository'; import { UpdateUsernameUseCase } from './domain/usecases/update-username.usecase'; import { UsernameProfile } from './mappers/username.profile'; import { AddUsernameUseCase } from './domain/usecases/add-username.usecase'; import { UpdatePasswordUseCase } from './domain/usecases/update-password.usecase'; import { DeleteUsernameUseCase } from './domain/usecases/delete-username.usecase'; import { DeleteAuthenticationUseCase } from './domain/usecases/delete-authentication.usecase'; import { RabbitMQModule } from '@golevelup/nestjs-rabbitmq'; import { ConfigModule, ConfigService } from '@nestjs/config'; import { AuthenticationMessagerController } from './adapters/primaries/authentication-messager.controller'; import { Messager } from './adapters/secondaries/messager'; @Module({ imports: [ DatabaseModule, CqrsModule, RabbitMQModule.forRootAsync(RabbitMQModule, { imports: [ConfigModule], useFactory: async (configService: ConfigService) => ({ exchanges: [ { name: configService.get('RMQ_EXCHANGE'), type: 'topic', }, ], handlers: { userUpdate: { exchange: configService.get('RMQ_EXCHANGE'), routingKey: 'user.update', }, userDelete: { exchange: configService.get('RMQ_EXCHANGE'), routingKey: 'user.delete', }, }, uri: configService.get('RMQ_URI'), connectionInitOptions: { wait: false }, enableControllerDiscovery: true, }), inject: [ConfigService], }), ], controllers: [AuthenticationController, AuthenticationMessagerController], providers: [ AuthenticationProfile, UsernameProfile, AuthenticationRepository, Messager, ValidateAuthenticationUseCase, CreateAuthenticationUseCase, AddUsernameUseCase, UpdateUsernameUseCase, UpdatePasswordUseCase, DeleteUsernameUseCase, DeleteAuthenticationUseCase, ], exports: [], }) export class AuthenticationModule {}