wapplr 1.0.74 → 1.0.76
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/dist/client/app.js +183 -243
- package/dist/client/config.js +1 -5
- package/dist/client/createClient.js +88 -134
- package/dist/client/history.js +10 -39
- package/dist/client/index.js +0 -15
- package/dist/client/middlewares.js +93 -168
- package/dist/common/config.js +1 -4
- package/dist/common/contents.js +91 -142
- package/dist/common/index.js +7 -18
- package/dist/common/log/index.js +27 -48
- package/dist/common/log/renderedContent.js +57 -70
- package/dist/common/logo/index.js +0 -2
- package/dist/common/middlewares.js +7 -61
- package/dist/common/requests.js +97 -143
- package/dist/common/router.js +97 -162
- package/dist/common/states.js +7 -68
- package/dist/common/styles.js +6 -51
- package/dist/common/template/index.js +19 -24
- package/dist/common/template/template_css.js +1 -1
- package/dist/common/utils.js +4 -18
- package/dist/server/app.js +151 -217
- package/dist/server/config.js +1 -13
- package/dist/server/createServer.js +110 -197
- package/dist/server/html.js +35 -46
- package/dist/server/index.js +1 -16
- package/dist/server/middlewares.js +14 -73
- package/dist/server/static.js +0 -26
- package/package.json +1 -1
|
@@ -1,109 +1,96 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = renderedContent;
|
|
9
|
-
|
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
9
|
var defaultTemplateStyle = require("./../template/template_css.js")["default"];
|
|
13
|
-
|
|
14
10
|
var defaultAppStyle = require("./../template/app_css.js")["default"];
|
|
15
|
-
|
|
16
11
|
var defaultLogoStyle = require("./../logo/logo_css.js")["default"];
|
|
17
|
-
|
|
18
12
|
var defaultLogStyle = require("./log_css.js")["default"];
|
|
19
|
-
|
|
20
13
|
function getLogo(p) {
|
|
21
14
|
var logoStyle = p.logoStyle;
|
|
22
15
|
return "<div class=\"".concat(logoStyle.logo, "\">\n <div class=\"").concat(logoStyle.icon, "\">\n <svg class=\"").concat(logoStyle.svg, "\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 252 211.72\">\n <path d=\"M15.52,246.7c13-22.86,26-45.68,38.85-68.57Q86.31,121.39,118.19,64.6a17.15,17.15,0,0,1,5.74-5.9c11.18-6.91,22.53-13.55,33.83-20.27,1.07-.63,2.19-1.17,4.63-2.46L57.52,222.7h210v1c-6.78,3.79-13.62,7.48-20.32,11.41-7,4.08-13.8,8.38-20.68,12.59q-103.26,0-206.52,0A21.71,21.71,0,0,1,15.52,246.7Z\" transform=\"translate(-15.52 -35.97)\" />\n <path d=\"M225.94,198.17c-9.24,0-17.66.1-26.07-.12-1.11,0-2.57-1.41-3.21-2.53q-23.55-41.67-46.87-83.45a5.41,5.41,0,0,1-.16-4.4c3.89-7.34,8.06-14.52,12.67-22.72Z\" transform=\"translate(-15.52 -35.97)\" />\n </svg>\n </div>\n</div>");
|
|
23
16
|
}
|
|
24
|
-
|
|
25
17
|
function getStyle(p) {
|
|
26
18
|
var type = p.type,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
templateStyle = p.templateStyle,
|
|
20
|
+
appStyle = p.appStyle,
|
|
21
|
+
logoStyle = p.logoStyle,
|
|
22
|
+
logStyle = p.logStyle;
|
|
31
23
|
return "<style ".concat(type === "content" ? "scoped" : "", ">").concat(templateStyle._getCss(), " ").concat(appStyle._getCss(), " ").concat(logoStyle._getCss(), " ").concat(logStyle._getCss(), " </style>");
|
|
32
24
|
}
|
|
33
|
-
|
|
34
25
|
function getContent(p) {
|
|
35
26
|
var templateStyle = p.templateStyle,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
27
|
+
logStyle = p.logStyle,
|
|
28
|
+
text = p.text,
|
|
29
|
+
copyright = p.copyright,
|
|
30
|
+
toConsole = p.toConsole,
|
|
31
|
+
logo = p.logo,
|
|
32
|
+
footerMenu = p.footerMenu;
|
|
42
33
|
return "<div class=\"".concat(templateStyle.page, "\">\n <div class=\"").concat(templateStyle.header, "\">\n <div class=\"").concat(templateStyle.innerHeader, "\">\n <div class=\"").concat(templateStyle.logo, "\">\n ").concat(logo, "\n </div>\n </div>\n </div>\n <div class=\"").concat(templateStyle.content, "\">\n <div class=\"").concat(logStyle.log, "\">\n <div class=\"").concat(logStyle.logo, "\">\n ").concat(logo, "\n </div>\n <div>").concat(text, "</div>\n </div>\n </div>\n <div class=\"").concat(templateStyle.footer, "\">\n <div>\n <div class=\"").concat(templateStyle.menu, "\">\n ").concat(footerMenu, "\n </div>\n <div class=\"").concat(templateStyle.copyright, "\">").concat(copyright, "</div>\n </div>\n </div>\n <script>\n window.addEventListener(\"scroll\", function (e) {\n const header = document.body.querySelector(\".").concat(templateStyle.header, "\");\n if (header){\n header.classList.toggle(\"").concat(templateStyle.sticky, "\", window.scrollY > 0 )\n }\n });\n if (").concat(typeof toConsole === "string", "){\n console.log(`").concat(toConsole, "`);\n }\n </script>\n </div>");
|
|
43
34
|
}
|
|
44
|
-
|
|
45
35
|
function getHtml(p) {
|
|
46
36
|
var title = p.title,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
37
|
+
style = p.style,
|
|
38
|
+
content = p.content,
|
|
39
|
+
appStyle = p.appStyle;
|
|
50
40
|
return "<html lang=\"en\">\n <head>\n <meta charSet=\"utf-8\"/>\n <title>".concat(title, "</title>\n <meta name=\"description\" content=\"").concat(title.split(" | ")[0], "\"/>\n <meta name=\"author\" content=\"Wapplr\"/>\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"/>\n <link rel=\"icon\" href=\"data:image/png;base64,iVBORw0KGgo=\"/>\n ").concat(style, "\n </head>\n <body>\n <div class=\"").concat(appStyle.app, "\" id=\"wapplr-container-element-id-buildHash\">\n ").concat(content, "\n </div>\n </body>\n</html>\n");
|
|
51
41
|
}
|
|
52
|
-
|
|
53
42
|
function renderedContent() {
|
|
54
43
|
var p = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
55
44
|
var _p$templateStyle = p.templateStyle,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
45
|
+
templateStyle = _p$templateStyle === void 0 ? defaultTemplateStyle : _p$templateStyle,
|
|
46
|
+
_p$appStyle = p.appStyle,
|
|
47
|
+
appStyle = _p$appStyle === void 0 ? defaultAppStyle : _p$appStyle,
|
|
48
|
+
_p$logoStyle = p.logoStyle,
|
|
49
|
+
logoStyle = _p$logoStyle === void 0 ? defaultLogoStyle : _p$logoStyle,
|
|
50
|
+
_p$logStyle = p.logStyle,
|
|
51
|
+
logStyle = _p$logStyle === void 0 ? defaultLogStyle : _p$logStyle;
|
|
63
52
|
var _p$title = p.title,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
53
|
+
title = _p$title === void 0 ? "Log | Wapplr" : _p$title,
|
|
54
|
+
_p$text = p.text,
|
|
55
|
+
text = _p$text === void 0 ? "[" + Date.now() + " - ::1] HTTP:1.1 GET / - [200]" : _p$text,
|
|
56
|
+
_p$copyright = p.copyright,
|
|
57
|
+
copyright = _p$copyright === void 0 ? "Wapplr ".concat(new Date().getFullYear(), " \xA9") : _p$copyright,
|
|
58
|
+
_p$toConsole = p.toConsole,
|
|
59
|
+
toConsole = _p$toConsole === void 0 ? false : _p$toConsole,
|
|
60
|
+
_p$logo = p.logo,
|
|
61
|
+
logo = _p$logo === void 0 ? getLogo((0, _objectSpread2["default"])({
|
|
62
|
+
logoStyle: logoStyle
|
|
63
|
+
}, p)) : _p$logo,
|
|
64
|
+
_p$footerMenu = p.footerMenu,
|
|
65
|
+
footerMenu = _p$footerMenu === void 0 ? "" : _p$footerMenu,
|
|
66
|
+
_p$type = p.type,
|
|
67
|
+
type = _p$type === void 0 ? "" : _p$type;
|
|
79
68
|
var _p$style = p.style,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
69
|
+
style = _p$style === void 0 ? getStyle((0, _objectSpread2["default"])({
|
|
70
|
+
templateStyle: templateStyle,
|
|
71
|
+
appStyle: appStyle,
|
|
72
|
+
logoStyle: logoStyle,
|
|
73
|
+
logStyle: logStyle
|
|
74
|
+
}, p)) : _p$style,
|
|
75
|
+
_p$content = p.content,
|
|
76
|
+
content = _p$content === void 0 ? getContent((0, _objectSpread2["default"])({
|
|
77
|
+
templateStyle: templateStyle,
|
|
78
|
+
logStyle: logStyle,
|
|
79
|
+
text: text,
|
|
80
|
+
copyright: copyright,
|
|
81
|
+
toConsole: toConsole,
|
|
82
|
+
logo: logo,
|
|
83
|
+
footerMenu: footerMenu
|
|
84
|
+
}, p)) : _p$content;
|
|
97
85
|
if (type === "content") {
|
|
98
86
|
return "".concat(content, " ").concat(style);
|
|
99
87
|
}
|
|
100
|
-
|
|
101
88
|
var _p$html = p.html,
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
89
|
+
html = _p$html === void 0 ? getHtml((0, _objectSpread2["default"])({
|
|
90
|
+
title: title,
|
|
91
|
+
style: style,
|
|
92
|
+
content: content,
|
|
93
|
+
appStyle: appStyle
|
|
94
|
+
}, p)) : _p$html;
|
|
108
95
|
return html;
|
|
109
96
|
}
|
|
@@ -1,78 +1,60 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = createMiddlewares;
|
|
9
|
-
|
|
10
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
-
|
|
12
9
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
13
|
-
|
|
14
10
|
var _log = _interopRequireDefault(require("./log"));
|
|
15
|
-
|
|
16
11
|
var _states = _interopRequireDefault(require("./states"));
|
|
17
|
-
|
|
18
12
|
var _requests = _interopRequireDefault(require("./requests"));
|
|
19
|
-
|
|
20
13
|
var _router = _interopRequireDefault(require("./router"));
|
|
21
|
-
|
|
22
14
|
var _contents = _interopRequireDefault(require("./contents"));
|
|
23
|
-
|
|
24
15
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
25
|
-
|
|
26
16
|
var _utils = require("./utils");
|
|
27
|
-
|
|
28
17
|
function createWappMiddleware() {
|
|
29
18
|
var p = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
30
19
|
var wapp = p.wapp;
|
|
31
|
-
|
|
32
20
|
function defaultAddHandle(obj) {
|
|
33
21
|
if (typeof obj === "object" && !obj.length) {
|
|
34
22
|
Object.keys(obj).forEach(function (handleName) {
|
|
35
23
|
var handle = obj[handleName];
|
|
36
|
-
|
|
37
24
|
if (typeof handle == "function") {
|
|
38
25
|
wappMiddleware.handles[handleName] = handle;
|
|
39
26
|
}
|
|
40
27
|
});
|
|
41
28
|
}
|
|
42
29
|
}
|
|
43
|
-
|
|
44
30
|
function defaultWappMiddleware(req, res, next) {
|
|
45
31
|
var globals = wapp.globals;
|
|
46
32
|
var DEV = globals.DEV;
|
|
47
33
|
var config = wapp.getTargetObject().config;
|
|
48
34
|
var _config$containerElem = config.containerElementId,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
35
|
+
containerElementId = _config$containerElem === void 0 ? "app" : _config$containerElem,
|
|
36
|
+
_config$appStateName = config.appStateName,
|
|
37
|
+
appStateName = _config$appStateName === void 0 ? "APP_STATE" : _config$appStateName;
|
|
52
38
|
var container = null;
|
|
53
|
-
|
|
54
39
|
if (typeof document !== "undefined") {
|
|
55
40
|
container = containerElementId && document.getElementById(containerElementId) ? document.getElementById(containerElementId) : res.container ? res.container : document.body;
|
|
56
|
-
|
|
57
41
|
if (DEV) {
|
|
58
42
|
window.wapp = wapp;
|
|
59
43
|
}
|
|
60
|
-
}
|
|
61
|
-
// timestamp, remoteAddress, container (Html Element on the client side)
|
|
44
|
+
}
|
|
62
45
|
|
|
46
|
+
// these properties are plus things, usually there are not in request or response
|
|
47
|
+
// timestamp, remoteAddress, container (Html Element on the client side)
|
|
63
48
|
|
|
64
49
|
if (!req.timestamp) {
|
|
65
50
|
req.timestamp = Date.now();
|
|
66
51
|
}
|
|
67
|
-
|
|
68
52
|
if (!req.remoteAddress) {
|
|
69
53
|
req.remoteAddress = (req.headers && req.headers["x-forwarded-for"] || "").split(",").pop().trim() || req.socket && req.socket.remoteAddress || "::1";
|
|
70
54
|
}
|
|
71
|
-
|
|
72
55
|
if (wapp.target === "web" && container) {
|
|
73
56
|
res.container = container;
|
|
74
57
|
}
|
|
75
|
-
|
|
76
58
|
var wappRequest = {};
|
|
77
59
|
var wappResponse = {};
|
|
78
60
|
wappRequest.timestamp = req.timestamp;
|
|
@@ -140,7 +122,6 @@ function createWappMiddleware() {
|
|
|
140
122
|
writable: false,
|
|
141
123
|
value: wappResponse
|
|
142
124
|
}));
|
|
143
|
-
|
|
144
125
|
wappResponse.status = function status() {
|
|
145
126
|
if (!wappResponse.sended) {
|
|
146
127
|
var http1 = wappRequest.httpVersion === "1.1" || wappRequest.httpVersion && Number(wappRequest.httpVersion.split(".")[0]) === 1;
|
|
@@ -150,29 +131,23 @@ function createWappMiddleware() {
|
|
|
150
131
|
var error = arguments.length <= 1 ? undefined : arguments[1];
|
|
151
132
|
var isError = !!(error && error.message && error.stack);
|
|
152
133
|
wappResponse.statusCode = statusCode;
|
|
153
|
-
|
|
154
134
|
if (statusCode) {
|
|
155
135
|
if (statusCode === 200) {
|
|
156
136
|
wappResponse.statusMessage = tempStatusCode === 200 && tempStatusMessage ? tempStatusMessage : "OK";
|
|
157
137
|
}
|
|
158
|
-
|
|
159
138
|
if (statusCode === 304) {
|
|
160
139
|
wappResponse.statusMessage = tempStatusCode === 304 && tempStatusMessage ? tempStatusMessage : "Not modified";
|
|
161
140
|
}
|
|
162
|
-
|
|
163
141
|
if (statusCode === 404) {
|
|
164
142
|
wappResponse.statusMessage = tempStatusCode === 404 && tempStatusMessage ? tempStatusMessage : "Not found";
|
|
165
143
|
}
|
|
166
|
-
|
|
167
144
|
if (statusCode === 500) {
|
|
168
145
|
wappResponse.statusMessage = isError && error.message ? error.name + ": " + error.message : tempStatusCode === 500 && tempStatusMessage ? tempStatusMessage : "Error: Internal Server Error";
|
|
169
146
|
}
|
|
170
|
-
|
|
171
147
|
if (http1) {
|
|
172
148
|
res.statusMessage = wappResponse.statusMessage;
|
|
173
149
|
}
|
|
174
150
|
}
|
|
175
|
-
|
|
176
151
|
if (wappResponse.store) {
|
|
177
152
|
if (wappResponse.store.getState("res.statusCode") !== wappResponse.statusCode) {
|
|
178
153
|
wappResponse.store.dispatch(wapp.states.runAction("res", {
|
|
@@ -180,14 +155,12 @@ function createWappMiddleware() {
|
|
|
180
155
|
value: wappResponse.statusCode
|
|
181
156
|
}));
|
|
182
157
|
}
|
|
183
|
-
|
|
184
158
|
if (wappResponse.store.getState("res.statusMessage") !== wappResponse.statusMessage) {
|
|
185
159
|
wappResponse.store.dispatch(wapp.states.runAction("res", {
|
|
186
160
|
name: "statusMessage",
|
|
187
161
|
value: wappResponse.statusMessage
|
|
188
162
|
}));
|
|
189
163
|
}
|
|
190
|
-
|
|
191
164
|
if (wappResponse.store.getState("res.errorMessage") !== wappResponse.errorMessage) {
|
|
192
165
|
wappResponse.store.dispatch(wapp.states.runAction("res", {
|
|
193
166
|
name: "errorMessage",
|
|
@@ -195,28 +168,23 @@ function createWappMiddleware() {
|
|
|
195
168
|
}));
|
|
196
169
|
}
|
|
197
170
|
}
|
|
198
|
-
|
|
199
171
|
return res.status.apply(res, arguments);
|
|
200
172
|
}
|
|
201
173
|
};
|
|
202
|
-
|
|
203
174
|
wappResponse.send = function send() {
|
|
204
175
|
if (!wappResponse.sended) {
|
|
205
176
|
for (var _len = arguments.length, attributes = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
206
177
|
attributes[_key] = arguments[_key];
|
|
207
178
|
}
|
|
208
|
-
|
|
209
179
|
var html = attributes[0],
|
|
210
|
-
|
|
180
|
+
restAttr = attributes.slice(1);
|
|
211
181
|
wappResponse.sendData = {
|
|
212
182
|
data: html
|
|
213
183
|
};
|
|
214
184
|
wappMiddleware.runSendMiddlewares(req, res, function next() {
|
|
215
185
|
var _wappResponse$sendDat;
|
|
216
|
-
|
|
217
186
|
var endHtml = ((_wappResponse$sendDat = wappResponse.sendData) === null || _wappResponse$sendDat === void 0 ? void 0 : _wappResponse$sendDat.data) || "";
|
|
218
187
|
var callback = restAttr[0];
|
|
219
|
-
|
|
220
188
|
if (typeof callback === 'function') {
|
|
221
189
|
res.send.apply(res, [endHtml, function () {
|
|
222
190
|
callback();
|
|
@@ -228,47 +196,38 @@ function createWappMiddleware() {
|
|
|
228
196
|
});
|
|
229
197
|
}
|
|
230
198
|
};
|
|
231
|
-
|
|
232
199
|
Object.defineProperty(res, "_originalEndFunction", {
|
|
233
200
|
enumerable: false,
|
|
234
201
|
writable: false,
|
|
235
202
|
configurable: false,
|
|
236
203
|
value: res.end
|
|
237
204
|
});
|
|
238
|
-
|
|
239
205
|
res.end = function () {
|
|
240
206
|
res._originalEndFunction.apply(res, arguments);
|
|
241
|
-
|
|
242
207
|
wappResponse.sended = true;
|
|
243
208
|
};
|
|
244
|
-
|
|
245
209
|
Object.defineProperty(res, "_originalStatusFunction", {
|
|
246
210
|
enumerable: false,
|
|
247
211
|
writable: false,
|
|
248
212
|
configurable: false,
|
|
249
213
|
value: res.status
|
|
250
214
|
});
|
|
251
|
-
|
|
252
215
|
res.status = function () {
|
|
253
216
|
if (!wappResponse.sended) {
|
|
254
217
|
res._originalStatusFunction.apply(res, arguments);
|
|
255
218
|
}
|
|
256
219
|
};
|
|
257
|
-
|
|
258
220
|
if (wapp.globals.DEV) {
|
|
259
221
|
wapp.wappResponse = wappResponse;
|
|
260
222
|
wapp.wappRequest = wappRequest;
|
|
261
223
|
}
|
|
262
|
-
|
|
263
224
|
next();
|
|
264
225
|
}
|
|
265
|
-
|
|
266
226
|
function defaultHandle(req, res, out) {
|
|
267
227
|
var handles = Object.keys(wappMiddleware.handles).sort().map(function (key) {
|
|
268
228
|
return wappMiddleware.handles[key];
|
|
269
229
|
});
|
|
270
230
|
var index = 0;
|
|
271
|
-
|
|
272
231
|
function next(err) {
|
|
273
232
|
if (handles[index]) {
|
|
274
233
|
var func = handles[index];
|
|
@@ -280,13 +239,10 @@ function createWappMiddleware() {
|
|
|
280
239
|
index = 0;
|
|
281
240
|
return out(err);
|
|
282
241
|
}
|
|
283
|
-
|
|
284
242
|
return null;
|
|
285
243
|
}
|
|
286
|
-
|
|
287
244
|
return next();
|
|
288
245
|
}
|
|
289
|
-
|
|
290
246
|
function defaultRunSendMiddlewares(req, res, out) {
|
|
291
247
|
if (wappMiddleware.sendMiddlewares) {
|
|
292
248
|
var next = function next() {
|
|
@@ -297,10 +253,8 @@ function createWappMiddleware() {
|
|
|
297
253
|
} else if (typeof out == "function") {
|
|
298
254
|
return out();
|
|
299
255
|
}
|
|
300
|
-
|
|
301
256
|
return null;
|
|
302
257
|
};
|
|
303
|
-
|
|
304
258
|
var sendMiddlewares = Object.keys(wappMiddleware.sendMiddlewares).map(function (key) {
|
|
305
259
|
return wappMiddleware.sendMiddlewares[key];
|
|
306
260
|
});
|
|
@@ -309,22 +263,18 @@ function createWappMiddleware() {
|
|
|
309
263
|
} else if (typeof out == "function") {
|
|
310
264
|
return out();
|
|
311
265
|
}
|
|
312
|
-
|
|
313
266
|
return null;
|
|
314
267
|
}
|
|
315
|
-
|
|
316
268
|
function defaultAddSendMiddleware(obj) {
|
|
317
269
|
if (typeof obj === "object" && !obj.length) {
|
|
318
270
|
Object.keys(obj).forEach(function (handleName) {
|
|
319
271
|
var handle = obj[handleName];
|
|
320
|
-
|
|
321
272
|
if (typeof handle == "function") {
|
|
322
273
|
wappMiddleware.sendMiddlewares[handleName] = handle;
|
|
323
274
|
}
|
|
324
275
|
});
|
|
325
276
|
}
|
|
326
277
|
}
|
|
327
|
-
|
|
328
278
|
var wappMiddlewareProperties = Object.create(Object.prototype, {
|
|
329
279
|
handle: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _utils.defaultDescriptor), {}, {
|
|
330
280
|
value: defaultHandle
|
|
@@ -347,15 +297,12 @@ function createWappMiddleware() {
|
|
|
347
297
|
value: {}
|
|
348
298
|
})
|
|
349
299
|
});
|
|
350
|
-
|
|
351
300
|
function wappMiddleware(req, res, next) {
|
|
352
301
|
if (typeof wappMiddleware.handle === "function") {
|
|
353
302
|
wappMiddleware.handle(req, res, next);
|
|
354
303
|
}
|
|
355
|
-
|
|
356
304
|
return wappMiddleware;
|
|
357
305
|
}
|
|
358
|
-
|
|
359
306
|
(0, _utils.mergeProperties)(wappMiddleware, wappMiddlewareProperties);
|
|
360
307
|
Object.defineProperty(wappMiddleware, "wapp", (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _utils.defaultDescriptor), {}, {
|
|
361
308
|
writable: false,
|
|
@@ -368,7 +315,6 @@ function createWappMiddleware() {
|
|
|
368
315
|
}));
|
|
369
316
|
return wappMiddleware;
|
|
370
317
|
}
|
|
371
|
-
|
|
372
318
|
function createMiddlewares(p) {
|
|
373
319
|
return {
|
|
374
320
|
wapp: createWappMiddleware(p),
|