@duplojs/http 0.6.1 → 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 (187) hide show
  1. package/dist/client/getBody.cjs +1 -1
  2. package/dist/client/getBody.mjs +1 -1
  3. package/dist/client/hooks.d.ts +1 -25
  4. package/dist/client/httpClient.d.ts +29 -25
  5. package/dist/client/promiseRequest.cjs +3 -0
  6. package/dist/client/promiseRequest.d.ts +31 -39
  7. package/dist/client/promiseRequest.mjs +4 -1
  8. package/dist/client/types/clientResponse.d.ts +6 -6
  9. package/dist/client/types/hooks.d.ts +25 -0
  10. package/dist/client/types/index.cjs +2 -0
  11. package/dist/client/types/index.d.ts +2 -0
  12. package/dist/client/types/index.mjs +2 -0
  13. package/dist/client/types/promiseRequestParams.cjs +2 -0
  14. package/dist/client/types/promiseRequestParams.d.ts +9 -0
  15. package/dist/client/types/promiseRequestParams.mjs +1 -0
  16. package/dist/client/types/serverRoute.d.ts +19 -1
  17. package/dist/client/unexpectedResponseError.d.ts +1 -2
  18. package/dist/core/builders/preflight/route.cjs +1 -0
  19. package/dist/core/builders/preflight/route.d.ts +4 -2
  20. package/dist/core/builders/preflight/route.mjs +1 -0
  21. package/dist/core/builders/route/builder.cjs +1 -0
  22. package/dist/core/builders/route/builder.d.ts +4 -2
  23. package/dist/core/builders/route/builder.mjs +1 -0
  24. package/dist/core/clean/constraint.cjs +24 -0
  25. package/dist/core/clean/constraint.d.ts +8 -0
  26. package/dist/core/clean/constraint.mjs +22 -0
  27. package/dist/core/clean/constraintsSet.cjs +27 -0
  28. package/dist/core/clean/constraintsSet.d.ts +8 -0
  29. package/dist/core/clean/constraintsSet.mjs +25 -0
  30. package/dist/core/clean/entity.cjs +33 -0
  31. package/dist/core/clean/entity.d.ts +20 -0
  32. package/dist/core/clean/entity.mjs +31 -0
  33. package/dist/core/clean/index.cjs +8 -0
  34. package/dist/core/clean/index.d.ts +5 -0
  35. package/dist/core/clean/index.mjs +5 -0
  36. package/dist/core/clean/newType.cjs +15 -0
  37. package/dist/core/clean/newType.d.ts +8 -0
  38. package/dist/core/clean/newType.mjs +13 -0
  39. package/dist/core/clean/primitive.cjs +12 -0
  40. package/dist/core/clean/primitive.d.ts +8 -0
  41. package/dist/core/clean/primitive.mjs +10 -0
  42. package/dist/core/defaultHooks/index.cjs +50 -0
  43. package/dist/core/defaultHooks/index.d.ts +5 -0
  44. package/dist/core/defaultHooks/index.mjs +48 -0
  45. package/dist/{interfaces/node/error → core/errors}/bodyParseWrongChunkReceived.cjs +6 -4
  46. package/dist/core/errors/bodyParseWrongChunkReceived.d.ts +9 -0
  47. package/dist/core/errors/bodyParseWrongChunkReceived.mjs +14 -0
  48. package/dist/{interfaces/node/error → core/errors}/bodySizeExceedsLimitError.cjs +2 -2
  49. package/dist/{interfaces/node/error → core/errors}/bodySizeExceedsLimitError.d.ts +2 -2
  50. package/dist/{interfaces/node/error → core/errors}/bodySizeExceedsLimitError.mjs +2 -2
  51. package/dist/{interfaces/node/error → core/errors}/index.cjs +6 -4
  52. package/dist/{interfaces/node/error → core/errors}/index.d.ts +3 -2
  53. package/dist/{interfaces/node/error → core/errors}/index.mjs +3 -2
  54. package/dist/core/errors/parseJsonError.cjs +16 -0
  55. package/dist/core/errors/parseJsonError.d.ts +9 -0
  56. package/dist/core/errors/parseJsonError.mjs +14 -0
  57. package/dist/core/errors/wrongContentTypeError.cjs +16 -0
  58. package/dist/core/errors/wrongContentTypeError.d.ts +9 -0
  59. package/dist/core/errors/wrongContentTypeError.mjs +14 -0
  60. package/dist/core/functionsBuilders/route/create.d.ts +2 -2
  61. package/dist/core/functionsBuilders/route/default.cjs +0 -11
  62. package/dist/core/functionsBuilders/route/default.mjs +0 -11
  63. package/dist/core/functionsBuilders/route/hook.d.ts +2 -2
  64. package/dist/core/functionsBuilders/steps/create.d.ts +2 -2
  65. package/dist/core/functionsBuilders/steps/defaults/cutStep.cjs +15 -18
  66. package/dist/core/functionsBuilders/steps/defaults/cutStep.mjs +15 -18
  67. package/dist/core/functionsBuilders/steps/defaults/extractStep.cjs +43 -19
  68. package/dist/core/functionsBuilders/steps/defaults/extractStep.d.ts +2 -1
  69. package/dist/core/functionsBuilders/steps/defaults/extractStep.mjs +44 -20
  70. package/dist/core/functionsBuilders/steps/defaults/handlerStep.cjs +14 -8
  71. package/dist/core/functionsBuilders/steps/defaults/handlerStep.mjs +14 -8
  72. package/dist/core/hub/defaultBodyController.cjs +8 -0
  73. package/dist/core/hub/defaultBodyController.d.ts +1 -0
  74. package/dist/core/hub/defaultBodyController.mjs +6 -0
  75. package/dist/core/hub/hooks.cjs +3 -1
  76. package/dist/core/hub/hooks.d.ts +2 -3
  77. package/dist/core/hub/hooks.mjs +3 -1
  78. package/dist/core/hub/index.cjs +101 -127
  79. package/dist/core/hub/index.d.ts +33 -34
  80. package/dist/core/hub/index.mjs +100 -128
  81. package/dist/core/implementHttpServer.cjs +5 -5
  82. package/dist/core/implementHttpServer.d.ts +2 -1
  83. package/dist/core/implementHttpServer.mjs +5 -5
  84. package/dist/core/index.cjs +35 -10
  85. package/dist/core/index.d.ts +3 -0
  86. package/dist/core/index.mjs +14 -2
  87. package/dist/core/request/bodyController/base.cjs +36 -0
  88. package/dist/core/request/bodyController/base.d.ts +28 -0
  89. package/dist/core/request/bodyController/base.mjs +34 -0
  90. package/dist/core/request/bodyController/formData.cjs +28 -0
  91. package/dist/core/request/bodyController/formData.d.ts +22 -0
  92. package/dist/core/request/bodyController/formData.mjs +25 -0
  93. package/dist/core/request/bodyController/index.cjs +13 -0
  94. package/dist/core/request/bodyController/index.d.ts +3 -0
  95. package/dist/core/request/bodyController/index.mjs +3 -0
  96. package/dist/core/request/bodyController/text.cjs +14 -0
  97. package/dist/core/request/bodyController/text.d.ts +10 -0
  98. package/dist/core/request/bodyController/text.mjs +11 -0
  99. package/dist/core/{request.cjs → request/index.cjs} +21 -3
  100. package/dist/core/{request.d.ts → request/index.d.ts} +10 -3
  101. package/dist/core/request/index.mjs +50 -0
  102. package/dist/core/response/contract.d.ts +1 -1
  103. package/dist/core/route/hooks.d.ts +0 -2
  104. package/dist/core/route/index.d.ts +2 -1
  105. package/dist/core/router/index.cjs +27 -8
  106. package/dist/core/router/index.d.ts +2 -1
  107. package/dist/core/router/index.mjs +28 -10
  108. package/dist/core/router/notFoundBodyReaderImplementationError.cjs +16 -0
  109. package/dist/core/router/notFoundBodyReaderImplementationError.d.ts +11 -0
  110. package/dist/core/router/notFoundBodyReaderImplementationError.mjs +14 -0
  111. package/dist/core/router/types/buildedRouter.d.ts +3 -3
  112. package/dist/core/steps/extract.d.ts +3 -1
  113. package/dist/core/steps/types/steps.d.ts +1 -3
  114. package/dist/core/types/hosts.cjs +2 -0
  115. package/dist/core/types/hosts.d.ts +4 -0
  116. package/dist/core/types/hosts.mjs +1 -0
  117. package/dist/core/types/httpServerParams.cjs +2 -0
  118. package/dist/core/types/httpServerParams.d.ts +11 -0
  119. package/dist/core/types/httpServerParams.mjs +1 -0
  120. package/dist/core/types/index.cjs +2 -0
  121. package/dist/core/types/index.d.ts +2 -0
  122. package/dist/core/types/index.mjs +2 -0
  123. package/dist/interfaces/bun/types/request.cjs +1 -1
  124. package/dist/interfaces/bun/types/request.mjs +1 -1
  125. package/dist/interfaces/node/bodyReaders/formData/error.cjs +14 -0
  126. package/dist/interfaces/node/bodyReaders/formData/error.d.ts +8 -0
  127. package/dist/interfaces/node/bodyReaders/formData/error.mjs +12 -0
  128. package/dist/interfaces/node/bodyReaders/formData/index.cjs +94 -0
  129. package/dist/interfaces/node/bodyReaders/formData/index.d.ts +4 -0
  130. package/dist/interfaces/node/bodyReaders/formData/index.mjs +90 -0
  131. package/dist/interfaces/node/bodyReaders/formData/readRequestFormData.cjs +175 -0
  132. package/dist/interfaces/node/bodyReaders/formData/readRequestFormData.d.ts +21 -0
  133. package/dist/interfaces/node/bodyReaders/formData/readRequestFormData.mjs +173 -0
  134. package/dist/interfaces/node/bodyReaders/index.cjs +9 -0
  135. package/dist/interfaces/node/bodyReaders/index.d.ts +2 -0
  136. package/dist/interfaces/node/bodyReaders/index.mjs +2 -0
  137. package/dist/interfaces/node/bodyReaders/text/index.cjs +41 -0
  138. package/dist/interfaces/node/bodyReaders/text/index.d.ts +3 -0
  139. package/dist/interfaces/node/bodyReaders/text/index.mjs +38 -0
  140. package/dist/interfaces/node/bodyReaders/text/readRequestText.cjs +37 -0
  141. package/dist/interfaces/node/bodyReaders/text/readRequestText.d.ts +6 -0
  142. package/dist/interfaces/node/bodyReaders/text/readRequestText.mjs +35 -0
  143. package/dist/interfaces/node/createHttpServer.cjs +13 -5
  144. package/dist/interfaces/node/createHttpServer.d.ts +13 -12
  145. package/dist/interfaces/node/createHttpServer.mjs +13 -5
  146. package/dist/interfaces/node/hooks/index.cjs +47 -0
  147. package/dist/interfaces/node/hooks/index.d.ts +5 -0
  148. package/dist/interfaces/node/hooks/index.mjs +45 -0
  149. package/dist/interfaces/node/index.cjs +13 -9
  150. package/dist/interfaces/node/index.d.ts +1 -1
  151. package/dist/interfaces/node/index.mjs +7 -5
  152. package/dist/interfaces/node/types/index.cjs +0 -1
  153. package/dist/interfaces/node/types/index.d.ts +0 -1
  154. package/dist/interfaces/node/types/index.mjs +0 -1
  155. package/dist/interfaces/node/types/request.cjs +1 -1
  156. package/dist/interfaces/node/types/request.mjs +1 -1
  157. package/dist/plugins/codeGenerator/index.cjs +2 -0
  158. package/dist/plugins/codeGenerator/index.mjs +1 -1
  159. package/dist/plugins/codeGenerator/plugin.cjs +8 -4
  160. package/dist/plugins/codeGenerator/plugin.mjs +9 -5
  161. package/dist/plugins/codeGenerator/routeToDataParser.cjs +24 -1
  162. package/dist/plugins/codeGenerator/routeToDataParser.d.ts +34 -0
  163. package/dist/plugins/codeGenerator/routeToDataParser.mjs +24 -3
  164. package/dist/plugins/codeGenerator/typescriptTransfomer.cjs +9 -0
  165. package/dist/plugins/codeGenerator/typescriptTransfomer.d.ts +1 -0
  166. package/dist/plugins/codeGenerator/typescriptTransfomer.mjs +7 -0
  167. package/dist/plugins/openApiGenerator/makeOpenApiRoute.d.ts +3 -0
  168. package/dist/plugins/openApiGenerator/plugin.cjs +3 -3
  169. package/dist/plugins/openApiGenerator/plugin.mjs +4 -4
  170. package/dist/plugins/openApiGenerator/routeToOpenApi.cjs +16 -1
  171. package/dist/plugins/openApiGenerator/routeToOpenApi.d.ts +10 -1
  172. package/dist/plugins/openApiGenerator/routeToOpenApi.mjs +16 -1
  173. package/dist/plugins/openApiGenerator/types/entrypoint.d.ts +6 -1
  174. package/dist/plugins/openApiGenerator/types/openApiMethod.d.ts +1 -1
  175. package/package.json +5 -6
  176. package/dist/core/request.mjs +0 -32
  177. package/dist/interfaces/node/error/bodyParseUnknownError.cjs +0 -16
  178. package/dist/interfaces/node/error/bodyParseUnknownError.d.ts +0 -9
  179. package/dist/interfaces/node/error/bodyParseUnknownError.mjs +0 -14
  180. package/dist/interfaces/node/error/bodyParseWrongChunkReceived.d.ts +0 -8
  181. package/dist/interfaces/node/error/bodyParseWrongChunkReceived.mjs +0 -12
  182. package/dist/interfaces/node/hooks.cjs +0 -126
  183. package/dist/interfaces/node/hooks.d.ts +0 -8
  184. package/dist/interfaces/node/hooks.mjs +0 -124
  185. package/dist/interfaces/node/types/host.d.ts +0 -4
  186. /package/dist/{interfaces/node/types/host.cjs → client/types/hooks.cjs} +0 -0
  187. /package/dist/{interfaces/node/types/host.mjs → client/types/hooks.mjs} +0 -0
