@expressots/adapter-express 3.0.0 → 4.0.0-preview.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 (244) hide show
  1. package/LICENSE.md +21 -21
  2. package/README.md +61 -118
  3. package/lib/CHANGELOG.md +36 -5
  4. package/lib/README.md +61 -118
  5. package/lib/cjs/adapter-express/application-express.base.js +3 -1
  6. package/lib/cjs/adapter-express/application-express.js +1405 -85
  7. package/lib/cjs/adapter-express/express-utils/conditional-middleware.js +102 -0
  8. package/lib/cjs/adapter-express/express-utils/constants.js +17 -0
  9. package/lib/cjs/adapter-express/express-utils/content-negotiation-decorators.js +129 -0
  10. package/lib/cjs/adapter-express/express-utils/decorators.js +225 -59
  11. package/lib/cjs/adapter-express/express-utils/exception-filter-decorators.js +11 -0
  12. package/lib/cjs/adapter-express/express-utils/guard-context-factory.js +84 -0
  13. package/lib/cjs/adapter-express/express-utils/guard-middleware.js +115 -0
  14. package/lib/cjs/adapter-express/express-utils/guard-utils.js +18 -0
  15. package/lib/cjs/adapter-express/express-utils/http-context-store.js +15 -0
  16. package/lib/cjs/adapter-express/express-utils/http-status-middleware.js +37 -2
  17. package/lib/cjs/adapter-express/express-utils/index.js +67 -1
  18. package/lib/cjs/adapter-express/express-utils/interceptor-middleware.js +132 -0
  19. package/lib/cjs/adapter-express/express-utils/inversify-express-server.js +827 -64
  20. package/lib/cjs/adapter-express/express-utils/lazy-module-middleware.js +241 -0
  21. package/lib/cjs/adapter-express/express-utils/middleware-composition.js +95 -0
  22. package/lib/cjs/adapter-express/express-utils/path-pattern-compat.js +129 -0
  23. package/lib/cjs/adapter-express/express-utils/permission-preloader.middleware.js +48 -0
  24. package/lib/cjs/adapter-express/express-utils/route-constraints.js +104 -0
  25. package/lib/cjs/adapter-express/express-utils/scope-extractor.interface.js +2 -0
  26. package/lib/cjs/adapter-express/express-utils/scope-extractor.js +66 -0
  27. package/lib/cjs/adapter-express/express-utils/setup-authorization.js +71 -0
  28. package/lib/cjs/adapter-express/express-utils/setup-event-system.js +113 -0
  29. package/lib/cjs/adapter-express/express-utils/setup-interceptors.js +103 -0
  30. package/lib/cjs/adapter-express/express-utils/setup-lazy-loading.js +228 -0
  31. package/lib/cjs/adapter-express/express-utils/utils.js +30 -12
  32. package/lib/cjs/adapter-express/express-utils/validation-decorators.js +205 -0
  33. package/lib/cjs/adapter-express/express-utils/validation-service.js +252 -0
  34. package/lib/cjs/adapter-express/index.js +7 -5
  35. package/lib/cjs/adapter-express/micro-api/application-express-micro-route.js +31 -1
  36. package/lib/cjs/adapter-express/micro-api/application-express-micro.js +8 -38
  37. package/lib/cjs/adapter-express/micro-api/gateway/circuit-breaker.js +174 -0
  38. package/lib/cjs/adapter-express/micro-api/gateway/index.js +11 -0
  39. package/lib/cjs/adapter-express/micro-api/gateway/service-proxy.js +214 -0
  40. package/lib/cjs/adapter-express/micro-api/index.js +27 -3
  41. package/lib/cjs/adapter-express/micro-api/micro.js +272 -0
  42. package/lib/cjs/adapter-express/micro-api/queue/index.js +8 -0
  43. package/lib/cjs/adapter-express/micro-api/queue/queue.interface.js +2 -0
  44. package/lib/cjs/adapter-express/micro-api/queue/rabbitmq-consumer.js +255 -0
  45. package/lib/cjs/adapter-express/micro-api/serverless/aws-lambda.adapter.js +183 -0
  46. package/lib/cjs/adapter-express/micro-api/serverless/cloudflare.adapter.js +158 -0
  47. package/lib/cjs/adapter-express/micro-api/serverless/index.js +12 -0
  48. package/lib/cjs/adapter-express/micro-api/serverless/vercel.adapter.js +102 -0
  49. package/lib/cjs/adapter-express/micro-api/service-mesh/index.js +10 -0
  50. package/lib/cjs/adapter-express/micro-api/service-mesh/service-client.js +194 -0
  51. package/lib/cjs/adapter-express/micro-api/service-mesh/service-discovery.js +261 -0
  52. package/lib/cjs/adapter-express/middleware/index.js +21 -0
  53. package/lib/cjs/adapter-express/middleware/request-logging.middleware.js +244 -0
  54. package/lib/cjs/adapter-express/render/engine.js +15 -15
  55. package/lib/cjs/adapter-express/render/index.js +5 -0
  56. package/lib/cjs/adapter-express/studio/index.js +10 -0
  57. package/lib/cjs/adapter-express/studio/studio-integration.js +267 -0
  58. package/lib/cjs/index.js +1 -1
  59. package/lib/cjs/types/adapter-express/application-express.base.d.ts +20 -7
  60. package/lib/cjs/types/adapter-express/application-express.d.ts +316 -33
  61. package/lib/cjs/types/adapter-express/express-utils/base-middleware.d.ts +2 -2
  62. package/lib/cjs/types/adapter-express/express-utils/conditional-middleware.d.ts +97 -0
  63. package/lib/cjs/types/adapter-express/express-utils/constants.d.ts +13 -0
  64. package/lib/cjs/types/adapter-express/express-utils/content-negotiation-decorators.d.ts +94 -0
  65. package/lib/cjs/types/adapter-express/express-utils/decorators.d.ts +54 -6
  66. package/lib/cjs/types/adapter-express/express-utils/exception-filter-decorators.d.ts +6 -0
  67. package/lib/cjs/types/adapter-express/express-utils/guard-context-factory.d.ts +17 -0
  68. package/lib/cjs/types/adapter-express/express-utils/guard-middleware.d.ts +22 -0
  69. package/lib/cjs/types/adapter-express/express-utils/guard-utils.d.ts +11 -0
  70. package/lib/cjs/types/adapter-express/express-utils/http-context-store.d.ts +20 -0
  71. package/lib/cjs/types/adapter-express/express-utils/httpResponseMessage.d.ts +1 -1
  72. package/lib/cjs/types/adapter-express/express-utils/index.d.ts +30 -2
  73. package/lib/cjs/types/adapter-express/express-utils/interceptor-middleware.d.ts +40 -0
  74. package/lib/cjs/types/adapter-express/express-utils/interfaces.d.ts +42 -5
  75. package/lib/cjs/types/adapter-express/express-utils/inversify-express-server.d.ts +114 -2
  76. package/lib/cjs/types/adapter-express/express-utils/lazy-module-middleware.d.ts +122 -0
  77. package/lib/cjs/types/adapter-express/express-utils/middleware-composition.d.ts +85 -0
  78. package/lib/cjs/types/adapter-express/express-utils/path-pattern-compat.d.ts +66 -0
  79. package/lib/cjs/types/adapter-express/express-utils/permission-preloader.middleware.d.ts +10 -0
  80. package/lib/cjs/types/adapter-express/express-utils/route-constraints.d.ts +98 -0
  81. package/lib/cjs/types/adapter-express/express-utils/scope-extractor.d.ts +21 -0
  82. package/lib/cjs/types/adapter-express/express-utils/scope-extractor.interface.d.ts +12 -0
  83. package/lib/cjs/types/adapter-express/express-utils/setup-authorization.d.ts +34 -0
  84. package/lib/cjs/types/adapter-express/express-utils/setup-event-system.d.ts +118 -0
  85. package/lib/cjs/types/adapter-express/express-utils/setup-interceptors.d.ts +115 -0
  86. package/lib/cjs/types/adapter-express/express-utils/setup-lazy-loading.d.ts +123 -0
  87. package/lib/cjs/types/adapter-express/express-utils/utils.d.ts +17 -2
  88. package/lib/cjs/types/adapter-express/express-utils/validation-decorators.d.ts +145 -0
  89. package/lib/cjs/types/adapter-express/express-utils/validation-service.d.ts +88 -0
  90. package/lib/cjs/types/adapter-express/index.d.ts +6 -4
  91. package/lib/cjs/types/adapter-express/micro-api/application-express-micro-route.d.ts +25 -14
  92. package/lib/cjs/types/adapter-express/micro-api/application-express-micro.d.ts +3 -10
  93. package/lib/cjs/types/adapter-express/micro-api/gateway/circuit-breaker.d.ts +111 -0
  94. package/lib/cjs/types/adapter-express/micro-api/gateway/index.d.ts +5 -0
  95. package/lib/cjs/types/adapter-express/micro-api/gateway/service-proxy.d.ts +83 -0
  96. package/lib/cjs/types/adapter-express/micro-api/index.d.ts +7 -1
  97. package/lib/cjs/types/adapter-express/micro-api/micro.d.ts +83 -0
  98. package/lib/cjs/types/adapter-express/micro-api/queue/index.d.ts +5 -0
  99. package/lib/cjs/types/adapter-express/micro-api/queue/queue.interface.d.ts +60 -0
  100. package/lib/cjs/types/adapter-express/micro-api/queue/rabbitmq-consumer.d.ts +86 -0
  101. package/lib/cjs/types/adapter-express/micro-api/serverless/aws-lambda.adapter.d.ts +77 -0
  102. package/lib/cjs/types/adapter-express/micro-api/serverless/cloudflare.adapter.d.ts +64 -0
  103. package/lib/cjs/types/adapter-express/micro-api/serverless/index.d.ts +6 -0
  104. package/lib/cjs/types/adapter-express/micro-api/serverless/vercel.adapter.d.ts +56 -0
  105. package/lib/cjs/types/adapter-express/micro-api/service-mesh/index.d.ts +5 -0
  106. package/lib/cjs/types/adapter-express/micro-api/service-mesh/service-client.d.ts +122 -0
  107. package/lib/cjs/types/adapter-express/micro-api/service-mesh/service-discovery.d.ts +150 -0
  108. package/lib/cjs/types/adapter-express/middleware/index.d.ts +5 -0
  109. package/lib/cjs/types/adapter-express/middleware/request-logging.middleware.d.ts +65 -0
  110. package/lib/cjs/types/adapter-express/render/index.d.ts +1 -0
  111. package/lib/cjs/types/adapter-express/studio/index.d.ts +1 -0
  112. package/lib/cjs/types/adapter-express/studio/studio-integration.d.ts +170 -0
  113. package/lib/cjs/types/index.d.ts +1 -1
  114. package/lib/esm/adapter-express/application-express.base.js +24 -0
  115. package/lib/esm/adapter-express/application-express.js +1656 -0
  116. package/lib/esm/adapter-express/application-express.types.js +1 -0
  117. package/lib/esm/adapter-express/express-utils/base-middleware.js +19 -0
  118. package/lib/esm/adapter-express/express-utils/conditional-middleware.js +96 -0
  119. package/lib/esm/adapter-express/express-utils/constants.js +63 -0
  120. package/lib/esm/adapter-express/express-utils/content/httpContent.js +6 -0
  121. package/lib/esm/adapter-express/express-utils/content-negotiation-decorators.js +120 -0
  122. package/lib/esm/adapter-express/express-utils/decorators.js +604 -0
  123. package/lib/esm/adapter-express/express-utils/exception-filter-decorators.js +6 -0
  124. package/lib/esm/adapter-express/express-utils/guard-context-factory.js +83 -0
  125. package/lib/esm/adapter-express/express-utils/guard-middleware.js +115 -0
  126. package/lib/esm/adapter-express/express-utils/guard-utils.js +14 -0
  127. package/lib/esm/adapter-express/express-utils/http-context-store.js +10 -0
  128. package/lib/esm/adapter-express/express-utils/http-status-middleware.js +116 -0
  129. package/lib/esm/adapter-express/express-utils/httpResponseMessage.js +29 -0
  130. package/lib/esm/adapter-express/express-utils/index.js +24 -0
  131. package/lib/esm/adapter-express/express-utils/interceptor-middleware.js +130 -0
  132. package/lib/esm/adapter-express/express-utils/interfaces.js +1 -0
  133. package/lib/esm/adapter-express/express-utils/inversify-express-server.js +1047 -0
  134. package/lib/esm/adapter-express/express-utils/lazy-module-middleware.js +236 -0
  135. package/lib/esm/adapter-express/express-utils/middleware-composition.js +89 -0
  136. package/lib/esm/adapter-express/express-utils/path-pattern-compat.js +125 -0
  137. package/lib/esm/adapter-express/express-utils/permission-preloader.middleware.js +45 -0
  138. package/lib/esm/adapter-express/express-utils/resolver-multer.js +30 -0
  139. package/lib/esm/adapter-express/express-utils/route-constraints.js +100 -0
  140. package/lib/esm/adapter-express/express-utils/scope-extractor.interface.js +1 -0
  141. package/lib/esm/adapter-express/express-utils/scope-extractor.js +63 -0
  142. package/lib/esm/adapter-express/express-utils/setup-authorization.js +68 -0
  143. package/lib/esm/adapter-express/express-utils/setup-event-system.js +110 -0
  144. package/lib/esm/adapter-express/express-utils/setup-interceptors.js +100 -0
  145. package/lib/esm/adapter-express/express-utils/setup-lazy-loading.js +225 -0
  146. package/lib/esm/adapter-express/express-utils/utils.js +68 -0
  147. package/lib/esm/adapter-express/express-utils/validation-decorators.js +199 -0
  148. package/lib/esm/adapter-express/express-utils/validation-service.js +251 -0
  149. package/lib/esm/adapter-express/index.js +7 -0
  150. package/lib/esm/adapter-express/micro-api/application-express-micro-container.js +48 -0
  151. package/lib/esm/adapter-express/micro-api/application-express-micro-route.js +128 -0
  152. package/lib/esm/adapter-express/micro-api/application-express-micro.js +157 -0
  153. package/lib/esm/adapter-express/micro-api/gateway/circuit-breaker.js +174 -0
  154. package/lib/esm/adapter-express/micro-api/gateway/index.js +5 -0
  155. package/lib/esm/adapter-express/micro-api/gateway/service-proxy.js +210 -0
  156. package/lib/esm/adapter-express/micro-api/index.js +10 -0
  157. package/lib/esm/adapter-express/micro-api/micro.js +266 -0
  158. package/lib/esm/adapter-express/micro-api/queue/index.js +4 -0
  159. package/lib/esm/adapter-express/micro-api/queue/queue.interface.js +1 -0
  160. package/lib/esm/adapter-express/micro-api/queue/rabbitmq-consumer.js +229 -0
  161. package/lib/esm/adapter-express/micro-api/serverless/aws-lambda.adapter.js +180 -0
  162. package/lib/esm/adapter-express/micro-api/serverless/cloudflare.adapter.js +155 -0
  163. package/lib/esm/adapter-express/micro-api/serverless/index.js +6 -0
  164. package/lib/esm/adapter-express/micro-api/serverless/vercel.adapter.js +99 -0
  165. package/lib/esm/adapter-express/micro-api/service-mesh/index.js +5 -0
  166. package/lib/esm/adapter-express/micro-api/service-mesh/service-client.js +191 -0
  167. package/lib/esm/adapter-express/micro-api/service-mesh/service-discovery.js +259 -0
  168. package/lib/esm/adapter-express/middleware/index.js +5 -0
  169. package/lib/esm/adapter-express/middleware/request-logging.middleware.js +239 -0
  170. package/lib/esm/adapter-express/render/constants.js +37 -0
  171. package/lib/esm/adapter-express/render/engine.js +51 -0
  172. package/lib/esm/adapter-express/render/index.js +1 -0
  173. package/lib/esm/adapter-express/render/resolve-render.js +30 -0
  174. package/lib/esm/adapter-express/studio/index.js +1 -0
  175. package/lib/esm/adapter-express/studio/studio-integration.js +236 -0
  176. package/lib/esm/index.mjs +1 -0
  177. package/lib/esm/package.json +3 -0
  178. package/lib/esm/types/adapter-express/application-express.base.d.ts +77 -0
  179. package/lib/esm/types/adapter-express/application-express.d.ts +453 -0
  180. package/lib/esm/types/adapter-express/application-express.types.d.ts +23 -0
  181. package/lib/esm/types/adapter-express/express-utils/base-middleware.d.ts +8 -0
  182. package/lib/esm/types/adapter-express/express-utils/conditional-middleware.d.ts +97 -0
  183. package/lib/esm/types/adapter-express/express-utils/constants.d.ts +57 -0
  184. package/lib/esm/types/adapter-express/express-utils/content/httpContent.d.ts +6 -0
  185. package/lib/esm/types/adapter-express/express-utils/content-negotiation-decorators.d.ts +94 -0
  186. package/lib/esm/types/adapter-express/express-utils/decorators.d.ts +257 -0
  187. package/lib/esm/types/adapter-express/express-utils/exception-filter-decorators.d.ts +6 -0
  188. package/lib/esm/types/adapter-express/express-utils/guard-context-factory.d.ts +17 -0
  189. package/lib/esm/types/adapter-express/express-utils/guard-middleware.d.ts +22 -0
  190. package/lib/esm/types/adapter-express/express-utils/guard-utils.d.ts +11 -0
  191. package/lib/esm/types/adapter-express/express-utils/http-context-store.d.ts +20 -0
  192. package/lib/esm/types/adapter-express/express-utils/http-status-middleware.d.ts +26 -0
  193. package/lib/esm/types/adapter-express/express-utils/httpResponseMessage.d.ts +14 -0
  194. package/lib/esm/types/adapter-express/express-utils/index.d.ts +30 -0
  195. package/lib/esm/types/adapter-express/express-utils/interceptor-middleware.d.ts +40 -0
  196. package/lib/esm/types/adapter-express/express-utils/interfaces.d.ts +115 -0
  197. package/lib/esm/types/adapter-express/express-utils/inversify-express-server.d.ts +172 -0
  198. package/lib/esm/types/adapter-express/express-utils/lazy-module-middleware.d.ts +122 -0
  199. package/lib/esm/types/adapter-express/express-utils/middleware-composition.d.ts +85 -0
  200. package/lib/esm/types/adapter-express/express-utils/path-pattern-compat.d.ts +66 -0
  201. package/lib/esm/types/adapter-express/express-utils/permission-preloader.middleware.d.ts +10 -0
  202. package/lib/esm/types/adapter-express/express-utils/resolver-multer.d.ts +7 -0
  203. package/lib/esm/types/adapter-express/express-utils/route-constraints.d.ts +98 -0
  204. package/lib/esm/types/adapter-express/express-utils/scope-extractor.d.ts +21 -0
  205. package/lib/esm/types/adapter-express/express-utils/scope-extractor.interface.d.ts +12 -0
  206. package/lib/esm/types/adapter-express/express-utils/setup-authorization.d.ts +34 -0
  207. package/lib/esm/types/adapter-express/express-utils/setup-event-system.d.ts +118 -0
  208. package/lib/esm/types/adapter-express/express-utils/setup-interceptors.d.ts +115 -0
  209. package/lib/esm/types/adapter-express/express-utils/setup-lazy-loading.d.ts +123 -0
  210. package/lib/esm/types/adapter-express/express-utils/utils.d.ts +24 -0
  211. package/lib/esm/types/adapter-express/express-utils/validation-decorators.d.ts +145 -0
  212. package/lib/esm/types/adapter-express/express-utils/validation-service.d.ts +88 -0
  213. package/lib/esm/types/adapter-express/index.d.ts +7 -0
  214. package/lib/esm/types/adapter-express/micro-api/application-express-micro-container.d.ts +47 -0
  215. package/lib/esm/types/adapter-express/micro-api/application-express-micro-route.d.ts +104 -0
  216. package/lib/esm/types/adapter-express/micro-api/application-express-micro.d.ts +72 -0
  217. package/lib/esm/types/adapter-express/micro-api/gateway/circuit-breaker.d.ts +111 -0
  218. package/lib/esm/types/adapter-express/micro-api/gateway/index.d.ts +5 -0
  219. package/lib/esm/types/adapter-express/micro-api/gateway/service-proxy.d.ts +83 -0
  220. package/lib/esm/types/adapter-express/micro-api/index.d.ts +7 -0
  221. package/lib/esm/types/adapter-express/micro-api/micro.d.ts +83 -0
  222. package/lib/esm/types/adapter-express/micro-api/queue/index.d.ts +5 -0
  223. package/lib/esm/types/adapter-express/micro-api/queue/queue.interface.d.ts +60 -0
  224. package/lib/esm/types/adapter-express/micro-api/queue/rabbitmq-consumer.d.ts +86 -0
  225. package/lib/esm/types/adapter-express/micro-api/serverless/aws-lambda.adapter.d.ts +77 -0
  226. package/lib/esm/types/adapter-express/micro-api/serverless/cloudflare.adapter.d.ts +64 -0
  227. package/lib/esm/types/adapter-express/micro-api/serverless/index.d.ts +6 -0
  228. package/lib/esm/types/adapter-express/micro-api/serverless/vercel.adapter.d.ts +56 -0
  229. package/lib/esm/types/adapter-express/micro-api/service-mesh/index.d.ts +5 -0
  230. package/lib/esm/types/adapter-express/micro-api/service-mesh/service-client.d.ts +122 -0
  231. package/lib/esm/types/adapter-express/micro-api/service-mesh/service-discovery.d.ts +150 -0
  232. package/lib/esm/types/adapter-express/middleware/index.d.ts +5 -0
  233. package/lib/esm/types/adapter-express/middleware/request-logging.middleware.d.ts +65 -0
  234. package/lib/esm/types/adapter-express/render/constants.d.ts +26 -0
  235. package/lib/esm/types/adapter-express/render/engine.d.ts +20 -0
  236. package/lib/esm/types/adapter-express/render/index.d.ts +5 -0
  237. package/lib/esm/types/adapter-express/render/resolve-render.d.ts +7 -0
  238. package/lib/esm/types/adapter-express/studio/index.d.ts +1 -0
  239. package/lib/esm/types/adapter-express/studio/studio-integration.d.ts +170 -0
  240. package/lib/esm/types/index.d.ts +1 -0
  241. package/lib/package.json +170 -146
  242. package/package.json +170 -146
  243. package/lib/cjs/di/di.interfaces.js +0 -10
  244. package/lib/cjs/types/di/di.interfaces.d.ts +0 -289
