wapplr 1.0.78 → 1.0.79
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 +44 -57
- package/dist/client/createClient.js +47 -57
- package/dist/client/middlewares.js +32 -40
- package/dist/common/contents.js +29 -38
- package/dist/common/middlewares.js +3 -3
- package/dist/common/requests.js +30 -35
- package/dist/common/router.js +33 -45
- package/dist/common/states.js +18 -7
- package/dist/server/app.js +44 -57
- package/dist/server/createServer.js +47 -57
- package/dist/server/middlewares.js +2 -2
- package/dist/server/static.js +38 -39
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports["default"] = createServer;
|
|
8
|
-
var
|
|
8
|
+
var _regenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/regenerator"));
|
|
9
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
10
|
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
|
|
11
11
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
@@ -369,71 +369,64 @@ function createServer() {
|
|
|
369
369
|
"static": app["static"](wapplrServer.config.publicPath)
|
|
370
370
|
}, _rest);
|
|
371
371
|
}
|
|
372
|
-
app.use(
|
|
373
|
-
var _defaultMiddlewaresWrapper = (0, _asyncToGenerator2["default"])(
|
|
374
|
-
var
|
|
375
|
-
return (0,
|
|
376
|
-
while (1) switch (_context3.
|
|
372
|
+
app.use(/*#__PURE__*/function () {
|
|
373
|
+
var _defaultMiddlewaresWrapper = (0, _asyncToGenerator2["default"])(/*#__PURE__*/(0, _regenerator2["default"])().m(function _callee3(req, res, out) {
|
|
374
|
+
var _next, middlewares, index;
|
|
375
|
+
return (0, _regenerator2["default"])().w(function (_context3) {
|
|
376
|
+
while (1) switch (_context3.n) {
|
|
377
377
|
case 0:
|
|
378
378
|
if (wapplrServer.config.disableUseDefaultMiddlewares) {
|
|
379
|
-
_context3.
|
|
379
|
+
_context3.n = 2;
|
|
380
380
|
break;
|
|
381
381
|
}
|
|
382
|
-
|
|
383
|
-
var _ref2 = (0, _asyncToGenerator2["default"])(
|
|
384
|
-
var func, defaultArgs, args;
|
|
385
|
-
return (0,
|
|
386
|
-
while (1) switch (_context2.
|
|
382
|
+
_next = /*#__PURE__*/function () {
|
|
383
|
+
var _ref2 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/(0, _regenerator2["default"])().m(function _callee2(err) {
|
|
384
|
+
var func, defaultArgs, args, _t;
|
|
385
|
+
return (0, _regenerator2["default"])().w(function (_context2) {
|
|
386
|
+
while (1) switch (_context2.p = _context2.n) {
|
|
387
387
|
case 0:
|
|
388
388
|
if (!middlewares[index]) {
|
|
389
|
-
_context2.
|
|
389
|
+
_context2.n = 5;
|
|
390
390
|
break;
|
|
391
391
|
}
|
|
392
392
|
func = middlewares[index];
|
|
393
393
|
index = index + 1;
|
|
394
|
-
defaultArgs = [req, res, err ? /*#__PURE__*/(0, _asyncToGenerator2["default"])(
|
|
395
|
-
return (0,
|
|
396
|
-
while (1) switch (_context.
|
|
394
|
+
defaultArgs = [req, res, err ? /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/(0, _regenerator2["default"])().m(function _callee() {
|
|
395
|
+
return (0, _regenerator2["default"])().w(function (_context) {
|
|
396
|
+
while (1) switch (_context.n) {
|
|
397
397
|
case 0:
|
|
398
|
-
_context.
|
|
399
|
-
return
|
|
400
|
-
case
|
|
401
|
-
|
|
402
|
-
return _context.stop();
|
|
398
|
+
_context.n = 1;
|
|
399
|
+
return _next(err);
|
|
400
|
+
case 1:
|
|
401
|
+
return _context.a(2);
|
|
403
402
|
}
|
|
404
403
|
}, _callee);
|
|
405
|
-
})) :
|
|
404
|
+
})) : _next];
|
|
406
405
|
args = func.length === 4 && err ? [err].concat(defaultArgs) : defaultArgs;
|
|
407
|
-
_context2.
|
|
408
|
-
_context2.
|
|
406
|
+
_context2.p = 1;
|
|
407
|
+
_context2.n = 2;
|
|
409
408
|
return func.apply(void 0, (0, _toConsumableArray2["default"])(args));
|
|
410
|
-
case
|
|
411
|
-
return _context2.
|
|
412
|
-
case
|
|
413
|
-
_context2.
|
|
414
|
-
|
|
415
|
-
res.wappResponse.status(500,
|
|
416
|
-
_context2.
|
|
417
|
-
return
|
|
418
|
-
case
|
|
419
|
-
return _context2.
|
|
420
|
-
case
|
|
421
|
-
_context2.next = 22;
|
|
422
|
-
break;
|
|
423
|
-
case 19:
|
|
409
|
+
case 2:
|
|
410
|
+
return _context2.a(2, _context2.v);
|
|
411
|
+
case 3:
|
|
412
|
+
_context2.p = 3;
|
|
413
|
+
_t = _context2.v;
|
|
414
|
+
res.wappResponse.status(500, _t);
|
|
415
|
+
_context2.n = 4;
|
|
416
|
+
return _next(_t);
|
|
417
|
+
case 4:
|
|
418
|
+
return _context2.a(2, _context2.v);
|
|
419
|
+
case 5:
|
|
424
420
|
if (!(typeof out === "function")) {
|
|
425
|
-
_context2.
|
|
421
|
+
_context2.n = 6;
|
|
426
422
|
break;
|
|
427
423
|
}
|
|
428
424
|
index = 0;
|
|
429
|
-
return _context2.
|
|
430
|
-
case
|
|
431
|
-
return _context2.
|
|
432
|
-
case 23:
|
|
433
|
-
case "end":
|
|
434
|
-
return _context2.stop();
|
|
425
|
+
return _context2.a(2, out(err));
|
|
426
|
+
case 6:
|
|
427
|
+
return _context2.a(2, null);
|
|
435
428
|
}
|
|
436
|
-
}, _callee2, null, [[
|
|
429
|
+
}, _callee2, null, [[1, 3]]);
|
|
437
430
|
}));
|
|
438
431
|
return function next(_x4) {
|
|
439
432
|
return _ref2.apply(this, arguments);
|
|
@@ -443,18 +436,15 @@ function createServer() {
|
|
|
443
436
|
return wapplrServer.middlewares[key];
|
|
444
437
|
});
|
|
445
438
|
index = 0;
|
|
446
|
-
_context3.
|
|
447
|
-
return
|
|
448
|
-
case
|
|
449
|
-
return _context3.
|
|
450
|
-
case
|
|
451
|
-
_context3.
|
|
439
|
+
_context3.n = 1;
|
|
440
|
+
return _next();
|
|
441
|
+
case 1:
|
|
442
|
+
return _context3.a(2, _context3.v);
|
|
443
|
+
case 2:
|
|
444
|
+
_context3.n = 3;
|
|
452
445
|
return out();
|
|
453
|
-
case
|
|
454
|
-
return _context3.
|
|
455
|
-
case 10:
|
|
456
|
-
case "end":
|
|
457
|
-
return _context3.stop();
|
|
446
|
+
case 3:
|
|
447
|
+
return _context3.a(2, _context3.v);
|
|
458
448
|
}
|
|
459
449
|
}, _callee3);
|
|
460
450
|
}));
|
|
@@ -275,8 +275,8 @@ function createMiddlewares(p) {
|
|
|
275
275
|
var mtime = stats.mtime,
|
|
276
276
|
size = stats.size;
|
|
277
277
|
if (!res.getHeader("ETag") && mtime && size) {
|
|
278
|
-
var
|
|
279
|
-
res.setHeader("ETag",
|
|
278
|
+
var _etag = "W/\"".concat(size.toString(16), "-").concat(mtime.getTime().toString(16), "\"");
|
|
279
|
+
res.setHeader("ETag", _etag);
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
282
|
return next();
|
package/dist/server/static.js
CHANGED
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.addCloseEventsForReadableStream = addCloseEventsForReadableStream;
|
|
8
8
|
exports["default"] = serveStatic;
|
|
9
9
|
exports.endStream = endStream;
|
|
10
|
-
var
|
|
10
|
+
var _regenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/regenerator"));
|
|
11
11
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
12
12
|
var fs = require("node:fs/promises");
|
|
13
13
|
var fsSync = require("node:fs");
|
|
@@ -86,10 +86,10 @@ function addCloseEventsForReadableStream(req, res, stream) {
|
|
|
86
86
|
}
|
|
87
87
|
function serveStatic(publicPath) {
|
|
88
88
|
return /*#__PURE__*/function () {
|
|
89
|
-
var _staticMiddleware = (0, _asyncToGenerator2["default"])(
|
|
90
|
-
var parsedUrl, sanitizePath, pathname, parsedSanitizePath, ext, stream, data, stats;
|
|
91
|
-
return (0,
|
|
92
|
-
while (1) switch (_context.
|
|
89
|
+
var _staticMiddleware = (0, _asyncToGenerator2["default"])(/*#__PURE__*/(0, _regenerator2["default"])().m(function _callee(req, res, next) {
|
|
90
|
+
var parsedUrl, sanitizePath, pathname, parsedSanitizePath, ext, stream, data, stats, _t, _t2;
|
|
91
|
+
return (0, _regenerator2["default"])().w(function (_context) {
|
|
92
|
+
while (1) switch (_context.p = _context.n) {
|
|
93
93
|
case 0:
|
|
94
94
|
parsedUrl = {
|
|
95
95
|
pathname: req.wappRequest.path
|
|
@@ -102,37 +102,37 @@ function serveStatic(publicPath) {
|
|
|
102
102
|
parsedSanitizePath = path.parse(pathname);
|
|
103
103
|
ext = parsedSanitizePath.ext;
|
|
104
104
|
if (ext) {
|
|
105
|
-
_context.
|
|
105
|
+
_context.n = 2;
|
|
106
106
|
break;
|
|
107
107
|
}
|
|
108
|
-
_context.
|
|
108
|
+
_context.n = 1;
|
|
109
109
|
return next();
|
|
110
|
-
case
|
|
111
|
-
return _context.
|
|
112
|
-
case
|
|
113
|
-
_context.
|
|
114
|
-
_context.
|
|
110
|
+
case 1:
|
|
111
|
+
return _context.a(2, _context.v);
|
|
112
|
+
case 2:
|
|
113
|
+
_context.p = 2;
|
|
114
|
+
_context.n = 3;
|
|
115
115
|
return fs.access(pathname);
|
|
116
|
-
case
|
|
117
|
-
_context.
|
|
116
|
+
case 3:
|
|
117
|
+
_context.n = 6;
|
|
118
118
|
break;
|
|
119
|
-
case
|
|
120
|
-
_context.
|
|
121
|
-
|
|
122
|
-
_context.
|
|
119
|
+
case 4:
|
|
120
|
+
_context.p = 4;
|
|
121
|
+
_t = _context.v;
|
|
122
|
+
_context.n = 5;
|
|
123
123
|
return next();
|
|
124
|
-
case
|
|
125
|
-
return _context.
|
|
126
|
-
case
|
|
127
|
-
_context.
|
|
128
|
-
_context.
|
|
124
|
+
case 5:
|
|
125
|
+
return _context.a(2, _context.v);
|
|
126
|
+
case 6:
|
|
127
|
+
_context.p = 6;
|
|
128
|
+
_context.n = 7;
|
|
129
129
|
return fs.readFile(pathname);
|
|
130
|
-
case
|
|
131
|
-
data = _context.
|
|
132
|
-
_context.
|
|
130
|
+
case 7:
|
|
131
|
+
data = _context.v;
|
|
132
|
+
_context.n = 8;
|
|
133
133
|
return fs.stat(pathname);
|
|
134
|
-
case
|
|
135
|
-
stats = _context.
|
|
134
|
+
case 8:
|
|
135
|
+
stats = _context.v;
|
|
136
136
|
res.wappResponse.status(200);
|
|
137
137
|
res.wappResponse.sendData = {
|
|
138
138
|
data: data,
|
|
@@ -153,20 +153,19 @@ function serveStatic(publicPath) {
|
|
|
153
153
|
stream.pipe(res);
|
|
154
154
|
});
|
|
155
155
|
});
|
|
156
|
-
_context.
|
|
156
|
+
_context.n = 10;
|
|
157
157
|
break;
|
|
158
|
-
case
|
|
159
|
-
_context.
|
|
160
|
-
|
|
158
|
+
case 9:
|
|
159
|
+
_context.p = 9;
|
|
160
|
+
_t2 = _context.v;
|
|
161
161
|
endStream(req, res, stream);
|
|
162
|
-
res.wappResponse.status(
|
|
163
|
-
res.wapp.log(
|
|
164
|
-
next(
|
|
165
|
-
case
|
|
166
|
-
|
|
167
|
-
return _context.stop();
|
|
162
|
+
res.wappResponse.status(_t2.statusCode || 500, _t2);
|
|
163
|
+
res.wapp.log(_t2, req, res);
|
|
164
|
+
next(_t2);
|
|
165
|
+
case 10:
|
|
166
|
+
return _context.a(2);
|
|
168
167
|
}
|
|
169
|
-
}, _callee, null, [[
|
|
168
|
+
}, _callee, null, [[6, 9], [2, 4]]);
|
|
170
169
|
}));
|
|
171
170
|
function staticMiddleware(_x, _x2, _x3) {
|
|
172
171
|
return _staticMiddleware.apply(this, arguments);
|