routup 0.8.1 → 0.8.3

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 +0,0 @@
1
- {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../../src/helpers/request/protocol.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,+BAAsC;AACtC,yCAAwE;AACxE,8CAAiE;AACjE,+CAA6C;AAQ7C,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,GAAwB,OAAO,CAAC,OAAO,CAAC;IACpD,0BAA0B;IAC1B,IACI,IAAA,qBAAc,EAAC,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC;QACvC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,EACxB;QACE,QAAQ,GAAG,OAAO,CAAC;KACtB;SAAM,IAAI,CAAC,QAAQ,EAAE;QAClB,QAAQ,GAAG,MAAM,CAAC;KACrB;IAED,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,aAAa,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC,EAAE;QACvE,OAAO,QAAQ,CAAC;KACnB;IAED,IAAI,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,sBAAU,CAAC,iBAAiB,CAAC,CAAC;IACvD,0BAA0B;IAC1B,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACvB,MAAM,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC;KACzB;IAED,IAAI,CAAC,MAAM,EAAE;QACT,OAAO,QAAQ,CAAC;KACnB;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAElC,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC;QACjB,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QACnC,MAAM,CAAC,IAAI,EAAE,CAAC;AACtB,CAAC;AAzCD,gDAyCC"}
@@ -1,8 +0,0 @@
1
- import { Response } from '../../type';
2
- export type ResponseCacheHeadersOptions = {
3
- maxAge?: number;
4
- modifiedTime?: string | Date;
5
- cacheControls?: string[];
6
- };
7
- export declare function setResponseCacheHeaders(res: Response, options?: ResponseCacheHeadersOptions): void;
8
- //# sourceMappingURL=cache.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/helpers/response/cache.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,MAAM,2BAA2B,GAAG;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;CAC3B,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,2BAA2B,QAkB3F"}
@@ -1,25 +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.setResponseCacheHeaders = void 0;
10
- function setResponseCacheHeaders(res, options) {
11
- options = options || {};
12
- const cacheControls = ['public'].concat(options.cacheControls || []);
13
- if (options.maxAge !== undefined) {
14
- cacheControls.push(`max-age=${+options.maxAge}`, `s-maxage=${+options.maxAge}`);
15
- }
16
- if (options.modifiedTime) {
17
- const modifiedTime = typeof options.modifiedTime === 'string' ?
18
- new Date(options.modifiedTime) :
19
- options.modifiedTime;
20
- res.setHeader('last-modified', modifiedTime.toUTCString());
21
- }
22
- res.setHeader('cache-control', cacheControls.join(', '));
23
- }
24
- exports.setResponseCacheHeaders = setResponseCacheHeaders;
25
- //# sourceMappingURL=cache.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../src/helpers/response/cache.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAUH,SAAgB,uBAAuB,CAAC,GAAa,EAAE,OAAqC;IACxF,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;IAExB,MAAM,aAAa,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC;IAErE,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE;QAC9B,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;KACnF;IAED,IAAI,OAAO,CAAC,YAAY,EAAE;QACtB,MAAM,YAAY,GAAG,OAAO,OAAO,CAAC,YAAY,KAAK,QAAQ,CAAC,CAAC;YAC3D,IAAI,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;YAChC,OAAO,CAAC,YAAY,CAAC;QAEzB,GAAG,CAAC,SAAS,CAAC,eAAe,EAAE,YAAY,CAAC,WAAW,EAAE,CAAC,CAAC;KAC9D;IAED,GAAG,CAAC,SAAS,CAAC,eAAe,EAAE,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAC7D,CAAC;AAlBD,0DAkBC"}
@@ -1,4 +0,0 @@
1
- /// <reference types="node" />
2
- import { ServerResponse } from 'http';
3
- export declare function setResponseHeaderAttachment(res: ServerResponse, filename?: string): void;
4
- //# sourceMappingURL=header-attachment.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"header-attachment.d.ts","sourceRoot":"","sources":["../../../src/helpers/response/header-attachment.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAKtC,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,cAAc,EAAE,QAAQ,CAAC,EAAE,MAAM,QAejF"}
@@ -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.setResponseHeaderAttachment = void 0;
13
- const path_1 = __importDefault(require("path"));
14
- const constants_1 = require("../../constants");
15
- const utils_1 = require("../../utils");
16
- function setResponseHeaderAttachment(res, filename) {
17
- if (typeof filename === 'string') {
18
- const ext = path_1.default.extname(filename);
19
- if (ext) {
20
- const type = (0, utils_1.getMimeType)(ext.substring(1));
21
- if (type) {
22
- res.setHeader(constants_1.HeaderName.CONTENT_TYPE, type);
23
- }
24
- }
25
- }
26
- res.setHeader(constants_1.HeaderName.CONTENT_DISPOSITION, `attachment${filename ? `; filename="${filename}"` : ''}`);
27
- }
28
- exports.setResponseHeaderAttachment = setResponseHeaderAttachment;
29
- //# sourceMappingURL=header-attachment.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"header-attachment.js","sourceRoot":"","sources":["../../../src/helpers/response/header-attachment.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;AAGH,gDAAwB;AACxB,+CAA6C;AAC7C,uCAA0C;AAE1C,SAAgB,2BAA2B,CAAC,GAAmB,EAAE,QAAiB;IAC9E,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;QAC9B,MAAM,GAAG,GAAG,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACnC,IAAI,GAAG,EAAE;YACL,MAAM,IAAI,GAAG,IAAA,mBAAW,EAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3C,IAAI,IAAI,EAAE;gBACN,GAAG,CAAC,SAAS,CAAC,sBAAU,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;aAChD;SACJ;KACJ;IAED,GAAG,CAAC,SAAS,CACT,sBAAU,CAAC,mBAAmB,EAC9B,aAAa,QAAQ,CAAC,CAAC,CAAC,eAAe,QAAQ,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAC5D,CAAC;AACN,CAAC;AAfD,kEAeC"}
@@ -1,3 +0,0 @@
1
- import { Response } from '../../type';
2
- export declare function setResponseHeaderContentType(res: Response, input: string, ifNotExists?: boolean): void;
3
- //# sourceMappingURL=header-content-type.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"header-content-type.d.ts","sourceRoot":"","sources":["../../../src/helpers/response/header-content-type.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,wBAAgB,4BAA4B,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,OAAO,QAY/F"}
@@ -1,25 +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.setResponseHeaderContentType = void 0;
10
- const constants_1 = require("../../constants");
11
- const utils_1 = require("../../utils");
12
- function setResponseHeaderContentType(res, input, ifNotExists) {
13
- if (ifNotExists) {
14
- const header = res.getHeader(constants_1.HeaderName.CONTENT_TYPE);
15
- if (header) {
16
- return;
17
- }
18
- }
19
- const contentType = (0, utils_1.getMimeType)(input);
20
- if (contentType) {
21
- res.setHeader(constants_1.HeaderName.CONTENT_TYPE, contentType);
22
- }
23
- }
24
- exports.setResponseHeaderContentType = setResponseHeaderContentType;
25
- //# sourceMappingURL=header-content-type.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"header-content-type.js","sourceRoot":"","sources":["../../../src/helpers/response/header-content-type.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,+CAA6C;AAE7C,uCAA0C;AAE1C,SAAgB,4BAA4B,CAAC,GAAa,EAAE,KAAa,EAAE,WAAqB;IAC5F,IAAI,WAAW,EAAE;QACb,MAAM,MAAM,GAAG,GAAG,CAAC,SAAS,CAAC,sBAAU,CAAC,YAAY,CAAC,CAAC;QACtD,IAAI,MAAM,EAAE;YACR,OAAO;SACV;KACJ;IAED,MAAM,WAAW,GAAG,IAAA,mBAAW,EAAC,KAAK,CAAC,CAAC;IACvC,IAAI,WAAW,EAAE;QACb,GAAG,CAAC,SAAS,CAAC,sBAAU,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;KACvD;AACL,CAAC;AAZD,oEAYC"}
@@ -1,6 +0,0 @@
1
- /// <reference types="node" />
2
- import { OutgoingHttpHeader } from 'http';
3
- import { Response } from '../../type';
4
- export declare function appendResponseHeader(res: Response, name: string, value: OutgoingHttpHeader): void;
5
- export declare function appendResponseHeaderDirective(res: Response, name: string, value: OutgoingHttpHeader): void;
6
- //# sourceMappingURL=header.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"header.d.ts","sourceRoot":"","sources":["../../../src/helpers/response/header.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,wBAAgB,oBAAoB,CAChC,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,kBAAkB,QAc5B;AAED,wBAAgB,6BAA6B,CACzC,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,kBAAkB,QAiC5B"}
@@ -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.appendResponseHeaderDirective = exports.appendResponseHeader = void 0;
10
- function appendResponseHeader(res, name, value) {
11
- let header = res.getHeader(name);
12
- if (!header) {
13
- res.setHeader(name, value);
14
- return;
15
- }
16
- if (!Array.isArray(header)) {
17
- header = [header.toString()];
18
- }
19
- res.setHeader(name, [...header, value]);
20
- }
21
- exports.appendResponseHeader = appendResponseHeader;
22
- function appendResponseHeaderDirective(res, name, value) {
23
- let header = res.getHeader(name);
24
- if (!header) {
25
- if (Array.isArray(value)) {
26
- res.setHeader(name, value.join('; '));
27
- return;
28
- }
29
- res.setHeader(name, value);
30
- return;
31
- }
32
- if (!Array.isArray(header)) {
33
- if (typeof header === 'string') {
34
- // split header by directive(s)
35
- header = header.split('; ');
36
- }
37
- if (typeof header === 'number') {
38
- header = [header.toString()];
39
- }
40
- }
41
- if (Array.isArray(value)) {
42
- header.push(...value);
43
- }
44
- else {
45
- header.push(`${value}`);
46
- }
47
- // todo: check for unique values
48
- res.setHeader(name, header.join('; '));
49
- }
50
- exports.appendResponseHeaderDirective = appendResponseHeaderDirective;
51
- //# sourceMappingURL=header.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"header.js","sourceRoot":"","sources":["../../../src/helpers/response/header.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAKH,SAAgB,oBAAoB,CAChC,GAAa,EACb,IAAY,EACZ,KAAyB;IAEzB,IAAI,MAAM,GAAG,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACjC,IAAI,CAAC,MAAM,EAAE;QACT,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAE3B,OAAO;KACV;IAED,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACxB,MAAM,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;KAChC;IAED,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,GAAG,MAAM,EAAE,KAAK,CAAsB,CAAC,CAAC;AACjE,CAAC;AAjBD,oDAiBC;AAED,SAAgB,6BAA6B,CACzC,GAAa,EACb,IAAY,EACZ,KAAyB;IAEzB,IAAI,MAAM,GAAG,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACjC,IAAI,CAAC,MAAM,EAAE;QACT,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YACtB,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YACtC,OAAO;SACV;QAED,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC3B,OAAO;KACV;IAED,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACxB,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;YAC5B,+BAA+B;YAC/B,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SAC/B;QAED,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;YAC5B,MAAM,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;SAChC;KACJ;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACtB,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;KACzB;SAAM;QACH,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC;KAC3B;IAED,gCAAgC;IAEhC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAC3C,CAAC;AApCD,sEAoCC"}
@@ -1,12 +0,0 @@
1
- export * from './cache';
2
- export * from './header';
3
- export * from './header-attachment';
4
- export * from './header-content-type';
5
- export * from './send';
6
- export * from './send-accepted';
7
- export * from './send-created';
8
- export * from './send-file';
9
- export * from './send-format';
10
- export * from './send-redirect';
11
- export * from './send-stream';
12
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/response/index.ts"],"names":[],"mappings":"AAOA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,QAAQ,CAAC;AACvB,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC"}
@@ -1,34 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022-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("./header"), exports);
25
- __exportStar(require("./header-attachment"), exports);
26
- __exportStar(require("./header-content-type"), exports);
27
- __exportStar(require("./send"), exports);
28
- __exportStar(require("./send-accepted"), exports);
29
- __exportStar(require("./send-created"), exports);
30
- __exportStar(require("./send-file"), exports);
31
- __exportStar(require("./send-format"), exports);
32
- __exportStar(require("./send-redirect"), exports);
33
- __exportStar(require("./send-stream"), exports);
34
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/response/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,0CAAwB;AACxB,2CAAyB;AACzB,sDAAoC;AACpC,wDAAsC;AACtC,yCAAuB;AACvB,kDAAgC;AAChC,iDAA+B;AAC/B,8CAA4B;AAC5B,gDAA8B;AAC9B,kDAAgC;AAChC,gDAA8B"}
@@ -1,3 +0,0 @@
1
- import { Response } from '../../type';
2
- export declare function sendAccepted(res: Response, chunk?: any): void;
3
- //# sourceMappingURL=send-accepted.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"send-accepted.d.ts","sourceRoot":"","sources":["../../../src/helpers/response/send-accepted.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,wBAAgB,YAAY,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE,GAAG,QAKtD"}
@@ -1,17 +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.sendAccepted = void 0;
10
- const send_1 = require("./send");
11
- function sendAccepted(res, chunk) {
12
- res.statusCode = 202;
13
- res.statusMessage = 'Accepted';
14
- return (0, send_1.send)(res, chunk);
15
- }
16
- exports.sendAccepted = sendAccepted;
17
- //# sourceMappingURL=send-accepted.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"send-accepted.js","sourceRoot":"","sources":["../../../src/helpers/response/send-accepted.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,iCAA8B;AAE9B,SAAgB,YAAY,CAAC,GAAa,EAAE,KAAW;IACnD,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC;IACrB,GAAG,CAAC,aAAa,GAAG,UAAU,CAAC;IAE/B,OAAO,IAAA,WAAI,EAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AAC5B,CAAC;AALD,oCAKC"}
@@ -1,3 +0,0 @@
1
- import { Response } from '../../type';
2
- export declare function sendCreated(res: Response, chunk?: any): void;
3
- //# sourceMappingURL=send-created.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"send-created.d.ts","sourceRoot":"","sources":["../../../src/helpers/response/send-created.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,wBAAgB,WAAW,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE,GAAG,QAKrD"}
@@ -1,17 +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.sendCreated = void 0;
10
- const send_1 = require("./send");
11
- function sendCreated(res, chunk) {
12
- res.statusCode = 201;
13
- res.statusMessage = 'Created';
14
- return (0, send_1.send)(res, chunk);
15
- }
16
- exports.sendCreated = sendCreated;
17
- //# sourceMappingURL=send-created.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"send-created.js","sourceRoot":"","sources":["../../../src/helpers/response/send-created.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,iCAA8B;AAE9B,SAAgB,WAAW,CAAC,GAAa,EAAE,KAAW;IAClD,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC;IACrB,GAAG,CAAC,aAAa,GAAG,SAAS,CAAC;IAE9B,OAAO,IAAA,WAAI,EAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AAC5B,CAAC;AALD,kCAKC"}
@@ -1,5 +0,0 @@
1
- /// <reference types="node" />
2
- import { ServerResponse } from 'http';
3
- import { Next } from '../../type';
4
- export declare function sendFile(res: ServerResponse, filePath: string, fn?: Next): void;
5
- //# sourceMappingURL=send-file.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"send-file.d.ts","sourceRoot":"","sources":["../../../src/helpers/response/send-file.ts"],"names":[],"mappings":";AAQA,OAAO,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAGtC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAIlC,wBAAgB,QAAQ,CAAC,GAAG,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,IAAI,QASxE"}
@@ -1,27 +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.sendFile = void 0;
13
- const fs_1 = require("fs");
14
- const path_1 = __importDefault(require("path"));
15
- const constants_1 = require("../../constants");
16
- const header_attachment_1 = require("./header-attachment");
17
- const send_stream_1 = require("./send-stream");
18
- function sendFile(res, filePath, fn) {
19
- const dispositionHeader = res.getHeader(constants_1.HeaderName.CONTENT_DISPOSITION);
20
- if (!dispositionHeader) {
21
- (0, header_attachment_1.setResponseHeaderAttachment)(res, path_1.default.basename(filePath));
22
- }
23
- const stream = (0, fs_1.createReadStream)(filePath);
24
- (0, send_stream_1.sendStream)(res, stream, fn);
25
- }
26
- exports.sendFile = sendFile;
27
- //# sourceMappingURL=send-file.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"send-file.js","sourceRoot":"","sources":["../../../src/helpers/response/send-file.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;AAEH,2BAAsC;AAEtC,gDAAwB;AACxB,+CAA6C;AAE7C,2DAAkE;AAClE,+CAA2C;AAE3C,SAAgB,QAAQ,CAAC,GAAmB,EAAE,QAAgB,EAAE,EAAS;IACrE,MAAM,iBAAiB,GAAG,GAAG,CAAC,SAAS,CAAC,sBAAU,CAAC,mBAAmB,CAAC,CAAC;IACxE,IAAI,CAAC,iBAAiB,EAAE;QACpB,IAAA,+CAA2B,EAAC,GAAG,EAAE,cAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;KAC7D;IAED,MAAM,MAAM,GAAG,IAAA,qBAAgB,EAAC,QAAQ,CAAC,CAAC;IAE1C,IAAA,wBAAU,EAAC,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;AAChC,CAAC;AATD,4BASC"}
@@ -1,7 +0,0 @@
1
- import { Request } from '../../type';
2
- export type ResponseFormat = {
3
- [key: string]: () => void;
4
- default: () => void;
5
- };
6
- export declare function sendFormat(res: Request, format: ResponseFormat): void;
7
- //# sourceMappingURL=send-format.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"send-format.d.ts","sourceRoot":"","sources":["../../../src/helpers/response/send-format.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,MAAM,MAAM,cAAc,GAAG;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,IAAI,CAAC;IAC1B,OAAO,EAAE,MAAM,IAAI,CAAA;CACtB,CAAC;AAEF,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,QAE9D"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"send-format.js","sourceRoot":"","sources":["../../../src/helpers/response/send-format.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AASH,SAAgB,UAAU,CAAC,GAAY,EAAE,MAAsB;AAE/D,CAAC;AAFD,gCAEC"}
@@ -1,3 +0,0 @@
1
- import { Response } from '../../type';
2
- export declare function sendRedirect(res: Response, location: string, statusCode?: number): void;
3
- //# sourceMappingURL=send-redirect.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"send-redirect.d.ts","sourceRoot":"","sources":["../../../src/helpers/response/send-redirect.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,wBAAgB,YAAY,CAAC,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,SAAM,QAQ7E"}
@@ -1,19 +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.sendRedirect = void 0;
10
- const send_1 = require("./send");
11
- function sendRedirect(res, location, statusCode = 302) {
12
- res.statusCode = statusCode;
13
- res.setHeader('location', location);
14
- const encodedLoc = location.replace(/"/g, '%22');
15
- const html = `<!DOCTYPE html><html><head><meta http-equiv="refresh" content="0; url=${encodedLoc}"></head></html>`;
16
- return (0, send_1.send)(res, html);
17
- }
18
- exports.sendRedirect = sendRedirect;
19
- //# sourceMappingURL=send-redirect.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"send-redirect.js","sourceRoot":"","sources":["../../../src/helpers/response/send-redirect.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,iCAA8B;AAE9B,SAAgB,YAAY,CAAC,GAAa,EAAE,QAAgB,EAAE,UAAU,GAAG,GAAG;IAC1E,GAAG,CAAC,UAAU,GAAG,UAAU,CAAC;IAC5B,GAAG,CAAC,SAAS,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IAEpC,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACjD,MAAM,IAAI,GAAG,yEAAyE,UAAU,kBAAkB,CAAC;IAEnH,OAAO,IAAA,WAAI,EAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AAC3B,CAAC;AARD,oCAQC"}
@@ -1,5 +0,0 @@
1
- /// <reference types="node" />
2
- import { Readable } from 'stream';
3
- import { Next, Response } from '../../type';
4
- export declare function sendStream(res: Response, stream: Readable, fn?: Next): void;
5
- //# sourceMappingURL=send-stream.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"send-stream.d.ts","sourceRoot":"","sources":["../../../src/helpers/response/send-stream.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE5C,wBAAgB,UAAU,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,CAAC,EAAE,IAAI,QAqBpE"}
@@ -1,33 +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.sendStream = void 0;
10
- function sendStream(res, stream, fn) {
11
- stream.on('open', () => {
12
- stream.pipe(res);
13
- });
14
- stream.on('error', (err) => {
15
- if (typeof fn === 'function') {
16
- fn(err);
17
- }
18
- else {
19
- res.statusCode = 500;
20
- res.end();
21
- }
22
- });
23
- stream.on('close', () => {
24
- if (typeof fn === 'function') {
25
- fn();
26
- }
27
- else {
28
- res.end();
29
- }
30
- });
31
- }
32
- exports.sendStream = sendStream;
33
- //# sourceMappingURL=send-stream.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"send-stream.js","sourceRoot":"","sources":["../../../src/helpers/response/send-stream.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAKH,SAAgB,UAAU,CAAC,GAAa,EAAE,MAAgB,EAAE,EAAS;IACjE,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;QACnB,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;QACvB,IAAI,OAAO,EAAE,KAAK,UAAU,EAAE;YAC1B,EAAE,CAAC,GAAG,CAAC,CAAC;SACX;aAAM;YACH,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC;YACrB,GAAG,CAAC,GAAG,EAAE,CAAC;SACb;IACL,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;QACpB,IAAI,OAAO,EAAE,KAAK,UAAU,EAAE;YAC1B,EAAE,EAAE,CAAC;SACR;aAAM;YACH,GAAG,CAAC,GAAG,EAAE,CAAC;SACb;IACL,CAAC,CAAC,CAAC;AACP,CAAC;AArBD,gCAqBC"}
@@ -1,3 +0,0 @@
1
- import { Response } from '../../type';
2
- export declare function send(res: Response, chunk?: any): void;
3
- //# sourceMappingURL=send.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../../../src/helpers/response/send.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAItC,wBAAgB,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE,GAAG,QA+F9C"}
@@ -1,97 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.send = void 0;
4
- /*
5
- * Copyright (c) 2022.
6
- * Author Peter Placzek (tada5hi)
7
- * For the full copyright and license information,
8
- * view the LICENSE file that was distributed with this source code.
9
- */
10
- const config_1 = require("../../config");
11
- const constants_1 = require("../../constants");
12
- const header_1 = require("./header");
13
- const header_content_type_1 = require("./header-content-type");
14
- function send(res, chunk) {
15
- switch (typeof chunk) {
16
- case 'string': {
17
- (0, header_content_type_1.setResponseHeaderContentType)(res, 'html', true);
18
- break;
19
- }
20
- case 'boolean':
21
- case 'number':
22
- case 'object': {
23
- if (chunk === null) {
24
- chunk = '';
25
- }
26
- else if (Buffer.isBuffer(chunk)) {
27
- (0, header_content_type_1.setResponseHeaderContentType)(res, 'bin', true);
28
- }
29
- else {
30
- chunk = JSON.stringify(chunk);
31
- (0, header_content_type_1.setResponseHeaderContentType)(res, 'application/json', true);
32
- }
33
- break;
34
- }
35
- }
36
- let encoding;
37
- if (typeof chunk === 'string') {
38
- res.setHeader(constants_1.HeaderName.CONTENT_ENCODING, 'utf-8');
39
- (0, header_1.appendResponseHeaderDirective)(res, constants_1.HeaderName.CONTENT_TYPE, 'charset=utf-8');
40
- encoding = 'utf-8';
41
- }
42
- // populate Content-Length
43
- let len;
44
- if (chunk !== undefined) {
45
- if (Buffer.isBuffer(chunk)) {
46
- // get length of Buffer
47
- len = chunk.length;
48
- }
49
- else if (chunk.length < 1000) {
50
- // just calculate length when no ETag + small chunk
51
- len = Buffer.byteLength(chunk, encoding);
52
- }
53
- else {
54
- // convert chunk to Buffer and calculate
55
- chunk = Buffer.from(chunk, encoding);
56
- encoding = undefined;
57
- len = chunk.length;
58
- }
59
- res.setHeader(constants_1.HeaderName.CONTENT_LENGTH, `${len}`);
60
- }
61
- const config = (0, config_1.useConfig)();
62
- const etagFn = config.get('etag');
63
- if (typeof len !== 'undefined') {
64
- const chunkHash = etagFn(chunk, encoding, len);
65
- if (typeof chunkHash === 'string') {
66
- res.setHeader('ETag', chunkHash);
67
- if (res.req.headers['if-none-match'] === chunkHash) {
68
- res.statusCode = 304;
69
- }
70
- }
71
- }
72
- // strip irrelevant headers
73
- if (res.statusCode === 204 || res.statusCode === 304) {
74
- res.removeHeader('Content-Type');
75
- res.removeHeader('Content-Length');
76
- res.removeHeader('Transfer-Encoding');
77
- chunk = '';
78
- }
79
- // alter headers for 205
80
- if (res.statusCode === 205) {
81
- res.setHeader('Content-Length', 0);
82
- res.removeHeader('Transfer-Encoding');
83
- chunk = '';
84
- }
85
- if (res.req.method === 'HEAD') {
86
- // skip body for HEAD
87
- res.end();
88
- return;
89
- }
90
- if (typeof encoding !== 'undefined') {
91
- res.end(chunk, encoding);
92
- return;
93
- }
94
- res.end(chunk);
95
- }
96
- exports.send = send;
97
- //# sourceMappingURL=send.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"send.js","sourceRoot":"","sources":["../../../src/helpers/response/send.ts"],"names":[],"mappings":"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"}
@@ -1,2 +0,0 @@
1
- export declare function getMimeType(type: string): string | undefined;
2
- //# sourceMappingURL=mime.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mime.d.ts","sourceRoot":"","sources":["../../src/utils/mime.ts"],"names":[],"mappings":"AASA,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAI,MAAM,GAAG,SAAS,CAM7D"}
@@ -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
- 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.getMimeType = void 0;
13
- const mime_1 = __importDefault(require("mime"));
14
- function getMimeType(type) {
15
- if (type.indexOf('/') !== -1) {
16
- return type;
17
- }
18
- return mime_1.default.getType(type) || undefined;
19
- }
20
- exports.getMimeType = getMimeType;
21
- //# sourceMappingURL=mime.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mime.js","sourceRoot":"","sources":["../../src/utils/mime.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;AAEH,gDAAwB;AAExB,SAAgB,WAAW,CAAC,IAAY;IACpC,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE;QAC1B,OAAO,IAAI,CAAC;KACf;IAED,OAAO,cAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC;AAC3C,CAAC;AAND,kCAMC"}
@@ -1,2 +0,0 @@
1
- export declare function isObject(item: unknown): item is Record<string, any>;
2
- //# sourceMappingURL=object.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../../src/utils/object.ts"],"names":[],"mappings":"AAOA,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAI,IAAI,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAMpE"}