sb-rabbitmq-provider 1.0.14 → 1.0.16

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
@@ -3,9 +3,22 @@
3
3
  * if all connections are established then ready event will get triggered
4
4
  */
5
5
  import { Connection as RabbitmqClientConnection, Channel as RabbitMQChannel, Options } from 'amqplib';
6
+ interface rabbitMQConfig {
7
+ protocol?: string | undefined;
8
+ hostname?: string | undefined;
9
+ port?: number | undefined;
10
+ username?: string | undefined;
11
+ password?: string | undefined;
12
+ locale?: string | undefined;
13
+ frameMax?: number | undefined;
14
+ heartbeat?: number | undefined;
15
+ vhost?: string | undefined;
16
+ exchangeName?: string;
17
+ exchangeType: string;
18
+ }
6
19
  type MyCallback = (data: any) => any;
7
20
  declare class RabbitMqConnection {
8
- url: string;
21
+ config: rabbitMQConfig;
9
22
  exchange: string;
10
23
  exchangeType: string;
11
24
  connection: any;
@@ -15,7 +28,7 @@ declare class RabbitMqConnection {
15
28
  * @param exchange rabbitmq exchange name
16
29
  * @param exchangeType type of exchange
17
30
  */
18
- constructor(url?: string, exchange?: string, exchangeType?: string);
31
+ constructor(config: rabbitMQConfig);
19
32
  /**
20
33
  * creates the rabbitmq connection
21
34
  * connection must be single, with multiple channel
package/dist/index.js CHANGED
@@ -24,16 +24,16 @@ class RabbitMqConnection {
24
24
  * @param exchange rabbitmq exchange name
25
25
  * @param exchangeType type of exchange
26
26
  */
27
- constructor(url = 'amqp://127.0.0.1:5672', exchange, exchangeType) {
27
+ constructor(config) {
28
28
  this.exchange = 'EXCHANGE';
29
29
  this.exchangeType = 'direct';
30
- this.url = url;
31
- if (exchange && typeof exchange === 'string') {
32
- this.exchange = exchange;
30
+ if (config.exchangeName && typeof config.exchangeName === 'string') {
31
+ this.exchange = config.exchangeName;
33
32
  }
34
- if (exchangeType && typeof exchangeType === 'string') {
35
- this.exchangeType = exchangeType;
33
+ if (config.exchangeType && typeof config.exchangeType === 'string') {
34
+ this.exchangeType = config.exchangeType;
36
35
  }
36
+ this.config = config;
37
37
  }
38
38
  /**
39
39
  * creates the rabbitmq connection
@@ -43,7 +43,7 @@ class RabbitMqConnection {
43
43
  createConnection() {
44
44
  return __awaiter(this, void 0, void 0, function* () {
45
45
  try {
46
- const connection = yield amqplib_1.default.connect(this.url);
46
+ const connection = yield amqplib_1.default.connect(this.config);
47
47
  // console.log('---RabbitMQ Connection Created---')
48
48
  this.connection = connection;
49
49
  return connection;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sb-rabbitmq-provider",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "description": "Pub/Sub model for RabbitMq",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",