2023-04-24 14:44:52 +00:00
|
|
|
import { RabbitMQModule } from '@golevelup/nestjs-rabbitmq';
|
|
|
|
import { Module } from '@nestjs/common';
|
|
|
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
|
|
import { AdMessagerController } from './adapters/primaries/ad-messager.controller';
|
2023-04-25 15:49:47 +00:00
|
|
|
import { AdProfile } from './mappers/ad.profile';
|
|
|
|
import { CreateAdUseCase } from './domain/usecases/create-ad.usecase';
|
|
|
|
import { AdRepository } from './adapters/secondaries/ad.repository';
|
|
|
|
import { DatabaseModule } from '../database/database.module';
|
|
|
|
import { CqrsModule } from '@nestjs/cqrs';
|
2023-04-28 13:53:57 +00:00
|
|
|
import { Messager } from './adapters/secondaries/messager';
|
|
|
|
import { TimezoneFinder } from './adapters/secondaries/timezone-finder';
|
|
|
|
import { GeoTimezoneFinder } from '../geography/adapters/secondaries/geo-timezone-finder';
|
2023-04-24 14:44:52 +00:00
|
|
|
|
|
|
|
@Module({
|
|
|
|
imports: [
|
2023-04-25 15:49:47 +00:00
|
|
|
DatabaseModule,
|
|
|
|
CqrsModule,
|
2023-04-24 14:44:52 +00:00
|
|
|
RabbitMQModule.forRootAsync(RabbitMQModule, {
|
|
|
|
imports: [ConfigModule],
|
|
|
|
useFactory: async (configService: ConfigService) => ({
|
|
|
|
exchanges: [
|
|
|
|
{
|
|
|
|
name: configService.get<string>('RMQ_EXCHANGE'),
|
|
|
|
type: 'topic',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
handlers: {
|
|
|
|
adCreated: {
|
|
|
|
exchange: configService.get<string>('RMQ_EXCHANGE'),
|
|
|
|
routingKey: 'ad.created',
|
2023-04-25 15:49:47 +00:00
|
|
|
queue: 'matcher-ad-created',
|
2023-04-24 14:44:52 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
uri: configService.get<string>('RMQ_URI'),
|
2023-04-24 14:55:14 +00:00
|
|
|
connectionInitOptions: { wait: false },
|
2023-04-24 14:44:52 +00:00
|
|
|
enableControllerDiscovery: true,
|
|
|
|
}),
|
|
|
|
inject: [ConfigService],
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
controllers: [AdMessagerController],
|
2023-04-28 13:53:57 +00:00
|
|
|
providers: [
|
|
|
|
AdProfile,
|
|
|
|
Messager,
|
|
|
|
AdRepository,
|
|
|
|
TimezoneFinder,
|
|
|
|
GeoTimezoneFinder,
|
|
|
|
CreateAdUseCase,
|
|
|
|
],
|
2023-04-24 14:44:52 +00:00
|
|
|
exports: [],
|
|
|
|
})
|
|
|
|
export class AdModule {}
|