@candlerip/shared3 0.0.101 → 0.0.102
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +16 -1
- package/src/_devops/get-project-config/domains/args/index.d.ts +5 -0
- package/src/_devops/get-project-config/domains/args/index.js +1 -0
- package/src/_devops/get-project-config/domains/index.d.ts +1 -0
- package/src/_devops/get-project-config/domains/index.js +1 -0
- package/src/_devops/get-project-config/index.d.ts +2 -0
- package/src/_devops/get-project-config/index.js +18 -0
- package/src/aws/account-id/config.d.ts +1 -0
- package/src/aws/account-id/config.js +1 -0
- package/src/aws/account-id/index.d.ts +1 -0
- package/src/aws/account-id/index.js +1 -0
- package/src/aws/app-config/get-app-config/index.d.ts +1 -0
- package/src/aws/app-config/get-app-config/index.js +1 -0
- package/src/aws/app-config/get-app-config/util.d.ts +10 -0
- package/src/aws/app-config/get-app-config/util.js +79 -0
- package/src/aws/app-config/index.d.ts +1 -0
- package/src/aws/app-config/index.js +1 -0
- package/src/aws/cdk/attach-policy/index.d.ts +1 -0
- package/src/aws/cdk/attach-policy/index.js +1 -0
- package/src/aws/cdk/attach-policy/type.d.ts +24 -0
- package/src/aws/cdk/attach-policy/type.js +1 -0
- package/src/aws/cdk/attach-policy/util.d.ts +2 -0
- package/src/aws/cdk/attach-policy/util.js +33 -0
- package/src/aws/cdk/compose-cdk-stack/index.d.ts +1 -0
- package/src/aws/cdk/compose-cdk-stack/index.js +1 -0
- package/src/aws/cdk/compose-cdk-stack/type.d.ts +2 -0
- package/src/aws/cdk/compose-cdk-stack/type.js +1 -0
- package/src/aws/cdk/compose-cdk-stack/util.d.ts +2 -0
- package/src/aws/cdk/compose-cdk-stack/util.js +2 -0
- package/src/aws/cdk/index.d.ts +2 -0
- package/src/aws/cdk/index.js +2 -0
- package/src/aws/index.d.ts +7 -0
- package/src/aws/index.js +7 -0
- package/src/aws/lambda/index.d.ts +2 -0
- package/src/aws/lambda/index.js +2 -0
- package/src/aws/lambda/lambda-arn/compose-lambda-arn/index.d.ts +1 -0
- package/src/aws/lambda/lambda-arn/compose-lambda-arn/index.js +1 -0
- package/src/aws/lambda/lambda-arn/compose-lambda-arn/type.d.ts +2 -0
- package/src/aws/lambda/lambda-arn/compose-lambda-arn/type.js +1 -0
- package/src/aws/lambda/lambda-arn/compose-lambda-arn/util.d.ts +2 -0
- package/src/aws/lambda/lambda-arn/compose-lambda-arn/util.js +2 -0
- package/src/aws/lambda/lambda-arn/config.d.ts +1 -0
- package/src/aws/lambda/lambda-arn/config.js +3 -0
- package/src/aws/lambda/lambda-arn/index.d.ts +2 -0
- package/src/aws/lambda/lambda-arn/index.js +2 -0
- package/src/aws/lambda/lambda-name/config.d.ts +1 -0
- package/src/aws/lambda/lambda-name/config.js +1 -0
- package/src/aws/lambda/lambda-name/index.d.ts +2 -0
- package/src/aws/lambda/lambda-name/index.js +2 -0
- package/src/aws/lambda/lambda-name/type.d.ts +2 -0
- package/src/aws/lambda/lambda-name/type.js +1 -0
- package/src/aws/region/config.d.ts +1 -0
- package/src/aws/region/config.js +1 -0
- package/src/aws/region/default.d.ts +2 -0
- package/src/aws/region/default.js +1 -0
- package/src/aws/region/index.d.ts +3 -0
- package/src/aws/region/index.js +3 -0
- package/src/aws/region/type.d.ts +2 -0
- package/src/aws/region/type.js +1 -0
- package/src/aws/s3/index.d.ts +1 -0
- package/src/aws/s3/index.js +1 -0
- package/src/aws/s3/s3-arn/compose-s3-arn/index.d.ts +1 -0
- package/src/aws/s3/s3-arn/compose-s3-arn/index.js +1 -0
- package/src/aws/s3/s3-arn/compose-s3-arn/type.d.ts +1 -0
- package/src/aws/s3/s3-arn/compose-s3-arn/type.js +1 -0
- package/src/aws/s3/s3-arn/compose-s3-arn/util.d.ts +2 -0
- package/src/aws/s3/s3-arn/compose-s3-arn/util.js +2 -0
- package/src/aws/s3/s3-arn/config.d.ts +1 -0
- package/src/aws/s3/s3-arn/config.js +1 -0
- package/src/aws/s3/s3-arn/index.d.ts +2 -0
- package/src/aws/s3/s3-arn/index.js +2 -0
- package/src/aws/sqs/index.d.ts +2 -0
- package/src/aws/sqs/index.js +2 -0
- package/src/aws/sqs/queue-arn/compose-queue-arn/index.d.ts +1 -0
- package/src/aws/sqs/queue-arn/compose-queue-arn/index.js +1 -0
- package/src/aws/sqs/queue-arn/compose-queue-arn/type.d.ts +2 -0
- package/src/aws/sqs/queue-arn/compose-queue-arn/type.js +1 -0
- package/src/aws/sqs/queue-arn/compose-queue-arn/util.d.ts +2 -0
- package/src/aws/sqs/queue-arn/compose-queue-arn/util.js +2 -0
- package/src/aws/sqs/queue-arn/config.d.ts +1 -0
- package/src/aws/sqs/queue-arn/config.js +3 -0
- package/src/aws/sqs/queue-arn/index.d.ts +2 -0
- package/src/aws/sqs/queue-arn/index.js +2 -0
- package/src/aws/sqs/queue-name/cache/config.d.ts +1 -0
- package/src/aws/sqs/queue-name/cache/config.js +1 -0
- package/src/aws/sqs/queue-name/cache/index.d.ts +2 -0
- package/src/aws/sqs/queue-name/cache/index.js +2 -0
- package/src/aws/sqs/queue-name/cache/type.d.ts +2 -0
- package/src/aws/sqs/queue-name/cache/type.js +1 -0
- package/src/aws/sqs/queue-name/index.d.ts +3 -0
- package/src/aws/sqs/queue-name/index.js +3 -0
- package/src/aws/sqs/queue-name/logger/config.d.ts +1 -0
- package/src/aws/sqs/queue-name/logger/config.js +1 -0
- package/src/aws/sqs/queue-name/logger/index.d.ts +2 -0
- package/src/aws/sqs/queue-name/logger/index.js +2 -0
- package/src/aws/sqs/queue-name/logger/type.d.ts +2 -0
- package/src/aws/sqs/queue-name/logger/type.js +1 -0
- package/src/aws/sqs/queue-name/queue-name/config.d.ts +1 -0
- package/src/aws/sqs/queue-name/queue-name/config.js +3 -0
- package/src/aws/sqs/queue-name/queue-name/index.d.ts +2 -0
- package/src/aws/sqs/queue-name/queue-name/index.js +2 -0
- package/src/aws/sqs/queue-name/queue-name/type.d.ts +2 -0
- package/src/aws/sqs/queue-name/queue-name/type.js +1 -0
- package/src/backend/cache/cache/index.d.ts +2 -0
- package/src/backend/cache/cache/index.js +2 -0
- package/src/backend/cache/cache/singleton.d.ts +23 -0
- package/src/backend/cache/cache/singleton.js +104 -0
- package/src/backend/cache/cache/type.d.ts +5 -0
- package/src/backend/cache/cache/type.js +1 -0
- package/src/backend/cache/cache-key/config.d.ts +1 -0
- package/src/backend/cache/cache-key/config.js +18 -0
- package/src/backend/cache/cache-key/index.d.ts +3 -0
- package/src/backend/cache/cache-key/index.js +3 -0
- package/src/backend/cache/cache-key/type-guard.d.ts +2 -0
- package/src/backend/cache/cache-key/type-guard.js +4 -0
- package/src/backend/cache/cache-key/type.d.ts +2 -0
- package/src/backend/cache/cache-key/type.js +1 -0
- package/src/backend/cache/index.d.ts +2 -0
- package/src/backend/cache/index.js +2 -0
- package/src/backend/database/connect-database/index.d.ts +1 -0
- package/src/backend/database/connect-database/index.js +1 -0
- package/src/backend/database/connect-database/type.d.ts +1 -0
- package/src/backend/database/connect-database/type.js +1 -0
- package/src/backend/database/connect-database/util.d.ts +2 -0
- package/src/backend/database/connect-database/util.js +12 -0
- package/src/backend/database/model/translation/index.d.ts +2 -0
- package/src/backend/database/model/translation/index.js +2 -0
- package/src/backend/database/model/translation/type.d.ts +7 -0
- package/src/backend/database/model/translation/type.js +1 -0
- package/src/backend/database/model/translation/util.d.ts +7 -0
- package/src/backend/database/model/translation/util.js +7 -0
- package/src/backend/database/mutation/translation/get-translations/index.d.ts +1 -0
- package/src/backend/database/mutation/translation/get-translations/index.js +1 -0
- package/src/backend/database/mutation/translation/get-translations/type.d.ts +8 -0
- package/src/backend/database/mutation/translation/get-translations/type.js +1 -0
- package/src/backend/database/mutation/translation/get-translations/util.d.ts +2 -0
- package/src/backend/database/mutation/translation/get-translations/util.js +30 -0
- package/src/backend/database/mutation/translation/get-translations-as-dictionary/index.d.ts +1 -0
- package/src/backend/database/mutation/translation/get-translations-as-dictionary/index.js +1 -0
- package/src/backend/database/mutation/translation/get-translations-as-dictionary/util.d.ts +7 -0
- package/src/backend/database/mutation/translation/get-translations-as-dictionary/util.js +51 -0
- package/src/backend/database/mutation/translation/index.d.ts +2 -0
- package/src/backend/database/mutation/translation/index.js +2 -0
- package/src/backend/dictionary/compose-dictionary/index.d.ts +1 -0
- package/src/backend/dictionary/compose-dictionary/index.js +1 -0
- package/src/backend/dictionary/compose-dictionary/type.d.ts +10 -0
- package/src/backend/dictionary/compose-dictionary/type.js +1 -0
- package/src/backend/dictionary/compose-dictionary/util.d.ts +2 -0
- package/src/backend/dictionary/compose-dictionary/util.js +10 -0
- package/src/backend/dictionary/get-excluded-translation-ids/index.d.ts +1 -0
- package/src/backend/dictionary/get-excluded-translation-ids/index.js +1 -0
- package/src/backend/dictionary/get-excluded-translation-ids/type.d.ts +5 -0
- package/src/backend/dictionary/get-excluded-translation-ids/type.js +1 -0
- package/src/backend/dictionary/get-excluded-translation-ids/util.d.ts +2 -0
- package/src/backend/dictionary/get-excluded-translation-ids/util.js +10 -0
- package/src/backend/dictionary/index.d.ts +2 -0
- package/src/backend/dictionary/index.js +2 -0
- package/src/backend/express/index.d.ts +1 -0
- package/src/backend/express/index.js +1 -0
- package/src/backend/express/start-express-app/index.d.ts +1 -0
- package/src/backend/express/start-express-app/index.js +1 -0
- package/src/backend/express/start-express-app/type.d.ts +2 -0
- package/src/backend/express/start-express-app/type.js +1 -0
- package/src/backend/express/start-express-app/util.d.ts +2 -0
- package/src/backend/express/start-express-app/util.js +8 -0
- package/src/backend/message-broker/index.d.ts +4 -0
- package/src/backend/message-broker/index.js +4 -0
- package/src/backend/message-broker/log-custom-error/index.d.ts +1 -0
- package/src/backend/message-broker/log-custom-error/index.js +1 -0
- package/src/backend/message-broker/log-custom-error/type.d.ts +2 -0
- package/src/backend/message-broker/log-custom-error/type.js +1 -0
- package/src/backend/message-broker/log-custom-error/util.d.ts +2 -0
- package/src/backend/message-broker/log-custom-error/util.js +2 -0
- package/src/backend/message-broker/message-broker/config.d.ts +4 -0
- package/src/backend/message-broker/message-broker/config.js +4 -0
- package/src/backend/message-broker/message-broker/index.d.ts +3 -0
- package/src/backend/message-broker/message-broker/index.js +3 -0
- package/src/backend/message-broker/message-broker/singleton.d.ts +7 -0
- package/src/backend/message-broker/message-broker/singleton.js +70 -0
- package/src/backend/message-broker/message-broker/type.d.ts +12 -0
- package/src/backend/message-broker/message-broker/type.js +1 -0
- package/src/backend/message-broker/message-broker-queue-name/index.d.ts +1 -0
- package/src/backend/message-broker/message-broker-queue-name/index.js +1 -0
- package/src/backend/message-broker/message-broker-queue-name/type.d.ts +2 -0
- package/src/backend/message-broker/message-broker-queue-name/type.js +1 -0
- package/src/backend/message-broker/message-broker-refresh-cache/index.d.ts +2 -0
- package/src/backend/message-broker/message-broker-refresh-cache/index.js +2 -0
- package/src/backend/message-broker/message-broker-refresh-cache/refresh-cache/index.d.ts +1 -0
- package/src/backend/message-broker/message-broker-refresh-cache/refresh-cache/index.js +1 -0
- package/src/backend/message-broker/message-broker-refresh-cache/refresh-cache/type.d.ts +2 -0
- package/src/backend/message-broker/message-broker-refresh-cache/refresh-cache/type.js +1 -0
- package/src/backend/message-broker/message-broker-refresh-cache/refresh-cache/util.d.ts +2 -0
- package/src/backend/message-broker/message-broker-refresh-cache/refresh-cache/util.js +6 -0
- package/src/backend/message-broker/message-broker-refresh-cache/type.d.ts +4 -0
- package/src/backend/message-broker/message-broker-refresh-cache/type.js +1 -0
@@ -0,0 +1,70 @@
|
|
1
|
+
import amqp from 'amqplib';
|
2
|
+
import { consoleCustomError, customErrorWorker } from '../../../error/index.js';
|
3
|
+
export const MessageBrokerSingleton = (() => {
|
4
|
+
let _channel;
|
5
|
+
let _connection;
|
6
|
+
let _errorMessage = 'Initializing MessageBroker';
|
7
|
+
let _url;
|
8
|
+
let _customErrorWorker;
|
9
|
+
const checkErrorStatus = () => {
|
10
|
+
if (_errorMessage) {
|
11
|
+
return _customErrorWorker.composeCustomError(_errorMessage);
|
12
|
+
}
|
13
|
+
return;
|
14
|
+
};
|
15
|
+
const connect = async () => {
|
16
|
+
try {
|
17
|
+
_connection = await amqp.connect(_url);
|
18
|
+
_connection.on('error', (_err) => {
|
19
|
+
handleError(_err);
|
20
|
+
});
|
21
|
+
_channel = await _connection.createChannel();
|
22
|
+
_errorMessage = null;
|
23
|
+
}
|
24
|
+
catch (err) {
|
25
|
+
handleError(err);
|
26
|
+
}
|
27
|
+
};
|
28
|
+
const handleError = (err) => {
|
29
|
+
_customErrorWorker.addInfo({ err });
|
30
|
+
_errorMessage = 'Error connect Rabbitmq';
|
31
|
+
setTimeout(connect, 10000);
|
32
|
+
};
|
33
|
+
const init = (url) => {
|
34
|
+
_url = url;
|
35
|
+
_customErrorWorker = customErrorWorker({ url });
|
36
|
+
connect();
|
37
|
+
};
|
38
|
+
const listenQueue = async (queue, onMessage) => {
|
39
|
+
const resp = checkErrorStatus();
|
40
|
+
if (resp) {
|
41
|
+
consoleCustomError(resp.customError);
|
42
|
+
console.error('QUEUE:', queue);
|
43
|
+
setTimeout(() => listenQueue(queue, onMessage), 10000);
|
44
|
+
return;
|
45
|
+
}
|
46
|
+
await _channel.assertQueue(queue, { durable: true });
|
47
|
+
_channel.consume(queue, (msg) => {
|
48
|
+
if (msg) {
|
49
|
+
onMessage(JSON.parse(msg.content.toString()));
|
50
|
+
_channel.ack(msg);
|
51
|
+
}
|
52
|
+
});
|
53
|
+
};
|
54
|
+
const sendMessage = async (queueName, message) => {
|
55
|
+
const resp = checkErrorStatus();
|
56
|
+
if (resp) {
|
57
|
+
consoleCustomError(resp.customError);
|
58
|
+
console.error('QUEUE:', queueName);
|
59
|
+
console.error('MESSAGE:', message);
|
60
|
+
return;
|
61
|
+
}
|
62
|
+
await _channel.assertQueue(queueName, { durable: true });
|
63
|
+
_channel.sendToQueue(queueName, Buffer.from(JSON.stringify(message)));
|
64
|
+
};
|
65
|
+
return {
|
66
|
+
init,
|
67
|
+
listenQueue,
|
68
|
+
sendMessage,
|
69
|
+
};
|
70
|
+
})();
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { MessageBrokerRefreshCache } from '../message-broker-refresh-cache/index.js';
|
2
|
+
import { MessageBrokerQueueName } from '../message-broker-queue-name/index.js';
|
3
|
+
import { MESSAGE_BROKER_CONFIG } from './config.js';
|
4
|
+
import { CustomError } from '../../../error/index.js';
|
5
|
+
export type MessageBroker = {
|
6
|
+
[key in MessageBrokerQueueName]: TypeMap[(typeof MESSAGE_BROKER_CONFIG)[key]];
|
7
|
+
};
|
8
|
+
interface TypeMap {
|
9
|
+
'MessageBrokerRefreshCache | null': MessageBrokerRefreshCache | null;
|
10
|
+
CustomError: CustomError;
|
11
|
+
}
|
12
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './type.js';
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './type.js';
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './util.js';
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './util.js';
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|