@less-is-more/less-js 1.2.25 → 1.2.26
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 +11 -7
package/package.json
CHANGED
package/src/router.js
CHANGED
|
@@ -37,6 +37,7 @@ module.exports = class Router {
|
|
|
37
37
|
console.log("start after action");
|
|
38
38
|
await targets.after(req, res, context);
|
|
39
39
|
}
|
|
40
|
+
console.log("end", (new Date().getTime() - startTime) / 1000, "s");
|
|
40
41
|
// controller方法有返回值的自动send
|
|
41
42
|
this._handleReturn(result, res);
|
|
42
43
|
} catch (e) {
|
|
@@ -49,7 +50,6 @@ module.exports = class Router {
|
|
|
49
50
|
} else {
|
|
50
51
|
return this._sendError("请输入方法", res);
|
|
51
52
|
}
|
|
52
|
-
console.log("end", (new Date().getTime() - startTime) / 1000, "s");
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
static _getPath(req) {
|
|
@@ -104,18 +104,22 @@ module.exports = class Router {
|
|
|
104
104
|
|
|
105
105
|
static _handleReturn(result, res) {
|
|
106
106
|
if (!Param.isBlank(result)) {
|
|
107
|
+
let content;
|
|
107
108
|
if (result instanceof Ret) {
|
|
108
|
-
|
|
109
|
-
res.send(result.toString());
|
|
109
|
+
content = result.toString();
|
|
110
110
|
} else {
|
|
111
111
|
if (typeof result === "string") {
|
|
112
|
-
|
|
113
|
-
res.send(result);
|
|
112
|
+
content = result;
|
|
114
113
|
} else {
|
|
115
|
-
|
|
116
|
-
res.send(JSON.stringify(result));
|
|
114
|
+
content = Json.stringify(result);
|
|
117
115
|
}
|
|
118
116
|
}
|
|
117
|
+
if (content.length > 500) {
|
|
118
|
+
console.log("return:", content.substring(0, 500));
|
|
119
|
+
} else {
|
|
120
|
+
console.log("return:", content);
|
|
121
|
+
}
|
|
122
|
+
res.send(content);
|
|
119
123
|
}
|
|
120
124
|
}
|
|
121
125
|
|