@shushed/helpers 0.0.198-v2-20251107121008 → 0.0.198-v2-20251107134609

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
- return Promise.resolve(x).then(x => JSON.parse(x)).catch((_) => x);
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);
@@ -237,6 +237,7 @@ function createFunction(expression) {
237
237
  return (payload) => global.functionsCache[expression](exports.FUNCTION_EXPR_ERROR, payload);
238
238
  }
239
239
  function onResponse(config, options) {
240
+ options.logging.log('onResponse', config);
240
241
  const flags = options.root[options.triggerId || options.trigger?.id].flags;
241
242
  const numberOfInputMessages = options.root[options.triggerId || options.trigger?.id].body.length;
242
243
  const outputBody = config.outputs.body;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shushed/helpers",
3
- "version": "0.0.198-v2-20251107121008",
3
+ "version": "0.0.198-v2-20251107134609",
4
4
  "author": "",
5
5
  "license": "UNLICENSED",
6
6
  "description": "",