@@ -1,146 +1,119 @@
1
1
  'use strict';
2
2
 
3
3
  var kind = require('../kind.cjs');
4
- var index = require('../route/index.cjs');
4
+ var index$1 = require('../route/index.cjs');
5
5
  var utils = require('@duplojs/utils');
6
6
  require('../steps/index.cjs');
7
- var request = require('../request.cjs');
7
+ var index = require('../request/index.cjs');
8
8
  var defaultNotfoundHandler = require('./defaultNotfoundHandler.cjs');
9
9
  var defaultExtractContract = require('./defaultExtractContract.cjs');
10
+ var defaultBodyController = require('./defaultBodyController.cjs');
10
11
  var hooks = require('./hooks.cjs');
11
12
  var handler = require('../steps/handler.cjs');
12
13
 
13
14
  const hubKind = kind.createCoreLibKind("hub");
15
+ class Hub extends utils.kindHeritage("hub", kind.createCoreLibKind("hub")) {
16
+ config;
17
+ plugins = [];
18
+ hooksRouteLifeCycle = [];
19
+ hooksHubLifeCycle = [];
20
+ routes = new Set();
21
+ routeFunctionBuilders = [];
22
+ stepFunctionBuilders = [];
23
+ bodyReaderImplementations = [];
24
+ classRequest = index.Request;
25
+ notfoundHandler = defaultNotfoundHandler.defaultNotfoundHandler;
26
+ defaultExtractContract = defaultExtractContract.defaultExtractContract;
27
+ defaultBodyController = defaultBodyController.defaultBodyController;
28
+ constructor(config) {
29
+ super({});
30
+ this.config = config;
31
+ }
32
+ register(routes) {
33
+ utils.pipe(routes, utils.P.when(index$1.routeKind.has, utils.A.coalescing), utils.P.when(utils.isType("iterable"), utils.A.from), utils.P.otherwise(utils.O.values), utils.A.map((route) => this.routes.add(route)));
34
+ return this;
35
+ }
36
+ addRouteFunctionBuilder(functionBuilder) {
37
+ this.routeFunctionBuilders.push(...utils.A.coalescing(functionBuilder));
38
+ return this;
39
+ }
40
+ addStepFunctionBuilder(functionBuilder) {
41
+ this.stepFunctionBuilders.push(...utils.A.coalescing(functionBuilder));
42
+ return this;
43
+ }
44
+ addRouteHooks(hook) {
45
+ this.hooksRouteLifeCycle.push(...utils.A.coalescing(hook));
46
+ return this;
47
+ }
48
+ addHubHooks(hook) {
49
+ this.hooksHubLifeCycle.push(...utils.A.coalescing(hook));
50
+ return this;
51
+ }
52
+ addBodyReaderImplementation(bodyReaderImplementation) {
53
+ this.bodyReaderImplementations.push(...utils.A.coalescing(bodyReaderImplementation));
54
+ return this;
55
+ }
56
+ plug(plugin) {
57
+ const pluginResult = typeof plugin === "function"
58
+ ? plugin(this)
59
+ : plugin;
60
+ if (pluginResult.bodyReaderImplementations) {
61
+ this.addBodyReaderImplementation(pluginResult.bodyReaderImplementations);
62
+ }
63
+ if (pluginResult.hooksHubLifeCycle) {
64
+ this.addHubHooks(pluginResult.hooksHubLifeCycle);
65
+ }
66
+ if (pluginResult.hooksRouteLifeCycle) {
67
+ this.addRouteHooks(pluginResult.hooksRouteLifeCycle);
68
+ }
69
+ if (pluginResult.routeFunctionBuilders) {
70
+ this.addRouteFunctionBuilder(pluginResult.routeFunctionBuilders);
71
+ }
72
+ if (pluginResult.routes) {
73
+ this.register(pluginResult.routes);
74
+ }
75
+ if (pluginResult.stepFunctionBuilders) {
76
+ this.addStepFunctionBuilder(pluginResult.stepFunctionBuilders);
77
+ }
78
+ this.plugins.push(pluginResult);
79
+ return this;
80
+ }
81
+ setNotfoundHandler(responseContract, theFunction) {
82
+ this.notfoundHandler = handler.createHandlerStep({
83
+ responseContract,
84
+ theFunction: (floor, params) => theFunction(params),
85
+ metadata: [],
86
+ });
87
+ return this;
88
+ }
89
+ setDefaultExtractContract(responseContract) {
90
+ this.defaultExtractContract = responseContract;
91
+ return this;
92
+ }
93
+ aggregatesHooksHubLifeCycle(hookName) {
94
+ return utils.A.flatMap(this.hooksHubLifeCycle, (hooks) => hooks[hookName] ?? []);
95
+ }
96
+ setDefaultBodyController(bodyController) {
97
+ this.defaultBodyController = bodyController;
98
+ return this;
99
+ }
100
+ aggregatesHooksRouteLifeCycle(hookName) {
101
+ return utils.A.flatMap(this.hooksRouteLifeCycle, (hooks) => hooks[hookName] ?? []);
102
+ }
103
+ /**
104
+ * @internal
105
+ */
106
+ static "new"(config) {
107
+ return new Hub(config);
108
+ }
109
+ }
14
110
  function createHub(config) {
15
- return {
16
- ...hubKind.addTo({}),
17
- config,
18
- plugins: [],
19
- hooksHubLifeCycle: [],
20
- hooksRouteLifeCycle: [],
21
- routeFunctionBuilders: [],
22
- routes: [],
23
- stepFunctionBuilders: [],
24
- notfoundHandler: defaultNotfoundHandler.defaultNotfoundHandler,
25
- defaultExtractContract: defaultExtractContract.defaultExtractContract,
26
- classRequest: request.Request,
27
- addHubHooks(hook) {
28
- return {
29
- ...this,
30
- hooksHubLifeCycle: utils.A.concat(this.hooksHubLifeCycle, utils.A.coalescing(hook)),
31
- };
32
- },
33
- addRouteFunctionBuilder(functionBuilder) {
34
- return {
35
- ...this,
36
- routeFunctionBuilders: utils.A.concat(this.routeFunctionBuilders, utils.A.coalescing(functionBuilder)),
37
- };
38
- },
39
- addRouteHooks(hook) {
40
- return {
41
- ...this,
42
- hooksRouteLifeCycle: utils.A.concat(this.hooksRouteLifeCycle, utils.A.coalescing(hook)),
43
- };
44
- },
45
- addStepFunctionBuilder(hook) {
46
- return {
47
- ...this,
48
- stepFunctionBuilders: utils.A.concat(this.stepFunctionBuilders, utils.A.coalescing(hook)),
49
- };
50
- },
51
- plug(plugin) {
52
- return {
53
- ...this,
54
- plugins: utils.A.push(this.plugins, typeof plugin === "function"
55
- ? plugin(this)
56
- : plugin),
57
- };
58
- },
59
- register(route) {
60
- return {
61
- ...this,
62
- routes: utils.A.concat(this.routes, utils.pipe(route, utils.P.when(index.routeKind.has, utils.A.coalescing), utils.P.when(utils.isType("iterable"), utils.A.from), utils.P.otherwise(utils.O.values), utils.A.filter((route) => !utils.A.includes(this.routes, route)))),
63
- };
64
- },
65
- setDefaultExtractContract(defaultExtractContract) {
66
- return {
67
- ...this,
68
- defaultExtractContract,
69
- };
70
- },
71
- setNotfoundHandler(responseContract, theFunction) {
72
- return {
73
- ...this,
74
- notfoundHandler: handler.createHandlerStep({
75
- responseContract,
76
- theFunction: (floor, params) => theFunction(params),
77
- metadata: [],
78
- }),
79
- };
80
- },
81
- aggregates() {
82
- return utils.A.reduce(this.plugins, utils.A.reduceFrom({
83
- hooksRouteLifeCycle: this.hooksRouteLifeCycle,
84
- routeFunctionBuilders: this.routeFunctionBuilders,
85
- stepFunctionBuilders: this.stepFunctionBuilders,
86
- routes: this.routes,
87
- hooksHubLifeCycle: this.hooksHubLifeCycle,
88
- }), ({ lastValue, element: plugin, next, }) => next({
89
- hooksRouteLifeCycle: plugin.hooksRouteLifeCycle
90
- ? utils.A.concat(lastValue.hooksRouteLifeCycle, plugin.hooksRouteLifeCycle)
91
- : lastValue.hooksRouteLifeCycle,
92
- routeFunctionBuilders: plugin.routeFunctionBuilders
93
- ? utils.A.concat(lastValue.routeFunctionBuilders, plugin.routeFunctionBuilders)
94
- : lastValue.routeFunctionBuilders,
95
- stepFunctionBuilders: plugin.stepFunctionBuilders
96
- ? utils.A.concat(lastValue.stepFunctionBuilders, plugin.stepFunctionBuilders)
97
- : lastValue.stepFunctionBuilders,
98
- routes: plugin.routes
99
- ? utils.A.concat(lastValue.routes, plugin.routes)
100
- : lastValue.routes,
101
- hooksHubLifeCycle: plugin.hooksHubLifeCycle
102
- ? utils.A.concat(lastValue.hooksHubLifeCycle, plugin.hooksHubLifeCycle)
103
- : lastValue.hooksHubLifeCycle,
104
- }));
105
- },
106
- aggregatesRoutes() {
107
- return utils.A.reduce(this.plugins, utils.A.reduceFrom(this.routes), ({ lastValue, element: { routes }, next, }) => routes
108
- ? next(utils.A.concat(lastValue, routes))
109
- : next(lastValue));
110
- },
111
- aggregatesRouteFunctionBuilders() {
112
- return utils.A.reduce(this.plugins, utils.A.reduceFrom(this.routeFunctionBuilders), ({ lastValue, element: { routeFunctionBuilders }, next, }) => routeFunctionBuilders
113
- ? next(utils.A.concat(lastValue, routeFunctionBuilders))
114
- : next(lastValue));
115
- },
116
- aggregatesStepFunctionBuilders() {
117
- return utils.A.reduce(this.plugins, utils.A.reduceFrom(this.stepFunctionBuilders), ({ lastValue, element: { stepFunctionBuilders }, next, }) => stepFunctionBuilders
118
- ? next(utils.A.concat(lastValue, stepFunctionBuilders))
119
- : next(lastValue));
120
- },
121
- aggregatesHooksHubLifeCycle(hookName) {
122
- const hooks = utils.A.flatMap(this.hooksHubLifeCycle, (hooks) => hooks[hookName] ?? []);
123
- return utils.A.reduce(this.plugins, utils.A.reduceFrom(hooks), ({ lastValue, element: { hooksHubLifeCycle }, next, }) => {
124
- if (!hooksHubLifeCycle) {
125
- return next(lastValue);
126
- }
127
- return next(utils.A.concat(lastValue, utils.A.flatMap(hooksHubLifeCycle, (hooks) => hooks[hookName] ?? [])));
128
- });
129
- },
130
- aggregatesHooksRouteLifeCycle(hookName) {
131
- const hooks = utils.A.flatMap(this.hooksRouteLifeCycle, (hooks) => hooks[hookName] ?? []);
132
- return utils.A.reduce(this.plugins, utils.A.reduceFrom(hooks), ({ lastValue, element: { hooksRouteLifeCycle }, next, }) => {
133
- if (!hooksRouteLifeCycle) {
134
- return next(lastValue);
135
- }
136
- return next(utils.A.concat(lastValue, utils.A.flatMap(hooksRouteLifeCycle, (hooks) => hooks[hookName] ?? [])));
137
- });
138
- },
139
- };
111
+ return Hub.new(config);
140
112
  }
