File

src/lib/client-rmq-exchange-module-options-factory.ts

Extends

RabbitmqOptionsFactory

Implements

ClientsModuleOptionsFactory

Index

Properties
Methods

Properties

Protected Readonly config
Type : ConfigService
Decorators :
@Inject(ConfigService)
Inherited from RabbitmqOptionsFactory
Protected Readonly logger
Type : Logger
Decorators :
@Inject(Logger)
Inherited from RabbitmqOptionsFactory
Protected Readonly vault
Type : RabbitmqVaultService
Decorators :
@Inject(RabbitmqVaultService)
Inherited from RabbitmqOptionsFactory

Methods

Async createClientOptions
createClientOptions(name: string, type: string)
Parameters :
Name Type Optional Default value
name string No this.config.getOrThrow('RABBITMQ_EXCHANGE_NAME')
type string No this.config.get('RABBITMQ_EXCHANGE_TYPE', 'topic')
Async build
build()
Inherited from RabbitmqOptionsFactory
Async buildUrl
buildUrl()
Inherited from RabbitmqOptionsFactory
Returns : Promise<string>
Async getCredentials
getCredentials()
Inherited from RabbitmqOptionsFactory
Returns : Promise<literal type>
import { ClientsModuleOptionsFactory } from '@nestjs/microservices';
import { CustomClientOptions } from '@nestjs/microservices/interfaces';
import { ClientRMQExchange } from './client-rmq-exchange';
import { ExchangeRmqOptions } from './options';
import { RabbitmqOptionsFactory } from './rabbitmq-options-factory';

export interface ClientRmqExchangeModuleOptions extends CustomClientOptions {
  options: ExchangeRmqOptions
}

export class ClientRmqExchangeModuleOptionsFactory extends RabbitmqOptionsFactory implements ClientsModuleOptionsFactory {

  async createClientOptions(
    name: string = this.config.getOrThrow('RABBITMQ_EXCHANGE_NAME'),
    type: string = this.config.get('RABBITMQ_EXCHANGE_TYPE', 'topic'),
  ): Promise<ClientRmqExchangeModuleOptions> {

    const options = await this.build();

    this.logger.debug(`Using exchange '${ name }' with type '${type}'`, 'ClientRmqExchangeModuleOptionsFactory');

    return {
      customClass: ClientRMQExchange,
      options: {
        ...options,
        exchange: {
          name,
          type,
        },
      }
    };
  }

}

results matching ""

    No results matching ""