src/lib/client-rmq-exchange-module-options-factory.ts
ClientsModuleOptionsFactory
Properties |
Methods |
|
| Protected Readonly config |
Type : ConfigService
|
Decorators :
@Inject(ConfigService)
|
|
Inherited from
RabbitmqOptionsFactory
|
|
Defined in
RabbitmqOptionsFactory:15
|
| Protected Readonly logger |
Type : Logger
|
Decorators :
@Inject(Logger)
|
|
Inherited from
RabbitmqOptionsFactory
|
|
Defined in
RabbitmqOptionsFactory:18
|
| Protected Readonly vault |
Type : RabbitmqVaultService
|
Decorators :
@Inject(RabbitmqVaultService)
|
|
Inherited from
RabbitmqOptionsFactory
|
|
Defined in
RabbitmqOptionsFactory:21
|
| Async createClientOptions | ||||||||||||
createClientOptions(name: string, type: string)
|
||||||||||||
|
Parameters :
Returns :
Promise<ClientRmqExchangeModuleOptions>
|
| Async build |
build()
|
|
Inherited from
RabbitmqOptionsFactory
|
|
Defined in
RabbitmqOptionsFactory:23
|
|
Returns :
Promise<BaseRmqOptions>
|
| Async buildUrl |
buildUrl()
|
|
Inherited from
RabbitmqOptionsFactory
|
|
Defined in
RabbitmqOptionsFactory:71
|
|
Returns :
Promise<string>
|
| Async getCredentials |
getCredentials()
|
|
Inherited from
RabbitmqOptionsFactory
|
|
Defined in
RabbitmqOptionsFactory:50
|
|
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,
},
}
};
}
}