routup 4.0.0 → 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 CHANGED
@@ -10,8 +10,7 @@ var readableStream = require('readable-stream');
10
10
  var http = require('@ebec/http');
11
11
  var pathToRegexp = require('path-to-regexp');
12
12
 
13
- exports.MethodName = void 0;
14
- (function(MethodName) {
13
+ var MethodName = /*#__PURE__*/ function(MethodName) {
15
14
  MethodName["GET"] = "GET";
16
15
  MethodName["POST"] = "POST";
17
16
  MethodName["PUT"] = "PUT";
@@ -19,9 +18,9 @@ exports.MethodName = void 0;
19
18
  MethodName["DELETE"] = "DELETE";
20
19
  MethodName["OPTIONS"] = "OPTIONS";
21
20
  MethodName["HEAD"] = "HEAD";
22
- })(exports.MethodName || (exports.MethodName = {}));
23
- exports.HeaderName = void 0;
24
- (function(HeaderName) {
21
+ return MethodName;
22
+ }({});
23
+ var HeaderName = /*#__PURE__*/ function(HeaderName) {
25
24
  HeaderName["ACCEPT"] = "accept";
26
25
  HeaderName["ACCEPT_CHARSET"] = "accept-charset";
27
26
  HeaderName["ACCEPT_ENCODING"] = "accept-encoding";
@@ -53,10 +52,11 @@ exports.HeaderName = void 0;
53
52
  HeaderName["X_FORWARDED_HOST"] = "x-forwarded-host";
54
53
  HeaderName["X_FORWARDED_FOR"] = "x-forwarded-for";
55
54
  HeaderName["X_FORWARDED_PROTO"] = "x-forwarded-proto";
56
- })(exports.HeaderName || (exports.HeaderName = {}));
55
+ return HeaderName;
56
+ }({});
57
57
 
