@less-is-more/less-js 1.4.25 → 1.4.26-1
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/package.json +1 -1
- package/src/router.js +14 -10
package/package.json
CHANGED
package/src/router.js
CHANGED
|
@@ -21,6 +21,20 @@ module.exports = class Router {
|
|
|
21
21
|
const { methodName, className } = this._getPath(req);
|
|
22
22
|
// 兼容非阿里云
|
|
23
23
|
await this._handleParams(req);
|
|
24
|
+
console.log(
|
|
25
|
+
"p:",
|
|
26
|
+
req.method,
|
|
27
|
+
req.path,
|
|
28
|
+
req.headers ? req.headers["content-type"] : "",
|
|
29
|
+
"q:",
|
|
30
|
+
req.queries ? JSON.stringify(req.queries).substring(0, 500) : "",
|
|
31
|
+
"b:",
|
|
32
|
+
req.body ? JSON.stringify(req.body).substring(0, 500) : "",
|
|
33
|
+
req.files ? "f:" : "",
|
|
34
|
+
req.files ? req.params : "",
|
|
35
|
+
req.files ? req.files : ""
|
|
36
|
+
);
|
|
37
|
+
|
|
24
38
|
if (methodName) {
|
|
25
39
|
const controller = targets[className];
|
|
26
40
|
if (controller == undefined) {
|
|
@@ -67,7 +81,6 @@ module.exports = class Router {
|
|
|
67
81
|
}
|
|
68
82
|
|
|
69
83
|
static _getPath(req) {
|
|
70
|
-
console.log("path:", req.method, req.path, req.headers["content-type"]);
|
|
71
84
|
const paths = req.path.split("/");
|
|
72
85
|
const className = paths.length > 2 ? "/" + paths[paths.length - 2] : "/";
|
|
73
86
|
const methodName = paths[paths.length - 1];
|
|
@@ -78,10 +91,6 @@ module.exports = class Router {
|
|
|
78
91
|
if (req.query) {
|
|
79
92
|
req.queries = req.query;
|
|
80
93
|
}
|
|
81
|
-
console.log(
|
|
82
|
-
"queries:",
|
|
83
|
-
req.queries ? JSON.stringify(req.queries).substring(0, 500) : ""
|
|
84
|
-
);
|
|
85
94
|
const isFile =
|
|
86
95
|
req.headers &&
|
|
87
96
|
req.headers["content-type"] &&
|
|
@@ -90,15 +99,11 @@ module.exports = class Router {
|
|
|
90
99
|
req.headers &&
|
|
91
100
|
req.headers["content-type"] &&
|
|
92
101
|
req.headers["content-type"].includes("application/json");
|
|
93
|
-
console.log("multipart:", isFile);
|
|
94
102
|
if (req.method == "POST") {
|
|
95
103
|
if (isFile) {
|
|
96
104
|
await this._getFile(req);
|
|
97
|
-
console.log("params:", req.params);
|
|
98
|
-
console.log("files:", req.files);
|
|
99
105
|
} else if (isJson) {
|
|
100
106
|
const data = await promisify(body)(req);
|
|
101
|
-
console.log("body: " + data);
|
|
102
107
|
if (!Param.isBlank(data)) {
|
|
103
108
|
try {
|
|
104
109
|
req.body = JSON.parse(data);
|
|
@@ -108,7 +113,6 @@ module.exports = class Router {
|
|
|
108
113
|
}
|
|
109
114
|
} else {
|
|
110
115
|
const data = await promisify(body)(req);
|
|
111
|
-
console.log("body: " + data.substring(0, 500));
|
|
112
116
|
req.body = qs.parse(data);
|
|
113
117
|
}
|
|
114
118
|
}
|