@seidor-cloud-produtos/orbit-backend-lib 2.0.11 → 2.0.12

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.
@@ -90,11 +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,
97
- ...(configs || {}),
103
+ ...buildedConfigs,
98
104
  });
99
105
  await channel.close();
100
106
  }
@@ -102,7 +108,7 @@ class AmqpQueue {
102
108
  this.messagesInMemory.push({
103
109
  exchangeName,
104
110
  domainEvent,
105
- configs,
111
+ configs: buildedConfigs,
106
112
  });
107
113
  console.log({
108
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": "2.0.11",
3
+ "version": "2.0.12",
4
4
  "description": "Internal lib for backend components",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",