cgserver 9.1.5 → 9.1.7
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/README.md +4 -0
- package/dist/lib/Framework/Database/Decorator/DBCache.js +1 -2
- package/dist/lib/Framework/Logic/HttpTool.js +27 -3
- package/dist/lib/Framework/SocketServer/ProtoFilter/JsonProtoFilter.js +1 -2
- package/dist/lib/Framework/ThirdParty/QQTool.js +1 -2
- package/dist/lib/Framework/WebServer/Engine/Request.js +1 -2
- package/dist/types/Framework/Logic/HttpTool.d.ts +3 -0
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.GDBCache = exports.VersionModel = void 0;
|
|
4
4
|
const Log_1 = require("./../../Logic/Log");
|
|
5
5
|
const fs = require("fs");
|
|
6
|
-
const lossless_json_1 = require("lossless-json");
|
|
7
6
|
class VersionModel {
|
|
8
7
|
table = "";
|
|
9
8
|
version = 0;
|
|
@@ -25,7 +24,7 @@ class DBCache {
|
|
|
25
24
|
if (fs.existsSync(this._path)) {
|
|
26
25
|
try {
|
|
27
26
|
let table = fs.readFileSync(this._path);
|
|
28
|
-
this._versions =
|
|
27
|
+
this._versions = JSON.parse(table.toString());
|
|
29
28
|
}
|
|
30
29
|
catch (e) {
|
|
31
30
|
Log_1.GLog.info("error:" + this._path);
|
|
@@ -5,9 +5,15 @@ const request = require("request");
|
|
|
5
5
|
const qs = require("querystring");
|
|
6
6
|
const Log_1 = require("./Log");
|
|
7
7
|
const Core_1 = require("../Core/Core");
|
|
8
|
-
const lossless_json_1 = require("lossless-json");
|
|
9
8
|
exports.GHttpTool = null;
|
|
10
9
|
class HttpTool {
|
|
10
|
+
_debug = false;
|
|
11
|
+
get debug() {
|
|
12
|
+
return this._debug;
|
|
13
|
+
}
|
|
14
|
+
set debug(value) {
|
|
15
|
+
this._debug = value;
|
|
16
|
+
}
|
|
11
17
|
get(options_url) {
|
|
12
18
|
let options = null;
|
|
13
19
|
if (Core_1.core.isString(options_url)) {
|
|
@@ -16,6 +22,9 @@ class HttpTool {
|
|
|
16
22
|
else {
|
|
17
23
|
options = options_url;
|
|
18
24
|
}
|
|
25
|
+
if (this._debug) {
|
|
26
|
+
Log_1.GLog.info("prepare get:" + options.url);
|
|
27
|
+
}
|
|
19
28
|
return new Promise((resolve, reject) => {
|
|
20
29
|
request.get(options, (error, response, body) => {
|
|
21
30
|
let originbody = body;
|
|
@@ -25,7 +34,7 @@ class HttpTool {
|
|
|
25
34
|
}
|
|
26
35
|
try {
|
|
27
36
|
if (Core_1.core.isString(body)) {
|
|
28
|
-
body =
|
|
37
|
+
body = JSON.parse(body);
|
|
29
38
|
}
|
|
30
39
|
}
|
|
31
40
|
catch (e) {
|
|
@@ -36,6 +45,12 @@ class HttpTool {
|
|
|
36
45
|
body = originbody;
|
|
37
46
|
}
|
|
38
47
|
}
|
|
48
|
+
if (this._debug) {
|
|
49
|
+
Log_1.GLog.info({
|
|
50
|
+
url: options.url,
|
|
51
|
+
originbody: originbody
|
|
52
|
+
});
|
|
53
|
+
}
|
|
39
54
|
resolve({ error, response, body, originbody });
|
|
40
55
|
});
|
|
41
56
|
});
|
|
@@ -48,6 +63,9 @@ class HttpTool {
|
|
|
48
63
|
else {
|
|
49
64
|
options = options_url;
|
|
50
65
|
}
|
|
66
|
+
if (this._debug) {
|
|
67
|
+
Log_1.GLog.info("prepare post:" + options.url);
|
|
68
|
+
}
|
|
51
69
|
return new Promise((resolve, reject) => {
|
|
52
70
|
request.post(options, (error, response, body) => {
|
|
53
71
|
let originbody = body;
|
|
@@ -57,7 +75,7 @@ class HttpTool {
|
|
|
57
75
|
}
|
|
58
76
|
try {
|
|
59
77
|
if (Core_1.core.isString(body)) {
|
|
60
|
-
body =
|
|
78
|
+
body = JSON.parse(body);
|
|
61
79
|
}
|
|
62
80
|
}
|
|
63
81
|
catch (e) {
|
|
@@ -68,6 +86,12 @@ class HttpTool {
|
|
|
68
86
|
body = originbody;
|
|
69
87
|
}
|
|
70
88
|
}
|
|
89
|
+
if (this._debug) {
|
|
90
|
+
Log_1.GLog.info({
|
|
91
|
+
url: options.url,
|
|
92
|
+
originbody: originbody
|
|
93
|
+
});
|
|
94
|
+
}
|
|
71
95
|
resolve({ error, response, body, originbody });
|
|
72
96
|
});
|
|
73
97
|
});
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.JsonProtoFilter = void 0;
|
|
4
4
|
const Core_1 = require("../../Core/Core");
|
|
5
5
|
const Log_1 = require("../../Logic/Log");
|
|
6
|
-
const lossless_json_1 = require("lossless-json");
|
|
7
6
|
class JsonProtoFilter {
|
|
8
7
|
init(path) {
|
|
9
8
|
return true;
|
|
@@ -17,7 +16,7 @@ class JsonProtoFilter {
|
|
|
17
16
|
decode(data) {
|
|
18
17
|
try {
|
|
19
18
|
if (Core_1.core.isString(data)) {
|
|
20
|
-
data =
|
|
19
|
+
data = JSON.parse(data);
|
|
21
20
|
}
|
|
22
21
|
}
|
|
23
22
|
catch (e) {
|
|
@@ -6,7 +6,6 @@ const URLEncode = require("urlencode");
|
|
|
6
6
|
const IServerConfig_1 = require("../Config/IServerConfig");
|
|
7
7
|
const HttpTool_1 = require("../Logic/HttpTool");
|
|
8
8
|
const Log_1 = require("../Logic/Log");
|
|
9
|
-
const lossless_json_1 = require("lossless-json");
|
|
10
9
|
class QQUserInfo {
|
|
11
10
|
ret = 0;
|
|
12
11
|
msg = "";
|
|
@@ -93,7 +92,7 @@ class QQTool {
|
|
|
93
92
|
body = body.replace("callback( ", "");
|
|
94
93
|
body = body.replace(" );\n", "");
|
|
95
94
|
try {
|
|
96
|
-
body =
|
|
95
|
+
body = JSON.parse(body);
|
|
97
96
|
}
|
|
98
97
|
catch (e) { }
|
|
99
98
|
if (!body.openid) {
|
|
@@ -4,7 +4,6 @@ exports.Request = void 0;
|
|
|
4
4
|
const url_1 = require("url");
|
|
5
5
|
const Core_1 = require("../../Core/Core");
|
|
6
6
|
const Log_1 = require("../../Logic/Log");
|
|
7
|
-
const lossless_json_1 = require("lossless-json");
|
|
8
7
|
class Request {
|
|
9
8
|
_req = null;
|
|
10
9
|
get baseReq() {
|
|
@@ -71,7 +70,7 @@ class Request {
|
|
|
71
70
|
}
|
|
72
71
|
if (Core_1.core.isString(body)) {
|
|
73
72
|
try {
|
|
74
|
-
body =
|
|
73
|
+
body = JSON.parse(body);
|
|
75
74
|
}
|
|
76
75
|
catch (e) {
|
|
77
76
|
Log_1.GLog.error("post data--" + body + "--parse error");
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as request from "request";
|
|
2
2
|
export declare let GHttpTool: HttpTool;
|
|
3
3
|
declare class HttpTool {
|
|
4
|
+
protected _debug: boolean;
|
|
5
|
+
get debug(): boolean;
|
|
6
|
+
set debug(value: boolean);
|
|
4
7
|
get(options_url: request.OptionsWithUrl | string): Promise<{
|
|
5
8
|
error: any;
|
|
6
9
|
response: any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cgserver",
|
|
3
|
-
"version": "9.1.
|
|
3
|
+
"version": "9.1.7",
|
|
4
4
|
"author": "trojan",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"description": "free for all.Websocket or Http",
|
|
@@ -62,7 +62,6 @@
|
|
|
62
62
|
"https": "^1.0.0",
|
|
63
63
|
"jsonc": "^2.0.0",
|
|
64
64
|
"log4js": "^6.9.1",
|
|
65
|
-
"lossless-json": "^4.0.1",
|
|
66
65
|
"mime": "^3.0.0",
|
|
67
66
|
"mongodb": "^6.7.0",
|
|
68
67
|
"mssql": "^11.0.0",
|