@kaushverse/rabbitmq-core 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,36 +1,25 @@
1
1
  import { Options, Channel, ConsumeMessage } from 'amqplib';
2
+ import { EventEmitter } from 'events';
2
3
 
3
4
  interface RabbitTLSOptions {
4
5
  caPath?: string;
5
6
  servername?: string;
6
7
  rejectUnauthorized?: boolean;
7
8
  }
8
- interface RabbitConnectionOptions$1 {
9
- url: string;
10
- tls?: RabbitTLSOptions;
11
- socketOptions?: Options.Connect;
12
- }
13
-
14
9
  interface RabbitConnectionOptions {
15
10
  url: string;
16
11
  tls?: RabbitTLSOptions;
12
+ socketOptions?: Options.Connect;
17
13
  }
18
- declare function connectRabbitMQ(options: RabbitConnectionOptions): Promise<Channel>;
19
- declare function getChannel(): Channel;
20
- declare function closeRabbitMQ(): Promise<void>;
21
- declare function isRabbitConnected(): boolean;
22
-
14
+ type ExchangeType = "direct" | "topic" | "fanout" | "headers";
23
15
  interface ConsumeOptions {
24
16
  queue: string;
25
17
  exchange: string;
26
- type: "direct" | "topic" | "fanout" | "headers";
18
+ type: ExchangeType;
27
19
  routingKey?: string;
28
20
  prefetch?: number;
29
21
  noAck?: boolean;
30
22
  }
31
- declare function consumeMessage(options: ConsumeOptions, handler: (data: any, raw: ConsumeMessage) => Promise<void> | void): Promise<void>;
32
-
33
- type ExchangeType = "direct" | "topic" | "fanout" | "headers";
34
23
  interface PublishOptions {
35
24
  exchange: string;
36
25
  type: ExchangeType;
@@ -38,6 +27,15 @@ interface PublishOptions {
38
27
  message: Buffer | string | object;
39
28
  headers?: Record<string, any>;
40
29
  }
30
+
31
+ declare const rabbitEvents: EventEmitter<[never]>;
32
+ declare function connectRabbitMQ(options: RabbitConnectionOptions): Promise<Channel>;
33
+ declare function getChannel(): Channel;
34
+ declare function closeRabbitMQ(): Promise<void>;
35
+ declare function isRabbitConnected(): boolean;
36
+
37
+ declare function consumeMessage(options: ConsumeOptions, handler: (data: any, raw: ConsumeMessage) => Promise<void> | void): Promise<void>;
38
+
41
39
  declare function publishMessage({ exchange, type, routingKey, message, headers, }: PublishOptions): Promise<void>;
42
40
 
43
- export { type RabbitConnectionOptions$1 as RabbitConnectionOptions, type RabbitTLSOptions, closeRabbitMQ, connectRabbitMQ, consumeMessage, getChannel, isRabbitConnected, publishMessage };
41
+ export { type ConsumeOptions, type ExchangeType, type PublishOptions, type RabbitConnectionOptions, type RabbitTLSOptions, closeRabbitMQ, connectRabbitMQ, consumeMessage, getChannel, isRabbitConnected, publishMessage, rabbitEvents };
package/dist/index.js CHANGED
@@ -35,7 +35,8 @@ __export(index_exports, {
35
35
  consumeMessage: () => consumeMessage,
36
36
  getChannel: () => getChannel,
37
37
  isRabbitConnected: () => isRabbitConnected,
38
- publishMessage: () => publishMessage
38
+ publishMessage: () => publishMessage,
39
+ rabbitEvents: () => rabbitEvents
39
40
  });
40
41
  module.exports = __toCommonJS(index_exports);
41
42
 
@@ -175,5 +176,6 @@ async function publishMessage({
175
176
  consumeMessage,
176
177
  getChannel,
177
178
  isRabbitConnected,
178
- publishMessage
179
+ publishMessage,
180
+ rabbitEvents
179
181
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaushverse/rabbitmq-core",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Reusable RabbitMQ (AMQP / AMQPS) core for Node.js & microservices",
5
5
  "author": "Kaushik (KaushVerse)",
6
6
  "license": "MIT",