@shushed/helpers 0.0.198-v2-20251107121008 → 0.0.198-v2-20251107122648
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.
|
@@ -655,9 +655,9 @@ class EnvEngine extends runtime_1.default {
|
|
|
655
655
|
const rawRequestBody = co_body_1.default.text(nodeReq, {
|
|
656
656
|
limit: '2mb'
|
|
657
657
|
});
|
|
658
|
-
requestBody = await rawRequestBody.then(x => JSON.parse(x)).catch(err => {
|
|
658
|
+
requestBody = await (rawRequestBody.then(x => JSON.parse(x)).catch(err => {
|
|
659
659
|
throw new Error('Could not parse the request of the body. Body provided: ' + requestBody + '. Error message: ' + err.message);
|
|
660
|
-
});
|
|
660
|
+
}));
|
|
661
661
|
}
|
|
662
662
|
const receivedArrayOfRequests = Array.isArray(requestBody);
|
|
663
663
|
const requestBodies = receivedArrayOfRequests ? requestBody : [requestBody];
|
|
@@ -665,12 +665,12 @@ class EnvEngine extends runtime_1.default {
|
|
|
665
665
|
for (let i = 0; i < requestBodies.length; i++) {
|
|
666
666
|
const requestBody = requestBodies[i];
|
|
667
667
|
let messageBody;
|
|
668
|
-
let messageBodyRaw;
|
|
668
|
+
let messageBodyRaw = null;
|
|
669
669
|
if (typeof requestBody?.message?.data === 'string' && Buffer.from(requestBody.message.data, "base64").toString('base64') === requestBody.message.data) {
|
|
670
670
|
messageBodyRaw = Buffer.from(requestBody.message.data, "base64").toString('utf-8');
|
|
671
|
-
messageBody = await Promise.resolve(messageBodyRaw).then(x => {
|
|
672
|
-
|
|
673
|
-
});
|
|
671
|
+
messageBody = await (Promise.resolve(messageBodyRaw).then(x => JSON.parse(x)).catch((_) => ({
|
|
672
|
+
error: 'Could not parse the message body. Original body: ' + messageBodyRaw + ' . Error: ' + _.message,
|
|
673
|
+
})));
|
|
674
674
|
}
|
|
675
675
|
else if (typeof requestBody?.message?.data === 'object' && typeof requestBody.subscription === 'string') {
|
|
676
676
|
messageBodyRaw = JSON.stringify(requestBody.message.data);
|