58
58
  function isRequestCacheable(req, modifiedTime) {
59
- const modifiedSince = req.headers[exports.HeaderName.IF_MODIFIED_SINCE];
59
+ const modifiedSince = req.headers[HeaderName.IF_MODIFIED_SINCE];
60
60
  if (!modifiedSince) {
61
61
  return false;
62
62
  }
@@ -411,7 +411,7 @@ function getRequestAcceptableContentType(req, input) {
411
411
  if (items.length === 0) {
412
412
  return getRequestAcceptableContentTypes(req).shift();
413
413
  }
414
- const header = getRequestHeader(req, exports.HeaderName.ACCEPT);
414
+ const header = getRequestHeader(req, HeaderName.ACCEPT);
415
415
  if (!header) {
416
416
  return items[0];
417
417
  }
@@ -485,7 +485,7 @@ function getRequestAcceptableLanguage(req, input) {
485
485
  }
486
486
 
487
487
  function matchRequestContentType(req, contentType) {
488
- const header = getRequestHeader(req, exports.HeaderName.CONTENT_TYPE);
488
+ const header = getRequestHeader(req, HeaderName.CONTENT_TYPE);
489
489
  if (!header) {
490
490
  return true;
491
491
  }
@@ -538,9 +538,9 @@ function getRequestHostName(req, options) {
538
538
  } else {
539
539
  trustProxy = findRouterOption('trustProxy', useRequestRouterPath(req));
540
540
  }
541
- let hostname = req.headers[exports.HeaderName.X_FORWARDED_HOST];
541
+ let hostname = req.headers[HeaderName.X_FORWARDED_HOST];
542
542
  if (!hostname || !req.socket.remoteAddress || !trustProxy(req.socket.remoteAddress, 0)) {
543
- hostname = req.headers[exports.HeaderName.HOST];
543
+ hostname = req.headers[HeaderName.HOST];
544
544
  } else {
545
545
  hostname = Array.isArray(hostname) ? hostname.pop() : hostname;
546
546
  if (hostname && hostname.indexOf(',') !== -1) {
@@ -627,7 +627,7 @@ function getRequestProtocol(req, options) {
627
627
  if (!req.socket.remoteAddress || !trustProxy(req.socket.remoteAddress, 0)) {
628
628
  return protocol;
629
629
  }
630
- let header = req.headers[exports.HeaderName.X_FORWARDED_PROTO];
630
+ let header = req.headers[HeaderName.X_FORWARDED_PROTO];
631
631
  /* istanbul ignore next */ if (Array.isArray(header)) {
632
632
  header = header.pop();
633
633
  }
@@ -793,11 +793,11 @@ class EventStream {
793
793
  this.end();
794
794
  });
795
795
  this.passThrough.on('close', ()=>this.end());
796
- this.response.setHeader(exports.HeaderName.CONTENT_TYPE, 'text/event-stream');
797
- this.response.setHeader(exports.HeaderName.CACHE_CONTROL, 'private, no-cache, no-store, no-transform, must-revalidate, max-age=0');
798
- this.response.setHeader(exports.HeaderName.X_ACCEL_BUFFERING, 'no');
796
+ this.response.setHeader(HeaderName.CONTENT_TYPE, 'text/event-stream');
797
+ this.response.setHeader(HeaderName.CACHE_CONTROL, 'private, no-cache, no-store, no-transform, must-revalidate, max-age=0');
798
+ this.response.setHeader(HeaderName.X_ACCEL_BUFFERING, 'no');
799
799
  if (!isRequestHTTP2(this.response.req)) {
800
- this.response.setHeader(exports.HeaderName.CONNECTION, 'keep-alive');
800
+ this.response.setHeader(HeaderName.CONNECTION, 'keep-alive');
801
801
  }
802
802
  this.response.statusCode = 200;
803
803
  }
@@ -909,7 +909,7 @@ function setResponseContentTypeByFileName(res, fileName) {
909
909
  if (charset) {
910
910
  type += `; charset=${charset}`;
911
911
  }
912
- res.setHeader(exports.HeaderName.CONTENT_TYPE, type);
912
+ res.setHeader(HeaderName.CONTENT_TYPE, type);
913
913
  }
914
914
  }
915
915
  }
@@ -918,19 +918,19 @@ function setResponseHeaderAttachment(res, filename) {
918
918
  if (typeof filename === 'string') {
919
919
  setResponseContentTypeByFileName(res, filename);
920
920
  }
921
- res.setHeader(exports.HeaderName.CONTENT_DISPOSITION, `attachment${filename ? `; filename="${filename}"` : ''}`);
921
+ res.setHeader(HeaderName.CONTENT_DISPOSITION, `attachment${filename ? `; filename="${filename}"` : ''}`);
922
922
  }
923
923
 
924
924
  function setResponseHeaderContentType(res, input, ifNotExists) {
925
925
  if (ifNotExists) {
926
- const header = res.getHeader(exports.HeaderName.CONTENT_TYPE);
926
+ const header = res.getHeader(HeaderName.CONTENT_TYPE);
927
927
  if (header) {
928
928
  return;
929
929
  }
930
930
  }
931
931
  const contentType = getMimeType(input);
932
932
  if (contentType) {
933
- res.setHeader(exports.HeaderName.CONTENT_TYPE, contentType);
933
+ res.setHeader(HeaderName.CONTENT_TYPE, contentType);
934
934
  }
935
935
  }
936
936
 
@@ -983,7 +983,7 @@ async function sendWebBlob(res, blob) {
983
983
 
984
984
  async function sendWebResponse(res, webResponse) {
985
985
  if (webResponse.redirected) {
986
- res.setHeader(exports.HeaderName.LOCATION, webResponse.url);
986
+ res.setHeader(HeaderName.LOCATION, webResponse.url);
987
987
  }
988
988
  if (webResponse.status) {
989
989
  res.statusCode = webResponse.status;
@@ -992,7 +992,7 @@ async function sendWebResponse(res, webResponse) {
992
992
  res.statusMessage = webResponse.statusText;
993
993
  }
994
994
  webResponse.headers.forEach((value, key)=>{
995
- if (key === exports.HeaderName.SET_COOKIE) {
995
+ if (key === HeaderName.SET_COOKIE) {
996
996
  res.appendHeader(key, splitCookiesString(value));
997
997
  } else {
998
998
  res.setHeader(key, value);
@@ -1045,8 +1045,8 @@ async function send(res, chunk) {
1045
1045
  }
1046
1046
  let encoding;
1047
1047
  if (typeof chunk === 'string') {
1048
- res.setHeader(exports.HeaderName.CONTENT_ENCODING, 'utf-8');
1049
- appendResponseHeaderDirective(res, exports.HeaderName.CONTENT_TYPE, 'charset=utf-8');
1048
+ res.setHeader(HeaderName.CONTENT_ENCODING, 'utf-8');
1049
+ appendResponseHeaderDirective(res, HeaderName.CONTENT_TYPE, 'charset=utf-8');
1050
1050
  encoding = 'utf-8';
1051
1051
  }
1052
1052
  // populate Content-Length
@@ -1064,7 +1064,7 @@ async function send(res, chunk) {
1064
1064
  encoding = undefined;
1065
1065
  len = chunk.length;
1066
1066
  }
1067
- res.setHeader(exports.HeaderName.CONTENT_LENGTH, `${len}`);
1067
+ res.setHeader(HeaderName.CONTENT_LENGTH, `${len}`);
1068
1068
  }
1069
1069
  if (typeof len !== 'undefined') {
1070
1070
  const etagFn = findRouterOption('etag', useRequestRouterPath(res.req));
@@ -1073,22 +1073,22 @@ async function send(res, chunk) {
1073
1073
  return;
1074
1074
  }
1075
1075
  if (typeof chunkHash === 'string') {
1076
- res.setHeader(exports.HeaderName.ETag, chunkHash);
1077
- if (res.req.headers[exports.HeaderName.IF_NONE_MATCH] === chunkHash) {
1076
+ res.setHeader(HeaderName.ETag, chunkHash);
1077
+ if (res.req.headers[HeaderName.IF_NONE_MATCH] === chunkHash) {
1078
1078
  res.statusCode = 304;
1079
1079
  }
1080
1080
  }
1081
1081
  }
1082
1082
  // strip irrelevant headers
1083
1083
  if (res.statusCode === 204 || res.statusCode === 304) {
1084
- res.removeHeader(exports.HeaderName.CONTENT_TYPE);
1085
- res.removeHeader(exports.HeaderName.CONTENT_LENGTH);
1086
- res.removeHeader(exports.HeaderName.TRANSFER_ENCODING);
1084
+ res.removeHeader(HeaderName.CONTENT_TYPE);
1085
+ res.removeHeader(HeaderName.CONTENT_LENGTH);
1086
+ res.removeHeader(HeaderName.TRANSFER_ENCODING);
1087
1087
  }
1088
1088
  // alter headers for 205
1089
1089
  if (res.statusCode === 205) {
1090
- res.setHeader(exports.HeaderName.CONTENT_LENGTH, 0);
1091
- res.removeHeader(exports.HeaderName.TRANSFER_ENCODING);
1090
+ res.setHeader(HeaderName.CONTENT_LENGTH, 0);
1091
+ res.removeHeader(HeaderName.TRANSFER_ENCODING);
1092
1092
  }
1093
1093
  if (isResponseGone(res)) {
1094
1094
  return;
@@ -1138,7 +1138,7 @@ async function sendFile(res, options, next) {
1138
1138
  if (name) {
1139
1139
  const fileName = basename(name);
1140
1140
  if (options.attachment) {
1141
- const dispositionHeader = res.getHeader(exports.HeaderName.CONTENT_DISPOSITION);
1141
+ const dispositionHeader = res.getHeader(HeaderName.CONTENT_DISPOSITION);
1142
1142
  if (!dispositionHeader) {
1143
1143
  setResponseHeaderAttachment(res, fileName);
1144
1144
  }
@@ -1148,7 +1148,7 @@ async function sendFile(res, options, next) {
1148
1148
  }
1149
1149
  const contentOptions = {};
1150
1150
  if (stats.size) {
1151
- const rangeHeader = res.req.headers[exports.HeaderName.RANGE];
1151
+ const rangeHeader = res.req.headers[HeaderName.RANGE];
1152
1152
  if (rangeHeader) {
1153
1153
  const [x, y] = rangeHeader.replace('bytes=', '').split('-');
1154
1154
  contentOptions.end = Math.min(parseInt(y, 10) || stats.size - 1, stats.size - 1);
@@ -1157,21 +1157,21 @@ async function sendFile(res, options, next) {
1157
1157
  contentOptions.end = stats.size - 1;
1158
1158
  }
1159
1159
  if (contentOptions.start >= stats.size) {
1160
- res.setHeader(exports.HeaderName.CONTENT_RANGE, `bytes */${stats.size}`);
1160
+ res.setHeader(HeaderName.CONTENT_RANGE, `bytes */${stats.size}`);
1161
1161
  res.statusCode = 416;
1162
1162
  res.end();
1163
1163
  return Promise.resolve();
1164
1164
  }
1165
- res.setHeader(exports.HeaderName.CONTENT_RANGE, `bytes ${contentOptions.start}-${contentOptions.end}/${stats.size}`);
1166
- res.setHeader(exports.HeaderName.CONTENT_LENGTH, contentOptions.end - contentOptions.start + 1);
1165
+ res.setHeader(HeaderName.CONTENT_RANGE, `bytes ${contentOptions.start}-${contentOptions.end}/${stats.size}`);
1166
+ res.setHeader(HeaderName.CONTENT_LENGTH, contentOptions.end - contentOptions.start + 1);
1167
1167
  } else {
1168
- res.setHeader(exports.HeaderName.CONTENT_LENGTH, stats.size);
1168
+ res.setHeader(HeaderName.CONTENT_LENGTH, stats.size);
1169
1169
  }
1170
- res.setHeader(exports.HeaderName.ACCEPT_RANGES, 'bytes');
1170
+ res.setHeader(HeaderName.ACCEPT_RANGES, 'bytes');
1171
1171
  if (stats.mtime) {
1172
1172
  const mtime = new Date(stats.mtime);
1173
- res.setHeader(exports.HeaderName.LAST_MODIFIED, mtime.toUTCString());
1174
- res.setHeader(exports.HeaderName.ETag, `W/"${stats.size}-${mtime.getTime()}"`);
1173
+ res.setHeader(HeaderName.LAST_MODIFIED, mtime.toUTCString());
1174
+ res.setHeader(HeaderName.ETag, `W/"${stats.size}-${mtime.getTime()}"`);
1175
1175
  }
1176
1176
  }
1177
1177
  try {
@@ -1273,7 +1273,7 @@ function createResponse(request) {
1273
1273
  finished: false,
1274
1274
  addTrailers (_headers) {},
1275
1275
  appendHeader (name, value) {
1276
- if (name === exports.HeaderName.SET_COOKIE) {
1276
+ if (name === HeaderName.SET_COOKIE) {
1277
1277
  value = splitCookiesString(value);
1278
1278
  }
1279
1279
  name = name.toLowerCase();
@@ -1308,12 +1308,24 @@ function createResponse(request) {
1308
1308
  delete headers[name.toLowerCase()];
1309
1309
  },
1310
1310
  setHeader (name, value) {
1311
- if (name === exports.HeaderName.SET_COOKIE && typeof value !== 'number') {
1311
+ if (name === HeaderName.SET_COOKIE && typeof value !== 'number') {
1312
1312
  value = splitCookiesString(value);
1313
1313
  }
1314
1314
  headers[name.toLowerCase()] = value;
1315
1315
  return this;
1316
1316
  },
1317
+ setHeaders (headers) {
1318
+ if (headers instanceof Map) {
1319
+ headers.entries().forEach(([key, value])=>{
1320
+ this.setHeader(key, value);
1321
+ });
1322
+ return this;
1323
+ }
1324
+ headers.forEach((value, key)=>{
1325
+ this.setHeader(key, value);
1326
+ });
1327
+ return this;
1328
+ },
1317
1329
  setTimeout (_msecs, _callback) {
1318
1330
  return this;
1319
1331
  },
@@ -1427,7 +1439,7 @@ class DispatchEvent {
1427
1439
  constructor(context){
1428
1440
  this.request = context.request;
1429
1441
  this.response = context.response;
1430
- this.method = context.method || exports.MethodName.GET;
1442
+ this.method = context.method || MethodName.GET;
1431
1443
  this.methodsAllowed = [];
1432
1444
  this.mountPath = '/';
1433
1445
  this.params = {};
@@ -1445,7 +1457,7 @@ async function dispatchNodeRequest(router, request, response) {
1445
1457
  request,
1446
1458
  response,
1447
1459
  path: useRequestPath(request),
1448
- method: toMethodName(request.method, exports.MethodName.GET)
1460
+ method: toMethodName(request.method, MethodName.GET)
1449
1461
  });
1450
1462
  await router.dispatch(event);
1451
1463
  if (event.dispatched) {
@@ -1497,7 +1509,7 @@ function transformHeadersToTuples(input) {
1497
1509
  }
1498
1510
 
1499
1511
  async function dispatchRawRequest(router, request) {
1500
- const method = toMethodName(request.method, exports.MethodName.GET);
1512
+ const method = toMethodName(request.method, MethodName.GET);
1501
1513
  const req = createRequest({
1502
1514
  url: request.path,
1503
1515
  method,
@@ -1555,7 +1567,7 @@ async function dispatchWebRequest(router, request) {
1555
1567
  request.headers.forEach((value, key)=>{
1556
1568
  headers[key] = value;
1557
1569
  });
1558
- const method = toMethodName(request.method, exports.MethodName.GET);
1570
+ const method = toMethodName(request.method, MethodName.GET);
1559
1571
  const res = await dispatchRawRequest(router, {
1560
1572
  method,
1561
1573
  path: url.pathname + url.search,
@@ -1563,7 +1575,7 @@ async function dispatchWebRequest(router, request) {
1563
1575
  body: request.body
1564
1576
  });
1565
1577
  let body;
1566
- if (method === exports.MethodName.HEAD || res.status === 304 || res.status === 101 || res.status === 204 || res.status === 205) {
1578
+ if (method === MethodName.HEAD || res.status === 304 || res.status === 101 || res.status === 204 || res.status === 205) {
1567
1579
  body = null;
1568
1580
  } else {
1569
1581
  body = res.body;
@@ -1578,22 +1590,22 @@ function createWebDispatcher(router) {
1578
1590
  return async (request)=>dispatchWebRequest(router, request);
1579
1591
  }
1580
1592
 
1581
- exports.HandlerType = void 0;
1582
- (function(HandlerType) {
1593
+ var HandlerType = /*#__PURE__*/ function(HandlerType) {
1583
1594
  HandlerType["CORE"] = "core";
1584
1595
  HandlerType["ERROR"] = "error";
1585
- })(exports.HandlerType || (exports.HandlerType = {}));
1596
+ return HandlerType;
1597
+ }({});
1586
1598
  const HandlerSymbol = Symbol.for('Handler');
1587
1599
 
1588
- var HookName;
1589
- (function(HookName) {
1600
+ var HookName = /*#__PURE__*/ function(HookName) {
1590
1601
  HookName["ERROR"] = "error";
1591
1602
  HookName["DISPATCH_START"] = "dispatchStart";
1592
1603
  HookName["DISPATCH_END"] = "dispatchEnd";
1593
1604
  HookName["CHILD_MATCH"] = "childMatch";
1594
1605
  HookName["CHILD_DISPATCH_BEFORE"] = "childDispatchBefore";
1595
1606
  HookName["CHILD_DISPATCH_AFTER"] = "childDispatchAfter";
1596
- })(HookName || (HookName = {}));
1607
+ return HookName;
1608
+ }({});
1597
1609
 
1598
1610
  class HookManager {
1599
1611
  // --------------------------------------------------
@@ -1725,7 +1737,7 @@ class PathMatcher {
1725
1737
  this.path = path;
1726
1738
  this.regexpOptions = options || {};
1727
1739
  const regexp = pathToRegexp.pathToRegexp(path, options);
1728
- this.regexp = regexp;
1740
+ this.regexp = regexp.regexp;
1729
1741
  this.regexpKeys = regexp.keys;
1730
1742
  }
1731
1743
  }
@@ -1766,7 +1778,7 @@ class Handler {
1766
1778
  }
1767
1779
  try {
1768
1780
  event.dispatched = await dispatch(event, (done)=>{
1769
- if (this.config.type === exports.HandlerType.ERROR) {
1781
+ if (this.config.type === HandlerType.ERROR) {
1770
1782
  if (event.error) {
1771
1783
  return this.config.fn(event.error, event.request, event.response, done);
1772
1784
  }
@@ -1810,7 +1822,7 @@ class Handler {
1810
1822
  }
1811
1823
  // --------------------------------------------------
1812
1824
  matchMethod(method) {
1813
- return !this.method || method === this.method || method === exports.MethodName.HEAD && this.method === exports.MethodName.GET;
1825
+ return !this.method || method === this.method || method === MethodName.HEAD && this.method === MethodName.GET;
1814
1826
  }
1815
1827
  setMethod(input) {
1816
1828
  const method = toMethodName(input);
@@ -1842,12 +1854,12 @@ class Handler {
1842
1854
  function coreHandler(input) {
1843
1855
  if (typeof input === 'function') {
1844
1856
  return new Handler({
1845
- type: exports.HandlerType.CORE,
1857
+ type: HandlerType.CORE,
1846
1858
  fn: input
1847
1859
  });
1848
1860
  }
1849
1861
  return new Handler({
1850
- type: exports.HandlerType.CORE,
1862
+ type: HandlerType.CORE,
1851
1863
  ...input
1852
1864
  });
1853
1865
  }
@@ -1855,12 +1867,12 @@ function coreHandler(input) {
1855
1867
  function errorHandler(input) {
1856
1868
  if (typeof input === 'function') {
1857
1869
  return new Handler({
1858
- type: exports.HandlerType.ERROR,
1870
+ type: HandlerType.ERROR,
1859
1871
  fn: input
1860
1872
  });
1861
1873
  }
1862
1874
  return new Handler({
1863
- type: exports.HandlerType.ERROR,
1875
+ type: HandlerType.ERROR,
1864
1876
  ...input
1865
1877
  });
1866
1878
  }
@@ -1893,15 +1905,15 @@ function transformRouterOptions(input) {
1893
1905
  }
1894
1906
 
1895
1907
  const RouterSymbol = Symbol.for('Router');
1896
- var RouterPipelineStep;
1897
- (function(RouterPipelineStep) {
1908
+ var RouterPipelineStep = /*#__PURE__*/ function(RouterPipelineStep) {
1898
1909
  RouterPipelineStep[RouterPipelineStep["START"] = 0] = "START";
1899
1910
  RouterPipelineStep[RouterPipelineStep["LOOKUP"] = 1] = "LOOKUP";
1900
1911
  RouterPipelineStep[RouterPipelineStep["CHILD_BEFORE"] = 2] = "CHILD_BEFORE";
1901
1912
  RouterPipelineStep[RouterPipelineStep["CHILD_DISPATCH"] = 3] = "CHILD_DISPATCH";
1902
1913
  RouterPipelineStep[RouterPipelineStep["CHILD_AFTER"] = 4] = "CHILD_AFTER";
1903
1914
  RouterPipelineStep[RouterPipelineStep["FINISH"] = 5] = "FINISH";
1904
- })(RouterPipelineStep || (RouterPipelineStep = {}));
1915
+ return RouterPipelineStep;
1916
+ }({});
1905
1917
 
1906
1918
  let nextId = 0;
1907
1919
  function generateRouterID() {
@@ -1976,7 +1988,7 @@ class Router {
1976
1988
  let match;
1977
1989
  const item = this.stack[context.stackIndex];
1978
1990
  if (isHandler(item)) {
1979
- if (context.event.error && item.type === exports.HandlerType.CORE || !context.event.error && item.type === exports.HandlerType.ERROR) {
1991
+ if (context.event.error && item.type === HandlerType.CORE || !context.event.error && item.type === HandlerType.ERROR) {
1980
1992
  context.stackIndex++;
1981
1993
  return this.executePipelineStepLookup(context);
1982
1994
  }
@@ -2050,13 +2062,13 @@ class Router {
2050
2062
  if (context.event.error || context.event.dispatched) {
2051
2063
  return this.hookManager.trigger(HookName.DISPATCH_END, context.event);
2052
2064
  }
2053
- if (!context.event.dispatched && context.event.routerPath.length === 1 && context.event.method && context.event.method === exports.MethodName.OPTIONS) {
2054
- if (context.event.methodsAllowed.indexOf(exports.MethodName.GET) !== -1) {
2055
- context.event.methodsAllowed.push(exports.MethodName.HEAD);
2065
+ if (!context.event.dispatched && context.event.routerPath.length === 1 && context.event.method && context.event.method === MethodName.OPTIONS) {
2066
+ if (context.event.methodsAllowed.indexOf(MethodName.GET) !== -1) {
2067
+ context.event.methodsAllowed.push(MethodName.HEAD);
2056
2068
  }
2057
2069
  smob.distinctArray(context.event.methodsAllowed);
2058
2070
  const options = context.event.methodsAllowed.map((key)=>key.toUpperCase()).join(',');
2059
- context.event.response.setHeader(exports.HeaderName.ALLOW, options);
2071
+ context.event.response.setHeader(HeaderName.ALLOW, options);
2060
2072
  await send(context.event.response, options);
2061
2073
  context.event.dispatched = true;
2062
2074
  }
@@ -2090,31 +2102,31 @@ class Router {
2090
2102
  });
2091
2103
  }
2092
2104
  delete(...input) {
2093
- this.useForMethod(exports.MethodName.DELETE, ...input);
2105
+ this.useForMethod(MethodName.DELETE, ...input);
2094
2106
  return this;
2095
2107
  }
2096
2108
  get(...input) {
2097
- this.useForMethod(exports.MethodName.GET, ...input);
2109
+ this.useForMethod(MethodName.GET, ...input);
2098
2110
  return this;
2099
2111
  }
2100
2112
  post(...input) {
2101
- this.useForMethod(exports.MethodName.POST, ...input);
2113
+ this.useForMethod(MethodName.POST, ...input);
2102
2114
  return this;
2103
2115
  }
2104
2116
  put(...input) {
2105
- this.useForMethod(exports.MethodName.PUT, ...input);
2117
+ this.useForMethod(MethodName.PUT, ...input);
2106
2118
  return this;
2107
2119
  }
2108
2120
  patch(...input) {
2109
- this.useForMethod(exports.MethodName.PATCH, ...input);
2121
+ this.useForMethod(MethodName.PATCH, ...input);
2110
2122
  return this;
2111
2123
  }
2112
2124
  head(...input) {
2113
- this.useForMethod(exports.MethodName.HEAD, ...input);
2125
+ this.useForMethod(MethodName.HEAD, ...input);
2114
2126
  return this;
2115
2127
  }
2116
2128
  options(...input) {
2117
- this.useForMethod(exports.MethodName.OPTIONS, ...input);
2129
+ this.useForMethod(MethodName.OPTIONS, ...input);
2118
2130
  return this;
2119
2131
  }
2120
2132
  // --------------------------------------------------
@@ -2226,6 +2238,9 @@ exports.DispatchEvent = DispatchEvent;
2226
2238
  exports.EventStream = EventStream;
2227
2239
  exports.Handler = Handler;
2228
2240
  exports.HandlerSymbol = HandlerSymbol;
2241
+ exports.HandlerType = HandlerType;
2242
+ exports.HeaderName = HeaderName;
2243
+ exports.MethodName = MethodName;
2229
2244
  exports.PathMatcher = PathMatcher;
2230
2245
  exports.Router = Router;
2231
2246
  exports.RoutupError = RoutupError;