golevelup / nestjs

A collection of badass modules and utilities to help you level up your NestJS applications 🚀
MIT License
2.16k stars 244 forks source link

feat(amqp/connection.ts): add publishOptions to RequestOptions; use them in AmqpConnection.request #723

Closed davidmwhynot closed 3 months ago

davidmwhynot commented 3 months ago

Added a new property named "publishOptions" to the RequestOptions interface so that the additional options available in the amqplib's Options.Publish interface can be provided when making rpc requests. Added said usage of the new property to the AmqpConnection.request method's call to this.publish.

re #719

davidmwhynot commented 3 months ago

This could also have been done like so:

export interface RequestOptions extends Omit<Options.Publish, 'replyTo'> {
  exchange: string;
  routingKey: string;
  timeout?: number;
  payload?: any;
}

// usage in AmqpConnection.request:
await this.publish(
  requestOptions.exchange,
  requestOptions.routingKey,
  payload,
  {
    ...requestOptions,
    replyTo: DIRECT_REPLY_QUEUE,
    correlationId,
  }
);

however, I did not want to pollute the existing RequestOptions interface with the relatively large number of additional options on the amqplib's Options.Publish interface.

I'm will to adjust to this style if it's preferred over the current change.

WonderPanda commented 3 months ago

Published as @golevelup/nestjs-rabbitmq@5.3.0