mm_ret 1.4.5 → 1.4.6

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/lib/error.js CHANGED
@@ -23,31 +23,31 @@ class Error {
23
23
  "zh-CN": {
24
24
  "10000": "业务逻辑错误",
25
25
  "0": "成功",
26
- "100": "继续",
27
- "101": "切换协议‌",
28
- "200": "确定",
29
- "201": "已创建",
30
- "202": "已接受",
31
- "204": "无内容",
32
- "301": "已永久移动",
33
- "302": "已找到",
34
- "303": "见其他",
35
- "304": "未修改",
36
- "307": "临时重定向‌",
37
- "400": "错误请求",
38
- "401": "未授权",
39
- "403": "禁止访问",
40
- "404": "未找到",
41
- "405": "方法不允许",
42
- "408": "请求超时",
43
- "413": "Payload Too Large",
44
- "415": "不支持的媒体类型",
45
- "429": "请求过多",
46
- "500": "内部服务器错误",
47
- "501": "未实现",
48
- "502": "错误网关",
49
- "503": "服务不可用",
50
- "504": "网关超时",
26
+ "100": "继续",
27
+ "101": "切换协议",
28
+ "200": "确定",
29
+ "201": "已创建",
30
+ "202": "已接受",
31
+ "204": "无内容",
32
+ "301": "已永久移动",
33
+ "302": "已找到",
34
+ "303": "见其他",
35
+ "304": "未修改",
36
+ "307": "临时重定向",
37
+ "400": "错误请求",
38
+ "401": "未授权",
39
+ "403": "禁止访问",
40
+ "404": "未找到",
41
+ "405": "方法不允许",
42
+ "408": "请求超时",
43
+ "413": "Payload Too Large",
44
+ "415": "不支持的媒体类型",
45
+ "429": "请求过多",
46
+ "500": "内部服务器错误",
47
+ "501": "未实现",
48
+ "502": "错误网关",
49
+ "503": "服务不可用",
50
+ "504": "网关超时",
51
51
  "-32700": "格式错误",
52
52
  "-32701": "不支持的编码",
53
53
  "-32702": "编码中包含无效字符",
@@ -66,31 +66,31 @@ class Error {
66
66
  "en-US": {
67
67
  "10000": "business logic error",
68
68
  "0": "success",
69
- "100": "Continue",
70
- "101": "Switching Protocols",
71
- "200": "OK",
72
- "201": "Created",
73
- "202": "Accepted",
74
- "204": "No Content",
75
- "301": "Moved Permanently",
76
- "302": "Found",
77
- "303": "See Other",
78
- "304": "Not Modified",
79
- "307": "Temporary Redirect",
80
- "400": "Bad Request",
81
- "401": "Unauthorized",
82
- "403": "Forbidden",
83
- "404": "Not Found",
84
- "405": "Method Not Allowed",
85
- "408": "Request Timeout",
86
- "413": "Payload Too Large",
87
- "415": "Unsupported Media Type",
88
- "429": "Too Many Requests",
89
- "500": "Internal Server Error",
90
- "501": "Not Implemented",
91
- "502": "Bad Gateway",
92
- "503": "Service Unavailable",
93
- "504": "Gateway Timeout",
69
+ "100": "Continue",
70
+ "101": "Switching Protocols",
71
+ "200": "OK",
72
+ "201": "Created",
73
+ "202": "Accepted",
74
+ "204": "No Content",
75
+ "301": "Moved Permanently",
76
+ "302": "Found",
77
+ "303": "See Other",
78
+ "304": "Not Modified",
79
+ "307": "Temporary Redirect",
80
+ "400": "Bad Request",
81
+ "401": "Unauthorized",
82
+ "403": "Forbidden",
83
+ "404": "Not Found",
84
+ "405": "Method Not Allowed",
85
+ "408": "Request Timeout",
86
+ "413": "Payload Too Large",
87
+ "415": "Unsupported Media Type",
88
+ "429": "Too Many Requests",
89
+ "500": "Internal Server Error",
90
+ "501": "Not Implemented",
91
+ "502": "Bad Gateway",
92
+ "503": "Service Unavailable",
93
+ "504": "Gateway Timeout",
94
94
  "-32700": "not well formed",
95
95
  "-32701": "unsupported encoding",
96
96
  "-32702": "invalid character for encoding",
@@ -126,7 +126,7 @@ Error.prototype.setConfig = function (config) {
126
126
  Error.prototype.get = function (code) {
127
127
  const lang = this._config.lang;
128
128
  const lang_pack = this._langs[lang];
129
-
129
+
130
130
  if (lang_pack && lang_pack[code]) {
131
131
  return lang_pack[code];
132
132
  }
package/lib/ret.js CHANGED
@@ -95,8 +95,10 @@ Ret.prototype._getMessage = function (code) {
95
95
  */
96
96
  Ret.prototype._toJsonRPC = function (result, error, id, diy = false) {
97
97
  const ret = {
98
- id
99
98
  };
99
+ if (id) {
100
+ ret.id = id;
101
+ }
100
102
 
101
103
  if (result) {
102
104
  ret.result = result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_ret",
3
- "version": "1.4.5",
3
+ "version": "1.4.6",
4
4
  "description": "这是超级美眉http请求结果输出类函数模块,用于输出json-rpc2.0标准结果",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/test.js CHANGED
@@ -88,6 +88,9 @@ function reqDemo() {
88
88
  $.log.debug("=== 测试JSON-RPC风格请求 进,RESTful风格请求 出 === ");
89
89
  $.req.setFormat("json-rpc");
90
90
  reqTest(new Req({ format: "restful" }));
91
+
92
+ var rest = $.ret.error(404, 'Not Found');
93
+ console.log("这hi", rest);
91
94
  }
92
95
 
93
96
  reqDemo();