@seidor-cloud-produtos/orbit-backend-lib 1.101.30 → 1.101.32

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.
@@ -51,7 +51,7 @@ class AmqpQueue {
51
51
  await channel.close();
52
52
  }
53
53
  catch (err) {
54
- console.log("⛔ Erro ao dar ack:", err);
54
+ console.log('⛔ Erro ao dar ack:', err);
55
55
  }
56
56
  }
57
57
  async nack(channel, msg, requeue = false) {
@@ -60,7 +60,7 @@ class AmqpQueue {
60
60
  await channel.close();
61
61
  }
62
62
  catch (err) {
63
- console.log("⛔ Erro ao dar nack:", err);
63
+ console.log('⛔ Erro ao dar nack:', err);
64
64
  }
65
65
  }
66
66
  async on(queueName, callback) {
@@ -90,10 +90,17 @@ class AmqpQueue {
90
90
  }
91
91
  }
92
92
  async publish(exchangeName, domainEvent, configs) {
93
+ const buildedConfigs = configs || {};
94
+ const isValidExpiration = configs?.expiration === null || typeof configs?.expiration === 'number';
95
+ if (!isValidExpiration) {
96
+ const fourTeenDaysExpiration = 14 * 24 * 60 * 60 * 1000;
97
+ buildedConfigs.expiration = fourTeenDaysExpiration;
98
+ }
93
99
  try {
94
100
  const channel = await this.connection.createChannel();
95
101
  channel.publish(exchangeName, domainEvent.name || '', Buffer.from(JSON.stringify(domainEvent)), {
96
102
  persistent: true,
103
+ ...buildedConfigs,
97
104
  });
98
105
  await channel.close();
99
106
  }
@@ -101,7 +108,7 @@ class AmqpQueue {
101
108
  this.messagesInMemory.push({
102
109
  exchangeName,
103
110
  domainEvent,
104
- configs,
111
+ configs: buildedConfigs,
105
112
  });
106
113
  console.log({
107
114
  message: `⛔ Error to publish messages to: ${domainEvent.name}. Publish in memory!`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seidor-cloud-produtos/orbit-backend-lib",
3
- "version": "1.101.30",
3
+ "version": "1.101.32",
4
4
  "description": "Internal lib for backend components",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",