@less-is-more/less-js 1.4.19 → 1.4.20
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 +8 -11
package/package.json
CHANGED
package/src/router.js
CHANGED
|
@@ -18,9 +18,9 @@ module.exports = class Router {
|
|
|
18
18
|
*/
|
|
19
19
|
static async route(targets, req, res, context) {
|
|
20
20
|
const startTime = new Date().getTime();
|
|
21
|
+
const { methodName, className } = this._getPath(req);
|
|
21
22
|
// 兼容非阿里云
|
|
22
23
|
await this._handleParams(req);
|
|
23
|
-
const { methodName, className } = this._getPath(req);
|
|
24
24
|
if (methodName) {
|
|
25
25
|
const controller = targets[className];
|
|
26
26
|
if (controller == undefined) {
|
|
@@ -64,13 +64,7 @@ module.exports = class Router {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
static _getPath(req) {
|
|
67
|
-
console.log(
|
|
68
|
-
"path:",
|
|
69
|
-
req.method,
|
|
70
|
-
req.path,
|
|
71
|
-
req.headers["content-type"],
|
|
72
|
-
JSON.stringify(req.params)
|
|
73
|
-
);
|
|
67
|
+
console.log("path:", req.method, req.path, req.headers["content-type"]);
|
|
74
68
|
const paths = req.path.split("/");
|
|
75
69
|
const className = paths.length > 2 ? "/" + paths[paths.length - 2] : "/";
|
|
76
70
|
const methodName = paths[paths.length - 1];
|
|
@@ -81,7 +75,10 @@ module.exports = class Router {
|
|
|
81
75
|
if (req.query) {
|
|
82
76
|
req.queries = req.query;
|
|
83
77
|
}
|
|
84
|
-
console.log(
|
|
78
|
+
console.log(
|
|
79
|
+
"queries:",
|
|
80
|
+
req.queries ? JSON.stringify(req.queries).substring(0, 500) : ""
|
|
81
|
+
);
|
|
85
82
|
const isFile =
|
|
86
83
|
req.headers &&
|
|
87
84
|
req.headers["content-type"] &&
|
|
@@ -108,7 +105,7 @@ module.exports = class Router {
|
|
|
108
105
|
}
|
|
109
106
|
} else {
|
|
110
107
|
const data = await promisify(body)(req);
|
|
111
|
-
console.log("body: " + data);
|
|
108
|
+
console.log("body: " + data.substring(0, 500));
|
|
112
109
|
req.body = qs.parse(data);
|
|
113
110
|
}
|
|
114
111
|
}
|
|
@@ -157,7 +154,7 @@ module.exports = class Router {
|
|
|
157
154
|
useTime + "s",
|
|
158
155
|
req.path,
|
|
159
156
|
"response:",
|
|
160
|
-
content.
|
|
157
|
+
content.substring(0, 500)
|
|
161
158
|
);
|
|
162
159
|
res.send(content);
|
|
163
160
|
}
|