Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | import { Global, Module } from '@nestjs/common'; import { EventEmitterModule } from '@nestjs/event-emitter'; import { ClientsModule } from '@nestjs/microservices'; import { EventSdkModule } from 'src/packages/event-sdk'; import { getKafkaCustomOptionsV1 } from 'src/shared/config/kafka.config'; import ENV from 'src/shared/env'; import { EventApiController } from './controllers/event.api.controller'; import { BuiltinKafkaService } from './services/builtin-kafka.service'; import { BuiltinRabbitMQService } from './services/builtin-rabbitmq.service'; import { CustomKafkaService } from './services/custom-kafka.service'; import { KAFKA_SERVICE_TOKEN, RABBITMQ_SERVICE_TOKEN } from './shared/event.const'; import { eventProviders } from './shared/event.provider'; const imports = [EventEmitterModule.forRoot()]; /** https://docs.nestjs.com/techniques/events */ Iif (!ENV.KAFKA.IS_CUSTOM_CLIENT || !ENV.RABBITMQ.IS_CUSTOM_CLIENT) { imports.push( ClientsModule.registerAsync(eventProviders), ); /** https://docs.nestjs.com/microservices/basics */ } Iif (ENV.KAFKA.IS_CUSTOM_CLIENT) { imports.push(EventSdkModule.forKafkajs(getKafkaCustomOptionsV1())); // imports.push(EventSdkModule.forRdKafka(getKafkaCustomOptionsV2())); } @Global() @Module({ imports, controllers: [EventApiController], providers: [ { provide: RABBITMQ_SERVICE_TOKEN, useClass: BuiltinRabbitMQService, }, { provide: KAFKA_SERVICE_TOKEN, useClass: ENV.KAFKA.IS_CUSTOM_CLIENT ? CustomKafkaService : BuiltinKafkaService, }, ], }) export class EventModule {} |