import { Global, Module } from '@nestjs/common';
import { EventEmitterModule } from '@nestjs/event-emitter';
import { BullModule } from '@nestjs/bullmq';
import { EventBusService } from './event-bus.service';
import { QUEUE_DOMAIN_EVENTS } from '../../infrastructure/queue/queue.service';

@Global()
@Module({
  imports: [
    EventEmitterModule.forRoot({ wildcard: true, delimiter: '.' }),
    BullModule.registerQueue({ name: QUEUE_DOMAIN_EVENTS }),
  ],
  providers: [EventBusService],
  exports: [EventBusService, EventEmitterModule],
})
export class EventBusModule {}
