@seidor-cloud-produtos/orbit-backend-lib 0.0.52 → 0.0.54
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/README.md +0 -0
- package/dist/clean-arch/application/queue/handler.d.ts +0 -0
- package/dist/clean-arch/application/queue/handler.js +0 -0
- package/dist/clean-arch/application/queue/messages-in-memory.d.ts +0 -0
- package/dist/clean-arch/application/queue/messages-in-memory.js +0 -0
- package/dist/clean-arch/application/queue/queue-connection.d.ts +0 -0
- package/dist/clean-arch/application/queue/queue-connection.js +0 -0
- package/dist/clean-arch/application/queue/queue.d.ts +0 -0
- package/dist/clean-arch/application/queue/queue.js +0 -0
- package/dist/clean-arch/domain/entities/aggregate-root.d.ts +0 -0
- package/dist/clean-arch/domain/entities/aggregate-root.js +0 -0
- package/dist/clean-arch/domain/entities/common-dto.d.ts +0 -0
- package/dist/clean-arch/domain/entities/common-dto.js +0 -0
- package/dist/clean-arch/domain/entities/entity.d.ts +0 -0
- package/dist/clean-arch/domain/entities/entity.js +0 -0
- package/dist/clean-arch/domain/entities/unique-entity-id.d.ts +0 -0
- package/dist/clean-arch/domain/entities/unique-entity-id.js +0 -0
- package/dist/clean-arch/domain/entities/value-object.d.ts +0 -0
- package/dist/clean-arch/domain/entities/value-object.js +0 -0
- package/dist/clean-arch/domain/entities/watched-list.d.ts +0 -0
- package/dist/clean-arch/domain/entities/watched-list.js +0 -0
- package/dist/clean-arch/domain/entities/watched-list.spec.d.ts +0 -0
- package/dist/clean-arch/domain/entities/watched-list.spec.js +0 -0
- package/dist/clean-arch/domain/errors/application-error.d.ts +0 -0
- package/dist/clean-arch/domain/errors/application-error.js +0 -0
- package/dist/clean-arch/domain/errors/domain-error.d.ts +0 -0
- package/dist/clean-arch/domain/errors/domain-error.js +0 -0
- package/dist/clean-arch/domain/errors/invalid-password-algorithm-error.d.ts +0 -0
- package/dist/clean-arch/domain/errors/invalid-password-algorithm-error.js +0 -0
- package/dist/clean-arch/domain/errors/invalid-password-length-error.d.ts +0 -0
- package/dist/clean-arch/domain/errors/invalid-password-length-error.js +0 -0
- package/dist/clean-arch/domain/errors/validation-error.d.ts +0 -0
- package/dist/clean-arch/domain/errors/validation-error.js +0 -0
- package/dist/clean-arch/domain/events/domain-event.d.ts +0 -0
- package/dist/clean-arch/domain/events/domain-event.js +0 -0
- package/dist/clean-arch/domain/factories/create-password-factory.d.ts +0 -0
- package/dist/clean-arch/domain/factories/create-password-factory.js +0 -0
- package/dist/clean-arch/domain/factories/random-password-temporary-factory.d.ts +0 -0
- package/dist/clean-arch/domain/factories/random-password-temporary-factory.js +0 -0
- package/dist/clean-arch/domain/types/optional.d.ts +0 -0
- package/dist/clean-arch/domain/types/optional.js +0 -0
- package/dist/clean-arch/domain/value-objects/password.d.ts +0 -0
- package/dist/clean-arch/domain/value-objects/password.js +0 -0
- package/dist/clean-arch/domain/value-objects/pbkdf2-password.d.ts +0 -0
- package/dist/clean-arch/domain/value-objects/pbkdf2-password.js +0 -0
- package/dist/clean-arch/domain/value-objects/sha1-password.d.ts +0 -0
- package/dist/clean-arch/domain/value-objects/sha1-password.js +0 -0
- package/dist/clean-arch/infra/adapters/express-adapter.d.ts +0 -0
- package/dist/clean-arch/infra/adapters/express-adapter.js +0 -0
- package/dist/clean-arch/infra/adapters/fastify-adapter.d.ts +0 -0
- package/dist/clean-arch/infra/adapters/fastify-adapter.js +0 -0
- package/dist/clean-arch/infra/authorizations/authorization.d.ts +0 -0
- package/dist/clean-arch/infra/authorizations/authorization.js +0 -0
- package/dist/clean-arch/infra/authorizations/authorizer.d.ts +0 -0
- package/dist/clean-arch/infra/authorizations/authorizer.js +0 -0
- package/dist/clean-arch/infra/authorizations/authorizer.spec.d.ts +0 -0
- package/dist/clean-arch/infra/authorizations/authorizer.spec.js +0 -0
- package/dist/clean-arch/infra/authorizations/not-allowed.d.ts +0 -0
- package/dist/clean-arch/infra/authorizations/not-allowed.js +0 -0
- package/dist/clean-arch/infra/errors/infra-error.d.ts +0 -0
- package/dist/clean-arch/infra/errors/infra-error.js +0 -0
- package/dist/clean-arch/infra/http/controller.d.ts +0 -0
- package/dist/clean-arch/infra/http/controller.js +0 -0
- package/dist/clean-arch/infra/http/handle-bool-filter.d.ts +0 -0
- package/dist/clean-arch/infra/http/handle-bool-filter.js +0 -0
- package/dist/clean-arch/infra/http/handle-is-active-query.d.ts +0 -0
- package/dist/clean-arch/infra/http/handle-is-active-query.js +0 -0
- package/dist/clean-arch/infra/http/handle-sort-param-query.d.ts +0 -0
- package/dist/clean-arch/infra/http/handle-sort-param-query.js +0 -0
- package/dist/clean-arch/infra/http/handle-user-headers.d.ts +0 -0
- package/dist/clean-arch/infra/http/handle-user-headers.js +0 -0
- package/dist/clean-arch/infra/http/health-connections.d.ts +0 -0
- package/dist/clean-arch/infra/http/health-connections.js +0 -0
- package/dist/clean-arch/infra/http/http.d.ts +0 -0
- package/dist/clean-arch/infra/http/http.js +0 -0
- package/dist/clean-arch/infra/queue/create-consumers.d.ts +0 -0
- package/dist/clean-arch/infra/queue/create-consumers.js +0 -0
- package/dist/clean-arch/infra/queue/in-memory/in-memory-queue.d.ts +0 -0
- package/dist/clean-arch/infra/queue/in-memory/in-memory-queue.js +0 -0
- package/dist/clean-arch/infra/queue/queue-controller.d.ts +0 -0
- package/dist/clean-arch/infra/queue/queue-controller.js +0 -0
- package/dist/clean-arch/infra/queue/rabbitmq/amqp-lib.d.ts +1 -1
- package/dist/clean-arch/infra/queue/rabbitmq/amqp-lib.js +38 -32
- package/dist/clean-arch/infra/queue/rabbitmq/amqp-lib.spec.d.ts +0 -0
- package/dist/clean-arch/infra/queue/rabbitmq/amqp-lib.spec.js +0 -0
- package/dist/clean-arch/shared/pagination/dto-response.d.ts +0 -0
- package/dist/clean-arch/shared/pagination/dto-response.js +0 -0
- package/dist/clean-arch/shared/pagination/get-take-and-skip.d.ts +0 -0
- package/dist/clean-arch/shared/pagination/get-take-and-skip.js +0 -0
- package/dist/clean-arch/shared/pagination/pagination.d.ts +0 -0
- package/dist/clean-arch/shared/pagination/pagination.js +0 -0
- package/dist/frameworks/express/api-gateway/mapping-model.d.ts +0 -0
- package/dist/frameworks/express/api-gateway/mapping-model.js +0 -0
- package/dist/frameworks/express/api-gateway/mapping-model.spec.d.ts +0 -0
- package/dist/frameworks/express/api-gateway/mapping-model.spec.js +0 -0
- package/dist/frameworks/express/api-gateway/middleware-express.d.ts +0 -0
- package/dist/frameworks/express/api-gateway/middleware-express.js +0 -0
- package/dist/frameworks/express/authorizations/authorization-express.d.ts +0 -0
- package/dist/frameworks/express/authorizations/authorization-express.js +0 -0
- package/dist/frameworks/express/authorizations/authorization-express.spec.d.ts +0 -0
- package/dist/frameworks/express/authorizations/authorization-express.spec.js +0 -0
- package/dist/frameworks/express/authorizations/middleware-express.d.ts +0 -0
- package/dist/frameworks/express/authorizations/middleware-express.js +0 -0
- package/dist/frameworks/express/types.d.ts +0 -0
- package/dist/frameworks/express/types.js +0 -0
- package/dist/frameworks/nest/authorizations/authorization-nest.d.ts +0 -0
- package/dist/frameworks/nest/authorizations/authorization-nest.js +0 -0
- package/dist/frameworks/nest/authorizations/guard-nest.d.ts +0 -0
- package/dist/frameworks/nest/authorizations/guard-nest.js +0 -0
- package/dist/index.d.ts +0 -0
- package/dist/index.js +0 -0
- package/dist/infra/authorizations/auth-matcher.d.ts +0 -0
- package/dist/infra/authorizations/auth-matcher.js +0 -0
- package/dist/infra/authorizations/auth-matcher.spec.d.ts +0 -0
- package/dist/infra/authorizations/auth-matcher.spec.js +0 -0
- package/dist/infra/authorizations/validator/api/api-validator.d.ts +0 -0
- package/dist/infra/authorizations/validator/api/api-validator.js +0 -0
- package/dist/infra/authorizations/validator/api/factories/unauthorized-response-factory.d.ts +0 -0
- package/dist/infra/authorizations/validator/api/factories/unauthorized-response-factory.js +0 -0
- package/dist/infra/authorizations/validator/api/factories/unauthorized-response-factory.spec.d.ts +0 -0
- package/dist/infra/authorizations/validator/api/factories/unauthorized-response-factory.spec.js +0 -0
- package/dist/infra/authorizations/validator/auth-validator.d.ts +0 -0
- package/dist/infra/authorizations/validator/auth-validator.js +0 -0
- package/dist/infra/authorizations/validator/auth-validator.spec.d.ts +0 -0
- package/dist/infra/authorizations/validator/auth-validator.spec.js +0 -0
- package/dist/infra/http/api-gateway/mapping-model.d.ts +0 -0
- package/dist/infra/http/api-gateway/mapping-model.js +4 -1
- package/dist/infra/http/api-gateway/mapping-model.spec.d.ts +0 -0
- package/dist/infra/http/api-gateway/mapping-model.spec.js +0 -0
- package/dist/infra/http/errors/api-common-error.d.ts +0 -0
- package/dist/infra/http/errors/api-common-error.js +0 -0
- package/dist/infra/http/errors/api-error.d.ts +0 -0
- package/dist/infra/http/errors/api-error.js +0 -0
- package/dist/infra/http/errors/unauthorized-response.d.ts +0 -0
- package/dist/infra/http/errors/unauthorized-response.js +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -23,7 +23,7 @@ export default class AmqpQueue implements QueueConnection {
|
|
|
23
23
|
setController(controller?: QueueController): this;
|
|
24
24
|
static getInstance(vHost: string): Promise<AmqpQueue>;
|
|
25
25
|
private treatReconnection;
|
|
26
|
-
private
|
|
26
|
+
private reconnectionChannels;
|
|
27
27
|
private publishMessagesOfMemory;
|
|
28
28
|
}
|
|
29
29
|
type CreateConsumers = {
|
|
@@ -5,7 +5,7 @@ const amqplib_1 = tslib_1.__importDefault(require('amqplib'));
|
|
|
5
5
|
class AmqpQueue {
|
|
6
6
|
constructor() {
|
|
7
7
|
this.messagesInMemory = [];
|
|
8
|
-
this.channels =
|
|
8
|
+
this.channels = new Map();
|
|
9
9
|
this.uri = process.env.BROKER_AMQP;
|
|
10
10
|
}
|
|
11
11
|
async connect(vHost) {
|
|
@@ -14,6 +14,7 @@ class AmqpQueue {
|
|
|
14
14
|
this.vHost = vHost;
|
|
15
15
|
await this.treatReconnection(vHost);
|
|
16
16
|
if (process.env.NODE_ENV !== 'test') {
|
|
17
|
+
console.log('\n');
|
|
17
18
|
console.log(`🐝 Queue connected on vHost: ${this.vHost}`);
|
|
18
19
|
}
|
|
19
20
|
return this;
|
|
@@ -21,34 +22,31 @@ class AmqpQueue {
|
|
|
21
22
|
async close() {
|
|
22
23
|
await this.connection.close();
|
|
23
24
|
if (process.env.NODE_ENV !== 'test') {
|
|
24
|
-
console.log(
|
|
25
|
+
console.log(`⛔ Queue closed on vHost ${this.vHost}`);
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
async on(queueName, callback) {
|
|
28
29
|
try {
|
|
29
30
|
const channel = await this.connection.createChannel();
|
|
30
|
-
this.channels.
|
|
31
|
+
this.channels.set(queueName, callback);
|
|
31
32
|
await channel.prefetch(callback.getSimultaneity());
|
|
32
|
-
await channel
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
this.channels.length !== 0 && channel.reject(message, false);
|
|
33
|
+
await channel.consume(queueName, async message => {
|
|
34
|
+
try {
|
|
35
|
+
await callback.handle(JSON.parse(message?.content.toString()));
|
|
36
|
+
channel.ack(message);
|
|
37
|
+
} catch (_) {
|
|
38
|
+
if (process.env.NODE_ENV === 'test') {
|
|
39
|
+
return;
|
|
42
40
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
});
|
|
41
|
+
channel.reject(message, false);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
47
44
|
console.log(`🍯 Consume on queue: [${queueName}] on vHost ${this.vHost}`);
|
|
48
45
|
} catch (err) {
|
|
49
|
-
console.log(
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
console.log({
|
|
47
|
+
message: `⛔ Error to consume messages: [${queueName}] on vHost ${this.vHost}`,
|
|
48
|
+
error: err,
|
|
49
|
+
});
|
|
52
50
|
}
|
|
53
51
|
}
|
|
54
52
|
async publish(exchangeName, domainEvent, configs) {
|
|
@@ -69,9 +67,10 @@ class AmqpQueue {
|
|
|
69
67
|
domainEvent,
|
|
70
68
|
configs,
|
|
71
69
|
});
|
|
72
|
-
console.log(
|
|
73
|
-
|
|
74
|
-
|
|
70
|
+
console.log({
|
|
71
|
+
message: `⛔ Error to publish messages to: ${domainEvent.name}. Publish in memory!`,
|
|
72
|
+
error: err,
|
|
73
|
+
});
|
|
75
74
|
}
|
|
76
75
|
}
|
|
77
76
|
async createConsumers(queueName, configs) {
|
|
@@ -107,9 +106,10 @@ class AmqpQueue {
|
|
|
107
106
|
);
|
|
108
107
|
await channel.close();
|
|
109
108
|
} catch (err) {
|
|
110
|
-
console.log(
|
|
111
|
-
|
|
112
|
-
|
|
109
|
+
console.log({
|
|
110
|
+
message: `⛔ Error to create queue: ${queueName} on vHost ${this.vHost}`,
|
|
111
|
+
error: err,
|
|
112
|
+
});
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
setController(controller) {
|
|
@@ -129,31 +129,37 @@ class AmqpQueue {
|
|
|
129
129
|
async treatReconnection(vHost) {
|
|
130
130
|
this.connection.removeAllListeners('close');
|
|
131
131
|
this.connection.on('close', async () => {
|
|
132
|
-
|
|
132
|
+
console.log('\n');
|
|
133
|
+
console.log('⛔ Connection Closed!!');
|
|
134
|
+
console.log(`⟳ Try connection to the vHost: ${vHost}`);
|
|
133
135
|
const interval = setInterval(async () => {
|
|
134
136
|
try {
|
|
135
137
|
AmqpQueue.instance = await this.connect(vHost);
|
|
136
138
|
this.controller;
|
|
139
|
+
await this.reconnectionChannels();
|
|
137
140
|
await this.publishMessagesOfMemory();
|
|
138
141
|
clearInterval(interval);
|
|
139
142
|
} catch {
|
|
140
|
-
console.log(
|
|
143
|
+
console.log(`⟳ Trying to connection to the vHost: ${vHost}`);
|
|
141
144
|
}
|
|
142
145
|
}, 5000);
|
|
143
146
|
});
|
|
144
147
|
}
|
|
145
|
-
async
|
|
146
|
-
for (const
|
|
147
|
-
await
|
|
148
|
+
async reconnectionChannels() {
|
|
149
|
+
for (const [queueName, callback] of this.channels) {
|
|
150
|
+
await this.on(queueName, callback);
|
|
148
151
|
}
|
|
149
|
-
this.channels = [];
|
|
150
152
|
}
|
|
151
153
|
async publishMessagesOfMemory() {
|
|
152
154
|
if (this.messagesInMemory.length > 0) {
|
|
153
155
|
while (this.messagesInMemory.length > 0) {
|
|
154
156
|
const data = this.messagesInMemory.shift();
|
|
155
157
|
await this.publish(data.exchangeName, data.domainEvent, data.configs);
|
|
158
|
+
console.log(
|
|
159
|
+
`✅ Publishing memory message to: [${data.domainEvent.name}]`,
|
|
160
|
+
);
|
|
156
161
|
}
|
|
162
|
+
console.log('✅ Published memory messages!');
|
|
157
163
|
}
|
|
158
164
|
}
|
|
159
165
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/index.d.ts
CHANGED
|
File without changes
|
package/dist/index.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/infra/authorizations/validator/api/factories/unauthorized-response-factory.d.ts
CHANGED
|
File without changes
|
|
File without changes
|
package/dist/infra/authorizations/validator/api/factories/unauthorized-response-factory.spec.d.ts
CHANGED
|
File without changes
|
package/dist/infra/authorizations/validator/api/factories/unauthorized-response-factory.spec.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -10,7 +10,10 @@ class MappingModel {
|
|
|
10
10
|
const params = body['api-gateway-params'];
|
|
11
11
|
if (!params) return this.next();
|
|
12
12
|
for (const key in params.header) {
|
|
13
|
-
if (
|
|
13
|
+
if (
|
|
14
|
+
this.getHeaders()[key] === undefined ||
|
|
15
|
+
key.toUpperCase() === 'ACCEPT'
|
|
16
|
+
) {
|
|
14
17
|
this.setHeader(key, params.header[key]);
|
|
15
18
|
}
|
|
16
19
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|