routup 0.8.1 → 0.8.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.
Files changed (220) hide show
  1. package/dist/handler/index.d.ts +0 -1
  2. package/dist/handler/index.d.ts.map +1 -1
  3. package/dist/handler/index.js +0 -1
  4. package/dist/handler/index.js.map +1 -1
  5. package/dist/handler/utils.d.ts +1 -1
  6. package/dist/handler/utils.d.ts.map +1 -1
  7. package/dist/handler/utils.js +3 -3
  8. package/dist/handler/utils.js.map +1 -1
  9. package/dist/index.d.ts +1 -2
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +1 -2
  12. package/dist/index.js.map +1 -1
  13. package/dist/layer/index.d.ts +1 -0
  14. package/dist/layer/index.d.ts.map +1 -1
  15. package/dist/layer/index.js +1 -0
  16. package/dist/layer/index.js.map +1 -1
  17. package/dist/layer/module.d.ts +4 -3
  18. package/dist/layer/module.d.ts.map +1 -1
  19. package/dist/layer/module.js +5 -10
  20. package/dist/layer/module.js.map +1 -1
  21. package/dist/layer/type.d.ts +7 -0
  22. package/dist/layer/type.d.ts.map +1 -0
  23. package/dist/{config → layer}/type.js +1 -1
  24. package/dist/{handler → layer}/type.js.map +1 -1
  25. package/dist/path/matcher.d.ts.map +1 -1
  26. package/dist/path/matcher.js +1 -0
  27. package/dist/path/matcher.js.map +1 -1
  28. package/dist/route/index.d.ts +1 -0
  29. package/dist/route/index.d.ts.map +1 -1
  30. package/dist/route/index.js +1 -0
  31. package/dist/route/index.js.map +1 -1
  32. package/dist/route/module.d.ts +4 -4
  33. package/dist/route/module.d.ts.map +1 -1
  34. package/dist/route/module.js +25 -22
  35. package/dist/route/module.js.map +1 -1
  36. package/dist/route/type.d.ts +7 -0
  37. package/dist/route/type.d.ts.map +1 -0
  38. package/dist/{helpers/response/send-format.js → route/type.js} +1 -5
  39. package/dist/{config → route}/type.js.map +1 -1
  40. package/dist/router/module.d.ts +35 -8
  41. package/dist/router/module.d.ts.map +1 -1
  42. package/dist/router/module.js +45 -23
  43. package/dist/router/module.js.map +1 -1
  44. package/dist/router/type.d.ts +14 -7
  45. package/dist/router/type.d.ts.map +1 -1
  46. package/dist/router/type.js +0 -6
  47. package/dist/router/type.js.map +1 -1
  48. package/dist/type.d.ts +0 -7
  49. package/dist/type.d.ts.map +1 -1
  50. package/dist/utils/index.d.ts +0 -2
  51. package/dist/utils/index.d.ts.map +1 -1
  52. package/dist/utils/index.js +0 -2
  53. package/dist/utils/index.js.map +1 -1
  54. package/dist/utils/request.d.ts +1 -1
  55. package/dist/utils/request.d.ts.map +1 -1
  56. package/package.json +8 -15
  57. package/dist/config/accessors.d.ts +0 -15
  58. package/dist/config/accessors.d.ts.map +0 -1
  59. package/dist/config/accessors.js +0 -32
  60. package/dist/config/accessors.js.map +0 -1
  61. package/dist/config/index.d.ts +0 -5
  62. package/dist/config/index.d.ts.map +0 -1
  63. package/dist/config/index.js +0 -27
  64. package/dist/config/index.js.map +0 -1
  65. package/dist/config/module.d.ts +0 -23
  66. package/dist/config/module.d.ts.map +0 -1
  67. package/dist/config/module.js +0 -126
  68. package/dist/config/module.js.map +0 -1
  69. package/dist/config/singleton.d.ts +0 -4
  70. package/dist/config/singleton.d.ts.map +0 -1
  71. package/dist/config/singleton.js +0 -50
  72. package/dist/config/singleton.js.map +0 -1
  73. package/dist/config/type.d.ts +0 -78
  74. package/dist/config/type.d.ts.map +0 -1
  75. package/dist/config/utils/etag.d.ts +0 -3
  76. package/dist/config/utils/etag.d.ts.map +0 -1
  77. package/dist/config/utils/etag.js +0 -43
  78. package/dist/config/utils/etag.js.map +0 -1
  79. package/dist/config/utils/index.d.ts +0 -4
  80. package/dist/config/utils/index.d.ts.map +0 -1
  81. package/dist/config/utils/index.js +0 -26
  82. package/dist/config/utils/index.js.map +0 -1
  83. package/dist/config/utils/trust-proxy.d.ts +0 -3
  84. package/dist/config/utils/trust-proxy.d.ts.map +0 -1
  85. package/dist/config/utils/trust-proxy.js +0 -31
  86. package/dist/config/utils/trust-proxy.js.map +0 -1
  87. package/dist/config/utils/validator.d.ts +0 -3
  88. package/dist/config/utils/validator.d.ts.map +0 -1
  89. package/dist/config/utils/validator.js +0 -20
  90. package/dist/config/utils/validator.js.map +0 -1
  91. package/dist/constants.d.ts +0 -30
  92. package/dist/constants.d.ts.map +0 -1
  93. package/dist/constants.js +0 -41
  94. package/dist/constants.js.map +0 -1
  95. package/dist/handler/type.d.ts +0 -4
  96. package/dist/handler/type.d.ts.map +0 -1
  97. package/dist/handler/type.js +0 -3
  98. package/dist/helpers/index.d.ts +0 -3
  99. package/dist/helpers/index.d.ts.map +0 -1
  100. package/dist/helpers/index.js +0 -25
  101. package/dist/helpers/index.js.map +0 -1
  102. package/dist/helpers/request/cache.d.ts +0 -3
  103. package/dist/helpers/request/cache.d.ts.map +0 -1
  104. package/dist/helpers/request/cache.js +0 -21
  105. package/dist/helpers/request/cache.js.map +0 -1
  106. package/dist/helpers/request/env.d.ts +0 -7
  107. package/dist/helpers/request/env.d.ts.map +0 -1
  108. package/dist/helpers/request/env.js +0 -57
  109. package/dist/helpers/request/env.js.map +0 -1
  110. package/dist/helpers/request/header-accept-charset.d.ts +0 -5
  111. package/dist/helpers/request/header-accept-charset.d.ts.map +0 -1
  112. package/dist/helpers/request/header-accept-charset.js +0 -26
  113. package/dist/helpers/request/header-accept-charset.js.map +0 -1
  114. package/dist/helpers/request/header-accept-encoding.d.ts +0 -4
  115. package/dist/helpers/request/header-accept-encoding.d.ts.map +0 -1
  116. package/dist/helpers/request/header-accept-encoding.js +0 -26
  117. package/dist/helpers/request/header-accept-encoding.js.map +0 -1
  118. package/dist/helpers/request/header-accept-language.d.ts +0 -4
  119. package/dist/helpers/request/header-accept-language.d.ts.map +0 -1
  120. package/dist/helpers/request/header-accept-language.js +0 -26
  121. package/dist/helpers/request/header-accept-language.js.map +0 -1
  122. package/dist/helpers/request/header-accept.d.ts +0 -4
  123. package/dist/helpers/request/header-accept.d.ts.map +0 -1
  124. package/dist/helpers/request/header-accept.js +0 -51
  125. package/dist/helpers/request/header-accept.js.map +0 -1
  126. package/dist/helpers/request/header-content-type.d.ts +0 -3
  127. package/dist/helpers/request/header-content-type.d.ts.map +0 -1
  128. package/dist/helpers/request/header-content-type.js +0 -28
  129. package/dist/helpers/request/header-content-type.js.map +0 -1
  130. package/dist/helpers/request/header.d.ts +0 -5
  131. package/dist/helpers/request/header.d.ts.map +0 -1
  132. package/dist/helpers/request/header.js +0 -18
  133. package/dist/helpers/request/header.js.map +0 -1
  134. package/dist/helpers/request/hostname.d.ts +0 -8
  135. package/dist/helpers/request/hostname.d.ts.map +0 -1
  136. package/dist/helpers/request/hostname.js +0 -46
  137. package/dist/helpers/request/hostname.js.map +0 -1
  138. package/dist/helpers/request/index.d.ts +0 -16
  139. package/dist/helpers/request/index.d.ts.map +0 -1
  140. package/dist/helpers/request/index.js +0 -38
  141. package/dist/helpers/request/index.js.map +0 -1
  142. package/dist/helpers/request/ip.d.ts +0 -8
  143. package/dist/helpers/request/ip.d.ts.map +0 -1
  144. package/dist/helpers/request/ip.js +0 -29
  145. package/dist/helpers/request/ip.js.map +0 -1
  146. package/dist/helpers/request/mount-path.d.ts +0 -5
  147. package/dist/helpers/request/mount-path.d.ts.map +0 -1
  148. package/dist/helpers/request/mount-path.js +0 -22
  149. package/dist/helpers/request/mount-path.js.map +0 -1
  150. package/dist/helpers/request/negotiator.d.ts +0 -5
  151. package/dist/helpers/request/negotiator.d.ts.map +0 -1
  152. package/dist/helpers/request/negotiator.js +0 -22
  153. package/dist/helpers/request/negotiator.js.map +0 -1
  154. package/dist/helpers/request/params.d.ts +0 -6
  155. package/dist/helpers/request/params.d.ts.map +0 -1
  156. package/dist/helpers/request/params.js +0 -35
  157. package/dist/helpers/request/params.js.map +0 -1
  158. package/dist/helpers/request/path.d.ts +0 -4
  159. package/dist/helpers/request/path.d.ts.map +0 -1
  160. package/dist/helpers/request/path.js +0 -21
  161. package/dist/helpers/request/path.js.map +0 -1
  162. package/dist/helpers/request/protocol.d.ts +0 -9
  163. package/dist/helpers/request/protocol.d.ts.map +0 -1
  164. package/dist/helpers/request/protocol.js +0 -50
  165. package/dist/helpers/request/protocol.js.map +0 -1
  166. package/dist/helpers/response/cache.d.ts +0 -8
  167. package/dist/helpers/response/cache.d.ts.map +0 -1
  168. package/dist/helpers/response/cache.js +0 -25
  169. package/dist/helpers/response/cache.js.map +0 -1
  170. package/dist/helpers/response/header-attachment.d.ts +0 -4
  171. package/dist/helpers/response/header-attachment.d.ts.map +0 -1
  172. package/dist/helpers/response/header-attachment.js +0 -29
  173. package/dist/helpers/response/header-attachment.js.map +0 -1
  174. package/dist/helpers/response/header-content-type.d.ts +0 -3
  175. package/dist/helpers/response/header-content-type.d.ts.map +0 -1
  176. package/dist/helpers/response/header-content-type.js +0 -25
  177. package/dist/helpers/response/header-content-type.js.map +0 -1
  178. package/dist/helpers/response/header.d.ts +0 -6
  179. package/dist/helpers/response/header.d.ts.map +0 -1
  180. package/dist/helpers/response/header.js +0 -51
  181. package/dist/helpers/response/header.js.map +0 -1
  182. package/dist/helpers/response/index.d.ts +0 -12
  183. package/dist/helpers/response/index.d.ts.map +0 -1
  184. package/dist/helpers/response/index.js +0 -34
  185. package/dist/helpers/response/index.js.map +0 -1
  186. package/dist/helpers/response/send-accepted.d.ts +0 -3
  187. package/dist/helpers/response/send-accepted.d.ts.map +0 -1
  188. package/dist/helpers/response/send-accepted.js +0 -17
  189. package/dist/helpers/response/send-accepted.js.map +0 -1
  190. package/dist/helpers/response/send-created.d.ts +0 -3
  191. package/dist/helpers/response/send-created.d.ts.map +0 -1
  192. package/dist/helpers/response/send-created.js +0 -17
  193. package/dist/helpers/response/send-created.js.map +0 -1
  194. package/dist/helpers/response/send-file.d.ts +0 -5
  195. package/dist/helpers/response/send-file.d.ts.map +0 -1
  196. package/dist/helpers/response/send-file.js +0 -27
  197. package/dist/helpers/response/send-file.js.map +0 -1
  198. package/dist/helpers/response/send-format.d.ts +0 -7
  199. package/dist/helpers/response/send-format.d.ts.map +0 -1
  200. package/dist/helpers/response/send-format.js.map +0 -1
  201. package/dist/helpers/response/send-redirect.d.ts +0 -3
  202. package/dist/helpers/response/send-redirect.d.ts.map +0 -1
  203. package/dist/helpers/response/send-redirect.js +0 -19
  204. package/dist/helpers/response/send-redirect.js.map +0 -1
  205. package/dist/helpers/response/send-stream.d.ts +0 -5
  206. package/dist/helpers/response/send-stream.d.ts.map +0 -1
  207. package/dist/helpers/response/send-stream.js +0 -33
  208. package/dist/helpers/response/send-stream.js.map +0 -1
  209. package/dist/helpers/response/send.d.ts +0 -3
  210. package/dist/helpers/response/send.d.ts.map +0 -1
  211. package/dist/helpers/response/send.js +0 -97
  212. package/dist/helpers/response/send.js.map +0 -1
  213. package/dist/utils/mime.d.ts +0 -2
  214. package/dist/utils/mime.d.ts.map +0 -1
  215. package/dist/utils/mime.js +0 -21
  216. package/dist/utils/mime.js.map +0 -1
  217. package/dist/utils/object.d.ts +0 -2
  218. package/dist/utils/object.d.ts.map +0 -1
  219. package/dist/utils/object.js +0 -16
  220. package/dist/utils/object.js.map +0 -1
