@faasjs/http 0.0.3-beta.91 → 0.0.3-beta.93
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 +7 -3
- package/dist/index.mjs +7 -3
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -439,16 +439,20 @@ var Http = class {
|
|
|
439
439
|
this.params = data.event.queryString || /* @__PURE__ */ Object.create(null);
|
|
440
440
|
this.response = { headers: /* @__PURE__ */ Object.create(null) };
|
|
441
441
|
if (data.event.body) {
|
|
442
|
-
if ((_a = this.headers["content-type"]) == null ? void 0 : _a.includes("application/json")) {
|
|
442
|
+
if (((_a = this.headers["content-type"]) == null ? void 0 : _a.includes("application/json")) && typeof data.event.body === "string" && data.event.body.length > 1) {
|
|
443
443
|
data.logger.debug("[onInvoke] Parse params from json body");
|
|
444
|
-
|
|
444
|
+
try {
|
|
445
|
+
this.params = Object.keys(this.params).length ? Object.assign(this.params, JSON.parse(data.event.body)) : JSON.parse(data.event.body);
|
|
446
|
+
} catch (error) {
|
|
447
|
+
data.logger.error("[onInvoke] Parse params from json body failed: %s", error.message);
|
|
448
|
+
}
|
|
445
449
|
} else {
|
|
446
450
|
data.logger.debug("[onInvoke] Parse params from raw body");
|
|
447
451
|
this.params = data.event.body || /* @__PURE__ */ Object.create(null);
|
|
448
452
|
}
|
|
449
453
|
if (this.params && typeof this.params === "object" && this.params["_"])
|
|
450
454
|
delete this.params["_"];
|
|
451
|
-
data.event.params = this.params;
|
|
455
|
+
data.event.params = JSON.parse(JSON.stringify(this.params));
|
|
452
456
|
data.logger.debug("[onInvoke] Params: %j", this.params);
|
|
453
457
|
}
|
|
454
458
|
this.cookie.invoke(this.headers.cookie, data.logger);
|
package/dist/index.mjs
CHANGED
|
@@ -437,16 +437,20 @@ var Http = class {
|
|
|
437
437
|
this.params = data.event.queryString || /* @__PURE__ */ Object.create(null);
|
|
438
438
|
this.response = { headers: /* @__PURE__ */ Object.create(null) };
|
|
439
439
|
if (data.event.body) {
|
|
440
|
-
if ((_a = this.headers["content-type"]) == null ? void 0 : _a.includes("application/json")) {
|
|
440
|
+
if (((_a = this.headers["content-type"]) == null ? void 0 : _a.includes("application/json")) && typeof data.event.body === "string" && data.event.body.length > 1) {
|
|
441
441
|
data.logger.debug("[onInvoke] Parse params from json body");
|
|
442
|
-
|
|
442
|
+
try {
|
|
443
|
+
this.params = Object.keys(this.params).length ? Object.assign(this.params, JSON.parse(data.event.body)) : JSON.parse(data.event.body);
|
|
444
|
+
} catch (error) {
|
|
445
|
+
data.logger.error("[onInvoke] Parse params from json body failed: %s", error.message);
|
|
446
|
+
}
|
|
443
447
|
} else {
|
|
444
448
|
data.logger.debug("[onInvoke] Parse params from raw body");
|
|
445
449
|
this.params = data.event.body || /* @__PURE__ */ Object.create(null);
|
|
446
450
|
}
|
|
447
451
|
if (this.params && typeof this.params === "object" && this.params["_"])
|
|
448
452
|
delete this.params["_"];
|
|
449
|
-
data.event.params = this.params;
|
|
453
|
+
data.event.params = JSON.parse(JSON.stringify(this.params));
|
|
450
454
|
data.logger.debug("[onInvoke] Params: %j", this.params);
|
|
451
455
|
}
|
|
452
456
|
this.cookie.invoke(this.headers.cookie, data.logger);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faasjs/http",
|
|
3
|
-
"version": "0.0.3-beta.
|
|
3
|
+
"version": "0.0.3-beta.93",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@faasjs/func": "
|
|
26
|
-
"@faasjs/logger": "
|
|
25
|
+
"@faasjs/func": "0.0.3-beta.93",
|
|
26
|
+
"@faasjs/logger": "0.0.3-beta.93"
|
|
27
27
|
},
|
|
28
28
|
"engines": {
|
|
29
29
|
"npm": ">=8.0.0",
|