141
113
 
142
114
  exports.defaultNotfoundHandler = defaultNotfoundHandler.defaultNotfoundHandler;
143
115
  exports.defaultExtractContract = defaultExtractContract.defaultExtractContract;
116
+ exports.defaultBodyController = defaultBodyController.defaultBodyController;
144
117
  exports.createHookHubLifeCycle = hooks.createHookHubLifeCycle;
145
118
  exports.hookServerExitKind = hooks.hookServerExitKind;
146
119
  exports.hookServerNextKind = hooks.hookServerNextKind;
@@ -149,5 +122,6 @@ exports.launchHookServer = hooks.launchHookServer;
149
122
  exports.launchHookServerError = hooks.launchHookServerError;
150
123
  exports.serverErrorExitHookFunction = hooks.serverErrorExitHookFunction;
151
124
  exports.serverErrorNextHookFunction = hooks.serverErrorNextHookFunction;
125
+ exports.Hub = Hub;
152
126
  exports.createHub = createHub;
153
127
  exports.hubKind = hubKind;
@@ -1,8 +1,8 @@
1
1
  import { type Route, type HookRouteLifeCycle } from "../route";
2
- import { type Kind, type MaybeArray, type MaybePromise, type DP } from "@duplojs/utils";
2
+ import { type MaybeArray, type MaybePromise, type DP } from "@duplojs/utils";
3
3
  import { type HookHubLifeCycle } from "./hooks";
