routup 0.5.0 → 0.7.0

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 (144) hide show
  1. package/README.md +7 -6
  2. package/dist/config/accessors.d.ts +15 -0
  3. package/dist/config/accessors.d.ts.map +1 -0
  4. package/dist/config/accessors.js +32 -0
  5. package/dist/config/accessors.js.map +1 -0
  6. package/dist/config/index.d.ts +5 -0
  7. package/dist/config/index.d.ts.map +1 -0
  8. package/dist/{decorators/parameter → config}/index.js +2 -0
  9. package/dist/config/index.js.map +1 -0
  10. package/dist/config/module.d.ts +20 -0
  11. package/dist/config/module.d.ts.map +1 -0
  12. package/dist/config/module.js +65 -0
  13. package/dist/config/module.js.map +1 -0
  14. package/dist/config/singleton.d.ts +4 -0
  15. package/dist/config/singleton.d.ts.map +1 -0
  16. package/dist/config/singleton.js +35 -0
  17. package/dist/config/singleton.js.map +1 -0
  18. package/dist/config/type.d.ts +66 -0
  19. package/dist/config/type.d.ts.map +1 -0
  20. package/dist/{decorators → config}/type.js +0 -0
  21. package/dist/{decorators → config}/type.js.map +1 -1
  22. package/dist/config/utils/defaults.d.ts +3 -0
  23. package/dist/config/utils/defaults.d.ts.map +1 -0
  24. package/dist/config/utils/defaults.js +23 -0
  25. package/dist/config/utils/defaults.js.map +1 -0
  26. package/dist/config/utils/etag.d.ts +3 -0
  27. package/dist/config/utils/etag.d.ts.map +1 -0
  28. package/dist/config/utils/etag.js +43 -0
  29. package/dist/config/utils/etag.js.map +1 -0
  30. package/dist/config/utils/index.d.ts +4 -0
  31. package/dist/config/utils/index.d.ts.map +1 -0
  32. package/dist/{decorators → config}/utils/index.js +3 -1
  33. package/dist/config/utils/index.js.map +1 -0
  34. package/dist/config/utils/trust-proxy.d.ts +3 -0
  35. package/dist/config/utils/trust-proxy.d.ts.map +1 -0
  36. package/dist/config/utils/trust-proxy.js +31 -0
  37. package/dist/config/utils/trust-proxy.js.map +1 -0
  38. package/dist/constants.d.ts +5 -1
  39. package/dist/constants.d.ts.map +1 -1
  40. package/dist/constants.js +4 -0
  41. package/dist/constants.js.map +1 -1
  42. package/dist/handler/type.d.ts +0 -3
  43. package/dist/handler/type.d.ts.map +1 -1
  44. package/dist/handler/utils.d.ts +1 -4
  45. package/dist/handler/utils.d.ts.map +1 -1
  46. package/dist/handler/utils.js +1 -28
  47. package/dist/handler/utils.js.map +1 -1
  48. package/dist/helpers/request/hostname.d.ts +8 -0
  49. package/dist/helpers/request/hostname.d.ts.map +1 -0
  50. package/dist/helpers/request/hostname.js +46 -0
  51. package/dist/helpers/request/hostname.js.map +1 -0
  52. package/dist/helpers/request/index.d.ts +3 -0
  53. package/dist/helpers/request/index.d.ts.map +1 -1
  54. package/dist/helpers/request/index.js +3 -0
  55. package/dist/helpers/request/index.js.map +1 -1
  56. package/dist/helpers/request/ip.d.ts +8 -0
  57. package/dist/helpers/request/ip.d.ts.map +1 -0
  58. package/dist/helpers/request/ip.js +29 -0
  59. package/dist/helpers/request/ip.js.map +1 -0
  60. package/dist/helpers/request/protocol.d.ts +9 -0
  61. package/dist/helpers/request/protocol.d.ts.map +1 -0
  62. package/dist/helpers/request/protocol.js +50 -0
  63. package/dist/helpers/request/protocol.js.map +1 -0
  64. package/dist/helpers/response/send.js +11 -14
  65. package/dist/helpers/response/send.js.map +1 -1
  66. package/dist/index.d.ts +1 -1
  67. package/dist/index.d.ts.map +1 -1
  68. package/dist/index.js +1 -1
  69. package/dist/index.js.map +1 -1
  70. package/dist/layer/module.d.ts.map +1 -1
  71. package/dist/layer/module.js +17 -2
  72. package/dist/layer/module.js.map +1 -1
  73. package/dist/route/module.d.ts.map +1 -1
  74. package/dist/route/module.js +3 -1
  75. package/dist/route/module.js.map +1 -1
  76. package/dist/router/module.d.ts +1 -3
  77. package/dist/router/module.d.ts.map +1 -1
  78. package/dist/router/module.js +27 -65
  79. package/dist/router/module.js.map +1 -1
  80. package/dist/type.d.ts +1 -3
  81. package/dist/type.d.ts.map +1 -1
  82. package/dist/utils/index.d.ts +2 -1
  83. package/dist/utils/index.d.ts.map +1 -1
  84. package/dist/utils/index.js +2 -1
  85. package/dist/utils/index.js.map +1 -1
  86. package/dist/utils/object.d.ts +2 -0
  87. package/dist/utils/object.d.ts.map +1 -0
  88. package/dist/{decorators/method/type.js → utils/object.js} +8 -1
  89. package/dist/utils/object.js.map +1 -0
  90. package/dist/utils/request.d.ts +3 -0
  91. package/dist/utils/request.d.ts.map +1 -0
  92. package/dist/utils/{response.js → request.js} +7 -6
  93. package/dist/utils/request.js.map +1 -0
  94. package/package.json +6 -4
  95. package/dist/decorators/controller/index.d.ts +0 -2
  96. package/dist/decorators/controller/index.d.ts.map +0 -1
  97. package/dist/decorators/controller/index.js +0 -24
  98. package/dist/decorators/controller/index.js.map +0 -1
  99. package/dist/decorators/controller/module.d.ts +0 -4
  100. package/dist/decorators/controller/module.d.ts.map +0 -1
  101. package/dist/decorators/controller/module.js +0 -29
  102. package/dist/decorators/controller/module.js.map +0 -1
  103. package/dist/decorators/index.d.ts +0 -5
  104. package/dist/decorators/index.d.ts.map +0 -1
  105. package/dist/decorators/index.js +0 -27
  106. package/dist/decorators/index.js.map +0 -1
  107. package/dist/decorators/method/arguments.d.ts +0 -4
  108. package/dist/decorators/method/arguments.d.ts.map +0 -1
  109. package/dist/decorators/method/arguments.js +0 -22
  110. package/dist/decorators/method/arguments.js.map +0 -1
  111. package/dist/decorators/method/index.d.ts +0 -4
  112. package/dist/decorators/method/index.d.ts.map +0 -1
  113. package/dist/decorators/method/index.js +0 -26
  114. package/dist/decorators/method/index.js.map +0 -1
  115. package/dist/decorators/method/module.d.ts +0 -8
  116. package/dist/decorators/method/module.d.ts.map +0 -1
  117. package/dist/decorators/method/module.js +0 -46
  118. package/dist/decorators/method/module.js.map +0 -1
  119. package/dist/decorators/method/type.d.ts +0 -7
  120. package/dist/decorators/method/type.d.ts.map +0 -1
  121. package/dist/decorators/method/type.js.map +0 -1
  122. package/dist/decorators/parameter/index.d.ts +0 -3
  123. package/dist/decorators/parameter/index.d.ts.map +0 -1
  124. package/dist/decorators/parameter/index.js.map +0 -1
  125. package/dist/decorators/parameter/module.d.ts +0 -10
  126. package/dist/decorators/parameter/module.d.ts.map +0 -1
  127. package/dist/decorators/parameter/module.js +0 -58
  128. package/dist/decorators/parameter/module.js.map +0 -1
  129. package/dist/decorators/parameter/type.d.ts +0 -8
  130. package/dist/decorators/parameter/type.d.ts.map +0 -1
  131. package/dist/decorators/parameter/type.js +0 -9
  132. package/dist/decorators/parameter/type.js.map +0 -1
  133. package/dist/decorators/type.d.ts +0 -14
  134. package/dist/decorators/type.d.ts.map +0 -1
  135. package/dist/decorators/utils/index.d.ts +0 -2
  136. package/dist/decorators/utils/index.d.ts.map +0 -1
  137. package/dist/decorators/utils/index.js.map +0 -1
  138. package/dist/decorators/utils/meta.d.ts +0 -3
  139. package/dist/decorators/utils/meta.d.ts.map +0 -1
  140. package/dist/decorators/utils/meta.js +0 -24
  141. package/dist/decorators/utils/meta.js.map +0 -1
  142. package/dist/utils/response.d.ts +0 -3
  143. package/dist/utils/response.d.ts.map +0 -1
  144. package/dist/utils/response.js.map +0 -1
