35 lines
1021 B
TypeScript
35 lines
1021 B
TypeScript
|
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';
|
||
|
|
||
|
@Module({
|
||
|
imports: [
|
||
|
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',
|
||
|
},
|
||
|
},
|
||
|
uri: configService.get<string>('RMQ_URI'),
|
||
|
connectionInitOptions: { wait: true },
|
||
|
enableControllerDiscovery: true,
|
||
|
}),
|
||
|
inject: [ConfigService],
|
||
|
}),
|
||
|
],
|
||
|
controllers: [AdMessagerController],
|
||
|
providers: [],
|
||
|
exports: [],
|
||
|
})
|
||
|
export class AdModule {}
|