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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/sqs/index.js +13 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vtlab-generic-functions",
3
- "version": "1.0.21",
3
+ "version": "1.0.22",
4
4
  "scripts": {
5
5
  "test": "jest"
6
6
  },
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
- const sqsClient = new SQSClient({
20
- region: awsCredentials.region,
21
- credentials: {
22
- accessKeyId: awsCredentials.accessKeyId,
23
- secretAccessKey: awsCredentials.secretAccessKey
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),