@@ -0,0 +1,453 @@
1
+ import { Server as HTTPServer } from "http";
2
+ import { AppContainer, IConsoleMessage, IMiddleware, Logger, ProviderManager, BannerConfig } from "@expressots/core";
3
+ import { IWebServerPublic, RenderEngine, Server } from "@expressots/shared";
4
+ import { interfaces } from "@expressots/core";
5
+ /**
6
+ * The AppExpress class provides methods for configuring and running an Express application.
7
+ * @class AppExpress
8
+ * @implements {IWebServer} - Interface for the WebServer application implementation.
9
+ * @extends {ApplicationBase} - Base class for the application implementation that provides lifecycle hooks.
10
+ * @method configure - Configures the InversifyJS container.
11
+ * @method listen - Start listening on the given port and environment.
12
+ * @method setGlobalRoutePrefix - Sets the global route prefix for the application.
13
+ * @method setEngine - Configures the application's view engine based on the provided configuration options.
14
+ * @method isDevelopment - Verifies if the current environment is development.
15
+ */
16
+ export declare class AppExpress implements Server.IWebServer {
17
+ protected logger: Logger;
18
+ private console;
19
+ private app;
20
+ private serverInstance;
21
+ private port;
22
+ private environment?;
23
+ private appContainer;
24
+ private globalPrefix;
25
+ private middlewareManager;
26
+ private middlewares;
27
+ private providerManager;
28
+ private renderOptions;
29
+ private lifecycleRegistry;
30
+ private isShuttingDown;
31
+ private bannerGenerator;
32
+ private bannerConfig;
33
+ private shutdownHandlers;
34
+ private studioConfig;
35
+ /**
36
+ * Latest snapshot of application metrics produced by `MetricsCollector`
37
+ * during banner display. We cache it so that `reportStudioRuntimeInfo`
38
+ * can forward the *runtime* provider/interceptor counts (which match
39
+ * what the CLI banner shows) to the Studio Agent without recomputing.
40
+ */
41
+ private lastApplicationMetrics;
42
+ /** Track active connections for force-close during shutdown */
43
+ private activeConnections;
44
+ /** Timeout for force-closing connections during shutdown (ms) */
45
+ private shutdownTimeout;
46
+ /** Number of retries when port is in use (for hot-reload scenarios) */
47
+ private portRetryAttempts;
48
+ /** Delay between port retry attempts (ms) */
49
+ private portRetryDelay;
50
+ private static originalStdoutWrite;
51
+ private static originalStderrWrite;
52
+ private static logBuffer;
53
+ private static isBuffering;
54
+ private static originalGlobalConsole;
55
+ /**
56
+ * Disable log buffering. Called by micro() to restore normal console output
57
+ * since micro API doesn't use the banner system.
58
+ * @public API
59
+ */
60
+ static disableBuffering(): void;
61
+ /**
62
+ * Start buffering all console output for the banner-first display flow.
63
+ * Captures both `console.*` and direct `process.stdout.write` / `process.stderr.write`
64
+ * calls so they can be flushed in the correct order after the banner displays.
65
+ *
66
+ * Idempotent: calling this multiple times is safe.
67
+ *
68
+ * @public API — called by `bootstrap()` so logs emitted during container
69
+ * setup are captured before the `AppExpress` instance exists. Also called
70
+ * automatically inside the constructor as a safety net.
71
+ */
72
+ static startLogBuffering(): void;
73
+ /**
74
+ * Stop buffering but keep the buffered logs for later flushing.
75
+ * This restores normal console/stdout output.
76
+ * @private
77
+ */
78
+ private static stopBuffering;
79
+ /**
80
+ * Flush all buffered logs to stdout.
81
+ * Should be called after stopBuffering() and after displaying the banner.
82
+ * @private
83
+ */
84
+ private static flushBufferedLogs;
85
+ constructor();
86
+ /**
87
+ * Helper function to handle both sync and async method calls.
88
+ * If the result is a Promise, awaits it; otherwise returns immediately.
89
+ * @private
90
+ */
91
+ private handleSyncOrAsync;
92
+ /**
93
+ * Implement this method to set up global configurations for the server.
94
+ * This method is called synchronously in the constructor before any other
95
+ * server initialization methods. Use this method to configure global settings
96
+ * that apply to the entire server application.
97
+ *
98
+ * Note: This method is synchronous and called during object construction.
99
+ * For asynchronous initialization, use `configureServices()` instead.
100
+ *
101
+ * @abstract
102
+ * @returns {void}
103
+ * @public API
104
+ */
105
+ protected globalConfiguration(): void;
106
+ /**
107
+ * Implement this method to set up required services or configurations before
108
+ * the server starts. This is essential for initializing dependencies or settings
109
+ * necessary for server operation. Supports both synchronous and asynchronous setup.
110
+ *
111
+ * @abstract
112
+ * @returns {void | Promise<void>}
113
+ * @public API
114
+ */
115
+ protected configureServices(): void | Promise<void>;
116
+ /**
117
+ * Implement this method to execute actions or configurations after the server
118
+ * has started. Use this for operations that need to run once the server is
119
+ * operational. Supports both synchronous and asynchronous execution.
120
+ *
121
+ * @abstract
122
+ * @returns {void | Promise<void>}
123
+ * @public API
124
+ */
125
+ protected postServerInitialization(): void | Promise<void>;
126
+ /**
127
+ * Implement this method to handle cleanup and final actions when the server
128
+ * is shutting down. Ideal for closing resources, stopping tasks, or other
129
+ * cleanup procedures to ensure a graceful server shutdown. Supports both
130
+ * synchronous and asynchronous cleanup.
131
+ *
132
+ * The signal parameter indicates what triggered the shutdown:
133
+ * - SIGTERM: Graceful termination (e.g., Kubernetes pod shutdown)
134
+ * - SIGINT: User interrupt (e.g., Ctrl+C)
135
+ * - SIGHUP: Terminal hangup
136
+ * - SIGQUIT: Quit with core dump
137
+ * - SIGBREAK: Windows break signal
138
+ *
139
+ * @abstract
140
+ * @param signal - The signal that triggered the shutdown (optional for backward compatibility)
141
+ * @returns {void | Promise<void>}
142
+ * @public API
143
+ */
144
+ protected serverShutdown(signal?: NodeJS.Signals): void | Promise<void>;
145
+ /**
146
+ * Performs graceful shutdown of the application.
147
+ *
148
+ * Shutdown sequence:
149
+ * 1. Execute lifecycle shutdown hooks on all IShutdown providers
150
+ * 2. Call user's serverShutdown hook
151
+ * 3. Close the HTTP server to stop accepting new connections
152
+ *
153
+ * @param signal - The signal that triggered the shutdown
154
+ * @returns Promise that resolves when shutdown is complete
155
+ * @internal
156
+ */
157
+ private handleExit;
158
+ /**
159
+ * Destroy all active connections immediately.
160
+ * Used during forced shutdown.
161
+ * @private
162
+ */
163
+ private destroyAllConnections;
164
+ /**
165
+ * Track a new connection for shutdown management.
166
+ * @private
167
+ */
168
+ private trackConnection;
169
+ /**
170
+ * Initialize the InversifyJS container with the provided modules and options.
171
+ * @param appModules - An array of application modules to be loaded into the container.
172
+ * @param containerOptions - Container global configuration options.
173
+ * @option skipBaseClassChecks - Skip the base class checks for the container.
174
+ * @option autoBindInjectable - Automatically bind the injectable classes.
175
+ * @option defaultScope - The default scope to use for bindings.
176
+ *
177
+ * @returns The configured AppContainer instance.
178
+ * @public API
179
+ */
180
+ configContainer(appModules: Array<interfaces.ContainerModule>, containerOptions?: interfaces.ContainerOptions): AppContainer;
181
+ /**
182
+ * Creates a middleware wrapper that automatically injects container when exception filters are enabled
183
+ * This allows users to simply set enableExceptionFilters: true without manually passing the container
184
+ */
185
+ private createMiddlewareWrapper;
186
+ /**
187
+ * Get the ProviderManager instance.
188
+ * @returns The ProviderManager instance.
189
+ * @public API
190
+ */
191
+ get Provider(): ProviderManager;
192
+ /**
193
+ * Get the Middleware instance.
194
+ * @returns The Middleware instance.
195
+ * @public API
196
+ */
197
+ get Middleware(): IMiddleware;
198
+ /**
199
+ * Configures the Express application with the provided middleware entries.
200
+ * @param app - The Express application instance.
201
+ * @param middlewareEntries - An array of Express middleware entries to be applied.
202
+ */
203
+ private configureMiddleware;
204
+ /**
205
+ * Create and configure the Express application.
206
+ * @param container - The InversifyJS container.
207
+ * @param middlewares - An array of Express middlewares to be applied.
208
+ * @returns The configured Application instance.
209
+ */
210
+ private init;
211
+ /**
212
+ * Start listening on the given port and environment.
213
+ * @param port - The port number to listen on.
214
+ * @param appInfo - Optional message to display the app name and version.
215
+ * @public API
216
+ */
217
+ listen(port: number | string, appInfo?: IConsoleMessage): Promise<IWebServerPublic>;
218
+ /**
219
+ * Close existing server instance if it exists.
220
+ * @private
221
+ */
222
+ private closeExistingServer;
223
+ /**
224
+ * Wait for a specified duration.
225
+ * @private
226
+ */
227
+ private delay;
228
+ /**
229
+ * Kill the process using a specific port.
230
+ * @private
231
+ */
232
+ private killProcessOnPort;
233
+ /**
234
+ * Check if the port is available by attempting to bind to it.
235
+ * @private
236
+ */
237
+ private isPortAvailable;
238
+ /**
239
+ * Ensure the port is available, killing the existing process if needed.
240
+ * This is the safest approach for hot-reload scenarios.
241
+ * @private
242
+ */
243
+ private ensurePortAvailable;
244
+ /**
245
+ * Remove existing shutdown signal handlers to prevent duplicates.
246
+ * @private
247
+ */
248
+ private removeShutdownHandlers;
249
+ /**
250
+ * Sets the global route prefix for the application.
251
+ * @method setGlobalRoutePrefix
252
+ * @param {string} prefix - The prefix to use for all routes.
253
+ * @public API
254
+ */
255
+ setGlobalRoutePrefix(prefix: string): Promise<void>;
256
+ /**
257
+ * Configures the application's view engine based on the provided configuration options.
258
+ */
259
+ private configEngine;
260
+ /**
261
+ * Configures the application's view engine based on the provided configuration options.
262
+ * @method setEngine
263
+ * @template T - A generic type extending from RenderTemplateOptions.
264
+ *
265
+ * @param {Engine} engine - The view engine to set
266
+ * @param {EngineOptions} [options] - The configuration options for the view engine
267
+ * @public API
268
+ */
269
+ /**
270
+ * Configure the startup banner display.
271
+ * Can be called in configureServices() or globalConfiguration().
272
+ *
273
+ * @param config - Banner configuration options
274
+ * @example
275
+ * ```typescript
276
+ * export class App extends AppExpress {
277
+ * configureServices(): void {
278
+ * this.setBanner({
279
+ * style: "full",
280
+ * showMetrics: true,
281
+ * showFeatures: true,
282
+ * showConfig: true,
283
+ * showPerformance: true,
284
+ * showResources: true,
285
+ * // Environment-specific overrides
286
+ * environment: {
287
+ * production: {
288
+ * style: "compact",
289
+ * showConfig: false,
290
+ * showResources: false,
291
+ * },
292
+ * },
293
+ * });
294
+ * }
295
+ * }
296
+ * ```
297
+ * @public API
298
+ */
299
+ setBanner(config: BannerConfig): void;
300
+ /**
301
+ * Configure ExpressoTS Studio integration.
302
+ * When enabled and @expressots/studio-agent is installed, automatically
303
+ * instruments the application for request recording and real-time monitoring.
304
+ *
305
+ * By default, Studio is auto-enabled in development if the package is installed.
306
+ * Use this method to customize behavior or enable in production.
307
+ *
308
+ * @param config - Studio configuration options
309
+ * @example
310
+ * ```typescript
311
+ * export class App extends AppExpress {
312
+ * configureServices(): void {
313
+ * this.setStudio({
314
+ * enabled: true, // Force enable (default: auto in dev)
315
+ * port: 3334, // WebSocket port for UI connection
316
+ * serviceName: 'my-app', // Service name for tracing
317
+ * });
318
+ * }
319
+ * }
320
+ * ```
321
+ * @public API
322
+ */
323
+ setStudio(config: {
324
+ enabled?: boolean;
325
+ port?: number;
326
+ dbPath?: string;
327
+ serviceName?: string;
328
+ }): void;
329
+ /**
330
+ * Check if ExpressoTS Studio is currently enabled.
331
+ * @returns Boolean indicating if Studio Agent is running.
332
+ * @public API
333
+ */
334
+ isStudioEnabled(): boolean;
335
+ /**
336
+ * Configure a view engine for server-side rendering.
337
+ *
338
+ * @deprecated Use `this.Middleware.render()` instead. Will be removed in v5.0.0.
339
+ *
340
+ * @example Migration
341
+ * ```typescript
342
+ * // Before (deprecated)
343
+ * this.setEngine(RenderEngine.Engine.EJS, { viewsDir: 'views' });
344
+ *
345
+ * // After (recommended)
346
+ * this.Middleware.render({ engine: 'ejs', viewsDir: 'views' });
347
+ *
348
+ * // Or with auto-detection
349
+ * this.Middleware.render();
350
+ * ```
351
+ *
352
+ * @param engine - The view engine to set
353
+ * @param options - The configuration options for the view engine
354
+ * @public API
355
+ */
356
+ setEngine<T extends RenderEngine.EngineOptions>(engine: RenderEngine.Engine, options?: T): Promise<void>;
357
+ /**
358
+ * Verifies if the current environment is development.
359
+ * @returns A boolean value indicating whether the current environment is development or not.
360
+ * @public API
361
+ */
362
+ isDevelopment(): Promise<boolean>;
363
+ /**
364
+ * Get the underlying HTTP server. (default: Express.js)
365
+ * @returns The underlying HTTP server after initialization.
366
+ * @public API
367
+ */
368
+ getHttpServer(): Promise<HTTPServer>;
369
+ /**
370
+ * Get the port the server is listening on.
371
+ * Useful for dynamic port assignment (port: 0) in testing scenarios.
372
+ * @returns The actual port number the server is bound to.
373
+ * @public API
374
+ */
375
+ getPort(): Promise<number>;
376
+ /**
377
+ * Detect API versions from @Version() decorators on controllers.
378
+ * @returns Array of unique API versions (e.g., ["v1", "v2"])
379
+ * @private
380
+ */
381
+ private detectApiVersions;
382
+ /**
383
+ * Harvest provider + interceptor *names* from DI metadata so the
384
+ * Studio Status page can drill down into the items behind the
385
+ * "Providers" / "Interceptors" counters.
386
+ *
387
+ * Reads the same metadata that {@link MetricsCollector} uses for the
388
+ * CLI banner — so what shows up here is the source of truth, not the
389
+ * agent's static file scan (which can't see framework-registered
390
+ * items like `Logger` or `LifecycleRegistry`).
391
+ *
392
+ * Returns `undefined` instead of an empty object so {@link
393
+ * reportStudioRuntimeInfo} can skip forwarding when nothing was
394
+ * harvested (keeps the WS payload small).
395
+ */
396
+ private collectStudioRuntimeItems;
397
+ /**
398
+ * Harvest controller- and route-scoped middleware bindings from
399
+ * Reflect metadata. Each entry describes a single edge the Studio
400
+ * architecture map should draw, e.g. "AuthMiddleware → UserController
401
+ * (route POST /users/:id)".
402
+ *
403
+ * The middleware values stored on `ControllerMetadata.middleware` are
404
+ * a polymorphic union (class, function, registered name, conditional
405
+ * config, …). We normalise each to a display name; entries we can't
406
+ * name (anonymous arrow functions, plain object configs without a
407
+ * `name` field) are omitted. The agent's static scan picks up the
408
+ * remaining named cases via decorator parsing — between the two
409
+ * sources Studio sees a complete graph for the common patterns.
410
+ */
411
+ private collectMiddlewareBindings;
412
+ /**
413
+ * Combine a controller's base path with a route path, normalising
414
+ * leading/trailing slashes. Mirrors the simpler logic Studio uses to
415
+ * build `RouteInfo.path` so the bindings line up with route entries.
416
+ */
417
+ private joinRoutePath;
418
+ /**
419
+ * Collect the ordered middleware pipeline from the Middleware service
420
+ * for forwarding to Studio. Uses feature-detection so older core
421
+ * versions that lack `getPipelineInfo()` won't break.
422
+ */
423
+ private collectMiddlewarePipelineItems;
424
+ /**
425
+ * Build the middleware preset info snapshot for Studio. Reads the
426
+ * last applied preset from the Middleware service and transforms it
427
+ * into the shape Studio expects.
428
+ */
429
+ private collectMiddlewarePresetInfo;
430
+ /**
431
+ * Display middleware startup logs after the banner.
432
+ *
433
+ * Warnings (e.g. missing optional packages like `helmet`) are always surfaced
434
+ * so the developer can act on them. Informational entries (e.g. "Security
435
+ * configured", "Applied preset: api") are demoted to `debug` since the
436
+ * dashboard already shows the active middleware count; set `LOG_LEVEL=DEBUG`
437
+ * to see the full breakdown.
438
+ * @private
439
+ */
440
+ private displayMiddlewareStartupLogs;
441
+ /**
442
+ * Display startup banner with application metrics.
443
+ * @param appInfo - Application info
444
+ * @private
445
+ */
446
+ private displayStartupBanner;
447
+ /**
448
+ * Display CI detection logs after the banner but before middleware logs.
449
+ * @param appInfo - Application info containing CI detection data
450
+ * @private
451
+ */
452
+ private displayCIDetectionLogs;
453
+ }
@@ -0,0 +1,23 @@
1
+ import express from "express";
2
+ /**
3
+ * ExpressHandler Type
4
+ *
5
+ * The ExpressHandler type is a union type that represents various types of Express middleware functions.
6
+ * It can be one of the following types:
7
+ * - express.ErrorRequestHandler: Handles errors in the middleware pipeline.
8
+ * - express.RequestParamHandler: Handles parameters in the middleware pipeline.
9
+ * - express.RequestHandler: General request handler.
10
+ * - undefined: Represents the absence of a handler.
11
+ */
12
+ export type ExpressHandler = express.ErrorRequestHandler | express.RequestParamHandler | express.RequestHandler | undefined;
13
+ /**
14
+ * MiddlewareConfig Interface
15
+ *
16
+ * The MiddlewareConfig interface specifies the structure for middleware configuration objects.
17
+ * - path: Optional. The route path for which the middleware is configured.
18
+ * - middlewares: An array of ExpressHandler types that make up the middleware pipeline for the route specified by 'path'.
19
+ */
20
+ export type MiddlewareConfig = {
21
+ path?: string;
22
+ middlewares: Array<ExpressHandler>;
23
+ };
@@ -0,0 +1,8 @@
1
+ import type { NextFunction, Request, Response } from "express";
2
+ import { interfaces as inversifyInterfaces } from "@expressots/core";
3
+ import type { HttpContext } from "./interfaces.js";
4
+ export declare abstract class BaseMiddleware implements BaseMiddleware {
5
+ httpContext: HttpContext;
6
+ protected bind<T>(serviceIdentifier: inversifyInterfaces.ServiceIdentifier<T>): inversifyInterfaces.BindingToSyntax<T>;
7
+ abstract handler(req: Request, res: Response, next: NextFunction): void;
8
+ }
@@ -0,0 +1,97 @@
1
+ import type { Request } from "express";
2
+ import type { Middleware, MiddlewareClass } from "./interfaces.js";
3
+ /**
4
+ * Type definition for middleware condition functions.
5
+ * Can be synchronous (returns boolean) or asynchronous (returns Promise<boolean>).
6
+ */
7
+ export type MiddlewareCondition = (req: Request) => boolean | Promise<boolean>;
8
+ /**
9
+ * Configuration object for conditional middleware execution.
10
+ * When the condition evaluates to true, the middleware is executed.
11
+ * When false, the middleware is skipped and next() is called.
12
+ */
13
+ export interface ConditionalMiddlewareConfig {
14
+ /**
15
+ * The condition function that determines whether the middleware should execute.
16
+ * Receives the Express Request object and returns a boolean or Promise<boolean>.
17
+ */
18
+ condition: MiddlewareCondition;
19
+ /**
20
+ * The middleware to execute when the condition is true.
21
+ * Can be any valid ExpressoTS middleware type (function, class instance, or container-bound).
22
+ */
23
+ middleware: Middleware;
24
+ /**
25
+ * Whether to skip middleware execution when condition is false.
26
+ * Default: true (skip if condition is false, execute if true)
27
+ * If false, the behavior is inverted (execute if condition is false).
28
+ */
29
+ skipOnFalse?: boolean;
30
+ }
31
+ /**
32
+ * Symbol to identify conditional middleware configuration objects.
33
+ * Used internally for type checking.
34
+ */
35
+ export declare const CONDITIONAL_MIDDLEWARE_SYMBOL: unique symbol;
36
+ /**
37
+ * Type guard to check if an object is a ConditionalMiddlewareConfig.
38
+ */
39
+ export declare function isConditionalMiddleware(item: unknown): item is ConditionalMiddlewareConfig;
40
+ /**
41
+ * Creates a conditional middleware configuration that executes the middleware
42
+ * when the condition evaluates to true.
43
+ *
44
+ * @param condition - Function that receives the Request and returns boolean or Promise<boolean>
45
+ * @param middleware - The middleware to execute when condition is true
46
+ * @returns ConditionalMiddlewareConfig object
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * // Phase 2: Class reference support - no 'new' keyword needed
51
+ * @Get("/admin",
52
+ * when(req => req.hostname.startsWith("admin."), AdminMiddleware),
53
+ * AuthMiddleware
54
+ * )
55
+ * async adminHandler() {}
56
+ * ```
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * // Async condition with class reference (Phase 2)
61
+ * @Get("/api",
62
+ * when(async req => {
63
+ * const user = await getUser(req);
64
+ * return user.isAdmin;
65
+ * }, AdminMiddleware)
66
+ * )
67
+ * async apiHandler() {}
68
+ * ```
69
+ */
70
+ export declare function when(condition: MiddlewareCondition, middleware: Middleware | MiddlewareClass | any): ConditionalMiddlewareConfig;
71
+ /**
72
+ * Creates a conditional middleware configuration that executes the middleware
73
+ * when the condition evaluates to false (inverse of `when`).
74
+ *
75
+ * @param condition - Function that receives the Request and returns boolean or Promise<boolean>
76
+ * @param middleware - The middleware to execute when condition is false
77
+ * @returns ConditionalMiddlewareConfig object
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * // Phase 2: Class reference support - no 'new' keyword needed
82
+ * @Get("/public",
83
+ * unless(req => req.headers.authorization, AuthMiddleware)
84
+ * )
85
+ * async publicHandler() {}
86
+ * ```
87
+ *
88
+ * @example
89
+ * ```typescript
90
+ * // Skip authentication for public routes (Phase 2: class reference)
91
+ * @Get("/health",
92
+ * unless(req => req.path.startsWith("/api"), AuthMiddleware)
93
+ * )
94
+ * async healthCheck() {}
95
+ * ```
96
+ */
97
+ export declare function unless(condition: MiddlewareCondition, middleware: Middleware | MiddlewareClass | any): ConditionalMiddlewareConfig;
@@ -0,0 +1,57 @@
1
+ export declare const TYPE: {
2
+ AuthProvider: symbol;
3
+ Controller: symbol;
4
+ HttpContext: symbol;
5
+ };
6
+ export declare const METADATA_KEY: {
7
+ controller: string;
8
+ controllerMethod: string;
9
+ controllerParameter: string;
10
+ httpContext: string;
11
+ version: string;
12
+ accept: string;
13
+ consumes: string;
14
+ produces: string;
15
+ csvOptions: string;
16
+ xmlOptions: string;
17
+ yamlOptions: string;
18
+ streamResponse: string;
19
+ validationSchema: string;
20
+ validationOptions: string;
21
+ exceptionFilter: string;
22
+ controllerExceptionFilters: string;
23
+ methodExceptionFilters: string;
24
+ };
25
+ export declare const HTTP_CODE_METADATA: {
26
+ httpCode: string;
27
+ statusCode: string;
28
+ path: string;
29
+ };
30
+ export declare const RENDER_METADATA_KEY: unique symbol;
31
+ export declare enum PARAMETER_TYPE {
32
+ REQUEST = 0,
33
+ RESPONSE = 1,
34
+ PARAMS = 2,
35
+ QUERY = 3,
36
+ BODY = 4,
37
+ HEADERS = 5,
38
+ COOKIES = 6,
39
+ NEXT = 7,
40
+ PRINCIPAL = 8
41
+ }
42
+ export declare enum HTTP_VERBS_ENUM {
43
+ all = "ALL",
44
+ connect = "CONNECT",
45
+ delete = "DELETE",
46
+ get = "GET",
47
+ head = "HEAD",
48
+ options = "OPTIONS",
49
+ patch = "PATCH",
50
+ post = "POST",
51
+ propfind = "PROPFIND",
52
+ put = "PUT",
53
+ trace = "TRACE"
54
+ }
55
+ export declare const DUPLICATED_CONTROLLER_NAME: (name: string) => string;
56
+ export declare const NO_CONTROLLERS_FOUND = "No controller found! Please ensure that you have register at least one Controller.";
57
+ export declare const DEFAULT_ROUTING_ROOT_PATH = "/";
@@ -0,0 +1,6 @@
1
+ import type { OutgoingHttpHeaders } from "node:http";
2
+ export declare abstract class HttpContent {
3
+ private _headers;
4
+ get headers(): OutgoingHttpHeaders;
5
+ abstract readAsync(): Promise<string | Record<string, unknown> | Record<string, unknown>[]>;
6
+ }