@faasjs/http 0.0.2-beta.426 → 0.0.2-beta.428

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/dist/index.js CHANGED
@@ -471,7 +471,7 @@ var Http = class {
471
471
  await next();
472
472
  }
473
473
  async onInvoke(data, next) {
474
- var _a, _b;
474
+ var _a;
475
475
  this.headers = data.event.headers || /* @__PURE__ */ Object.create(null);
476
476
  this.body = data.event.body;
477
477
  this.params = /* @__PURE__ */ Object.create(null);
@@ -532,7 +532,9 @@ var Http = class {
532
532
  data.response = Object.assign({}, data.response, this.response);
533
533
  const originBody = data.response.body;
534
534
  data.response.originBody = originBody;
535
- if (data.response.isBase64Encoded || typeof data.response.body !== "string" || !((_b = data.response.headers["Content-Type"]) == null ? void 0 : _b.includes("json")) || data.response.body.length < 100)
535
+ if (originBody && !data.response.isBase64Encoded && typeof originBody !== "string")
536
+ data.response.body = JSON.stringify(originBody);
537
+ if (!data.response.body || data.response.isBase64Encoded || typeof data.response.body !== "string" || data.response.body.length < 100)
536
538
  return;
537
539
  const acceptEncoding = this.headers["accept-encoding"] || this.headers["Accept-Encoding"];
538
540
  if (!acceptEncoding || !/(br|gzip|deflate)/.test(acceptEncoding))
package/dist/index.mjs CHANGED
@@ -461,7 +461,7 @@ var Http = class {
461
461
  await next();
462
462
  }
463
463
  async onInvoke(data, next) {
464
- var _a, _b;
464
+ var _a;
465
465
  this.headers = data.event.headers || /* @__PURE__ */ Object.create(null);
466
466
  this.body = data.event.body;
467
467
  this.params = /* @__PURE__ */ Object.create(null);
@@ -522,7 +522,9 @@ var Http = class {
522
522
  data.response = Object.assign({}, data.response, this.response);
523
523
  const originBody = data.response.body;
524
524
  data.response.originBody = originBody;
525
- if (data.response.isBase64Encoded || typeof data.response.body !== "string" || !((_b = data.response.headers["Content-Type"]) == null ? void 0 : _b.includes("json")) || data.response.body.length < 100)
525
+ if (originBody && !data.response.isBase64Encoded && typeof originBody !== "string")
526
+ data.response.body = JSON.stringify(originBody);
527
+ if (!data.response.body || data.response.isBase64Encoded || typeof data.response.body !== "string" || data.response.body.length < 100)
526
528
  return;
527
529
  const acceptEncoding = this.headers["accept-encoding"] || this.headers["Accept-Encoding"];
528
530
  if (!acceptEncoding || !/(br|gzip|deflate)/.test(acceptEncoding))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/http",
3
- "version": "0.0.2-beta.426",
3
+ "version": "0.0.2-beta.428",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -23,8 +23,8 @@
23
23
  "dist"
24
24
  ],
25
25
  "dependencies": {
26
- "@faasjs/func": "^0.0.2-beta.426",
27
- "@faasjs/logger": "^0.0.2-beta.426"
26
+ "@faasjs/func": "^0.0.2-beta.428",
27
+ "@faasjs/logger": "^0.0.2-beta.428"
28
28
  },
29
29
  "devDependencies": {
30
30
  "tsup": "*",