4
4
  import { type HandlerStepFunctionParams, type HandlerStep } from "../steps";
5
- import { Request } from "../request";
5
+ import { type BodyController, type BodyReaderImplementation, Request } from "../request";
6
6
  import { type ClientErrorResponseCode, type ResponseContract } from "../response";
7
7
  import { type Environment } from "../types";
8
8
  import { type createStepFunctionBuilder } from "../functionsBuilders/steps";
@@ -10,6 +10,7 @@ import { type createRouteFunctionBuilder } from "../functionsBuilders/route";
10
10
  export * from "./hooks";
11
11
  export * from "./defaultNotfoundHandler";
12
12
  export * from "./defaultExtractContract";
13
+ export * from "./defaultBodyController";
13
14
  export declare const hubKind: import("@duplojs/utils").KindHandler<import("@duplojs/utils").KindDefinition<"@DuplojsHttpCore/hub", unknown>>;
14
15
  export interface HubConfig {
15
16
  readonly environment: Environment;
@@ -21,38 +22,36 @@ export interface HubPlugin {
21
22
  readonly routes?: readonly Route[];
22
23
  readonly routeFunctionBuilders?: readonly ReturnType<typeof createRouteFunctionBuilder>[];
23
24
  readonly stepFunctionBuilders?: readonly ReturnType<typeof createStepFunctionBuilder>[];
25
+ readonly bodyReaderImplementations?: readonly BodyReaderImplementation[];
24
26
  }
25
- export interface HubAggregates {
26
- readonly hooksRouteLifeCycle: readonly HookRouteLifeCycle[];
27
- readonly hooksHubLifeCycle: readonly HookHubLifeCycle[];
28
- readonly routes: readonly Route[];
29
- readonly routeFunctionBuilders: readonly ReturnType<typeof createRouteFunctionBuilder>[];
30
- readonly stepFunctionBuilders: readonly ReturnType<typeof createStepFunctionBuilder>[];
31
- }
32
- export interface Hub<GenericConfig extends HubConfig = HubConfig> extends Kind<typeof hubKind.definition> {
33
- readonly config: GenericConfig;
34
- readonly plugins: readonly HubPlugin[];
35
- readonly hooksRouteLifeCycle: readonly HookRouteLifeCycle[];
36
- readonly hooksHubLifeCycle: readonly HookHubLifeCycle[];
37
- readonly routes: readonly Route[];
38
- readonly routeFunctionBuilders: readonly ReturnType<typeof createRouteFunctionBuilder>[];
39
- readonly stepFunctionBuilders: readonly ReturnType<typeof createStepFunctionBuilder>[];
40
- readonly classRequest: typeof Request;
41
- readonly notfoundHandler: HandlerStep;
42
- readonly defaultExtractContract: ResponseContract.Contract<ClientErrorResponseCode, string, DP.DataParserEmpty>;
43
- register(routes: Route | Iterable<Route> | Record<string, Route>): Hub<GenericConfig>;
44
- addRouteFunctionBuilder(functionBuilder: MaybeArray<ReturnType<typeof createRouteFunctionBuilder>>): Hub<GenericConfig>;
45
- addStepFunctionBuilder(functionBuilder: MaybeArray<ReturnType<typeof createStepFunctionBuilder>>): Hub<GenericConfig>;
46
- addRouteHooks(hook: MaybeArray<HookRouteLifeCycle>): Hub<GenericConfig>;
47
- addHubHooks(hook: MaybeArray<HookHubLifeCycle>): Hub<GenericConfig>;
48
- plug(plugin: HubPlugin | ((self: this) => HubPlugin)): Hub<GenericConfig>;
49
- setNotfoundHandler<GenericResponseContract extends ResponseContract.Contract, GenericResponse extends ResponseContract.Convert<GenericResponseContract>>(responseContract: GenericResponseContract, theFunction: (param: HandlerStepFunctionParams<Request, GenericResponse>) => MaybePromise<GenericResponse>): Hub<GenericConfig>;
50
- setDefaultExtractContract(responseContract: this["defaultExtractContract"]): Hub<GenericConfig>;
51
- aggregates(): HubAggregates;
52
- aggregatesRoutes(): readonly Route[];
53
- aggregatesRouteFunctionBuilders(): readonly ReturnType<typeof createRouteFunctionBuilder>[];
54
- aggregatesStepFunctionBuilders(): readonly ReturnType<typeof createStepFunctionBuilder>[];
55
- aggregatesHooksHubLifeCycle<GenericHookName extends keyof HookHubLifeCycle>(hookName: GenericHookName): readonly Exclude<HookHubLifeCycle[GenericHookName], undefined>[];
56
- aggregatesHooksRouteLifeCycle<GenericHookName extends keyof HookRouteLifeCycle>(hookName: GenericHookName): readonly Exclude<HookRouteLifeCycle[GenericHookName], undefined>[];
27
+ declare const Hub_base: new (params?: {
28
+ "@DuplojsHttpCore/hub"?: unknown;
29
+ } | undefined) => import("@duplojs/utils").Kind<import("@duplojs/utils").KindDefinition<"@DuplojsHttpCore/hub", unknown>, unknown> & import("@duplojs/utils").Kind<import("@duplojs/utils").KindDefinition<"hub", unknown>, unknown>;
30
+ export declare class Hub<GenericConfig extends HubConfig = HubConfig> extends Hub_base {
31
+ config: GenericConfig;
32
+ plugins: HubPlugin[];
33
+ hooksRouteLifeCycle: HookRouteLifeCycle[];
34
+ hooksHubLifeCycle: HookHubLifeCycle[];
35
+ routes: Set<Route<import("../route").RouteDefinition>>;
36
+ routeFunctionBuilders: ReturnType<typeof createRouteFunctionBuilder>[];
37
+ stepFunctionBuilders: ReturnType<typeof createStepFunctionBuilder>[];
38
+ bodyReaderImplementations: BodyReaderImplementation[];
39
+ classRequest: typeof Request;
40
+ notfoundHandler: HandlerStep;
41
+ defaultExtractContract: ResponseContract.Contract<ClientErrorResponseCode, string, DP.DataParserEmpty>;
42
+ defaultBodyController: BodyController;
43
+ private constructor();
44
+ register(routes: Route | Iterable<Route> | Record<string, Route>): this;
45
+ addRouteFunctionBuilder(functionBuilder: MaybeArray<ReturnType<typeof createRouteFunctionBuilder>>): this;
46
+ addStepFunctionBuilder(functionBuilder: MaybeArray<ReturnType<typeof createStepFunctionBuilder>>): this;
47
+ addRouteHooks(hook: MaybeArray<HookRouteLifeCycle>): this;
48
+ addHubHooks(hook: MaybeArray<HookHubLifeCycle>): this;
49
+ addBodyReaderImplementation(bodyReaderImplementation: MaybeArray<BodyReaderImplementation>): this;
50
+ plug(plugin: HubPlugin | ((self: this) => HubPlugin)): this;
51
+ setNotfoundHandler<GenericResponseContract extends ResponseContract.Contract, GenericResponse extends ResponseContract.Convert<GenericResponseContract>>(responseContract: GenericResponseContract, theFunction: (param: HandlerStepFunctionParams<Request, GenericResponse>) => MaybePromise<GenericResponse>): this;
52
+ setDefaultExtractContract(responseContract: this["defaultExtractContract"]): this;
53
+ aggregatesHooksHubLifeCycle<GenericHookName extends keyof HookHubLifeCycle>(hookName: GenericHookName): (NonNullable<HookHubLifeCycle[GenericHookName]> extends infer T ? T extends NonNullable<HookHubLifeCycle[GenericHookName]> ? T extends readonly (infer InnerArr)[] ? InnerArr extends readonly (infer InnerArr)[] ? InnerArr : InnerArr : T : never : never)[];
54
+ setDefaultBodyController(bodyController: BodyController): this;
55
+ aggregatesHooksRouteLifeCycle<GenericHookName extends keyof HookRouteLifeCycle>(hookName: GenericHookName): (NonNullable<HookRouteLifeCycle<Request>[GenericHookName]> extends infer T ? T extends NonNullable<HookRouteLifeCycle<Request>[GenericHookName]> ? T extends readonly (infer InnerArr)[] ? InnerArr extends readonly (infer InnerArr)[] ? InnerArr : InnerArr : T : never : never)[];
57
56
  }
58
57
  export declare function createHub<const GenericConfig extends HubConfig>(config: GenericConfig): Hub<GenericConfig>;
@@ -1,140 +1,112 @@
1
1
  import { createCoreLibKind } from '../kind.mjs';
2
2
  import { routeKind } from '../route/index.mjs';
3
- import { A, pipe, P, isType, O } from '@duplojs/utils';
3
+ import { kindHeritage, pipe, P, A, isType, O } from '@duplojs/utils';
4
4
  import '../steps/index.mjs';
5
- import { Request } from '../request.mjs';
5
+ import { Request } from '../request/index.mjs';
6
6
  import { defaultNotfoundHandler } from './defaultNotfoundHandler.mjs';
7
7
  import { defaultExtractContract } from './defaultExtractContract.mjs';
8
+ import { defaultBodyController } from './defaultBodyController.mjs';
8
9
  export { createHookHubLifeCycle, hookServerExitKind, hookServerNextKind, launchHookBeforeBuildRoute, launchHookServer, launchHookServerError, serverErrorExitHookFunction, serverErrorNextHookFunction } from './hooks.mjs';
9
10
  import { createHandlerStep } from '../steps/handler.mjs';
10
11
 
11
12
  const hubKind = createCoreLibKind("hub");
13
+ class Hub extends kindHeritage("hub", createCoreLibKind("hub")) {
14
+ config;
15
+ plugins = [];
16
+ hooksRouteLifeCycle = [];
17
+ hooksHubLifeCycle = [];
18
+ routes = new Set();
19
+ routeFunctionBuilders = [];
20
+ stepFunctionBuilders = [];
21
+ bodyReaderImplementations = [];
22
+ classRequest = Request;
23
+ notfoundHandler = defaultNotfoundHandler;
24
+ defaultExtractContract = defaultExtractContract;
25
+ defaultBodyController = defaultBodyController;
26
+ constructor(config) {
27
+ super({});
28
+ this.config = config;
29
+ }
30
+ register(routes) {
31
+ pipe(routes, P.when(routeKind.has, A.coalescing), P.when(isType("iterable"), A.from), P.otherwise(O.values), A.map((route) => this.routes.add(route)));
32
+ return this;
33
+ }
34
+ addRouteFunctionBuilder(functionBuilder) {
35
+ this.routeFunctionBuilders.push(...A.coalescing(functionBuilder));
36
+ return this;
37
+ }
38
+ addStepFunctionBuilder(functionBuilder) {
39
+ this.stepFunctionBuilders.push(...A.coalescing(functionBuilder));
40
+ return this;
41
+ }
42
+ addRouteHooks(hook) {
43
+ this.hooksRouteLifeCycle.push(...A.coalescing(hook));
44
+ return this;
45
+ }
46
+ addHubHooks(hook) {
47
+ this.hooksHubLifeCycle.push(...A.coalescing(hook));
48
+ return this;
49
+ }
50
+ addBodyReaderImplementation(bodyReaderImplementation) {
51
+ this.bodyReaderImplementations.push(...A.coalescing(bodyReaderImplementation));
52
+ return this;
53
+ }
54
+ plug(plugin) {
55
+ const pluginResult = typeof plugin === "function"
56
+ ? plugin(this)
57
+ : plugin;
58
+ if (pluginResult.bodyReaderImplementations) {
59
+ this.addBodyReaderImplementation(pluginResult.bodyReaderImplementations);
60
+ }
61
+ if (pluginResult.hooksHubLifeCycle) {
62
+ this.addHubHooks(pluginResult.hooksHubLifeCycle);
63
+ }
64
+ if (pluginResult.hooksRouteLifeCycle) {
65
+ this.addRouteHooks(pluginResult.hooksRouteLifeCycle);
66
+ }
67
+ if (pluginResult.routeFunctionBuilders) {
68
+ this.addRouteFunctionBuilder(pluginResult.routeFunctionBuilders);
69
+ }
70
+ if (pluginResult.routes) {
71
+ this.register(pluginResult.routes);
72
+ }
73
+ if (pluginResult.stepFunctionBuilders) {
74
+ this.addStepFunctionBuilder(pluginResult.stepFunctionBuilders);
75
+ }
76
+ this.plugins.push(pluginResult);
77
+ return this;
78
+ }
79
+ setNotfoundHandler(responseContract, theFunction) {
80
+ this.notfoundHandler = createHandlerStep({
81
+ responseContract,
82
+ theFunction: (floor, params) => theFunction(params),
83
+ metadata: [],
84
+ });
85
+ return this;
86
+ }
87
+ setDefaultExtractContract(responseContract) {
88
+ this.defaultExtractContract = responseContract;
89
+ return this;
90
+ }
91
+ aggregatesHooksHubLifeCycle(hookName) {
92
+ return A.flatMap(this.hooksHubLifeCycle, (hooks) => hooks[hookName] ?? []);
93
+ }
94
+ setDefaultBodyController(bodyController) {
95
+ this.defaultBodyController = bodyController;
96
+ return this;
97
+ }
98
+ aggregatesHooksRouteLifeCycle(hookName) {
99
+ return A.flatMap(this.hooksRouteLifeCycle, (hooks) => hooks[hookName] ?? []);
100
+ }
101
+ /**
102
+ * @internal
103
+ */
104
+ static "new"(config) {
105
+ return new Hub(config);
106
+ }
107
+ }
12
108
  function createHub(config) {
13
- return {
14
- ...hubKind.addTo({}),
15
- config,
16
- plugins: [],
17
- hooksHubLifeCycle: [],
18
- hooksRouteLifeCycle: [],
19
- routeFunctionBuilders: [],
20
- routes: [],
21
- stepFunctionBuilders: [],
22
- notfoundHandler: defaultNotfoundHandler,
23
- defaultExtractContract,
24
- classRequest: Request,
25
- addHubHooks(hook) {
26
- return {
27
- ...this,
28
- hooksHubLifeCycle: A.concat(this.hooksHubLifeCycle, A.coalescing(hook)),
29
- };
30
- },
31
- addRouteFunctionBuilder(functionBuilder) {
32
- return {
33
- ...this,
34
- routeFunctionBuilders: A.concat(this.routeFunctionBuilders, A.coalescing(functionBuilder)),
35
- };
36
- },
37
- addRouteHooks(hook) {
38
- return {
39
- ...this,
40
- hooksRouteLifeCycle: A.concat(this.hooksRouteLifeCycle, A.coalescing(hook)),
41
- };
42
- },
43
- addStepFunctionBuilder(hook) {
44
- return {
45
- ...this,
46
- stepFunctionBuilders: A.concat(this.stepFunctionBuilders, A.coalescing(hook)),
47
- };
48
- },
49
- plug(plugin) {
50
- return {
51
- ...this,
52
- plugins: A.push(this.plugins, typeof plugin === "function"
53
- ? plugin(this)
54
- : plugin),
55
- };
56
- },
57
- register(route) {
58
- return {
59
- ...this,
60
- routes: A.concat(this.routes, pipe(route, P.when(routeKind.has, A.coalescing), P.when(isType("iterable"), A.from), P.otherwise(O.values), A.filter((route) => !A.includes(this.routes, route)))),
61
- };
62
- },
63
- setDefaultExtractContract(defaultExtractContract) {
64
- return {
65
- ...this,
66
- defaultExtractContract,
67
- };
68
- },
69
- setNotfoundHandler(responseContract, theFunction) {
70
- return {
71
- ...this,
72
- notfoundHandler: createHandlerStep({
73
- responseContract,
74
- theFunction: (floor, params) => theFunction(params),
75
- metadata: [],
76
- }),
77
- };
78
- },
79
- aggregates() {
80
- return A.reduce(this.plugins, A.reduceFrom({
81
- hooksRouteLifeCycle: this.hooksRouteLifeCycle,
82
- routeFunctionBuilders: this.routeFunctionBuilders,
83
- stepFunctionBuilders: this.stepFunctionBuilders,
84
- routes: this.routes,
85
- hooksHubLifeCycle: this.hooksHubLifeCycle,
86
- }), ({ lastValue, element: plugin, next, }) => next({
87
- hooksRouteLifeCycle: plugin.hooksRouteLifeCycle
88
- ? A.concat(lastValue.hooksRouteLifeCycle, plugin.hooksRouteLifeCycle)
89
- : lastValue.hooksRouteLifeCycle,
90
- routeFunctionBuilders: plugin.routeFunctionBuilders
91
- ? A.concat(lastValue.routeFunctionBuilders, plugin.routeFunctionBuilders)
92
- : lastValue.routeFunctionBuilders,
93
- stepFunctionBuilders: plugin.stepFunctionBuilders
94
- ? A.concat(lastValue.stepFunctionBuilders, plugin.stepFunctionBuilders)
95
- : lastValue.stepFunctionBuilders,
96
- routes: plugin.routes
97
- ? A.concat(lastValue.routes, plugin.routes)
98
- : lastValue.routes,
99
- hooksHubLifeCycle: plugin.hooksHubLifeCycle
100
- ? A.concat(lastValue.hooksHubLifeCycle, plugin.hooksHubLifeCycle)
101
- : lastValue.hooksHubLifeCycle,
102
- }));
103
- },
104
- aggregatesRoutes() {
105
- return A.reduce(this.plugins, A.reduceFrom(this.routes), ({ lastValue, element: { routes }, next, }) => routes
106
- ? next(A.concat(lastValue, routes))
107
- : next(lastValue));
108
- },
109
- aggregatesRouteFunctionBuilders() {
110
- return A.reduce(this.plugins, A.reduceFrom(this.routeFunctionBuilders), ({ lastValue, element: { routeFunctionBuilders }, next, }) => routeFunctionBuilders
111
- ? next(A.concat(lastValue, routeFunctionBuilders))
112
- : next(lastValue));
113
- },
114
- aggregatesStepFunctionBuilders() {
115
- return A.reduce(this.plugins, A.reduceFrom(this.stepFunctionBuilders), ({ lastValue, element: { stepFunctionBuilders }, next, }) => stepFunctionBuilders
116
- ? next(A.concat(lastValue, stepFunctionBuilders))
117
- : next(lastValue));
118
- },
119
- aggregatesHooksHubLifeCycle(hookName) {
120
- const hooks = A.flatMap(this.hooksHubLifeCycle, (hooks) => hooks[hookName] ?? []);
121
- return A.reduce(this.plugins, A.reduceFrom(hooks), ({ lastValue, element: { hooksHubLifeCycle }, next, }) => {
122
- if (!hooksHubLifeCycle) {
123
- return next(lastValue);
124
- }
125
- return next(A.concat(lastValue, A.flatMap(hooksHubLifeCycle, (hooks) => hooks[hookName] ?? [])));
126
- });
127
- },
128
- aggregatesHooksRouteLifeCycle(hookName) {
129
- const hooks = A.flatMap(this.hooksRouteLifeCycle, (hooks) => hooks[hookName] ?? []);
130
- return A.reduce(this.plugins, A.reduceFrom(hooks), ({ lastValue, element: { hooksRouteLifeCycle }, next, }) => {
131
- if (!hooksRouteLifeCycle) {
132
- return next(lastValue);
133
- }
134
- return next(A.concat(lastValue, A.flatMap(hooksRouteLifeCycle, (hooks) => hooks[hookName] ?? [])));
135
- });
136
- },
137
- };
109
+ return Hub.new(config);
138
110
  }
139
111
 
140
- export { createHub, defaultExtractContract, defaultNotfoundHandler, hubKind };
112
+ export { Hub, createHub, defaultBodyController, defaultExtractContract, defaultNotfoundHandler, hubKind };
@@ -6,10 +6,10 @@ var utils = require('@duplojs/utils');
6
6
  var hooks = require('./hub/hooks.cjs');
7
7
 
8
8
  async function implementHttpServer(params, initHttpServer) {
9
- const newHub1 = await hooks.launchHookServer(params.hub.aggregatesHooksHubLifeCycle("beforeServerBuildRoutes"), params.hub, params.httpServerParams);
10
- const router = await index.buildRouter(newHub1);
11
- const newHub2 = await hooks.launchHookServer(newHub1.aggregatesHooksHubLifeCycle("beforeStartServer"), newHub1, params.httpServerParams);
12
- const serverErrorHooks = newHub1.aggregatesHooksHubLifeCycle("serverError");
9
+ await hooks.launchHookServer(params.hub.aggregatesHooksHubLifeCycle("beforeServerBuildRoutes"), params.hub, params.httpServerParams);
10
+ const router = await index.buildRouter(params.hub);
11
+ await hooks.launchHookServer(params.hub.aggregatesHooksHubLifeCycle("beforeStartServer"), params.hub, params.httpServerParams);
12
+ const serverErrorHooks = params.hub.aggregatesHooksHubLifeCycle("serverError");
13
13
  function catchCriticalError(error) {
14
14
  console.error("Critical Error :", error);
15
15
  }
@@ -29,7 +29,7 @@ async function implementHttpServer(params, initHttpServer) {
29
29
  execRouteSystem: execRouteSystem,
30
30
  httpServerParams: params.httpServerParams,
31
31
  });
32
- await hooks.launchHookServer(newHub2.aggregatesHooksHubLifeCycle("afterStartServer"), newHub2, params.httpServerParams);
32
+ await hooks.launchHookServer(params.hub.aggregatesHooksHubLifeCycle("afterStartServer"), params.hub, params.httpServerParams);
33
33
  return result;
34
34
  }
35
35
 
@@ -1,6 +1,7 @@
1
- import { type Hub, type HttpServerParams } from "./hub";
1
+ import { type Hub } from "./hub";
2
2
  import { type RouterInitializationData } from "./router";
3
3
  import { type MaybePromise } from "@duplojs/utils";
4
+ import { type HttpServerParams } from "./types";
4
5
  export interface ImplementHttpServerParams {
5
6
  readonly hub: Hub;
6
7
  readonly httpServerParams: HttpServerParams;
@@ -4,10 +4,10 @@ import { forward } from '@duplojs/utils';
4
4
  import { launchHookServer, launchHookServerError, serverErrorNextHookFunction, serverErrorExitHookFunction } from './hub/hooks.mjs';
5
5
 
6
6
  async function implementHttpServer(params, initHttpServer) {
7
- const newHub1 = await launchHookServer(params.hub.aggregatesHooksHubLifeCycle("beforeServerBuildRoutes"), params.hub, params.httpServerParams);
8
- const router = await buildRouter(newHub1);
9
- const newHub2 = await launchHookServer(newHub1.aggregatesHooksHubLifeCycle("beforeStartServer"), newHub1, params.httpServerParams);
10
- const serverErrorHooks = newHub1.aggregatesHooksHubLifeCycle("serverError");
7
+ await launchHookServer(params.hub.aggregatesHooksHubLifeCycle("beforeServerBuildRoutes"), params.hub, params.httpServerParams);
8
+ const router = await buildRouter(params.hub);
9
+ await launchHookServer(params.hub.aggregatesHooksHubLifeCycle("beforeStartServer"), params.hub, params.httpServerParams);
10
+ const serverErrorHooks = params.hub.aggregatesHooksHubLifeCycle("serverError");
11
11
  function catchCriticalError(error) {
12
12
  console.error("Critical Error :", error);
13
13
  }
@@ -27,7 +27,7 @@ async function implementHttpServer(params, initHttpServer) {
27
27
  execRouteSystem: execRouteSystem,
28
28
  httpServerParams: params.httpServerParams,
29
29
  });
30
- await launchHookServer(newHub2.aggregatesHooksHubLifeCycle("afterStartServer"), newHub2, params.httpServerParams);
30
+ await launchHookServer(params.hub.aggregatesHooksHubLifeCycle("afterStartServer"), params.hub, params.httpServerParams);
31
31
  return result;
32
32
  }
33
33