Skip to content

Commit d8f80ef

Browse files
committed
refactor(microservices): Extract AmqpExchangeType
Defined a dedicated type for AMQP exchange types to enhance type safety and maintain IDE support, replacing inline union with a named type for better readability and reusability.
1 parent ef632bf commit d8f80ef

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

packages/microservices/external/rmq-url.interface.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,10 @@ export interface AmqplibQueueOptions {
6868
maxPriority?: number;
6969
[key: string]: any;
7070
}
71+
72+
type AmqpMainExchangeType = 'direct' | 'fanout' | 'topic' | 'headers';
73+
74+
/**
75+
* @publicApi
76+
*/
77+
export type AmqpExchangeType = AmqpMainExchangeType | (string & {});

packages/microservices/interfaces/microservice-configuration.interface.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { MqttClientOptions, QoS } from '../external/mqtt-options.interface';
1414
import { IORedisOptions } from '../external/redis.interface';
1515
import {
1616
AmqpConnectionManagerSocketOptions,
17+
AmqpExchangeType,
1718
AmqplibQueueOptions,
1819
RmqUrl,
1920
} from '../external/rmq-url.interface';
@@ -286,7 +287,7 @@ export interface RmqOptions {
286287
* Type of the exchange
287288
* @default 'topic'
288289
*/
289-
exchangeType?: string;
290+
exchangeType?: AmqpExchangeType;
290291
/**
291292
* Additional routing key for the topic exchange.
292293
*/

0 commit comments

Comments
 (0)