cgserver 7.1.661 → 7.2.684

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.
@@ -4,6 +4,7 @@ exports.GHttpTool = void 0;
4
4
  const request = require("request");
5
5
  const qs = require("querystring");
6
6
  const Log_1 = require("./Log");
7
+ const cgserver_1 = require("cgserver");
7
8
  exports.GHttpTool = null;
8
9
  class HttpTool {
9
10
  httpRequest(url, noParse) {
@@ -29,16 +30,16 @@ class HttpTool {
29
30
  });
30
31
  });
31
32
  }
32
- httpPost(url, form) {
33
+ httpPost(options) {
33
34
  return new Promise((resolve, reject) => {
34
- request.post({ url: url, form: form }, (error, response, body) => {
35
+ request.post(options, (error, response, body) => {
35
36
  let bd = body;
36
37
  if (error) {
37
- Log_1.GLog.error("post:" + url);
38
+ Log_1.GLog.error("post:" + options.url);
38
39
  Log_1.GLog.error(error);
39
40
  }
40
41
  try {
41
- if (body) {
42
+ if (cgserver_1.core.isString(body)) {
42
43
  body = JSON.parse(body);
43
44
  }
44
45
  }
@@ -174,12 +174,12 @@ class AppleTool {
174
174
  let reqb = new RequestBody();
175
175
  reqb['receipt-data'] = receipt;
176
176
  //先验证生产环境
177
- var resb = (await HttpTool_1.GHttpTool.httpPost(url, JSON.stringify(reqb))).body;
177
+ var resb = (await HttpTool_1.GHttpTool.httpPost({ url, form: JSON.stringify(reqb) })).body;
178
178
  Log_1.GLog.info("production end onVerify_Res============================status=" + (resb ? resb.status : "null"));
179
179
  //状态21007表示是沙盒环境
180
180
  if (resb && resb.status == 21007) {
181
181
  url = this._sandboxVerifyUrl;
182
- resb = (await HttpTool_1.GHttpTool.httpPost(url, JSON.stringify(reqb))).body;
182
+ resb = (await HttpTool_1.GHttpTool.httpPost({ url, form: JSON.stringify(reqb) })).body;
183
183
  Log_1.GLog.info("sandbox end onVerify_Res============================status=" + (resb ? resb.status : "null"));
184
184
  }
185
185
  Log_1.GLog.info(resb);
@@ -16,7 +16,7 @@ class OpenSocial {
16
16
  unionid: unionid,
17
17
  openid: openid
18
18
  };
19
- let rs = await HttpTool_1.GHttpTool.httpPost(IServerConfig_1.GServerCfg.third_cfg.open_social.user_url, msg);
19
+ let rs = await HttpTool_1.GHttpTool.httpPost({ url: IServerConfig_1.GServerCfg.third_cfg.open_social.user_url, json: msg });
20
20
  return rs.body;
21
21
  }
22
22
  async updatePwd(unionid, openid, new_pwd) {
@@ -25,7 +25,7 @@ class OpenSocial {
25
25
  openid: openid,
26
26
  password: new_pwd
27
27
  };
28
- let jsonData = await HttpTool_1.GHttpTool.httpPost(IServerConfig_1.GServerCfg.third_cfg.open_social.update_pwd_url, msg);
28
+ let jsonData = await HttpTool_1.GHttpTool.httpPost({ url: IServerConfig_1.GServerCfg.third_cfg.open_social.update_pwd_url, json: msg });
29
29
  return jsonData.body || jsonData.error;
30
30
  }
31
31
  }
@@ -1,3 +1,4 @@
1
+ import * as request from "request";
1
2
  export declare let GHttpTool: HttpTool;
2
3
  declare class HttpTool {
3
4
  httpRequest(url: string, noParse?: boolean): Promise<{
@@ -5,7 +6,7 @@ declare class HttpTool {
5
6
  response: any;
6
7
  body: any;
7
8
  }>;
8
- httpPost(url: any, form: any): Promise<{
9
+ httpPost(options: request.OptionsWithUrl): Promise<{
9
10
  error: any;
10
11
  response: any;
11
12
  body: any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cgserver",
3
- "version": "7.1.661",
3
+ "version": "7.2.684",
4
4
  "author": "trojan",
5
5
  "type": "commonjs",
6
6
  "description": "free for all.Websocket or Http",