@faasjs/http 0.0.2-beta.445 → 0.0.2-beta.447

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,24 +471,20 @@ var Http = class {
471
471
  await next();
472
472
  }
473
473
  async onInvoke(data, next) {
474
- var _a;
474
+ var _a, _b;
475
475
  this.headers = data.event.headers || /* @__PURE__ */ Object.create(null);
476
476
  this.body = data.event.body;
477
- this.params = /* @__PURE__ */ Object.create(null);
477
+ this.params = data.event.queryString || /* @__PURE__ */ Object.create(null);
478
478
  this.response = { headers: /* @__PURE__ */ Object.create(null) };
479
479
  if (data.event.body) {
480
- if (data.event.headers && data.event.headers["content-type"] && data.event.headers["content-type"].includes("application/json")) {
480
+ if ((_a = this.headers["content-type"]) == null ? void 0 : _a.includes("application/json")) {
481
481
  data.logger.debug("[onInvoke] Parse params from json body");
482
- this.params = JSON.parse(data.event.body);
482
+ this.params = Object.assign(this.params, JSON.parse(data.event.body));
483
483
  } else {
484
484
  data.logger.debug("[onInvoke] Parse params from raw body");
485
- this.params = data.event.body;
485
+ this.params = data.event.body || /* @__PURE__ */ Object.create(null);
486
486
  }
487
487
  data.logger.debug("[onInvoke] Params: %j", this.params);
488
- } else if (data.event.queryString) {
489
- data.logger.debug("[onInvoke] Parse params from queryString");
490
- this.params = data.event.queryString;
491
- data.logger.debug("[onInvoke] Params: %j", this.params);
492
488
  }
493
489
  this.cookie.invoke(this.headers.cookie);
494
490
  if (this.headers.cookie) {
@@ -511,7 +507,7 @@ var Http = class {
511
507
  }
512
508
  this.session.update();
513
509
  if (data.response)
514
- if (data.response instanceof Error || ((_a = data.response.constructor) == null ? void 0 : _a.name) === "Error") {
510
+ if (data.response instanceof Error || ((_b = data.response.constructor) == null ? void 0 : _b.name) === "Error") {
515
511
  data.logger.error(data.response);
516
512
  this.response.body = JSON.stringify({ error: { message: data.response.message } });
517
513
  try {
package/dist/index.mjs CHANGED
@@ -461,24 +461,20 @@ var Http = class {
461
461
  await next();
462
462
  }
463
463
  async onInvoke(data, next) {
464
- var _a;
464
+ var _a, _b;
465
465
  this.headers = data.event.headers || /* @__PURE__ */ Object.create(null);
466
466
  this.body = data.event.body;
467
- this.params = /* @__PURE__ */ Object.create(null);
467
+ this.params = data.event.queryString || /* @__PURE__ */ Object.create(null);
468
468
  this.response = { headers: /* @__PURE__ */ Object.create(null) };
469
469
  if (data.event.body) {
470
- if (data.event.headers && data.event.headers["content-type"] && data.event.headers["content-type"].includes("application/json")) {
470
+ if ((_a = this.headers["content-type"]) == null ? void 0 : _a.includes("application/json")) {
471
471
  data.logger.debug("[onInvoke] Parse params from json body");
472
- this.params = JSON.parse(data.event.body);
472
+ this.params = Object.assign(this.params, JSON.parse(data.event.body));
473
473
  } else {
474
474
  data.logger.debug("[onInvoke] Parse params from raw body");
475
- this.params = data.event.body;
475
+ this.params = data.event.body || /* @__PURE__ */ Object.create(null);
476
476
  }
477
477
  data.logger.debug("[onInvoke] Params: %j", this.params);
478
- } else if (data.event.queryString) {
479
- data.logger.debug("[onInvoke] Parse params from queryString");
480
- this.params = data.event.queryString;
481
- data.logger.debug("[onInvoke] Params: %j", this.params);
482
478
  }
483
479
  this.cookie.invoke(this.headers.cookie);
484
480
  if (this.headers.cookie) {
@@ -501,7 +497,7 @@ var Http = class {
501
497
  }
502
498
  this.session.update();
503
499
  if (data.response)
504
- if (data.response instanceof Error || ((_a = data.response.constructor) == null ? void 0 : _a.name) === "Error") {
500
+ if (data.response instanceof Error || ((_b = data.response.constructor) == null ? void 0 : _b.name) === "Error") {
505
501
  data.logger.error(data.response);
506
502
  this.response.body = JSON.stringify({ error: { message: data.response.message } });
507
503
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/http",
3
- "version": "0.0.2-beta.445",
3
+ "version": "0.0.2-beta.447",
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.445",
27
- "@faasjs/logger": "^0.0.2-beta.445"
26
+ "@faasjs/func": "^0.0.2-beta.447",
27
+ "@faasjs/logger": "^0.0.2-beta.447"
28
28
  },
29
29
  "devDependencies": {
30
30
  "tsup": "*",