@seidor-cloud-produtos/orbit-backend-lib 2.0.69 → 2.0.71

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.
@@ -2,7 +2,6 @@ import amqp from 'amqplib';
2
2
  import Handler from '../../../application/queue/handler';
3
3
  import QueueConnection from '../../../application/queue/queue-connection';
4
4
  import DomainEvent from '../../../domain/events/domain-event';
5
- import QueueController from '../queue-controller';
6
5
  import { AmqpQueueGetResult } from './types';
7
6
  import { Logger } from '../../../application/logger';
8
7
  interface SocketOptions {
@@ -19,7 +18,6 @@ export default class AmqpQueue implements QueueConnection {
19
18
  private vHost;
20
19
  private connection;
21
20
  private messagesInMemory;
22
- private controller;
23
21
  private channels;
24
22
  protected socketOptions?: SocketOptions;
25
23
  constructor(socketOptions?: SocketOptions, uri?: string, logger?: Logger);
@@ -34,7 +32,6 @@ export default class AmqpQueue implements QueueConnection {
34
32
  private publishToServer;
35
33
  private static delayOperation;
36
34
  createConsumers(queueName: string, configs: CreateConsumers): Promise<void>;
37
- setController(controller?: QueueController): this;
38
35
  static getInstance(vHost: string, socketOptions?: SocketOptions, uri?: string): Promise<AmqpQueue>;
39
36
  private treatReconnection;
40
37
  private reconnectionChannels;
@@ -11,7 +11,6 @@ class AmqpQueue {
11
11
  vHost;
12
12
  connection;
13
13
  messagesInMemory = [];
14
- controller;
15
14
  channels = new Map();
16
15
  socketOptions;
17
16
  constructor(socketOptions, uri = process.env.BROKER_AMQP, logger = console) {
@@ -180,8 +179,12 @@ class AmqpQueue {
180
179
  await channel.assertExchange(`${configs.exchangeName}.DLX`, configs.exchangeType || 'direct', {
181
180
  durable: true,
182
181
  });
182
+ const oneDayMs = 86400000;
183
183
  await channel.assertQueue(`${queueName}.DLQ`, {
184
184
  durable: true,
185
+ arguments: {
186
+ 'x-message-ttl': 7 * oneDayMs,
187
+ },
185
188
  });
186
189
  await channel.bindQueue(`${queueName}.DLQ`, `${configs.exchangeName}.DLX`, `${queueName || ''}.DLK`);
187
190
  await channel.close();
@@ -193,12 +196,6 @@ class AmqpQueue {
193
196
  });
194
197
  }
195
198
  }
196
- setController(controller) {
197
- if (controller) {
198
- this.controller = controller;
199
- }
200
- return this;
201
- }
202
199
  static async getInstance(vHost, socketOptions, uri) {
203
200
  if (AmqpQueue.instance && AmqpQueue.instance.vHost === vHost) {
204
201
  return AmqpQueue.instance;
@@ -11,6 +11,9 @@ class MappingModel {
11
11
  const params = body ? body['api-gateway-params'] : undefined;
12
12
  if (!params)
13
13
  return this.next();
14
+ if (!params.context) {
15
+ params.context = {};
16
+ }
14
17
  for (const key in params.header) {
15
18
  if (this.getHeaders()[key] === undefined ||
16
19
  (key?.toUpperCase && ['ACCEPT'].includes(key.toUpperCase()))) {
@@ -33,7 +36,7 @@ class MappingModel {
33
36
  }
34
37
  }
35
38
  let fiscalIdsFromTenantHeaderValue = '[]';
36
- if (params.context?.fiscalIdsFromTenant) {
39
+ if (params.context.fiscalIdsFromTenant) {
37
40
  fiscalIdsFromTenantHeaderValue = JSON.stringify(params.context.fiscalIdsFromTenant);
38
41
  }
39
42
  return this.setHeader('authorizations', params.context.authorizations)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seidor-cloud-produtos/orbit-backend-lib",
3
- "version": "2.0.69",
3
+ "version": "2.0.71",
4
4
  "description": "Internal lib for backend components",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",