@@ -1,26 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.getRequestAcceptableEncoding = exports.getRequestAcceptableEncodings = void 0;
10
- const negotiator_1 = require("./negotiator");
11
- function getRequestAcceptableEncodings(req) {
12
- const negotiator = (0, negotiator_1.useRequestNegotiator)(req);
13
- return negotiator.encodings();
14
- }
15
- exports.getRequestAcceptableEncodings = getRequestAcceptableEncodings;
16
- function getRequestAcceptableEncoding(req, input) {
17
- input = input || [];
18
- const items = Array.isArray(input) ? input : [input];
19
- if (items.length === 0) {
20
- return getRequestAcceptableEncodings(req).shift();
21
- }
22
- const negotiator = (0, negotiator_1.useRequestNegotiator)(req);
23
- return negotiator.encodings(items).shift() || undefined;
24
- }
25
- exports.getRequestAcceptableEncoding = getRequestAcceptableEncoding;
26
- //# sourceMappingURL=header-accept-encoding.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"header-accept-encoding.js","sourceRoot":"","sources":["../../../src/helpers/request/header-accept-encoding.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,6CAAoD;AAEpD,SAAgB,6BAA6B,CAAC,GAAY;IACtD,MAAM,UAAU,GAAG,IAAA,iCAAoB,EAAC,GAAG,CAAC,CAAC;IAC7C,OAAO,UAAU,CAAC,SAAS,EAAE,CAAC;AAClC,CAAC;AAHD,sEAGC;AAED,SAAgB,4BAA4B,CAAC,GAAY,EAAE,KAAwB;IAC/E,KAAK,GAAG,KAAK,IAAI,EAAE,CAAC;IAEpB,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAErD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QACpB,OAAO,6BAA6B,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC;KACrD;IAED,MAAM,UAAU,GAAG,IAAA,iCAAoB,EAAC,GAAG,CAAC,CAAC;IAC7C,OAAO,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,IAAI,SAAS,CAAC;AAC5D,CAAC;AAXD,oEAWC"}
@@ -1,4 +0,0 @@
1
- import { Request } from '../../type';
2
- export declare function getRequestAcceptableLanguages(req: Request): string[];
3
- export declare function getRequestAcceptableLanguage(req: Request, input?: string | string[]): string | undefined;
4
- //# sourceMappingURL=header-accept-language.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"header-accept-language.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/header-accept-language.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAGrC,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,OAAO,GAAI,MAAM,EAAE,CAGrE;AAED,wBAAgB,4BAA4B,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAI,MAAM,GAAG,SAAS,CAWzG"}
@@ -1,26 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.getRequestAcceptableLanguage = exports.getRequestAcceptableLanguages = void 0;
10
- const negotiator_1 = require("./negotiator");
11
- function getRequestAcceptableLanguages(req) {
12
- const negotiator = (0, negotiator_1.useRequestNegotiator)(req);
13
- return negotiator.languages();
14
- }
15
- exports.getRequestAcceptableLanguages = getRequestAcceptableLanguages;
16
- function getRequestAcceptableLanguage(req, input) {
17
- input = input || [];
18
- const items = Array.isArray(input) ? input : [input];
19
- if (items.length === 0) {
20
- return getRequestAcceptableLanguages(req).shift();
21
- }
22
- const negotiator = (0, negotiator_1.useRequestNegotiator)(req);
23
- return negotiator.languages(items).shift() || undefined;
24
- }
25
- exports.getRequestAcceptableLanguage = getRequestAcceptableLanguage;
26
- //# sourceMappingURL=header-accept-language.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"header-accept-language.js","sourceRoot":"","sources":["../../../src/helpers/request/header-accept-language.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,6CAAoD;AAEpD,SAAgB,6BAA6B,CAAC,GAAY;IACtD,MAAM,UAAU,GAAG,IAAA,iCAAoB,EAAC,GAAG,CAAC,CAAC;IAC7C,OAAO,UAAU,CAAC,SAAS,EAAE,CAAC;AAClC,CAAC;AAHD,sEAGC;AAED,SAAgB,4BAA4B,CAAC,GAAY,EAAE,KAAyB;IAChF,KAAK,GAAG,KAAK,IAAI,EAAE,CAAC;IAEpB,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAErD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QACpB,OAAO,6BAA6B,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC;KACrD;IAED,MAAM,UAAU,GAAG,IAAA,iCAAoB,EAAC,GAAG,CAAC,CAAC;IAC7C,OAAO,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,IAAI,SAAS,CAAC;AAC5D,CAAC;AAXD,oEAWC"}
@@ -1,4 +0,0 @@
1
- import { Request } from '../../type';
2
- export declare function getRequestAcceptableContentTypes(req: Request): string[];
3
- export declare function getRequestAcceptableContentType(req: Request, input?: string | string[]): string | undefined;
4
- //# sourceMappingURL=header-accept.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"header-accept.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/header-accept.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAKrC,wBAAgB,gCAAgC,CAAC,GAAG,EAAE,OAAO,GAAI,MAAM,EAAE,CAIxE;AAED,wBAAgB,+BAA+B,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAI,MAAM,GAAG,SAAS,CAoC5G"}
@@ -1,51 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.getRequestAcceptableContentType = exports.getRequestAcceptableContentTypes = void 0;
10
- const constants_1 = require("../../constants");
11
- const utils_1 = require("../../utils");
12
- const header_1 = require("./header");
13
- const negotiator_1 = require("./negotiator");
14
- function getRequestAcceptableContentTypes(req) {
15
- const negotiator = (0, negotiator_1.useRequestNegotiator)(req);
16
- return negotiator.mediaTypes();
17
- }
18
- exports.getRequestAcceptableContentTypes = getRequestAcceptableContentTypes;
19
- function getRequestAcceptableContentType(req, input) {
20
- input = input || [];
21
- const items = Array.isArray(input) ? input : [input];
22
- if (items.length === 0) {
23
- return getRequestAcceptableContentTypes(req).shift();
24
- }
25
- const header = (0, header_1.getRequestHeader)(req, constants_1.HeaderName.ACCEPT);
26
- if (!header) {
27
- return items[0];
28
- }
29
- let polluted = false;
30
- const mimeTypes = [];
31
- for (let i = 0; i < items.length; i++) {
32
- const mimeType = (0, utils_1.getMimeType)(items[i]);
33
- if (mimeType) {
34
- mimeTypes.push(mimeType);
35
- }
36
- else {
37
- polluted = true;
38
- }
39
- }
40
- const negotiator = (0, negotiator_1.useRequestNegotiator)(req);
41
- const matches = negotiator.mediaTypes(mimeTypes);
42
- if (matches.length > 0) {
43
- if (polluted) {
44
- return items[0];
45
- }
46
- return items[mimeTypes.indexOf(matches[0])];
47
- }
48
- return undefined;
49
- }
50
- exports.getRequestAcceptableContentType = getRequestAcceptableContentType;
51
- //# sourceMappingURL=header-accept.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"header-accept.js","sourceRoot":"","sources":["../../../src/helpers/request/header-accept.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,+CAA6C;AAE7C,uCAA0C;AAC1C,qCAA4C;AAC5C,6CAAoD;AAEpD,SAAgB,gCAAgC,CAAC,GAAY;IACzD,MAAM,UAAU,GAAG,IAAA,iCAAoB,EAAC,GAAG,CAAC,CAAC;IAE7C,OAAO,UAAU,CAAC,UAAU,EAAE,CAAC;AACnC,CAAC;AAJD,4EAIC;AAED,SAAgB,+BAA+B,CAAC,GAAY,EAAE,KAAyB;IACnF,KAAK,GAAG,KAAK,IAAI,EAAE,CAAC;IAEpB,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAErD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QACpB,OAAO,gCAAgC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC;KACxD;IAED,MAAM,MAAM,GAAG,IAAA,yBAAgB,EAAC,GAAG,EAAE,sBAAU,CAAC,MAAM,CAAC,CAAC;IACxD,IAAI,CAAC,MAAM,EAAE;QACT,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;KACnB;IAED,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,MAAM,SAAS,GAAc,EAAE,CAAC;IAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACnC,MAAM,QAAQ,GAAG,IAAA,mBAAW,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACvC,IAAI,QAAQ,EAAE;YACV,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SAC5B;aAAM;YACH,QAAQ,GAAG,IAAI,CAAC;SACnB;KACJ;IAED,MAAM,UAAU,GAAG,IAAA,iCAAoB,EAAC,GAAG,CAAC,CAAC;IAC7C,MAAM,OAAO,GAAG,UAAU,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACjD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;QACpB,IAAI,QAAQ,EAAE;YACV,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;SACnB;QAED,OAAO,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAC/C;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AApCD,0EAoCC"}
@@ -1,3 +0,0 @@
1
- import { Request } from '../../type';
2
- export declare function matchRequestContentType(req: Request, contentType: string): boolean;
3
- //# sourceMappingURL=header-content-type.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"header-content-type.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/header-content-type.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAIrC,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,GAAI,OAAO,CAgBnF"}
@@ -1,28 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.matchRequestContentType = void 0;
10
- const constants_1 = require("../../constants");
11
- const utils_1 = require("../../utils");
12
- const header_1 = require("./header");
13
- function matchRequestContentType(req, contentType) {
14
- const header = (0, header_1.getRequestHeader)(req, constants_1.HeaderName.CONTENT_TYPE);
15
- if (!header) {
16
- return true;
17
- }
18
- /* istanbul ignore next */
19
- if (Array.isArray(header)) {
20
- if (header.length === 0) {
21
- return true;
22
- }
23
- return header[0] === (0, utils_1.getMimeType)(contentType);
24
- }
25
- return header.split('; ').shift() === (0, utils_1.getMimeType)(contentType);
26
- }
27
- exports.matchRequestContentType = matchRequestContentType;
28
- //# sourceMappingURL=header-content-type.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"header-content-type.js","sourceRoot":"","sources":["../../../src/helpers/request/header-content-type.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,+CAA6C;AAE7C,uCAA0C;AAC1C,qCAA4C;AAE5C,SAAgB,uBAAuB,CAAC,GAAY,EAAE,WAAmB;IACrE,MAAM,MAAM,GAAG,IAAA,yBAAgB,EAAC,GAAG,EAAE,sBAAU,CAAC,YAAY,CAAC,CAAC;IAC9D,IAAI,CAAC,MAAM,EAAE;QACT,OAAO,IAAI,CAAC;KACf;IAED,0BAA0B;IAC1B,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACvB,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;YACrB,OAAO,IAAI,CAAC;SACf;QAED,OAAO,MAAM,CAAC,CAAC,CAAC,KAAK,IAAA,mBAAW,EAAC,WAAW,CAAC,CAAC;KACjD;IAED,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,KAAK,IAAA,mBAAW,EAAC,WAAW,CAAC,CAAC;AACnE,CAAC;AAhBD,0DAgBC"}
@@ -1,5 +0,0 @@
1
- /// <reference types="node" />
2
- import { IncomingHttpHeaders, IncomingMessage } from 'http';
3
- export declare function getRequestHeader<K extends keyof IncomingHttpHeaders>(req: IncomingMessage, name: K): IncomingHttpHeaders[K];
4
- export declare function setRequestHeader<K extends keyof IncomingHttpHeaders>(req: IncomingMessage, name: K, value: IncomingHttpHeaders[K]): void;
5
- //# sourceMappingURL=header.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"header.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/header.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAE5D,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,mBAAmB,EAChE,GAAG,EAAE,eAAe,EACpB,IAAI,EAAE,CAAC,GACP,mBAAmB,CAAC,CAAC,CAAC,CAEzB;AAED,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,mBAAmB,EAChE,GAAG,EAAE,eAAe,EACpB,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,mBAAmB,CAAC,CAAC,CAAC,QAGhC"}
@@ -1,18 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.setRequestHeader = exports.getRequestHeader = void 0;
10
- function getRequestHeader(req, name) {
11
- return req.headers[name];
12
- }
13
- exports.getRequestHeader = getRequestHeader;
14
- function setRequestHeader(req, name, value) {
15
- req.headers[name] = value;
16
- }
17
- exports.setRequestHeader = setRequestHeader;
18
- //# sourceMappingURL=header.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"header.js","sourceRoot":"","sources":["../../../src/helpers/request/header.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAIH,SAAgB,gBAAgB,CAC5B,GAAoB,EACpB,IAAO;IAEP,OAAO,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC;AALD,4CAKC;AAED,SAAgB,gBAAgB,CAC5B,GAAoB,EACpB,IAAO,EACP,KAA6B;IAE7B,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;AAC9B,CAAC;AAND,4CAMC"}
@@ -1,8 +0,0 @@
1
- import { TrustProxyInput } from '../../config';
2
- import { Request } from '../../type';
3
- type RequestHostNameOptions = {
4
- trustProxy?: TrustProxyInput;
5
- };
6
- export declare function getRequestHostName(req: Request, options?: RequestHostNameOptions): string | undefined;
7
- export {};
8
- //# sourceMappingURL=hostname.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hostname.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/hostname.ts"],"names":[],"mappings":"AAOA,OAAO,EAAgB,eAAe,EAAa,MAAM,cAAc,CAAC;AAGxE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,KAAK,sBAAsB,GAAG;IAC1B,UAAU,CAAC,EAAE,eAAe,CAAA;CAC/B,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAI,MAAM,GAAG,SAAS,CAkCtG"}
@@ -1,46 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.getRequestHostName = void 0;
10
- const config_1 = require("../../config");
11
- const utils_1 = require("../../config/utils");
12
- const constants_1 = require("../../constants");
13
- function getRequestHostName(req, options) {
14
- options = options || {};
15
- let trustProxy;
16
- if (typeof options.trustProxy !== 'undefined') {
17
- trustProxy = (0, utils_1.buildConfigTrustProxyOption)(options.trustProxy);
18
- }
19
- else {
20
- const config = (0, config_1.useConfig)();
21
- trustProxy = config.get('trustProxy');
22
- }
23
- let hostname = req.headers[constants_1.HeaderName.X_FORWARDED_HOST];
24
- if (!hostname || !req.socket.remoteAddress || !trustProxy(req.socket.remoteAddress, 0)) {
25
- hostname = req.headers[constants_1.HeaderName.HOST];
26
- }
27
- else {
28
- hostname = Array.isArray(hostname) ? hostname.pop() : hostname;
29
- if (hostname && hostname.indexOf(',') !== -1) {
30
- hostname = hostname.substring(0, hostname.indexOf(',')).trimEnd();
31
- }
32
- }
33
- if (!hostname) {
34
- return undefined;
35
- }
36
- // IPv6 literal support
37
- const offset = hostname[0] === '[' ?
38
- hostname.indexOf(']') + 1 :
39
- 0;
40
- const index = hostname.indexOf(':', offset);
41
- return index !== -1 ?
42
- hostname.substring(0, index) :
43
- hostname;
44
- }
45
- exports.getRequestHostName = getRequestHostName;
46
- //# sourceMappingURL=hostname.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hostname.js","sourceRoot":"","sources":["../../../src/helpers/request/hostname.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,yCAAwE;AACxE,8CAAiE;AACjE,+CAA6C;AAO7C,SAAgB,kBAAkB,CAAC,GAAY,EAAE,OAAgC;IAC7E,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;IAExB,IAAI,UAAyB,CAAC;IAC9B,IAAI,OAAO,OAAO,CAAC,UAAU,KAAK,WAAW,EAAE;QAC3C,UAAU,GAAG,IAAA,mCAA2B,EAAC,OAAO,CAAC,UAAU,CAAC,CAAC;KAChE;SAAM;QACH,MAAM,MAAM,GAAG,IAAA,kBAAS,GAAE,CAAC;QAC3B,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;KACzC;IAED,IAAI,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,sBAAU,CAAC,gBAAgB,CAAC,CAAC;IACxD,IAAI,CAAC,QAAQ,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,aAAa,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC,EAAE;QACpF,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,sBAAU,CAAC,IAAI,CAAC,CAAC;KAC3C;SAAM;QACH,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;QAC/D,IAAI,QAAQ,IAAI,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE;YAC1C,QAAQ,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SACrE;KACJ;IAED,IAAI,CAAC,QAAQ,EAAE;QACX,OAAO,SAAS,CAAC;KACpB;IAED,uBAAuB;IACvB,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;QAChC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QAC3B,CAAC,CAAC;IACN,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAE5C,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC;QACjB,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;QAC9B,QAAQ,CAAC;AACjB,CAAC;AAlCD,gDAkCC"}
@@ -1,16 +0,0 @@
1
- export * from './cache';
2
- export * from './env';
3
- export * from './header';
4
- export * from './header-accept';
5
- export * from './header-accept-charset';
6
- export * from './header-accept-encoding';
7
- export * from './header-accept-language';
8
- export * from './header-content-type';
9
- export * from './hostname';
10
- export * from './ip';
11
- export * from './mount-path';
12
- export * from './negotiator';
13
- export * from './params';
14
- export * from './protocol';
15
- export * from './path';
16
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/index.ts"],"names":[],"mappings":"AAOA,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,YAAY,CAAC;AAC3B,cAAc,MAAM,CAAC;AACrB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC"}
@@ -1,38 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- var desc = Object.getOwnPropertyDescriptor(m, k);
11
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
- desc = { enumerable: true, get: function() { return m[k]; } };
13
- }
14
- Object.defineProperty(o, k2, desc);
15
- }) : (function(o, m, k, k2) {
16
- if (k2 === undefined) k2 = k;
17
- o[k2] = m[k];
18
- }));
19
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
- };
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- __exportStar(require("./cache"), exports);
24
- __exportStar(require("./env"), exports);
25
- __exportStar(require("./header"), exports);
26
- __exportStar(require("./header-accept"), exports);
27
- __exportStar(require("./header-accept-charset"), exports);
28
- __exportStar(require("./header-accept-encoding"), exports);
29
- __exportStar(require("./header-accept-language"), exports);
30
- __exportStar(require("./header-content-type"), exports);
31
- __exportStar(require("./hostname"), exports);
32
- __exportStar(require("./ip"), exports);
33
- __exportStar(require("./mount-path"), exports);
34
- __exportStar(require("./negotiator"), exports);
35
- __exportStar(require("./params"), exports);
36
- __exportStar(require("./protocol"), exports);
37
- __exportStar(require("./path"), exports);
38
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/request/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,0CAAwB;AACxB,wCAAsB;AACtB,2CAAyB;AACzB,kDAAgC;AAChC,0DAAwC;AACxC,2DAAyC;AACzC,2DAAyC;AACzC,wDAAsC;AACtC,6CAA2B;AAC3B,uCAAqB;AACrB,+CAA6B;AAC7B,+CAA6B;AAC7B,2CAAyB;AACzB,6CAA2B;AAC3B,yCAAuB"}
@@ -1,8 +0,0 @@
1
- import { TrustProxyInput } from '../../config';
2
- import { Request } from '../../type';
3
- type RequestIpOptions = {
4
- trustProxy?: TrustProxyInput;
5
- };
6
- export declare function getRequestIp(req: Request, options?: RequestIpOptions): string;
7
- export {};
8
- //# sourceMappingURL=ip.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ip.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/ip.ts"],"names":[],"mappings":"AAQA,OAAO,EAAgB,eAAe,EAAa,MAAM,cAAc,CAAC;AAExE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,KAAK,gBAAgB,GAAG;IACpB,UAAU,CAAC,EAAE,eAAe,CAAA;CAC/B,CAAC;AAEF,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAI,MAAM,CAY9E"}
@@ -1,29 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- var __importDefault = (this && this.__importDefault) || function (mod) {
9
- return (mod && mod.__esModule) ? mod : { "default": mod };
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.getRequestIp = void 0;
13
- const proxy_addr_1 = __importDefault(require("proxy-addr"));
14
- const config_1 = require("../../config");
15
- const utils_1 = require("../../config/utils");
16
- function getRequestIp(req, options) {
17
- options = options || {};
18
- let trustProxy;
19
- if (typeof options.trustProxy !== 'undefined') {
20
- trustProxy = (0, utils_1.buildConfigTrustProxyOption)(options.trustProxy);
21
- }
22
- else {
23
- const config = (0, config_1.useConfig)();
24
- trustProxy = config.get('trustProxy');
25
- }
26
- return (0, proxy_addr_1.default)(req, trustProxy);
27
- }
28
- exports.getRequestIp = getRequestIp;
29
- //# sourceMappingURL=ip.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ip.js","sourceRoot":"","sources":["../../../src/helpers/request/ip.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;AAEH,4DAAmC;AACnC,yCAAwE;AACxE,8CAAiE;AAOjE,SAAgB,YAAY,CAAC,GAAY,EAAE,OAA0B;IACjE,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;IAExB,IAAI,UAAyB,CAAC;IAC9B,IAAI,OAAO,OAAO,CAAC,UAAU,KAAK,WAAW,EAAE;QAC3C,UAAU,GAAG,IAAA,mCAA2B,EAAC,OAAO,CAAC,UAAU,CAAC,CAAC;KAChE;SAAM;QACH,MAAM,MAAM,GAAG,IAAA,kBAAS,GAAE,CAAC;QAC3B,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;KACzC;IAED,OAAO,IAAA,oBAAS,EAAC,GAAG,EAAE,UAAU,CAAC,CAAC;AACtC,CAAC;AAZD,oCAYC"}
@@ -1,5 +0,0 @@
1
- /// <reference types="node" />
2
- import { IncomingMessage } from 'http';
3
- export declare function useRequestMountPath(req: IncomingMessage): string;
4
- export declare function setRequestMountPath(req: IncomingMessage, basePath: string): void;
5
- //# sourceMappingURL=mount-path.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mount-path.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/mount-path.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAIvC,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,eAAe,GAAI,MAAM,CAMjE;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,QAEzE"}
@@ -1,22 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.setRequestMountPath = exports.useRequestMountPath = void 0;
10
- const ReqMountPathSymbol = Symbol.for('ReqMountPath');
11
- function useRequestMountPath(req) {
12
- if (ReqMountPathSymbol in req) {
13
- return req[ReqMountPathSymbol];
14
- }
15
- return '/';
16
- }
17
- exports.useRequestMountPath = useRequestMountPath;
18
- function setRequestMountPath(req, basePath) {
19
- req[ReqMountPathSymbol] = basePath;
20
- }
21
- exports.setRequestMountPath = setRequestMountPath;
22
- //# sourceMappingURL=mount-path.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mount-path.js","sourceRoot":"","sources":["../../../src/helpers/request/mount-path.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAIH,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;AAEtD,SAAgB,mBAAmB,CAAC,GAAoB;IACpD,IAAI,kBAAkB,IAAI,GAAG,EAAE;QAC3B,OAAQ,GAAW,CAAC,kBAAkB,CAAC,CAAC;KAC3C;IAED,OAAO,GAAG,CAAC;AACf,CAAC;AAND,kDAMC;AAED,SAAgB,mBAAmB,CAAC,GAAoB,EAAE,QAAgB;IACrE,GAAW,CAAC,kBAAkB,CAAC,GAAG,QAAQ,CAAC;AAChD,CAAC;AAFD,kDAEC"}
@@ -1,5 +0,0 @@
1
- /// <reference types="node" />
2
- import { IncomingMessage } from 'http';
3
- import Negotiator from 'negotiator';
4
- export declare function useRequestNegotiator(req: IncomingMessage): Negotiator;
5
- //# sourceMappingURL=negotiator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"negotiator.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/negotiator.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,UAAU,MAAM,YAAY,CAAC;AAIpC,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,eAAe,GAAI,UAAU,CAMtE"}
@@ -1,22 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- var __importDefault = (this && this.__importDefault) || function (mod) {
9
- return (mod && mod.__esModule) ? mod : { "default": mod };
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.useRequestNegotiator = void 0;
13
- const negotiator_1 = __importDefault(require("negotiator"));
14
- const NegotiatorSymbol = Symbol.for('ReqNegotiator');
15
- function useRequestNegotiator(req) {
16
- if (NegotiatorSymbol in req) {
17
- return req[NegotiatorSymbol];
18
- }
19
- return new negotiator_1.default(req);
20
- }
21
- exports.useRequestNegotiator = useRequestNegotiator;
22
- //# sourceMappingURL=negotiator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"negotiator.js","sourceRoot":"","sources":["../../../src/helpers/request/negotiator.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;AAGH,4DAAoC;AAEpC,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AAErD,SAAgB,oBAAoB,CAAC,GAAoB;IACrD,IAAI,gBAAgB,IAAI,GAAG,EAAE;QACzB,OAAQ,GAAW,CAAC,gBAAgB,CAAC,CAAC;KACzC;IAED,OAAO,IAAI,oBAAU,CAAC,GAAG,CAAC,CAAC;AAC/B,CAAC;AAND,oDAMC"}
@@ -1,6 +0,0 @@
1
- import { Request } from '../../type';
2
- export declare function useRequestParams(req: Request): Record<string, any>;
3
- export declare function useRequestParam(req: Request, key: string): any;
4
- export declare function setRequestParams(req: Request, data: Record<string, any>): void;
5
- export declare function setRequestParam(req: Request, key: string, value: any): void;
6
- //# sourceMappingURL=params.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/params.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAIrC,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAUnE;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAI,GAAG,CAE/D;AAED,wBAAgB,gBAAgB,CAC5B,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAG5B;AAED,wBAAgB,eAAe,CAC3B,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,GAAG,QAMb"}
@@ -1,35 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.setRequestParam = exports.setRequestParams = exports.useRequestParam = exports.useRequestParams = void 0;
10
- const ParamsSymbol = Symbol.for('ReqParams');
11
- function useRequestParams(req) {
12
- if ('params' in req) {
13
- return req.params;
14
- }
15
- if (ParamsSymbol in req) {
16
- return req[ParamsSymbol];
17
- }
18
- return {};
19
- }
20
- exports.useRequestParams = useRequestParams;
21
- function useRequestParam(req, key) {
22
- return useRequestParams(req)[key];
23
- }
24
- exports.useRequestParam = useRequestParam;
25
- function setRequestParams(req, data) {
26
- req[ParamsSymbol] = data;
27
- }
28
- exports.setRequestParams = setRequestParams;
29
- function setRequestParam(req, key, value) {
30
- const params = useRequestParams(req);
31
- params[key] = value;
32
- setRequestParams(req, params);
33
- }
34
- exports.setRequestParam = setRequestParam;
35
- //# sourceMappingURL=params.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"params.js","sourceRoot":"","sources":["../../../src/helpers/request/params.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAIH,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AAE7C,SAAgB,gBAAgB,CAAC,GAAY;IACzC,IAAI,QAAQ,IAAI,GAAG,EAAE;QACjB,OAAQ,GAAW,CAAC,MAAM,CAAC;KAC9B;IAED,IAAI,YAAY,IAAI,GAAG,EAAE;QACrB,OAAQ,GAAW,CAAC,YAAY,CAAC,CAAC;KACrC;IAED,OAAO,EAAE,CAAC;AACd,CAAC;AAVD,4CAUC;AAED,SAAgB,eAAe,CAAC,GAAY,EAAE,GAAW;IACrD,OAAO,gBAAgB,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;AACtC,CAAC;AAFD,0CAEC;AAED,SAAgB,gBAAgB,CAC5B,GAAY,EACZ,IAAyB;IAExB,GAAW,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;AACtC,CAAC;AALD,4CAKC;AAED,SAAgB,eAAe,CAC3B,GAAY,EACZ,GAAW,EACX,KAAU;IAEV,MAAM,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;IACrC,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAEpB,gBAAgB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AAClC,CAAC;AATD,0CASC"}
@@ -1,4 +0,0 @@
1
- /// <reference types="node" />
2
- import { IncomingMessage } from 'http';
3
- export declare function useRequestPath(req: IncomingMessage): string;
4
- //# sourceMappingURL=path.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/path.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAEvC,wBAAgB,cAAc,CAAC,GAAG,EAAE,eAAe,GAAI,MAAM,CAY5D"}
@@ -1,21 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.useRequestPath = void 0;
10
- function useRequestPath(req) {
11
- if ('path' in req) {
12
- return req.path;
13
- }
14
- if (typeof req.url === 'undefined') {
15
- return '/';
16
- }
17
- const parsed = new URL(req.url, 'http://localhost/');
18
- return parsed.pathname;
19
- }
20
- exports.useRequestPath = useRequestPath;
21
- //# sourceMappingURL=path.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"path.js","sourceRoot":"","sources":["../../../src/helpers/request/path.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAIH,SAAgB,cAAc,CAAC,GAAoB;IAC/C,IAAI,MAAM,IAAI,GAAG,EAAE;QACf,OAAQ,GAAW,CAAC,IAAI,CAAC;KAC5B;IAED,IAAI,OAAO,GAAG,CAAC,GAAG,KAAK,WAAW,EAAE;QAChC,OAAO,GAAG,CAAC;KACd;IAED,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,mBAAmB,CAAC,CAAC;IAErD,OAAO,MAAM,CAAC,QAAQ,CAAC;AAC3B,CAAC;AAZD,wCAYC"}
@@ -1,9 +0,0 @@
1
- import { TrustProxyInput } from '../../config';
2
- import { Request } from '../../type';
3
- type RequestProtocolOptions = {
4
- trustProxy?: TrustProxyInput;
5
- default?: string;
6
- };
7
- export declare function getRequestProtocol(req: Request, options?: RequestProtocolOptions): string;
8
- export {};
9
- //# sourceMappingURL=protocol.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/protocol.ts"],"names":[],"mappings":"AAQA,OAAO,EAAgB,eAAe,EAAa,MAAM,cAAc,CAAC;AAGxE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,KAAK,sBAAsB,GAAG;IAC1B,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAA;CACnB,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,sBAAsB,UAyChF"}
@@ -1,50 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.getRequestProtocol = void 0;
10
- const smob_1 = require("smob");
11
- const config_1 = require("../../config");
12
- const utils_1 = require("../../config/utils");
13
- const constants_1 = require("../../constants");
14
- function getRequestProtocol(req, options) {
15
- options = options || {};
16
- let trustProxy;
17
- if (typeof options.trustProxy !== 'undefined') {
18
- trustProxy = (0, utils_1.buildConfigTrustProxyOption)(options.trustProxy);
19
- }
20
- else {
21
- const config = (0, config_1.useConfig)();
22
- trustProxy = config.get('trustProxy');
23
- }
24
- let protocol = options.default;
25
- /* istanbul ignore next */
26
- if ((0, smob_1.hasOwnProperty)(req.socket, 'encrypted') &&
27
- !!req.socket.encrypted) {
28
- protocol = 'https';
29
- }
30
- else if (!protocol) {
31
- protocol = 'http';
32
- }
33
- if (!req.socket.remoteAddress || !trustProxy(req.socket.remoteAddress, 0)) {
34
- return protocol;
35
- }
36
- let header = req.headers[constants_1.HeaderName.X_FORWARDED_PROTO];
37
- /* istanbul ignore next */
38
- if (Array.isArray(header)) {
39
- header = header.pop();
40
- }
41
- if (!header) {
42
- return protocol;
43
- }
44
- const index = header.indexOf(',');
45
- return index !== -1 ?
46
- header.substring(0, index).trim() :
47
- header.trim();
48
- }
49
- exports.getRequestProtocol = getRequestProtocol;
50
- //# sourceMappingURL=protocol.js.map