@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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/router.js +11 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@less-is-more/less-js",
3
- "version": "1.2.25",
3
+ "version": "1.2.26",
4
4
  "description": "Fast develop kit for nodejs",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
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
- console.log("return:", result.toString());
109
- res.send(result.toString());
109
+ content = result.toString();
110
110
  } else {
111
111
  if (typeof result === "string") {
112
- console.log("return:", result);
113
- res.send(result);
112
+ content = result;
114
113
  } else {
115
- console.log("return:", JSON.stringify(result));
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