vtlab-generic-functions 1.0.21 → 1.0.22
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/package.json +1 -1
- package/sqs/index.js +13 -8
package/package.json
CHANGED
package/sqs/index.js
CHANGED
|
@@ -11,18 +11,23 @@ const validator = require('../validator');
|
|
|
11
11
|
* @returns {Promise<Object>} - A promise that resolves to the response from SQS.
|
|
12
12
|
* @throws {Error} - Throws an error if sending the message fails.
|
|
13
13
|
*/
|
|
14
|
+
|
|
15
|
+
let sqsClient;
|
|
16
|
+
|
|
14
17
|
const sendSQSMessage = async (message, queueUrl, isFIFOQueue = true) => {
|
|
15
18
|
try {
|
|
16
|
-
const awsCredentials = await config.get('awsCredentials');
|
|
17
19
|
const environment = process.env.NODE_ENV || 'develop';
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
if (!sqsClient) {
|
|
22
|
+
const awsCredentials = await config.get('awsCredentials');
|
|
23
|
+
sqsClient = new SQSClient({
|
|
24
|
+
region: awsCredentials.region,
|
|
25
|
+
credentials: {
|
|
26
|
+
accessKeyId: awsCredentials.accessKeyId,
|
|
27
|
+
secretAccessKey: awsCredentials.secretAccessKey
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
26
31
|
|
|
27
32
|
const params = {
|
|
28
33
|
MessageBody: JSON.stringify(message),
|