vtlab-generic-functions 1.0.19 → 1.0.21
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/rds/index.js +1 -1
- package/sqs/index.js +28 -3
package/package.json
CHANGED
package/rds/index.js
CHANGED
|
@@ -9,7 +9,7 @@ const {getValueOrNull} = require('../utils/index');
|
|
|
9
9
|
*/
|
|
10
10
|
const connectMyRDS = async (databaseName) => {
|
|
11
11
|
try {
|
|
12
|
-
const dbParams = await config.get(
|
|
12
|
+
const dbParams = await config.get(databaseName, "rds");
|
|
13
13
|
|
|
14
14
|
if (!dbParams) {
|
|
15
15
|
throw new Error('Database name is not valid in the Secret Manager');
|
package/sqs/index.js
CHANGED
|
@@ -78,8 +78,33 @@ const saveIntegrationMessages = async (document = {}) => {
|
|
|
78
78
|
throw error;
|
|
79
79
|
}
|
|
80
80
|
};
|
|
81
|
+
/**
|
|
82
|
+
* Sends a ZPL message to an SQS queue.
|
|
83
|
+
* @async
|
|
84
|
+
* @function sendZplSqsMessage
|
|
85
|
+
* @param {Object} options - The options object.
|
|
86
|
+
* @param {string} options.s3PathOrigin - The S3 path of the origin.
|
|
87
|
+
* @param {string} options.s3PathDestination - The S3 path of the destination.
|
|
88
|
+
* @param {string} [options.type="pdf"] - The type of the message. Defaults to "pdf".
|
|
89
|
+
* @param {string} [options.size="4x6"] - The size of the message. Defaults to "4x6".
|
|
90
|
+
* @throws {Error} Throws an error if required parameters are missing.
|
|
91
|
+
* @returns {Promise<void>} A Promise that resolves when the message is sent.
|
|
92
|
+
*/
|
|
93
|
+
const sendZplSqsMessage = async ({s3PathOrigin, s3PathDestination, type = "pdf", size = "4x6"}) => {
|
|
94
|
+
if (!s3PathOrigin || !s3PathDestination) {
|
|
95
|
+
throw {
|
|
96
|
+
message: 'Missing required parameters'
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const queue = await config.get("microservices.sqs.zplQueue");
|
|
100
|
+
const environment = process.env.NODE_ENV || "develop";
|
|
101
|
+
const payload = {
|
|
102
|
+
s3PathOrigin, s3PathDestination, type, size, environment
|
|
103
|
+
};
|
|
104
|
+
const stageVariables = {environment}
|
|
105
|
+
return await sendSQSMessage({payload, stageVariables}, queue, true);
|
|
106
|
+
}
|
|
81
107
|
|
|
82
108
|
module.exports = {
|
|
83
|
-
saveJobEvent,
|
|
84
|
-
|
|
85
|
-
};
|
|
109
|
+
saveJobEvent, saveIntegrationMessages, sendZplSqsMessage
|
|
110
|
+
};
|