package/README.md CHANGED
@@ -62,12 +62,13 @@ router.listen(3000);
62
62
  According to the fact that routup is a minimalistic framework, it depends on plugins to cover some
63
63
  typically http framework functions, which are not integrated in the main package.
64
64
 
65
- | Name | Description |
66
- |----------------------------------------------------------|------------------------------------------------------------------------|
67
- | [body](https://www.npmjs.com/package/@routup/body) | Read and parse the request body. |
68
- | [cookie](https://www.npmjs.com/package/@routup/cookie) | Read and parse request cookies and serialize cookies for the response. |
69
- | [query](https://www.npmjs.com/package/@routup/query) | Read and parse the query string of the request url. |
70
- | [swagger](https://www.npmjs.com/package/@routup/swagger) | Serve generated docs from URL or based on a JSON file. |
65
+ | Name | Description |
66
+ |-----------------------------------------------------------------|--------------------------------------------------------------------------|
67
+ | [body](https://www.npmjs.com/package/@routup/body) | Read and parse the request body. |
68
+ | [cookie](https://www.npmjs.com/package/@routup/cookie) | Read and parse request cookies and serialize cookies for the response. |
69
+ | [decorators](https://www.npmjs.com/package/@routup/decorators) | Create request handlers with class-, method- & parameter-decorators. |
70
+ | [query](https://www.npmjs.com/package/@routup/query) | Read and parse the query string of the request url. |
71
+ | [swagger](https://www.npmjs.com/package/@routup/swagger) | Serve generated docs from URL or based on a JSON file. |
71
72
 
72
73
  ## License
73
74
 
@@ -0,0 +1,15 @@
1
+ import { ConfigOptions, ConfigOptionsInput } from './type';
2
+ /**
3
+ * Fast set config option accessor.
4
+ *
5
+ * @param key
6
+ * @param value
7
+ */
8
+ export declare function setConfigOption<K extends keyof ConfigOptionsInput>(key: K, value: ConfigOptionsInput[K]): void;
9
+ /**
10
+ * Fast get config option accessor.
11
+ *
12
+ * @param key
13
+ */
14
+ export declare function getConfigOption<K extends keyof ConfigOptions>(key: K): ConfigOptions[K];
15
+ //# sourceMappingURL=accessors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accessors.d.ts","sourceRoot":"","sources":["../../src/config/accessors.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAE3D;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,kBAAkB,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,QAIvG;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,aAAa,EAAE,GAAG,EAAE,CAAC,GAAI,aAAa,CAAC,CAAC,CAAC,CAIxF"}
@@ -0,0 +1,32 @@
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.getConfigOption = exports.setConfigOption = void 0;
10
+ const singleton_1 = require("./singleton");
11
+ /**
12
+ * Fast set config option accessor.
13
+ *
14
+ * @param key
15
+ * @param value
16
+ */
17
+ function setConfigOption(key, value) {
18
+ const config = (0, singleton_1.useConfig)();
19
+ config.set(key, value);
20
+ }
21
+ exports.setConfigOption = setConfigOption;
22
+ /**
23
+ * Fast get config option accessor.
24
+ *
25
+ * @param key
26
+ */
27
+ function getConfigOption(key) {
28
+ const config = (0, singleton_1.useConfig)();
29
+ return config.get(key);
30
+ }
31
+ exports.getConfigOption = getConfigOption;
32
+ //# sourceMappingURL=accessors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accessors.js","sourceRoot":"","sources":["../../src/config/accessors.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,2CAAwC;AAGxC;;;;;GAKG;AACH,SAAgB,eAAe,CAAqC,GAAM,EAAE,KAA4B;IACpG,MAAM,MAAM,GAAG,IAAA,qBAAS,GAAE,CAAC;IAE3B,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AAC3B,CAAC;AAJD,0CAIC;AAED;;;;GAIG;AACH,SAAgB,eAAe,CAAgC,GAAM;IACjE,MAAM,MAAM,GAAG,IAAA,qBAAS,GAAE,CAAC;IAE3B,OAAO,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC;AAJD,0CAIC"}
@@ -0,0 +1,5 @@
1
+ export * from './accessors';
2
+ export * from './module';
3
+ export * from './singleton';
4
+ export * from './type';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAOA,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC"}
@@ -20,6 +20,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
20
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
+ __exportStar(require("./accessors"), exports);
23
24
  __exportStar(require("./module"), exports);
25
+ __exportStar(require("./singleton"), exports);
24
26
  __exportStar(require("./type"), exports);
25
27
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,8CAA4B;AAC5B,2CAAyB;AACzB,8CAA4B;AAC5B,yCAAuB"}
@@ -0,0 +1,20 @@
1
+ import { ObjectLiteral } from '../type';
2
+ import { ConfigContext, ConfigOptionsTransformer } from './type';
3
+ export declare class Config<O extends ObjectLiteral, I extends {
4
+ [T in keyof O]?: any;
5
+ } = O> {
6
+ protected options: Partial<O>;
7
+ protected defaults: O;
8
+ protected transformer: ConfigOptionsTransformer<O>;
9
+ constructor(context: ConfigContext<O>);
10
+ set<K extends keyof O>(key: K, value: I[K]): this;
11
+ has(key: keyof O): boolean;
12
+ reset(): this;
13
+ reset(key: keyof O): this;
14
+ reset(keys: (keyof O)[]): this;
15
+ get<K extends keyof O>(key: K): O[K];
16
+ getRaw<K extends keyof O>(key: K): O[K] | undefined;
17
+ setDefault<K extends keyof O>(key: K, value: I[K]): this;
18
+ getDefault<K extends keyof O>(key: K): O[K];
19
+ }
20
+ //# sourceMappingURL=module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/config/module.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,QAAQ,CAAC;AAEjE,qBAAa,MAAM,CACf,CAAC,SAAS,aAAa,EACvB,CAAC,SAAS;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG;CAAE,GAAG,CAAC;IAEtC,SAAS,CAAC,OAAO,EAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAE/B,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC;IAEtB,SAAS,CAAC,WAAW,EAAE,wBAAwB,CAAC,CAAC,CAAC,CAAC;gBAIvC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC;IAQrC,GAAG,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,GAAI,IAAI;IAMlD,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,GAAI,OAAO;IAM3B,KAAK,IAAK,IAAI;IAEd,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,GAAI,IAAI;IAE1B,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,GAAI,IAAI;IAyB/B,GAAG,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,GAAI,CAAC,CAAC,CAAC,CAAC;IAQrC,MAAM,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,GAAI,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS;IAUpD,UAAU,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,GAAI,IAAI;IAMzD,UAAU,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,GAAI,CAAC,CAAC,CAAC,CAAC;CAG/C"}
@@ -0,0 +1,65 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.Config = void 0;
10
+ const smob_1 = require("smob");
11
+ class Config {
12
+ // -------------------------------------------------
13
+ constructor(context) {
14
+ this.options = context.options || {};
15
+ this.defaults = context.defaults;
16
+ this.transformer = context.transform;
17
+ }
18
+ // -------------------------------------------------
19
+ set(key, value) {
20
+ this.options[key] = this.transformer(key, value);
21
+ return this;
22
+ }
23
+ has(key) {
24
+ return (0, smob_1.hasOwnProperty)(this.options, key);
25
+ }
26
+ reset(key) {
27
+ if (typeof key === 'undefined') {
28
+ this.options = {};
29
+ return this;
30
+ }
31
+ if (Array.isArray(key)) {
32
+ for (let i = 0; i < key.length; i++) {
33
+ this.reset(key[i]);
34
+ }
35
+ return this;
36
+ }
37
+ if ((0, smob_1.hasOwnProperty)(this.options, key)) {
38
+ delete this.options[key];
39
+ }
40
+ return this;
41
+ }
42
+ // ----------------------------------------------
43
+ get(key) {
44
+ if ((0, smob_1.hasOwnProperty)(this.options, key)) {
45
+ return this.options[key];
46
+ }
47
+ return this.defaults[key];
48
+ }
49
+ getRaw(key) {
50
+ if ((0, smob_1.hasOwnProperty)(this.options, key)) {
51
+ return this.options[key];
52
+ }
53
+ return undefined;
54
+ }
55
+ // -------------------------------------------------
56
+ setDefault(key, value) {
57
+ this.defaults[key] = this.transformer(key, value);
58
+ return this;
59
+ }
60
+ getDefault(key) {
61
+ return this.defaults[key];
62
+ }
63
+ }
64
+ exports.Config = Config;
65
+ //# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/config/module.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,+BAAsC;AAItC,MAAa,MAAM;IAUf,oDAAoD;IAEpD,YAAY,OAAyB;QACjC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;QACrC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC;IACzC,CAAC;IAED,oDAAoD;IAEpD,GAAG,CAAoB,GAAM,E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AS,CAAC;IACrB,CAAC;IAED,oDAAoD;IAEpD,UAAU,CAAoB,GAAM,EAAE,KAAW;QAC7C,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,KAAK,CAAS,CAAC;QAE1D,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,UAAU,CAAoB,GAAM;QAChC,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;CACJ;AAxFD,wBAwFC"}
@@ -0,0 +1,4 @@
1
+ import { Config } from './module';
2
+ import { ConfigOptions, ConfigOptionsInput } from './type';
3
+ export declare function useConfig(): Config<ConfigOptions, ConfigOptionsInput>;
4
+ //# sourceMappingURL=singleton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"singleton.d.ts","sourceRoot":"","sources":["../../src/config/singleton.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAK3D,wBAAgB,SAAS,IAAK,MAAM,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAsBtE"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2021.
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.useConfig = void 0;
10
+ const module_1 = require("./module");
11
+ const utils_1 = require("./utils");
12
+ let instance;
13
+ function useConfig() {
14
+ if (typeof instance !== 'undefined') {
15
+ return instance;
16
+ }
17
+ instance = new module_1.Config({
18
+ defaults: (0, utils_1.buildConfigDefaultOptions)(),
19
+ transform: (key, value) => {
20
+ switch (key) {
21
+ /* istanbul ignore next */
22
+ case 'etag':
23
+ return (0, utils_1.buildConfigEtagOption)(value);
24
+ /* istanbul ignore next */
25
+ case 'trustProxy':
26
+ return (0, utils_1.buildConfigTrustProxyOption)(value);
27
+ default:
28
+ return value;
29
+ }
30
+ },
31
+ });
32
+ return instance;
33
+ }
34
+ exports.useConfig = useConfig;
35
+ //# sourceMappingURL=singleton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"singleton.js","sourceRoot":"","sources":["../../src/config/singleton.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,qCAAkC;AAElC,mCAAwG;AAExG,IAAI,QAAgE,CAAC;AAErE,SAAgB,SAAS;IACrB,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;QACjC,OAAO,QAAQ,CAAC;KACnB;IAED,QAAQ,GAAG,IAAI,eAAM,CAAoC;QACrD,QAAQ,EAAE,IAAA,iCAAyB,GAAE;QACrC,SAAS,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;YACtB,QAAQ,GAAG,EAAE;gBACT,0BAA0B;gBAC1B,KAAK,MAAM;oBACP,OAAO,IAAA,6BAAqB,EAAC,KAAK,CAAC,CAAC;gBACxC,0BAA0B;gBAC1B,KAAK,YAAY;oBACb,OAAO,IAAA,mCAA2B,EAAC,KAAK,CAAC,CAAC;gBAC9C;oBACI,OAAO,KAAK,CAAC;aACpB;QACL,CAAC;KACJ,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;AACpB,CAAC;AAtBD,8BAsBC"}
@@ -0,0 +1,66 @@
1
+ /// <reference types="node" />
2
+ import { Options as EtagBaseOptions } from 'etag';
3
+ import { ObjectLiteral } from '../type';
4
+ export type EtagOptions = EtagBaseOptions & {
5
+ /**
6
+ * Threshold of bytes from which an etag is generated.
7
+ *
8
+ * default: undefined
9
+ */
10
+ threshold?: number;
11
+ };
12
+ export type EtagFn = (body: any, encoding?: BufferEncoding, size?: number) => string | undefined;
13
+ export type EtagInput = boolean | EtagOptions | EtagFn;
14
+ export type TrustProxyFn = (address: string, hop: number) => boolean;
15
+ export type TrustProxyInput = boolean | number | string | string[] | TrustProxyFn;
16
+ export type ConfigOptions = {
17
+ /**
18
+ * default: process.NODE_ENV
19
+ */
20
+ env: string;
21
+ /**
22
+ * default: () => false
23
+ */
24
+ trustProxy: TrustProxyFn;
25
+ /**
26
+ * default: 2
27
+ */
28
+ subdomainOffset: number;
29
+ /**
30
+ * default: () => true
31
+ */
32
+ etag: EtagFn;
33
+ /**
34
+ * Default: X-Forwarded-For
35
+ */
36
+ proxyIpHeader: string;
37
+ /**
38
+ * default: 0
39
+ */
40
+ proxyIpMax?: number;
41
+ /**
42
+ * default: true
43
+ */
44
+ caseSensitive: boolean;
45
+ /**
46
+ * default: request-id
47
+ */
48
+ requestIdHeader: string;
49
+ };
50
+ export type ConfigOptionsInput = {
51
+ /**
52
+ * default: true
53
+ */
54
+ etag?: EtagInput;
55
+ /**
56
+ * default: false
57
+ */
58
+ trustProxy?: TrustProxyInput;
59
+ } & Partial<Omit<ConfigOptions, 'etag' | 'trustProxy'>>;
60
+ export type ConfigOptionsTransformer<T extends ObjectLiteral, K extends keyof T = keyof T> = (key: K, value: any) => T[K];
61
+ export type ConfigContext<T extends ObjectLiteral> = {
62
+ defaults: T;
63
+ options?: Partial<T>;
64
+ transform: ConfigOptionsTransformer<T>;
65
+ };
66
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/config/type.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,MAAM,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,MAAM,MAAM,WAAW,GAAG,eAAe,GAAG;IACxC;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACrB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,CAAC,EAAE,cAAc,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,MAAM,G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AwB,CAAC,CAAC,CAAC,CAAA;CACzC,CAAC"}
File without changes
@@ -1 +1 @@
1
- {"version":3,"file":"type.js","sourceRoot":"","sources":["../../src/decorators/type.ts"],"names":[],"mappings":";AAAA;;;;;GAKG"}
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../../src/config/type.ts"],"names":[],"mappings":";AAAA;;;;;GAKG"}
@@ -0,0 +1,3 @@
1
+ import { ConfigOptions } from '../type';
2
+ export declare function buildConfigDefaultOptions(): ConfigOptions;
3
+ //# sourceMappingURL=defaults.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../../src/config/utils/defaults.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGxC,wBAAgB,yBAAyB,IAAK,aAAa,CAU1D"}
@@ -0,0 +1,23 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.buildConfigDefaultOptions = void 0;
10
+ const etag_1 = require("./etag");
11
+ function buildConfigDefaultOptions() {
12
+ return {
13
+ env: process.env.NODE_ENV || 'development',
14
+ trustProxy: () => false,
15
+ subdomainOffset: 2,
16
+ etag: (0, etag_1.buildConfigEtagOption)(),
17
+ proxyIpHeader: 'X-Forwarded-For',
18
+ caseSensitive: true,
19
+ requestIdHeader: 'request-id',
20
+ };
21
+ }
22
+ exports.buildConfigDefaultOptions = buildConfigDefaultOptions;
23
+ //# sourceMappingURL=defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../../src/config/utils/defaults.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,iCAA+C;AAE/C,SAAgB,yBAAyB;IACrC,OAAO;QACH,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,aAAa;QAC1C,UAAU,EAAE,GAAG,EAAE,CAAC,KAAK;QACvB,eAAe,EAAE,CAAC;QAClB,IAAI,EAAE,IAAA,4BAAqB,GAAE;QAC7B,aAAa,EAAE,iBAAiB;QAChC,aAAa,EAAE,IAAI;QACnB,eAAe,EAAE,YAAY;KAChC,CAAC;AACN,CAAC;AAVD,8DAUC"}
@@ -0,0 +1,3 @@
1
+ import { EtagFn, EtagOptions } from '../type';
2
+ export declare function buildConfigEtagOption(input?: boolean | EtagOptions | EtagFn): EtagFn;
3
+ //# sourceMappingURL=etag.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"etag.d.ts","sourceRoot":"","sources":["../../../src/config/utils/etag.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE9C,wBAAgB,qBAAqB,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,WAAW,GAAG,MAAM,GAAI,MAAM,CAkCrF"}
@@ -0,0 +1,43 @@
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.buildConfigEtagOption = void 0;
13
+ const etag_1 = __importDefault(require("etag"));
14
+ const smob_1 = require("smob");
15
+ function buildConfigEtagOption(input) {
16
+ if (typeof input === 'function') {
17
+ return input;
18
+ }
19
+ input = input !== null && input !== void 0 ? input : true;
20
+ if (input === false) {
21
+ return () => undefined;
22
+ }
23
+ let options = {
24
+ weak: true,
25
+ };
26
+ if ((0, smob_1.isObject)(input)) {
27
+ options = (0, smob_1.merge)(input, options);
28
+ }
29
+ return (body, encoding, size) => {
30
+ const buff = Buffer.isBuffer(body) ?
31
+ body :
32
+ Buffer.from(body, encoding);
33
+ if (typeof options.threshold !== 'undefined') {
34
+ size = size !== null && size !== void 0 ? size : Buffer.byteLength(buff);
35
+ if (size <= options.threshold) {
36
+ return undefined;
37
+ }
38
+ }
39
+ return (0, etag_1.default)(buff, options);
40
+ };
41
+ }
42
+ exports.buildConfigEtagOption = buildConfigEtagOption;
43
+ //# sourceMappingURL=etag.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"etag.js","sourceRoot":"","sources":["../../../src/config/utils/etag.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;AAEH,gDAAwB;AACxB,+BAAuC;AAGvC,SAAgB,qBAAqB,CAAC,KAAsC;IACxE,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;QAC7B,OAAO,KAAK,CAAC;KAChB;IAED,KAAK,GAAG,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,IAAI,CAAC;IAEtB,IAAI,KAAK,KAAK,KAAK,EAAE;QACjB,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC;KAC1B;IAED,IAAI,OAAO,GAAiB;QACxB,IAAI,EAAE,IAAI;KACb,CAAC;IAEF,IAAI,IAAA,eAAQ,EAAC,KAAK,CAAC,EAAE;QACjB,OAAO,GAAG,IAAA,YAAK,EAAC,KAAK,EAAE,OAAO,CAAC,CAAC;KACnC;IAED,OAAO,CAAC,IAAS,EAAE,QAAyB,EAAE,IAAa,EAAE,EAAE;QAC3D,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;YAChC,IAAI,CAAC,CAAC;YACN,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAEhC,IAAI,OAAO,OAAO,CAAC,SAAS,KAAK,WAAW,EAAE;YAC1C,IAAI,GAAG,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YAEvC,IAAI,IAAI,IAAI,OAAO,CAAC,SAAS,EAAE;gBAC3B,OAAO,SAAS,CAAC;aACpB;SACJ;QAED,OAAO,IAAA,cAAI,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC/B,CAAC,CAAC;AACN,CAAC;AAlCD,sDAkCC"}
@@ -0,0 +1,4 @@
1
+ export * from './defaults';
2
+ export * from './etag';
3
+ export * from './trust-proxy';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/config/utils/index.ts"],"names":[],"mappings":"AAOA,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC"}
@@ -20,5 +20,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
20
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- __exportStar(require("./meta"), exports);
23
+ __exportStar(require("./defaults"), exports);
24
+ __exportStar(require("./etag"), exports);
25
+ __exportStar(require("./trust-proxy"), exports);
24
26
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/config/utils/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,6CAA2B;AAC3B,yCAAuB;AACvB,gDAA8B"}
@@ -0,0 +1,3 @@
1
+ import { TrustProxyFn } from '../type';
2
+ export declare function buildConfigTrustProxyOption(input?: boolean | number | string | string[] | TrustProxyFn): TrustProxyFn;
3
+ //# sourceMappingURL=trust-proxy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trust-proxy.d.ts","sourceRoot":"","sources":["../../../src/config/utils/trust-proxy.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,wBAAgB,2BAA2B,CACvC,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,YAAY,GAC3D,YAAY,CAmBf"}
@@ -0,0 +1,31 @@
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.buildConfigTrustProxyOption = void 0;
13
+ const proxy_addr_1 = __importDefault(require("proxy-addr"));
14
+ function buildConfigTrustProxyOption(input) {
15
+ if (typeof input === 'function') {
16
+ return input;
17
+ }
18
+ if (input === true) {
19
+ return () => true;
20
+ }
21
+ if (typeof input === 'number') {
22
+ return (address, hop) => hop < input;
23
+ }
24
+ if (typeof input === 'string') {
25
+ input = input.split(',')
26
+ .map((value) => value.trim());
27
+ }
28
+ return proxy_addr_1.default.compile(input || []);
29
+ }
30
+ exports.buildConfigTrustProxyOption = buildConfigTrustProxyOption;
31
+ //# sourceMappingURL=trust-proxy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trust-proxy.js","sourceRoot":"","sources":["../../../src/config/utils/trust-proxy.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;AAEH,4DAAmC;AAGnC,SAAgB,2BAA2B,CACvC,KAA2D;IAE3D,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;QAC7B,OAAO,KAAK,CAAC;KAChB;IAED,IAAI,KAAK,KAAK,IAAI,EAAE;QAChB,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC;KACrB;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC3B,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAI,KAAgB,CAAC;KACpD;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC3B,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;aACnB,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;KACrC;IAED,OAAO,oBAAS,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;AAC1C,CAAC;AArBD,kEAqBC"}
@@ -19,8 +19,12 @@ export declare enum HeaderName {
19
19
  CONTENT_LENGTH = "content-length",
20
20
  CONTENT_TYPE = "content-type",
21
21
  COOKIE = "cookie",
22
+ HOST = "host",
22
23
  LAST_MODIFIED = "last-modified",
23
24
  LOCATION = "location",
24
- SET_COOKIE = "set-cookie"
25
+ SET_COOKIE = "set-cookie",
26
+ X_FORWARDED_HOST = "x-forwarded-host",
27
+ X_FORWARDED_FOR = "x-forwarded-for",
28
+ X_FORWARDED_PROTO = "x-forwarded-proto"
25
29
  }
26
30
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAOA,oBAAY,MAAM;IACd,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,IAAI,SAAS;CAChB;AAED,oBAAY,UAAU;IAClB,MAAM,WAAW;IACjB,cAAc,mBAAmB;IACjC,eAAe,oBAAoB;IACnC,eAAe,oBAAoB;IACnC,KAAK,UAAU;IACf,aAAa,kBAAkB;IAC/B,mBAAmB,wBAAwB;IAC3C,gBAAgB,qBAAqB;IACrC,cAAc,mBAAmB;IACjC,YAAY,iBAAiB;IAC7B,MAAM,WAAW;IACjB,aAAa,kBAAkB;IAC/B,QAAQ,aAAa;IACrB,UAAU,eAAe;CAC5B"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAOA,oBAAY,MAAM;IACd,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,IAAI,SAAS;CAChB;AAED,oBAAY,UAAU;IAClB,MAAM,WAAW;IACjB,cAAc,mBAAmB;IACjC,eAAe,oBAAoB;IACnC,eAAe,oBAAoB;IACnC,KAAK,UAAU;IACf,aAAa,kBAAkB;IAC/B,mBAAmB,wBAAwB;IAC3C,gBAAgB,qBAAqB;IACrC,cAAc,mBAAmB;IACjC,YAAY,iBAAiB;IAC7B,MAAM,WAAW;IACjB,IAAI,SAAS;IACb,aAAa,kBAAkB;IAC/B,QAAQ,aAAa;IACrB,UAAU,eAAe;IACzB,gBAAgB,qBAAqB;IACrC,eAAe,oBAAoB;IACnC,iBAAiB,sBAAsB;CAC1C"}
package/dist/constants.js CHANGED
@@ -30,8 +30,12 @@ var HeaderName;
30
30
  HeaderName["CONTENT_LENGTH"] = "content-length";
31
31
  HeaderName["CONTENT_TYPE"] = "content-type";
32
32
  HeaderName["COOKIE"] = "cookie";
33
+ HeaderName["HOST"] = "host";
33
34
  HeaderName["LAST_MODIFIED"] = "last-modified";
34
35
  HeaderName["LOCATION"] = "location";
35
36
  HeaderName["SET_COOKIE"] = "set-cookie";
37
+ HeaderName["X_FORWARDED_HOST"] = "x-forwarded-host";
38
+ HeaderName["X_FORWARDED_FOR"] = "x-forwarded-for";
39
+ HeaderName["X_FORWARDED_PROTO"] = "x-forwarded-proto";
36
40
  })(HeaderName = exports.HeaderName || (exports.HeaderName = {}));
37
41
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,IAAY,MAQX;AARD,WAAY,MAAM;IACd,qBAAW,CAAA;IACX,uBAAa,CAAA;IACb,qBAAW,CAAA;IACX,yBAAe,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UAAU,GAAV,kBAAU,KAAV,kBAAU,QAmBrB"}
@@ -1,7 +1,4 @@
1
1
  import { Next, Request, Response } from '../type';
2
2
  export type Handler = (req: Request, res: Response, next: Next) => unknown;
3
3
  export type ErrorHandler = (err: Error, req: Request, res: Response, next: Next) => unknown;
4
- export interface HandlerInterface {
5
- run(request: Request, response: Response, next: Next): Promise<void> | void;
6
- }
7
4
  //# sourceMappingURL=type.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/handler/type.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAElD,MAAM,MAAM,OAAO,GAAG,CAClB,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,IAAI,KACT,OAAO,CAAC;AAEb,MAAM,MAAM,YAAY,GAAG,CACvB,GAAG,EAAE,KAAK,EACV,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,IAAI,KACT,OAAO,CAAC;AAEb,MAAM,WAAW,gBAAgB;IAC7B,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAC/E"}
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/handler/type.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAElD,MAAM,MAAM,OAAO,GAAG,CAClB,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,IAAI,KACT,OAAO,CAAC;AAEb,MAAM,MAAM,YAAY,GAAG,CACvB,GAAG,EAAE,KAAK,EACV,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,IAAI,KACT,OAAO,CAAC"}
@@ -1,6 +1,3 @@
1
- import { ClassType, Next, Response } from '../type';
2
- import { Handler, HandlerInterface } from './type';
3
- export declare function isHandlerClassInstance(input: unknown): input is HandlerInterface;
4
- export declare function createHandlerForClassType(item: ClassType): Handler;
1
+ import { Next, Response } from '../type';
5
2
  export declare function processHandlerExecutionOutput(res: Response, next: Next, output?: unknown): void;
6
3
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/handler/utils.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEpD,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAEnD,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAI,KAAK,IAAI,gBAAgB,CAGjF;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,SAAS,GAAI,OAAO,CAkBnE;AAED,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,OAAO,QAiBxF"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/handler/utils.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGzC,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,OAAO,QAiBxF"}
@@ -6,36 +6,9 @@
6
6
  * view the LICENSE file that was distributed with this source code.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.processHandlerExecutionOutput = exports.createHandlerForClassType = exports.isHandlerClassInstance = void 0;
10
- const smob_1 = require("smob");
9
+ exports.processHandlerExecutionOutput = void 0;
11
10
  const helpers_1 = require("../helpers");
12
11
  const utils_1 = require("../utils");
13
- function isHandlerClassInstance(input) {
14
- return (0, smob_1.isObject)(input) &&
15
- typeof input.run === 'function';
16
- }
17
- exports.isHandlerClassInstance = isHandlerClassInstance;
18
- function createHandlerForClassType(item) {
19
- return (req, res, next) => {
20
- try {
21
- const middle = new item();
22
- if (isHandlerClassInstance(middle)) {
23
- middle.run(req, res, next);
24
- }
25
- else {
26
- /* istanbul ignore next */
27
- middle(req, res, next);
28
- }
29
- }
30
- catch (e) {
31
- /* istanbul ignore next */
32
- if (e instanceof Error) {
33
- next(e);
34
- }
35
- }
36
- };
37
- }
38
- exports.createHandlerForClassType = createHandlerForClassType;
39
12
  function processHandlerExecutionOutput(res, next, output) {
40
13
  if ((0, utils_1.isPromise)(output)) {
41
14
  output
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/handler/utils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,+BAAgC;AAChC,wCAAkC;AAElC,oCAAqC;AAGrC,SAAgB,sBAAsB,CAAC,KAAc;IACjD,OAAO,IAAA,eAAQ,EAAC,KAAK,CAAC;QAClB,OAAQ,KAAa,CAAC,GAAG,KAAK,UAAU,CAAC;AACjD,CAAC;AAHD,wDAGC;AAED,SAAgB,yBAAyB,CAAC,IAAe;IACrD,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QACtB,IAAI;YACA,MAAM,MAAM,GAAG,IAAK,IAAkB,EAAE,CAAC;YAEzC,IAAI,sBAAsB,CAAC,MAAM,CAAC,EAAE;gBAChC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;aAC9B;iBAAM;gBACH,0BAA0B;gBAC1B,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;aAC1B;SACJ;QAAC,OAAO,CAAC,EAAE;YACR,0BAA0B;YAC1B,IAAI,CAAC,YAAY,KAAK,EAAE;gBACpB,IAAI,CAAC,CAAC,CAAC,CAAC;aACX;SACJ;IACL,CAAC,CAAC;AACN,CAAC;AAlBD,8DAkBC;AAED,SAAgB,6BAA6B,CAAC,GAAa,EAAE,IAAU,EAAE,MAAgB;IACrF,IAAI,IAAA,iBAAS,EAAC,MAAM,CAAC,EAAE;QACnB,MAAM;aACD,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;YACR,IAAI,OAAO,CAAC,KAAK,WAAW,EAAE;gBAC1B,IAAA,cAAI,EAAC,GAAG,EAAE,CAAC,CAAC,CAAC;aAChB;YAED,OAAO,CAAC,CAAC;QACb,CAAC,CAAC;aACD,KAAK,CAAC,IAAI,CAAC,CAAC;QACjB,OAAO;KACV;IAED,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QAC/B,IAAA,cAAI,EAAC,GAAG,EAAE,MAAM,CAAC,CAAC;KACrB;AACL,CAAC;AAjBD,sEAiBC"}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/handler/utils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,wCAAkC;AAElC,oCAAqC;AAErC,SAAgB,6BAA6B,CAAC,GAAa,EAAE,IAAU,EAAE,MAAgB;IACrF,IAAI,IAAA,iBAAS,EAAC,MAAM,CAAC,EAAE;QACnB,MAAM;aACD,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;YACR,IAAI,OAAO,CAAC,KAAK,WAAW,EAAE;gBAC1B,IAAA,cAAI,EAAC,GAAG,EAAE,CAAC,CAAC,CAAC;aAChB;YAED,OAAO,CAAC,CAAC;QACb,CAAC,CAAC;aACD,KAAK,CAAC,IAAI,CAAC,CAAC;QACjB,OAAO;KACV;IAED,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QAC/B,IAAA,cAAI,EAAC,GAAG,EAAE,MAAM,CAAC,CAAC;KACrB;AACL,CAAC;AAjBD,sEAiBC"}
@@ -0,0 +1,8 @@
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
@@ -0,0 +1 @@
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"}