node-easywechat 3.0.0-beta.4 → 3.0.0-beta.5
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/CHANGELOG.md
CHANGED
|
@@ -43,7 +43,7 @@ declare class ServerRequest implements ServerRequestInterface {
|
|
|
43
43
|
* @param body 支持 Buffer、object对象、JSON字符串、XML字符串、QueryString格式的 body 内容字符串
|
|
44
44
|
* @returns
|
|
45
45
|
*/
|
|
46
|
-
static createFromIncomingMessage(req: IncomingMessage, body?: Buffer | Record<string, any> | string): ServerRequest
|
|
46
|
+
static createFromIncomingMessage(req: IncomingMessage, body?: Buffer | Record<string, any> | string): Promise<ServerRequest>;
|
|
47
47
|
}
|
|
48
48
|
interface ServerRequest extends MessageMixin, RequestMixin {
|
|
49
49
|
}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
13
|
};
|
|
@@ -124,13 +133,14 @@ class ServerRequest {
|
|
|
124
133
|
* @returns
|
|
125
134
|
*/
|
|
126
135
|
static createFromIncomingMessage(req, body = null) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
136
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
137
|
+
let request = new ServerRequest(req.method, req.url, req.headers || {}, body, req.httpVersion);
|
|
138
|
+
if (!body) {
|
|
139
|
+
let res = yield (0, raw_body_1.default)(req);
|
|
130
140
|
request.withBody(res);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
141
|
+
}
|
|
142
|
+
return request;
|
|
143
|
+
});
|
|
134
144
|
}
|
|
135
145
|
}
|
|
136
146
|
;
|
package/dist/Core/Message.js
CHANGED
|
@@ -49,7 +49,11 @@ class Message {
|
|
|
49
49
|
*/
|
|
50
50
|
static createFromRequest(request) {
|
|
51
51
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
let originContent =
|
|
52
|
+
let originContent = '';
|
|
53
|
+
let body = request.getBody();
|
|
54
|
+
if (body) {
|
|
55
|
+
originContent = body.toString();
|
|
56
|
+
}
|
|
53
57
|
let attributes = {};
|
|
54
58
|
if ('<' === originContent.substring(0, 1)) {
|
|
55
59
|
attributes = yield (0, Utils_1.parseXml)(originContent);
|
|
@@ -75,11 +75,6 @@ class Application {
|
|
|
75
75
|
}
|
|
76
76
|
getServer() {
|
|
77
77
|
if (!this.server) {
|
|
78
|
-
let token = this.getAccount().getToken();
|
|
79
|
-
let aesKey = this.getAccount().getAesKey();
|
|
80
|
-
if (!token || !aesKey) {
|
|
81
|
-
throw new Error('token or aes_key cannot be empty.');
|
|
82
|
-
}
|
|
83
78
|
this.server = new Server_1.default(this.getRequest(), this.getAccount().getAesKey() ? this.getEncryptor() : null);
|
|
84
79
|
}
|
|
85
80
|
return this.server;
|