routup 4.0.1 → 4.0.2
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/index.cjs +90 -75
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +27 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +25 -22
package/dist/index.mjs
CHANGED
|
@@ -8,8 +8,7 @@ import { Readable, PassThrough, Writable } from 'readable-stream';
|
|
|
8
8
|
import { HTTPError } from '@ebec/http';
|
|
9
9
|
import { pathToRegexp } from 'path-to-regexp';
|
|
10
10
|
|
|
11
|
-
var MethodName
|
|
12
|
-
(function(MethodName) {
|
|
11
|
+
var MethodName = /*#__PURE__*/ function(MethodName) {
|
|
13
12
|
MethodName["GET"] = "GET";
|
|
14
13
|
MethodName["POST"] = "POST";
|
|
15
14
|
MethodName["PUT"] = "PUT";
|
|
@@ -17,9 +16,9 @@ var MethodName;
|
|
|
17
16
|
MethodName["DELETE"] = "DELETE";
|
|
18
17
|
MethodName["OPTIONS"] = "OPTIONS";
|
|
19
18
|
MethodName["HEAD"] = "HEAD";
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
return MethodName;
|
|
20
|
+
}({});
|
|
21
|
+
var HeaderName = /*#__PURE__*/ function(HeaderName) {
|
|
23
22
|
HeaderName["ACCEPT"] = "accept";
|
|
24
23
|
HeaderName["ACCEPT_CHARSET"] = "accept-charset";
|
|
25
24
|
HeaderName["ACCEPT_ENCODING"] = "accept-encoding";
|
|
@@ -51,7 +50,8 @@ var HeaderName;
|
|
|
51
50
|
HeaderName["X_FORWARDED_HOST"] = "x-forwarded-host";
|
|
52
51
|
HeaderName["X_FORWARDED_FOR"] = "x-forwarded-for";
|
|
53
52
|
HeaderName["X_FORWARDED_PROTO"] = "x-forwarded-proto";
|
|
54
|
-
|
|
53
|
+
return HeaderName;
|
|
54
|
+
}({});
|
|
55
55
|
|
|
56
56
|
function isRequestCacheable(req, modifiedTime) {
|
|
57
57
|
const modifiedSince = req.headers[HeaderName.IF_MODIFIED_SINCE];
|
|
@@ -1312,6 +1312,18 @@ function createResponse(request) {
|
|
|
1312
1312
|
headers[name.toLowerCase()] = value;
|
|
1313
1313
|
return this;
|
|
1314
1314
|
},
|
|
1315
|
+
setHeaders (headers) {
|
|
1316
|
+
if (headers instanceof Map) {
|
|
1317
|
+
headers.entries().forEach(([key, value])=>{
|
|
1318
|
+
this.setHeader(key, value);
|
|
1319
|
+
});
|
|
1320
|
+
return this;
|
|
1321
|
+
}
|
|
1322
|
+
headers.forEach((value, key)=>{
|
|
1323
|
+
this.setHeader(key, value);
|
|
1324
|
+
});
|
|
1325
|
+
return this;
|
|
1326
|
+
},
|
|
1315
1327
|
setTimeout (_msecs, _callback) {
|
|
1316
1328
|
return this;
|
|
1317
1329
|
},
|
|
@@ -1576,22 +1588,22 @@ function createWebDispatcher(router) {
|
|
|
1576
1588
|
return async (request)=>dispatchWebRequest(router, request);
|
|
1577
1589
|
}
|
|
1578
1590
|
|
|
1579
|
-
var HandlerType
|
|
1580
|
-
(function(HandlerType) {
|
|
1591
|
+
var HandlerType = /*#__PURE__*/ function(HandlerType) {
|
|
1581
1592
|
HandlerType["CORE"] = "core";
|
|
1582
1593
|
HandlerType["ERROR"] = "error";
|
|
1583
|
-
|
|
1594
|
+
return HandlerType;
|
|
1595
|
+
}({});
|
|
1584
1596
|
const HandlerSymbol = Symbol.for('Handler');
|
|
1585
1597
|
|
|
1586
|
-
var HookName
|
|
1587
|
-
(function(HookName) {
|
|
1598
|
+
var HookName = /*#__PURE__*/ function(HookName) {
|
|
1588
1599
|
HookName["ERROR"] = "error";
|
|
1589
1600
|
HookName["DISPATCH_START"] = "dispatchStart";
|
|
1590
1601
|
HookName["DISPATCH_END"] = "dispatchEnd";
|
|
1591
1602
|
HookName["CHILD_MATCH"] = "childMatch";
|
|
1592
1603
|
HookName["CHILD_DISPATCH_BEFORE"] = "childDispatchBefore";
|
|
1593
1604
|
HookName["CHILD_DISPATCH_AFTER"] = "childDispatchAfter";
|
|
1594
|
-
|
|
1605
|
+
return HookName;
|
|
1606
|
+
}({});
|
|
1595
1607
|
|
|
1596
1608
|
class HookManager {
|
|
1597
1609
|
// --------------------------------------------------
|
|
@@ -1891,15 +1903,15 @@ function transformRouterOptions(input) {
|
|
|
1891
1903
|
}
|
|
1892
1904
|
|
|
1893
1905
|
const RouterSymbol = Symbol.for('Router');
|
|
1894
|
-
var RouterPipelineStep
|
|
1895
|
-
(function(RouterPipelineStep) {
|
|
1906
|
+
var RouterPipelineStep = /*#__PURE__*/ function(RouterPipelineStep) {
|
|
1896
1907
|
RouterPipelineStep[RouterPipelineStep["START"] = 0] = "START";
|
|
1897
1908
|
RouterPipelineStep[RouterPipelineStep["LOOKUP"] = 1] = "LOOKUP";
|
|
1898
1909
|
RouterPipelineStep[RouterPipelineStep["CHILD_BEFORE"] = 2] = "CHILD_BEFORE";
|
|
1899
1910
|
RouterPipelineStep[RouterPipelineStep["CHILD_DISPATCH"] = 3] = "CHILD_DISPATCH";
|
|
1900
1911
|
RouterPipelineStep[RouterPipelineStep["CHILD_AFTER"] = 4] = "CHILD_AFTER";
|
|
1901
1912
|
RouterPipelineStep[RouterPipelineStep["FINISH"] = 5] = "FINISH";
|
|
1902
|
-
|
|
1913
|
+
return RouterPipelineStep;
|
|
1914
|
+
}({});
|
|
1903
1915
|
|
|
1904
1916
|
let nextId = 0;
|
|
1905
1917
|
function generateRouterID() {
|