@forinda/kickjs 6.1.1 → 6.3.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 (167) hide show
  1. package/README.md +15 -0
  2. package/dist/{adapter-D_uzU-QA.d.mts → adapter-stSpsUHs.d.mts} +63 -17
  3. package/dist/adapter-stSpsUHs.d.mts.map +1 -0
  4. package/dist/{app-module-CuAS6hJC.d.mts → app-module-BwYtACD6.d.mts} +3 -3
  5. package/dist/{app-module-CuAS6hJC.d.mts.map → app-module-BwYtACD6.d.mts.map} +1 -1
  6. package/dist/application-CHYTI1Q_.mjs +12 -0
  7. package/dist/application-CHYTI1Q_.mjs.map +1 -0
  8. package/dist/{application-CFenLjbY.d.mts → application-C_KlrNoH.d.mts} +4 -4
  9. package/dist/{application-CFenLjbY.d.mts.map → application-C_KlrNoH.d.mts.map} +1 -1
  10. package/dist/{bootstrap-DodgsiDG.d.mts → bootstrap-BgffgFNX.d.mts} +2 -2
  11. package/dist/{bootstrap-DodgsiDG.d.mts.map → bootstrap-BgffgFNX.d.mts.map} +1 -1
  12. package/dist/{bootstrap-Dj96_O6j.mjs → bootstrap-sB0dlLu7.mjs} +3 -3
  13. package/dist/{bootstrap-Dj96_O6j.mjs.map → bootstrap-sB0dlLu7.mjs.map} +1 -1
  14. package/dist/{cache-BSFDtsEG.d.mts → cache-CwZzIH0D.d.mts} +9 -11
  15. package/dist/cache-CwZzIH0D.d.mts.map +1 -0
  16. package/dist/config/index.d.mts +1 -1
  17. package/dist/config/index.mjs +2 -2
  18. package/dist/{config-sXLOhrp4.mjs → config-DqO6gB-n.mjs} +3 -3
  19. package/dist/{config-sXLOhrp4.mjs.map → config-DqO6gB-n.mjs.map} +1 -1
  20. package/dist/container-C522k8AX.mjs +108 -0
  21. package/dist/container-C522k8AX.mjs.map +1 -0
  22. package/dist/{container-TWOUyR_0.d.mts → container-iED1swkd.d.mts} +19 -3
  23. package/dist/container-iED1swkd.d.mts.map +1 -0
  24. package/dist/context-Cmnmn68a.mjs +12 -0
  25. package/dist/context-Cmnmn68a.mjs.map +1 -0
  26. package/dist/contributor-runner-C4qFEVIz.mjs +13 -0
  27. package/dist/contributor-runner-C4qFEVIz.mjs.map +1 -0
  28. package/dist/core/adapter.d.mts +1 -1
  29. package/dist/core/adapter.mjs +1 -1
  30. package/dist/core/app-module.d.mts +1 -1
  31. package/dist/core/app-module.mjs +1 -1
  32. package/dist/core/cache.d.mts +1 -1
  33. package/dist/core/cache.mjs +2 -2
  34. package/dist/core/cache.mjs.map +1 -1
  35. package/dist/core/container.d.mts +1 -1
  36. package/dist/core/container.mjs +2 -2
  37. package/dist/core/cron.mjs +2 -2
  38. package/dist/core/decorators.d.mts +2 -2
  39. package/dist/core/decorators.mjs +2 -2
  40. package/dist/core/decorators.mjs.map +1 -1
  41. package/dist/core/errors.mjs +1 -1
  42. package/dist/core/interfaces.d.mts +1 -1
  43. package/dist/core/interfaces.mjs +2 -2
  44. package/dist/core/interfaces.mjs.map +1 -1
  45. package/dist/core/logger.mjs +2 -2
  46. package/dist/core/logger.mjs.map +1 -1
  47. package/dist/core/path.mjs +1 -1
  48. package/dist/core/plugin.d.mts +1 -1
  49. package/dist/core/plugin.mjs +1 -1
  50. package/dist/core/reactivity.d.mts +1 -1
  51. package/dist/core/reactivity.mjs +2 -2
  52. package/dist/core/reactivity.mjs.map +1 -1
  53. package/dist/core-3S12kJ7Q.mjs +12 -0
  54. package/dist/core-3S12kJ7Q.mjs.map +1 -0
  55. package/dist/csrf-7nUXGTuz.d.mts.map +1 -1
  56. package/dist/csrf-CbB5oAPn.mjs +12 -0
  57. package/dist/csrf-CbB5oAPn.mjs.map +1 -0
  58. package/dist/{decorators-ejABLo9H.d.mts → decorators-wEJBqXHg.d.mts} +21 -5
  59. package/dist/decorators-wEJBqXHg.d.mts.map +1 -0
  60. package/dist/disposables-BBTIbZkX.mjs +12 -0
  61. package/dist/disposables-BBTIbZkX.mjs.map +1 -0
  62. package/dist/env-Cj5QLqnZ.mjs +13 -0
  63. package/dist/{env-RP8lbK-Z.mjs.map → env-Cj5QLqnZ.mjs.map} +1 -1
  64. package/dist/handler-db1-nMd6.mjs +12 -0
  65. package/dist/handler-db1-nMd6.mjs.map +1 -0
  66. package/dist/http/application.d.mts +1 -1
  67. package/dist/http/application.mjs +2 -2
  68. package/dist/http/bootstrap.d.mts +1 -1
  69. package/dist/http/bootstrap.mjs +2 -2
  70. package/dist/http/context.d.mts +3 -3
  71. package/dist/http/context.mjs +2 -2
  72. package/dist/http/middleware/cors.mjs +1 -1
  73. package/dist/http/middleware/csrf.mjs +2 -3
  74. package/dist/http/middleware/error-handler.mjs +2 -2
  75. package/dist/http/middleware/helmet.mjs +1 -1
  76. package/dist/http/middleware/rate-limit.mjs +2 -2
  77. package/dist/http/middleware/rate-limit.mjs.map +1 -1
  78. package/dist/http/middleware/request-id.mjs +2 -2
  79. package/dist/http/middleware/request-id.mjs.map +1 -1
  80. package/dist/http/middleware/request-logger.mjs +2 -2
  81. package/dist/http/middleware/session.mjs +2 -2
  82. package/dist/http/middleware/session.mjs.map +1 -1
  83. package/dist/http/middleware/spa.d.mts +1 -1
  84. package/dist/http/middleware/spa.mjs +2 -2
  85. package/dist/http/middleware/spa.mjs.map +1 -1
  86. package/dist/http/middleware/upload.d.mts +2 -2
  87. package/dist/http/middleware/upload.mjs +3 -3
  88. package/dist/http/middleware/upload.mjs.map +1 -1
  89. package/dist/http/middleware/validate.mjs +2 -2
  90. package/dist/http/middleware/validate.mjs.map +1 -1
  91. package/dist/http/middleware/views.d.mts +1 -1
  92. package/dist/http/middleware/views.mjs +2 -2
  93. package/dist/http/query/index.mjs +2 -2
  94. package/dist/http/router-builder.d.mts +1 -1
  95. package/dist/http/router-builder.mjs +2 -2
  96. package/dist/http/router-builder.mjs.map +1 -1
  97. package/dist/http/runtimes/fastify.d.mts +1 -1
  98. package/dist/http/runtimes/fastify.d.mts.map +1 -1
  99. package/dist/http/runtimes/fastify.mjs +3 -3
  100. package/dist/http/runtimes/fastify.mjs.map +1 -1
  101. package/dist/http/runtimes/h3-web.d.mts +52 -0
  102. package/dist/http/runtimes/h3-web.d.mts.map +1 -0
  103. package/dist/http/runtimes/h3-web.mjs +12 -0
  104. package/dist/http/runtimes/h3-web.mjs.map +1 -0
  105. package/dist/http/runtimes/h3.d.mts +10 -4
  106. package/dist/http/runtimes/h3.d.mts.map +1 -1
  107. package/dist/http/runtimes/h3.mjs +2 -2
  108. package/dist/http/runtimes/h3.mjs.map +1 -1
  109. package/dist/{index-zIcb4wjg.d.mts → index-D98NLfS5.d.mts} +2 -2
  110. package/dist/{index-zIcb4wjg.d.mts.map → index-D98NLfS5.d.mts.map} +1 -1
  111. package/dist/index.d.mts +16 -15
  112. package/dist/index.mjs +2 -2
  113. package/dist/index.mjs.map +1 -1
  114. package/dist/{interfaces-DbTyKGdS.d.mts → interfaces-CayXPOAf.d.mts} +2 -1
  115. package/dist/{interfaces-DbTyKGdS.d.mts.map → interfaces-CayXPOAf.d.mts.map} +1 -1
  116. package/dist/{metadata-C-yduM8v.mjs → metadata-W54KhZoU.mjs} +2 -2
  117. package/dist/{metadata-C-yduM8v.mjs.map → metadata-W54KhZoU.mjs.map} +1 -1
  118. package/dist/module-registry-BbYVBwD9.mjs +12 -0
  119. package/dist/module-registry-BbYVBwD9.mjs.map +1 -0
  120. package/dist/{query-C0vJlGKm.mjs → query-B0ucxuU0.mjs} +2 -2
  121. package/dist/{query-C0vJlGKm.mjs.map → query-B0ucxuU0.mjs.map} +1 -1
  122. package/dist/rate-limit-oLL5EPUf.d.mts.map +1 -1
  123. package/dist/{reactivity-DWmLcN0A.d.mts → reactivity-XL0fFDvG.d.mts} +10 -16
  124. package/dist/reactivity-XL0fFDvG.d.mts.map +1 -0
  125. package/dist/reply-2CvBP_Sl.d.mts +63 -0
  126. package/dist/reply-2CvBP_Sl.d.mts.map +1 -0
  127. package/dist/reply-DI4EqF0R.mjs +12 -0
  128. package/dist/reply-DI4EqF0R.mjs.map +1 -0
  129. package/dist/request-id-IDobbxU-.d.mts.map +1 -1
  130. package/dist/rolldown-runtime-Dv-xQPN8.mjs +11 -0
  131. package/dist/{router-builder-Bh3qSiDz.d.mts → router-builder-BK7yPm89.d.mts} +2 -2
  132. package/dist/router-builder-BK7yPm89.d.mts.map +1 -0
  133. package/dist/session-DSRA-PUX.d.mts.map +1 -1
  134. package/dist/{spa-BdvZFXJz.d.mts → spa-BwO1qOuA.d.mts} +2 -2
  135. package/dist/{spa-BdvZFXJz.d.mts.map → spa-BwO1qOuA.d.mts.map} +1 -1
  136. package/dist/{upload-Bc_rBRtE.d.mts → upload-CIZc803m.d.mts} +9 -7
  137. package/dist/upload-CIZc803m.d.mts.map +1 -0
  138. package/dist/upload-config-D8gsl_ox.mjs +12 -0
  139. package/dist/upload-config-D8gsl_ox.mjs.map +1 -0
  140. package/dist/validate-DoZDOhCi.d.mts.map +1 -1
  141. package/dist/{views-DcTVDiOh.d.mts → views-w0EPrhui.d.mts} +7 -5
  142. package/dist/views-w0EPrhui.d.mts.map +1 -0
  143. package/dist/web.d.mts +150 -0
  144. package/dist/web.d.mts.map +1 -0
  145. package/dist/web.mjs +12 -0
  146. package/dist/web.mjs.map +1 -0
  147. package/package.json +22 -13
  148. package/dist/adapter-D_uzU-QA.d.mts.map +0 -1
  149. package/dist/application-KaKi6jgi.mjs +0 -12
  150. package/dist/application-KaKi6jgi.mjs.map +0 -1
  151. package/dist/cache-BSFDtsEG.d.mts.map +0 -1
  152. package/dist/container-Oy24XRnS.mjs +0 -108
  153. package/dist/container-Oy24XRnS.mjs.map +0 -1
  154. package/dist/container-TWOUyR_0.d.mts.map +0 -1
  155. package/dist/context-Co72dNA_.mjs +0 -12
  156. package/dist/context-Co72dNA_.mjs.map +0 -1
  157. package/dist/core-kmJ4y4fJ.mjs +0 -13
  158. package/dist/core-kmJ4y4fJ.mjs.map +0 -1
  159. package/dist/decorators-ejABLo9H.d.mts.map +0 -1
  160. package/dist/env-RP8lbK-Z.mjs +0 -13
  161. package/dist/http/middleware/csrf.mjs.map +0 -1
  162. package/dist/reactivity-DWmLcN0A.d.mts.map +0 -1
  163. package/dist/request-scope-C_taFScZ.mjs +0 -12
  164. package/dist/request-scope-C_taFScZ.mjs.map +0 -1
  165. package/dist/router-builder-Bh3qSiDz.d.mts.map +0 -1
  166. package/dist/upload-Bc_rBRtE.d.mts.map +0 -1
  167. package/dist/views-DcTVDiOh.d.mts.map +0 -1
package/README.md CHANGED
@@ -132,6 +132,20 @@ export const app = await bootstrap({ modules, runtime: fastifyRuntime() })
132
132
 
133
133
  `kick new --runtime express|fastify|h3` scaffolds the right peers. File uploads (`@FileUpload` → `ctx.file` / `ctx.files`) and the rest of the surface work the same on all three. See [HTTP Runtimes](https://kickjs.app/guide/http-runtimes.html).
134
134
 
135
+ Two web-standard entries sit alongside them (h3 v2 engine — additive, the v1 runtime is untouched):
136
+
137
+ ```ts
138
+ import { h3WebRuntime } from '@forinda/kickjs/h3-web' // bootstrap() on node, WHATWG pipeline
139
+ import { createWebApp } from '@forinda/kickjs/web' // fetch(Request) → Response — Workers / Bun / Deno
140
+ import * as h3 from 'h3' // v2 — passed in: edge bundlers have no createRequire
141
+ import { modules } from './modules'
142
+
143
+ const app = createWebApp({ h3, modules })
144
+ export default { fetch: (req: Request) => app.fetch(req) }
145
+ ```
146
+
147
+ See [Edge Deployment](https://kickjs.app/guide/edge-deployment.html).
148
+
135
149
  ## Project Layout
136
150
 
137
151
  `kick new` produces this convention; everything except the bootstrap entry is configurable via `kick.config.ts`:
@@ -157,6 +171,7 @@ vite.config.ts # Vite + KickJS HMR
157
171
  ## Core Concepts
158
172
 
159
173
  - **Pluggable HTTP runtimes** — one `HttpRuntime` seam over Express (default), Fastify, or h3. Swap the engine in one line; everything above stays the same. See [HTTP Runtimes](https://kickjs.app/guide/http-runtimes.html).
174
+ - **Return-value handlers + typed client** — `return` the payload (`reply(201, body)` for other statuses) and the response type flows through `kick typegen` into `KickRoutes.Api`, consumed by [`@forinda/kickjs-client`](https://kickjs.app/guide/typed-client.html) on the frontend. Declare `{ response: schema }` on a route and the same contract feeds the OpenAPI success response. See [Controllers](https://kickjs.app/guide/controllers.html#return-value-handlers), [Typed Client](https://kickjs.app/guide/typed-client.html).
160
175
  - **First-class database** — `kick/db`: code-first schema, fully typed queries, and migrations for PostgreSQL / SQLite / MySQL. `kick add db` (or `pg` / `sqlite` / `mysql`). See [Database](https://kickjs.app/guide/database/).
161
176
  - **Custom DI container** — three scopes (singleton / transient / request), slash-delimited tokens (`createToken<T>('app/users/repository')`), constructor + property injection. No external DI dep. See [Dependency Injection](https://kickjs.app/guide/dependency-injection.html).
162
177
  - **Factory-first** — `defineAdapter()`, `definePlugin()`, `defineModule()`, `defineHttpContextDecorator()`. No class hierarchies to inherit from. See [Adapters](https://kickjs.app/guide/adapters.html), [Plugins](https://kickjs.app/guide/plugins.html).
@@ -1,8 +1,8 @@
1
1
 
2
- import { i as Constructor, o as MaybePromise } from "./interfaces-DbTyKGdS.mjs";
3
- import { s as InjectionToken, t as Container } from "./container-TWOUyR_0.mjs";
4
- import { O as RouteDefinition, g as FileUploadConfig, x as MiddlewareHandler } from "./decorators-ejABLo9H.mjs";
5
- import { _ as ExecutionContext, a as AnyContributorRegistration, d as ContributorRegistrations, r as AppModuleEntry, t as AppModule, v as MetaValue } from "./app-module-CuAS6hJC.mjs";
2
+ import { i as Constructor, o as MaybePromise } from "./interfaces-CayXPOAf.mjs";
3
+ import { s as InjectionToken, t as Container } from "./container-iED1swkd.mjs";
4
+ import { g as FileUploadConfig, k as RouteDefinition, x as MiddlewareHandler } from "./decorators-wEJBqXHg.mjs";
5
+ import { _ as ExecutionContext, a as AnyContributorRegistration, d as ContributorRegistrations, r as AppModuleEntry, t as AppModule, v as MetaValue } from "./app-module-BwYtACD6.mjs";
6
6
  import { i as ProblemDetails } from "./errors-n0H96eEz.mjs";
7
7
  import { S as QueryFieldConfig, T as TypedParsedQuery, t as ParseQueryOptions } from "./index-BtWJ9SLP.mjs";
8
8
  import http, { IncomingMessage, ServerResponse } from "node:http";
@@ -688,6 +688,25 @@ declare class ModuleList extends Array<AppModuleEntry> {
688
688
  */
689
689
  declare function defineModules(...initial: AppModuleEntry[]): ModuleList;
690
690
  //#endregion
691
+ //#region src/core/disposables.d.ts
692
+ /**
693
+ * Registry for framework-owned resources that hold timers or other handles
694
+ * outside the adapter/plugin lifecycle — e.g. the in-memory session and
695
+ * rate-limit stores' cleanup intervals. `Application.shutdown()` drains it so
696
+ * startup and shutdown stay symmetric even for resources created lazily by
697
+ * middleware factories.
698
+ *
699
+ * Intervals are `.unref()`'d so they never wedge process exit — this registry
700
+ * exists for IN-PROCESS teardown (test suites, HMR, multi-app hosts) where
701
+ * each un-disposed store would otherwise leak a live interval + backing Map
702
+ * per app instance.
703
+ */
704
+ type Disposable = () => void | Promise<void>;
705
+ /** Register a cleanup callback. Returns an unregister function. */
706
+ declare function registerDisposable(fn: Disposable): () => void;
707
+ /** Run and clear all registered disposables. Errors are swallowed per-entry. */
708
+ declare function disposeAll(): Promise<void>;
709
+ //#endregion
691
710
  //#region src/core/kick-error.d.ts
692
711
  /**
693
712
  * Structured framework error with code, cause, and actionable fix hint.
@@ -1335,6 +1354,8 @@ declare class RequestContext<TBody = any, TParams = any, TQuery = any> implement
1335
1354
  * parse instead of re-walking the filter/sort strings.
1336
1355
  */
1337
1356
  private _qsMemo?;
1357
+ /** Memoized {@link problem} sender — built lazily on first access. */
1358
+ private _problem?;
1338
1359
  /**
1339
1360
  * Read-side accessor for the per-request metadata map.
1340
1361
  *
@@ -1603,26 +1624,49 @@ declare class RequestContext<TBody = any, TParams = any, TQuery = any> implement
1603
1624
  * Start an SSE (Server-Sent Events) stream.
1604
1625
  * Sets the correct headers and returns helpers to send events.
1605
1626
  *
1627
+ * Pass a payload type to get typed sends — and `return sse` from the
1628
+ * handler so `kick typegen` carries the event type into
1629
+ * `KickRoutes.Api`, where `@forinda/kickjs-client`'s `api.stream()`
1630
+ * picks it up (the returned handler is ignored at runtime — the
1631
+ * response is already streaming).
1632
+ *
1606
1633
  * @example
1607
1634
  * ```ts
1635
+ * interface Tick { time: string }
1636
+ *
1608
1637
  * @Get('/events')
1609
1638
  * async stream(ctx: RequestContext) {
1610
- * const sse = ctx.sse()
1639
+ * const sse = ctx.sse<Tick>()
1611
1640
  *
1612
1641
  * const interval = setInterval(() => {
1613
1642
  * sse.send({ time: new Date().toISOString() }, 'tick')
1614
1643
  * }, 1000)
1615
1644
  *
1616
1645
  * sse.onClose(() => clearInterval(interval))
1646
+ * return sse // typed as SseHandler<Tick> → response inference
1617
1647
  * }
1618
1648
  * ```
1619
1649
  */
1620
- sse(): {
1621
- /** Send an SSE event with optional event name and id */send: (data: any, event?: string, id?: string) => void; /** Send a comment (keeps connection alive) */
1622
- comment: (text: string) => void; /** Register a callback when the client disconnects */
1623
- onClose: (fn: () => void) => void; /** End the SSE stream */
1624
- close: () => void;
1625
- };
1650
+ sse<T = unknown>(): SseHandler<T>;
1651
+ }
1652
+ /**
1653
+ * The handle {@link RequestContext.sse} returns. The optional phantom
1654
+ * `__sse` property carries the event payload type STRUCTURALLY — never set
1655
+ * at runtime — so `kick typegen`'s response inference (handler `return sse`)
1656
+ * flows it into `KickRoutes.Api`, and `@forinda/kickjs-client` detects SSE
1657
+ * routes without importing any server types.
1658
+ */
1659
+ interface SseHandler<T = unknown> {
1660
+ /** Phantom event-payload type marker — never assigned at runtime. */
1661
+ readonly __sse?: T;
1662
+ /** Send an SSE event with optional event name and id. */
1663
+ send(data: T, event?: string, id?: string): void;
1664
+ /** Send a comment line (keeps the connection alive through proxies). */
1665
+ comment(text: string): void;
1666
+ /** Register a callback for client disconnect. */
1667
+ onClose(fn: () => void): void;
1668
+ /** End the SSE stream. */
1669
+ close(): void;
1626
1670
  }
1627
1671
  /**
1628
1672
  * Short alias for `RequestContext` parameterised by a route shape.
@@ -1653,11 +1697,13 @@ type Ctx<TRoute extends RouteShape = RouteShape> = RequestContext<TRoute extends
1653
1697
  /**
1654
1698
  * Global ambient registry of typed routes, populated by `kick typegen`.
1655
1699
  *
1656
- * Each interface inside `KickRoutes` corresponds to a controller class;
1657
- * each property is one route method on that controller. The values
1658
- * conform to `RouteShape`.
1700
+ * Interfaces inside `KickRoutes` correspond to controller classes (each
1701
+ * property one route method, conforming to `RouteShape`) — plus the
1702
+ * reserved `KickRoutes.Api`: a flat `'METHOD /mounted/path'` map over the
1703
+ * same shapes, consumed by `@forinda/kickjs-client`. Don't name a
1704
+ * controller class `Api` — it would declaration-merge into that map.
1659
1705
  *
1660
- * Empty by default — declarations come from `.kickjs/types/routes.d.ts`
1706
+ * Empty by default — declarations come from `.kickjs/types/kick__routes.ts`
1661
1707
  * generated alongside the rest of the typegen output.
1662
1708
  */
1663
1709
  declare global {
@@ -2117,5 +2163,5 @@ interface AppAdapter {
2117
2163
  /** Constructor type for AppAdapter classes */
2118
2164
  type AppAdapterClass = new () => AppAdapter;
2119
2165
  //#endregion
2120
- export { CircuitBreaker as $, GroupAssetKeysResult as A, definePlugin as At, MountKind as B, IntrospectionSnapshot as Bt, Ctx as C, DefineModuleOptions as Ct, AssetKeyPair as D, DefinePluginOptions as Dt, RouteShape as E, BuildContext as Et, DefineAdapterOptions as F, KickJsPluginName as Ft, BuildPipelineOptions as G, mountSort as H, defineAdapter as I, KickJsPluginRegistry as It, SourcedRegistration as J, ContributorPipeline as K, DuplicateMountNameError as L, defineAugmentation as Lt, stripExt as M, ModuleRegistry as Mt, AdapterAsyncOptions as N, MutableModuleRegistry as Nt, AssetKeyStrategy as O, PluginAsyncOptions as Ot, AdapterFactory as P, AugmentationMeta as Pt, MissingContributorError as Q, MissingMountDepError as R, IntrospectFn as Rt, UseConnectOptions as S, defineModules as St, RequestContext as T, defineModule as Tt, RunContributorsOptions as U, MountSortItem as V, runContributors as W, ContributorCycleError as X, buildPipeline as Y, DuplicateContributorError as Z, RouteTable as _, FormatKickErrorOptions as _t, MiddlewarePath as a, getClassMetaOrUndefined as at, RuntimeResponse as b, formatKickError as bt, AdapterHttp as c, getMethodMeta as ct, ExpressRuntimeTypes as d, pushClassMeta as dt, CircuitBreakerOptions as et, HttpRuntime as f, pushMethodMeta as ft, RouteMethod as g, setMethodMeta as gt, RouteMeta as h, setInMetaRecord as ht, AppAdapterClass as i, getClassMeta as it, groupAssetKeys as j, KickPlugin as jt, GroupAssetKeysOptions as k, PluginFactory as kt, ConnectMiddleware as l, getMethodMetaOrUndefined as lt, RouteEntry as m, setInMetaMap as mt, AdapterMiddleware as n, CircuitBreakerStats as nt, MiddlewarePhase as o, getMetaMap as ot, KickRuntimeRegister as p, setClassMeta as pt, ContributorSource as q, AppAdapter as r, CircuitOpenError as rt, ActiveRuntime as s, getMetaRecord as st, AdapterContext as t, CircuitBreakerState as tt, CtxHandler as u, hasClassMeta as ut, RuntimeAppOptions as v, KickError as vt, DeepReadonly as w, ModuleFactory as wt, RuntimeTypeMap as x, ModuleList as xt, RuntimeCapabilities as y, KickErrorInit as yt, MountCycleError as z, IntrospectionKind as zt };
2121
- //# sourceMappingURL=adapter-D_uzU-QA.d.mts.map
2166
+ export { MissingContributorError as $, GroupAssetKeysOptions as A, BuildContext as At, MountCycleError as B, KickJsPluginRegistry as Bt, Ctx as C, disposeAll as Ct, SseHandler as D, DefineModuleOptions as Dt, RouteShape as E, defineModules as Et, AdapterFactory as F, KickPlugin as Ft, runContributors as G, MountSortItem as H, IntrospectFn as Ht, DefineAdapterOptions as I, ModuleRegistry as It, ContributorSource as J, BuildPipelineOptions as K, defineAdapter as L, MutableModuleRegistry as Lt, groupAssetKeys as M, PluginAsyncOptions as Mt, stripExt as N, PluginFactory as Nt, AssetKeyPair as O, ModuleFactory as Ot, AdapterAsyncOptions as P, definePlugin as Pt, DuplicateContributorError as Q, DuplicateMountNameError as R, AugmentationMeta as Rt, UseConnectOptions as S, Disposable as St, RequestContext as T, ModuleList as Tt, mountSort as U, IntrospectionKind as Ut, MountKind as V, defineAugmentation as Vt, RunContributorsOptions as W, IntrospectionSnapshot as Wt, buildPipeline as X, SourcedRegistration as Y, ContributorCycleError as Z, RouteTable as _, setMethodMeta as _t, MiddlewarePath as a, getClassMeta as at, RuntimeResponse as b, KickErrorInit as bt, AdapterHttp as c, getMetaRecord as ct, ExpressRuntimeTypes as d, hasClassMeta as dt, CircuitBreaker as et, HttpRuntime as f, pushClassMeta as ft, RouteMethod as g, setInMetaRecord as gt, RouteMeta as h, setInMetaMap as ht, AppAdapterClass as i, CircuitOpenError as it, GroupAssetKeysResult as j, DefinePluginOptions as jt, AssetKeyStrategy as k, defineModule as kt, ConnectMiddleware as l, getMethodMeta as lt, RouteEntry as m, setClassMeta as mt, AdapterMiddleware as n, CircuitBreakerState as nt, MiddlewarePhase as o, getClassMetaOrUndefined as ot, KickRuntimeRegister as p, pushMethodMeta as pt, ContributorPipeline as q, AppAdapter as r, CircuitBreakerStats as rt, ActiveRuntime as s, getMetaMap as st, AdapterContext as t, CircuitBreakerOptions as tt, CtxHandler as u, getMethodMetaOrUndefined as ut, RuntimeAppOptions as v, FormatKickErrorOptions as vt, DeepReadonly as w, registerDisposable as wt, RuntimeTypeMap as x, formatKickError as xt, RuntimeCapabilities as y, KickError as yt, MissingMountDepError as z, KickJsPluginName as zt };
2167
+ //# sourceMappingURL=adapter-stSpsUHs.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter-stSpsUHs.d.mts","names":[],"sources":["../src/core/introspect.ts","../src/core/augmentation.ts","../src/core/module-registry.ts","../src/core/plugin.ts","../src/core/define-plugin.ts","../src/core/define-module.ts","../src/core/define-modules.ts","../src/core/disposables.ts","../src/core/kick-error.ts","../src/core/metadata.ts","../src/core/circuit-breaker.ts","../src/core/context-errors.ts","../src/core/contributor-pipeline.ts","../src/core/contributor-runner.ts","../src/core/mount-sort.ts","../src/core/define-adapter.ts","../src/core/asset-keys.ts","../src/http/context.ts","../src/http/runtime.ts","../src/core/adapter.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAkBA;;;;;;UAAiB,q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AAAA;;KAIU,eAAA,aAA4B,UAAU"}
@@ -1,6 +1,6 @@
1
1
 
2
- import { i as Constructor, o as MaybePromise } from "./interfaces-DbTyKGdS.mjs";
3
- import { s as InjectionToken, t as Container } from "./container-TWOUyR_0.mjs";
2
+ import { i as Constructor, o as MaybePromise } from "./interfaces-CayXPOAf.mjs";
3
+ import { s as InjectionToken, t as Container } from "./container-iED1swkd.mjs";
4
4
  //#region src/core/execution-context.d.ts
5
5
  /**
6
6
  * Transport-agnostic execution context primitives.
@@ -522,4 +522,4 @@ type AppModuleClass = new () => AppModule;
522
522
  type AppModuleEntry = AppModuleClass | AppModule;
523
523
  //#endregion
524
524
  export { ExecutionContext as _, AnyContributorRegistration as a, ContextDecoratorTarget as c, ContributorRegistrations as d, DepValue as f, ContextMeta as g, ContextKeys as h, ModuleRoutes as i, ContextMetaKey as l, defineContextDecorator as m, AppModuleClass as n, ContextDecorator as o, ResolvedDeps as p, AppModuleEntry as r, ContextDecoratorSpec as s, AppModule as t, ContributorRegistration as u, MetaValue as v };
525
- //# sourceMappingURL=app-module-CuAS6hJC.d.mts.map
525
+ //# sourceMappingURL=app-module-BwYtACD6.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"app-module-CuAS6hJC.d.mts","names":[],"sources":["../src/core/execution-context.ts","../src/core/context-decorator.ts","../src/core/app-module.ts"],"mappings":";;;;;;;;;AA8CA;;;;AAA4B;AAgC5B;;;;AAA4B;AAG5B;;;;;;;;;;;;;;;;;;AAEY;AAUZ;;;;;;;;;;UA/CiB,WAAA;;;;;;;;;;;;;;;AAqDG;;;;AC/F4E;;;;AAuBpC;AAC5D;;;;AAAyF;AAUzF;UDwCiB,WAAA;;KAGL,SAAA,yCAAkD,CAAA,eAAgB,WAAA,GAC1E,WAAA,CAAY,CAAA,IACZ,QAAA;ACpCJ;;;;;;;;AAAA,UD8CiB,gBAAA;EC3CX;ED6CJ,GAAA,mBAAsB,GAAA,EAAK,CAAA,GAAI,SAAA,CAAU,CAAA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UEjEiB,YAAA;EFiEW;EE/D1B,IAAA;EFkEU;;;;;;EE3DV,MAAA;EF6DE;EE3DF,OAAA;EF2DU;;;;;EErDV,UAAA;AAAA;;;AFqDU;AAUZ;;;;;;;;UEjDiB,SAAA;EFqD+B;EEnD9C,QAAA,EAAU,SAAA,EAAW,SAAA;EFiDrB;;;;;;;;EExCA,YAAA,KAAiB,wBAAA;EF0CK;EExCtB,MAAA,IAAU,YAAA,GAAe,YAAA;AAAA;;;;AF0CP;;;;AC/F4E;;;;AAuBpC;AAC5D;KC6CY,cAAA,aAA2B,SAAS;;;AD7CyC;AAUzF;;;;AAA4D;AAS5D;;;;;;KC0CY,cAAA,GAAiB,cAAA,GAAiB,SAAS"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @forinda/kickjs v6.3.0
3
+ *
4
+ * Copyright (c) Felix Orinda
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */
11
+ import{METADATA}from"./core/interfaces.mjs";import{n as tokenName,o as moduleRouteMissingControllerError,t as Container}from"./container-C522k8AX.mjs";import{Logger,createLogger}from"./core/logger.mjs";import{t as getClassMeta}from"./metadata-W54KhZoU.mjs";import{g as mountSort}from"./core-3S12kJ7Q.mjs";import{t as MutableModuleRegistry}from"./module-registry-BbYVBwD9.mjs";import{i as runDisposables,n as drainDisposables,r as registerDisposable,t as disposeAll}from"./disposables-BBTIbZkX.mjs";import{normalizePath}from"./core/path.mjs";import{requestId}from"./http/middleware/request-id.mjs";import{errorHandler,notFoundHandler}from"./http/middleware/error-handler.mjs";import{i as requestStore,t as RequestContext}from"./context-Cmnmn68a.mjs";import{o as isRequestScopeMiddleware,s as requestScopeMiddleware,t as applyHandlerResult}from"./reply-DI4EqF0R.mjs";import{_setExternalContributorSources,buildRouteTable}from"./http/router-builder.mjs";import{validate}from"./http/middleware/validate.mjs";import{buildUploadMiddleware}from"./http/middleware/upload.mjs";import http from"node:http";import express,{Router}from"express";function materializeRouter(entries){let router=Router();for(let entry of entries){let method=entry.method.toLowerCase(),handlers=[];entry.meta.validation&&handlers.push(validate(entry.meta.validation)),entry.meta.upload&&handlers.push(buildUploadMiddleware(entry.meta.upload));for(let mw of entry.middlewares)handlers.push((req,res,next)=>{let ctx=new RequestContext(req,res,next);Promise.resolve(mw(ctx,next)).catch(next)});if(entry.contributorRunner){let run=entry.contributorRunner;handlers.push(async(req,res,next)=>{let ctx=new RequestContext(req,res,next);try{await run(ctx),next()}catch(err){next(err)}})}handlers.push(async(req,res,next)=>{let ctx=new RequestContext(req,res,next);try{let result=await entry.handler(ctx);res.headersSent||applyHandlerResult(ctx,result)}catch(err){next(err)}}),router[method](entry.path,...handlers)}return router}function buildRoutes(controllerClass,options={}){return materializeRouter(buildRouteTable(controllerClass,options))}function expressRuntime(){return{name:`express`,createApp(options={}){let app=express();return app.disable(`x-powered-by`),app.set(`trust proxy`,options.trustProxy??!1),app},nodeHandler(app){return(req,res,next)=>{next?app(req,res,next):app(req,res)}},mountRoutes(app,table){for(let{mountPath,routes}of table)app.use(mountPath,materializeRouter(routes))},useConnect(app,mw,opts={}){opts.path===void 0?app.use(mw):app.use(opts.path,mw)},serveStatic(app,prefix,dir){app.use(prefix,express.static(dir))},setNotFound(app,mw){app.use(mw)},setErrorHandler(app,mw){app.use(mw)},capabilities:{render:!0,uploads:!0,connectMiddleware:!0,nativeBodyParsing:!1}}}const log=createLogger(`Application`);var Application=class{options;app;runtime;container;httpServer=null;adapters;plugins;_moduleContributors=[];_inFlightRequests=0;_draining=!1;_shutdownInitiated=!1;_drainResolvers=[];constructor(options){this.options=options,this.runtime=options.runtime??expressRuntime(),this.app=this.runtime.createApp({trustProxy:options.trustProxy}),this.container=Container.getInstance(),this.plugins=mountSort(options.plugins??[],`plugin`);let allAdapters=[...this.plugins.flatMap(p=>p.adapters?.()??[]),...options.adapters??[]],anonAdapterCount=0,namedAdapters=allAdapters.map(adapter=>{if(!adapter.name){let ctorName=adapter.constructor?.name,fallback=ctorName&&ctorName!==`Object`?ctorName:`AnonymousAdapter#${anonAdapterCount++}`;return Object.assign(adapter,{name:fallback})}return adapter});this.adapters=mountSort(namedAdapters,`adapter`),Container._requestStoreProvider=()=>requestStore.getStore()??null}get isDraining(){return this._draining}get inFlightRequests(){return this._inFlightRequests}getContainer(){return this.container}handle(req,res,next){let handler=this.runtime.nodeHandler(this.app);next?handler(req,res,next):handler(req,res)}adapterCtx(server){let env=process.env.NODE_ENV??`development`;return{http:this.adapterHttp(),app:this.app,container:this.container,server,env,isProduction:env===`production`}}adapterHttp(){return{route:(method,path,handler)=>{let entry={method,path,middlewares:[],contributorRunner:null,handler,meta:{}};this.runtime.mountRoutes(this.app,[{mountPath:`/`,routes:[entry]}])},mount:(prefix,routes)=>{this.runtime.mountRoutes(this.app,[{mountPath:prefix,routes}])},serveStatic:(prefix,dir)=>{this.runtime.serveStatic(this.app,prefix,dir)},use:(mw,opts)=>{this.runtime.useConnect(this.app,mw,opts)}}}async callHook(hook,ctx){if(hook)try{let result=hook(ctx);result&&typeof result.then==`function`&&await result}catch(err){log.error(err,`Adapter hook failed`)}}async setup(){log.debug(`Bootstrapping application...`),this._moduleContributors=[];let adapterMw=this.collectAdapterMiddleware();this.app.__kickApp=this;let ctx=this.adapterCtx();for(let adapter of this.adapters)await this.callHook(adapter.beforeMount?.bind(adapter),ctx);this.runtime.useConnect(this.app,this.requestTrackingMiddleware()),this.mountHealthEndpoints(),this.shouldAutoMountRequestScope()&&this.runtime.useConnect(this.app,requestScopeMiddleware()),this.mountMiddlewareList(adapterMw.beforeGlobal);for(let plugin of this.plugins)plugin.register?.(this.container);for(let plugin of this.plugins)try{let mw=plugin.middleware?.()??[];for(let handler of mw)this.runtime.useConnect(this.app,handler)}catch(err){log.error(err,`Plugin middleware failed: ${plugin.name??`unknown`}`)}if(this.options.security?.helmet!==!1)try{let{helmet:helmetFn}=await import(`./http/middleware/helmet.mjs`);this.runtime.useConnect(this.app,helmetFn())}catch{}let userMiddlewares=this.options.middlewares??this.options.middleware;if(userMiddlewares)for(let entry of userMiddlewares)this.mountMiddlewareEntry(entry);else this.runtime.useConnect(this.app,requestId()),this.runtime.capabilities.nativeBodyParsing||this.runtime.useConnect(this.app,express.json({limit:this.options.jsonLimit??`1mb`}));this.mountMiddlewareList(adapterMw.afterGlobal);let moduleRegistry=new MutableModuleRegistry;for(let plugin of this.plugins){for(let m of plugin.modules?.()??[])moduleRegistry.mount(m);plugin.setup?.(moduleRegistry)}for(let m of this.options.modules)moduleRegistry.mount(m);this.options.setup?.(moduleRegistry);let modules=moduleRegistry.entries.map(entry=>{let mod=typeof entry==`function`?new entry:entry;return mod.register?.(this.container),mod});this.container.bootstrap(),this.container.has(Logger)||this.container.registerInstance(Logger,new Logger),this.mountMiddlewareList(adapterMw.beforeRoutes);let apiPrefix=this.options.apiPrefix??`/api`,defaultVersion=this.options.defaultVersion??1,shouldLogRoutes=this.options.logRouteTable??this.options.logRoutesTable??!1,mountedRoutes=[],adapterSources=[];for(let adapter of this.adapters){let adapterContribs=adapter.contributors?.()??[],adapterLabel=adapter.name??adapter.constructor.name??`adapter`;for(let registration of adapterContribs)adapterSources.push({source:`adapter`,registration,label:adapterLabel})}for(let plugin of this.plugins){let pluginContribs=plugin.contributors?.()??[],pluginLabel=plugin.name??plugin.constructor?.name??`plugin`;for(let registration of pluginContribs)adapterSources.push({source:`adapter`,registration,label:pluginLabel})}let globalSources=(this.options.contributors??[]).map(registration=>({source:`global`,registration,label:`bootstrap`}));this._moduleContributors=[];for(let mod of modules){let declaredName=mod.name,ctorName=mod.constructor?.name,moduleLabel=typeof declaredName==`string`&&declaredName.length>0?declaredName:ctorName&&ctorName!==`Object`?ctorName:`module`,moduleSources=(mod.contributors?.()??[]).map(registration=>({source:`module`,registration,label:moduleLabel}));for(let src of moduleSources)this._moduleContributors.push({registration:src.registration,label:moduleLabel});_setExternalContributorSources([...moduleSources,...adapterSources,...globalSources]);try{let result=mod.routes();if(!result)continue;let routeSets=Array.isArray(result)?result:[result];for(let route of routeSets){let mountPath=`${apiPrefix}/v${route.version??defaultVersion}${normalizePath(route.path)}`;if(route.router)this.runtime.useConnect(this.app,route.router,{path:mountPath});else if(route.controller)this.runtime.mountRoutes(this.app,[{mountPath,routes:buildRouteTable(route.controller)}]);else throw moduleRouteMissingControllerError(mountPath);if(route.controller){for(let adapter of this.adapters)try{adapter.onRouteMount?.(route.controller,mountPath)}catch(err){log.error(err,`adapter.onRouteMount() failed for ${mountPath}`)}shouldLogRoutes&&mountedRoutes.push({controller:route.controller,mountPath})}}}finally{_setExternalContributorSources([])}}if(shouldLogRoutes&&mountedRoutes.length>0){let methodOrder=[`GET`,`POST`,`PUT`,`PATCH`,`DELETE`,`HEAD`,`OPTIONS`],methodRank=m=>{let i=methodOrder.indexOf(m);return i===-1?99:i},totalRoutes=0;log.info(`Routes:`);for(let{controller,mountPath}of mountedRoutes){let defs=getClassMeta(METADATA.ROUTES,controller,[]);if(defs.length===0)continue;let counts={};for(let def of defs){let m=def.method.toUpperCase();counts[m]=(counts[m]||0)+1}totalRoutes+=defs.length;let methods=Object.entries(counts).toSorted(([a],[b])=>methodRank(a)-methodRank(b)).map(([m,n])=>`${n} ${m}`).join(`, `),name=controller.name||`Controller`;log.info(` ${name.padEnd(30)} ${mountPath.padEnd(25)} ${defs.length} routes (${methods})`)}log.info(` Total: ${totalRoutes} routes`)}this.mountMiddlewareList(adapterMw.afterRoutes);for(let adapter of this.adapters)await this.callHook(adapter.beforeStart?.bind(adapter),ctx);this.runtime.setNotFound(this.app,this.options.onNotFound??notFoundHandler()),this.runtime.setErrorHandler(this.app,this.options.onError??errorHandler())}async registerOnly(){await this.setup()}async start(){await this.setup();let g=globalThis;if(g.__kickjs_httpServer){this.httpServer=g.__kickjs_httpServer,log.debug(`Attached to Vite dev server`),g.__kickjs_app_shutdown=()=>this.shutdown();for(let adapter of this.adapters){let ctx=this.adapterCtx(this.httpServer);await this.callHook(adapter.afterStart?.bind(adapter),ctx)}for(let plugin of this.plugins)await plugin.onReady?.(this.container);return}let port=this.options.port??parseInt(process.env.PORT||`3000`,10);this.httpServer=http.createServer(this.runtime.nodeHandler(this.app)),this.httpServer.on(`error`,err=>{throw err.code===`EADDRINUSE`&&(log.error(`Port ${port} is already in use. Kill the existing process or use a different port:\n PORT=${port+1} kick dev\n lsof -i :${port} # find what's using it\n kill <PID> # stop it`),process.exit(1)),err}),await new Promise((resolve,reject)=>{this.httpServer.listen(port,async()=>{try{log.info(`Server running on http://localhost:${port}`);for(let adapter of this.adapters){let afterCtx=this.adapterCtx(this.httpServer);await this.callHook(adapter.afterStart?.bind(adapter),afterCtx)}for(let plugin of this.plugins)await plugin.onReady?.(this.container);resolve()}catch(err){reject(err)}})})}async rebuild(){let prevApp=this.app,prevContainer=this.container,staleDisposables=drainDisposables();try{Container.reset(),this.container=Container.getInstance(),this.app=this.runtime.createApp({trustProxy:this.options.trustProxy}),await this.setup()}catch(err){log.error(err,`HMR rebuild failed, keeping previous app`),await runDisposables(drainDisposables());for(let d of staleDisposables)registerDisposable(d);this.app=prevApp,this.container=prevContainer;return}await runDisposables(staleDisposables),this.httpServer&&(this.httpServer.removeAllListeners(`request`),this.httpServer.on(`request`,this.runtime.nodeHandler(this.app)),log.debug(`HMR: app rebuilt and swapped`))}async shutdown(){if(this._shutdownInitiated){log.debug(`Shutdown already in progress, skipping duplicate call`);return}this._shutdownInitiated=!0,this._draining=!0,log.debug(`Shutting down — draining in-flight requests...`);let timeoutMs=this.options.shutdownTimeout??3e4,timer,forceExitPromise=timeoutMs>0?new Promise(resolve=>{timer=setTimeout(()=>resolve(`timeout`),timeoutMs),timer.unref()}):new Promise(()=>{});try{if(this.httpServer&&this.httpServer.close(()=>{}),this._inFlightRequests>0){log.debug(`Waiting for ${this._inFlightRequests} in-flight request(s) to complete...`);let drainPromise=new Promise(resolve=>{this._drainResolvers.push(()=>resolve(`drained`))});await Promise.race([drainPromise,forceExitPromise])===`timeout`?log.warn(`Shutdown timeout (${timeoutMs}ms) reached with ${this._inFlightRequests} request(s) still in-flight, forcing shutdown`):log.debug(`All in-flight requests completed`)}let results=await Promise.allSettled([...this.plugins.map(plugin=>Promise.resolve(plugin.shutdown?.())),...this.adapters.map(adapter=>Promise.resolve(adapter.shutdown?.()))]);for(let result of results)result.status===`rejected`&&log.error({err:result.reason},`Adapter shutdown failed`);await disposeAll(),this.container.flushChanges()}finally{timer&&clearTimeout(timer)}}getRuntimeApp(){return this.app}getActiveRuntime(){return{name:this.runtime.name,capabilities:this.runtime.capabilities}}getExpressApp(){return this.app}getAdapters(){return this.adapters}getPlugins(){return this.plugins}getContributors(){let out=[],ingest=(list,source,label)=>{if(list)for(let reg of list){let r=reg;if(r.key===void 0||r.key===null)continue;let key=typeof r.key==`string`?r.key:tokenName(r.key);out.push({key,source,label,dependsOn:Array.isArray(r.dependsOn)?r.dependsOn:[]})}};for(let adapter of this.adapters)ingest(adapter.contributors?.(),`adapter`,adapter.name??`adapter`);for(let plugin of this.plugins)ingest(plugin.contributors?.(),`plugin`,plugin.name??`plugin`);for(let{registration,label}of this._moduleContributors)ingest([registration],`module`,label);return ingest(this.options.contributors,`global`,`bootstrap`),out}getHttpServer(){return this.httpServer}shouldAutoMountRequestScope(){if(this.options.contextStore===`manual`)return!1;let userEntries=this.options.middlewares??this.options.middleware??[];for(let entry of userEntries)if(isRequestScopeMiddleware(typeof entry==`function`?entry:entry.handler))return!1;return!0}collectAdapterMiddleware(){let result={beforeGlobal:[],afterGlobal:[],beforeRoutes:[],afterRoutes:[]};for(let adapter of this.adapters){let entries=adapter.middleware?.()??[];for(let entry of entries)result[entry.phase??`afterGlobal`].push(entry)}return result}mountMiddlewareList(entries){for(let entry of entries){if(entry.path===void 0){this.runtime.useConnect(this.app,entry.handler);continue}this.runtime.useConnect(this.app,entry.handler,{path:entry.path})}}mountMiddlewareEntry(entry){typeof entry==`function`?this.runtime.useConnect(this.app,entry):this.runtime.useConnect(this.app,entry.handler,{path:entry.path})}requestTrackingMiddleware(){return(_req,res,next)=>{this._inFlightRequests++;let onFinish=()=>{if(res.removeListener(`finish`,onFinish),res.removeListener(`close`,onFinish),this._inFlightRequests--,this._draining&&this._inFlightRequests===0){for(let resolve of this._drainResolvers)resolve();this._drainResolvers=[]}};res.on(`finish`,onFinish),res.on(`close`,onFinish),next()}}mountHealthEndpoints(){let http=this.adapterHttp();http.route(`GET`,`/health/live`,ctx=>{this._draining?ctx.res.status(503).json({status:`draining`,uptime:process.uptime()}):ctx.json({status:`ok`,uptime:process.uptime()})}),http.route(`GET`,`/health/ready`,async ctx=>{if(this._draining){ctx.res.status(503).json({status:`draining`,checks:[]});return}let adaptersWithHealth=this.adapters.filter(a=>a.onHealthCheck),results=(await Promise.allSettled(adaptersWithHealth.map(a=>a.onHealthCheck()))).map((c,i)=>c.status===`fulfilled`?c.value:{name:adaptersWithHealth[i].name??`unknown`,status:`down`}),healthy=results.every(r=>r.status===`up`);ctx.res.status(healthy?200:503).json({status:healthy?`ready`:`degraded`,checks:results})})}};export{materializeRouter as i,buildRoutes as n,expressRuntime as r,Application as t};
12
+ //# sourceMappingURL=application-CHYTI1Q_.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"application-CHYTI1Q_.mjs","names":[],"sources":["../src/http/runtimes/express.ts","../src/http/application.ts"],"sourcesContent":["// The default Express runtime — the M1 reference implementation of HttpRuntime.\n//\n// Its route materializer rebuilds the exact `(req, res, next)` handler chain\n// the old `buildRoutes()` produced, so swapping decorators → RouteTable →\n// runtime is behavior-neutral under Express. `buildRoutes()` (the public,\n// Router-returning API) now lives here as a thin shim over `buildRouteTable()`\n// + this materializer.\n\nimport express, {\n Router,\n type Express,\n type Request,\n type Response,\n type NextFunction,\n type RequestHandler,\n} from 'express'\n\nimport { buildRouteTable, type BuildRoutesOptions } from '../router-builder'\nimport { RequestContext } from '../context'\nimport { applyHandlerResult } from '../reply'\nimport { validate } from '../middleware/validate'\nimport { buildUploadMiddleware } from '../middleware/upload'\nimport type {\n ConnectMiddleware,\n HttpRuntime,\n RouteEntry,\n RouteTable,\n RuntimeAppOptions,\n UseConnectOptions,\n} from '../runtime'\n\n/**\n * Materialize a controller's {@link RouteEntry}[] onto a fresh `express.Router`.\n * Reproduces the legacy handler ordering precisely: validation → upload →\n * `(ctx, next)` middleware → contributor runner → terminal handler. Each step\n * constructs its own `RequestContext` over the same `req`/`res` — request-scoped\n * state lives in the AsyncLocalStorage store, not on the ctx instance, so the\n * per-step instances share state exactly as before.\n */\nexport function materializeRouter(entries: RouteEntry[]): Router {\n const router = Router()\n\n for (const entry of entries) {\n const method = entry.method.toLowerCase() as 'get' | 'post' | 'put' | 'delete' | 'patch'\n const handlers: RequestHandler[] = []\n\n // Validation middleware (shared with the standalone validate() export).\n if (entry.meta.validation) {\n handlers.push(validate(entry.meta.validation))\n }\n\n // @FileUpload — auto-attach upload middleware from metadata.\n if (entry.meta.upload) {\n handlers.push(buildUploadMiddleware(entry.meta.upload))\n }\n\n // Class + method middleware — wrapped as Express middleware with error catching.\n for (const mw of entry.middlewares) {\n handlers.push((req: Request, res: Response, next: NextFunction) => {\n const ctx = new RequestContext(req, res, next)\n Promise.resolve(mw(ctx, next)).catch(next)\n })\n }\n\n // Context Contributor pipeline (#107) — runs, then advances the chain.\n if (entry.contributorRunner) {\n const run = entry.contributorRunner\n handlers.push(async (req: Request, res: Response, next: NextFunction) => {\n const ctx = new RequestContext(req, res, next)\n try {\n await run(ctx)\n next()\n } catch (err) {\n next(err)\n }\n })\n }\n\n // Terminal handler.\n handlers.push(async (req: Request, res: Response, next: NextFunction) => {\n const ctx = new RequestContext(req, res, next)\n try {\n const result = await entry.handler(ctx)\n // Return-value handlers (reply.ts): auto-send the returned payload\n // when the handler wrote nothing. `undefined` keeps prior behavior.\n if (!res.headersSent) applyHandlerResult(ctx, result)\n } catch (err) {\n next(err)\n }\n })\n ;(router as any)[method](entry.path, ...handlers)\n }\n\n return router\n}\n\n/**\n * Build an Express Router from a controller class decorated with @Get, @Post,\n * etc. The public, back-compatible entry point: a thin shim over\n * {@link buildRouteTable} + {@link materializeRouter}. Returns an\n * `express.Router` exactly as before — modules pass it to `app.use(path, router)`.\n *\n * @see buildRouteTable for the engine-neutral route-table form.\n */\nexport function buildRoutes(controllerClass: any, options: BuildRoutesOptions = {}): Router {\n return materializeRouter(buildRouteTable(controllerClass, options))\n}\n\n/**\n * The default HTTP runtime. Express stays a peer dependency of `@forinda/kickjs`;\n * apps that pass no `runtime` get this and behave exactly as before.\n */\nexport function expressRuntime(): HttpRuntime<Express> {\n return {\n name: 'express',\n\n createApp(options: RuntimeAppOptions = {}): Express {\n const app = express()\n // Engine hardening + config the Application used to apply directly.\n app.disable('x-powered-by')\n app.set('trust proxy', options.trustProxy ?? false)\n return app\n },\n\n nodeHandler(app) {\n return (req, res, next) => {\n if (next) {\n ;(app as any)(req, res, next)\n } else {\n ;(app as any)(req, res)\n }\n }\n },\n\n mountRoutes(app, table: RouteTable) {\n for (const { mountPath, routes } of table) {\n app.use(mountPath, materializeRouter(routes))\n }\n },\n\n useConnect(app, mw: ConnectMiddleware, opts: UseConnectOptions = {}) {\n if (opts.path !== undefined) {\n ;(app as any).use(opts.path, mw)\n } else {\n ;(app as any).use(mw)\n }\n },\n\n serveStatic(app, prefix, dir) {\n app.use(prefix, express.static(dir))\n },\n\n setNotFound(app, mw: ConnectMiddleware) {\n ;(app as any).use(mw)\n },\n\n setErrorHandler(app, mw: ConnectMiddleware) {\n ;(app as any).use(mw)\n },\n\n capabilities: {\n render: true,\n uploads: true,\n connectMiddleware: true,\n nativeBodyParsing: false,\n },\n }\n}\n","import http from 'node:http'\nimport express, { type Express, type RequestHandler } from 'express'\nimport {\n Container,\n createLogger,\n Logger,\n normalizePath,\n tokenName,\n METADATA,\n type AppModule,\n type AppModuleClass,\n type AppModuleEntry,\n type AppAdapter,\n type AdapterContext,\n type AdapterMiddleware,\n type ContributorRegistrations,\n type KickPlugin,\n type ModuleRegistry,\n type RouteDefinition,\n type SourcedRegistration,\n mountSort,\n MutableModuleRegistry,\n} from '../core'\nimport { moduleRouteMissingControllerError } from '../core/kick-errors'\nimport {\n disposeAll,\n drainDisposables,\n registerDisposable,\n runDisposables,\n} from '../core/disposables'\nimport { getClassMeta } from '../core/metadata'\nimport { requestId } from './middleware/request-id'\nimport { notFoundHandler, errorHandler } from './middleware/error-handler'\nimport { requestScopeMiddleware, isRequestScopeMiddleware } from './middleware/request-scope'\nimport { _setExternalContributorSources, buildRouteTable } from './router-builder'\nimport { expressRuntime } from './runtimes/express'\nimport type {\n ActiveRuntime,\n AdapterHttp,\n HttpRuntime,\n RouteEntry,\n RuntimeCapabilities,\n} from './runtime'\nimport { requestStore } from './request-store'\n\nconst log = createLogger('Application')\n\n/**\n * A middleware entry in the declarative pipeline.\n * Can be a bare handler or an object with path scoping.\n */\nexport type MiddlewareEntry = RequestHandler | { path: string; handler: RequestHandler }\n\nexport interface ApplicationOptions {\n /**\n * Feature modules to load. Accepts both class form\n * (`SomeModule extends AppModule`, instantiated via `new`) and\n * instance form (output of {@link defineModule}'s factory call,\n * e.g. `TasksModule({ scope: 'admin' })`) — the loader discriminates\n * and either `new`-s the class or uses the instance directly.\n *\n * Static path — for conditional / dynamic registration, use the\n * {@link ApplicationOptions.setup} callback instead.\n */\n modules: AppModuleEntry[]\n\n /**\n * Imperative module registration callback. Receives a\n * {@link ModuleRegistry} you call `.mount(module)` on to register\n * modules conditionally — based on env flags, runtime config, a\n * tenant list, etc. Runs after every plugin's `setup()` hook and\n * after the static `modules: [...]` array is collected.\n *\n * @example\n * ```ts\n * bootstrap({\n * modules: [HelloModule()],\n * setup(registry) {\n * if (env.ENABLE_ADMIN) registry.mount(AdminModule())\n * },\n * })\n * ```\n */\n setup?(registry: ModuleRegistry): void\n /** Adapters that hook into the lifecycle (DB, Redis, Swagger, etc.) */\n adapters?: AppAdapter[]\n /** Server port (falls back to PORT env var, then 3000) */\n port?: number\n /** Global API prefix (default: '/api') */\n apiPrefix?: string\n /** Default API version (default: 1) — routes become /{prefix}/v{version}/{path} */\n defaultVersion?: number\n\n /**\n * Global middleware pipeline. Declared in order.\n * Replaces the hardcoded middleware stack — you control exactly what runs.\n *\n * @example\n * ```ts\n * bootstrap({\n * modules,\n * middlewares: [\n * helmet(),\n * cors(),\n * compression(),\n * morgan('dev'),\n * express.json({ limit: '1mb' }),\n * ],\n * })\n * ```\n *\n * If omitted, a sensible default is applied:\n * requestId(), express.json({ limit: '100kb' })\n */\n middlewares?: MiddlewareEntry[]\n /**\n * @deprecated Use {@link ApplicationOptions.middlewares} (plural).\n * Kept as an alias for back-compat; `middlewares` wins when both are\n * set.\n */\n middleware?: MiddlewareEntry[]\n\n /** Plugins that bundle modules, adapters, middleware, and DI bindings */\n plugins?: KickPlugin[]\n\n /**\n * Global Context Contributors (#107) that apply to every route in the\n * application. Merge into the per-route pipeline at the `'global'`\n * precedence level — they lose to module, adapter, class, and method\n * contributors with the same key, providing app-wide defaults that any\n * narrower scope can override.\n *\n * @example\n * ```ts\n * const StartedAt = defineContextDecorator({\n * key: 'requestStartedAt',\n * resolve: () => Date.now(),\n * })\n *\n * bootstrap({\n * modules,\n * contributors: [StartedAt.registration],\n * })\n * ```\n */\n contributors?: ContributorRegistrations\n\n /**\n * Backing store strategy for {@link RequestContext} `set/get` and the\n * Context Contributor pipeline (#107).\n *\n * - `'auto'` (default) — Application mounts {@link requestScopeMiddleware}\n * automatically before any user middleware. If the user-supplied\n * `middleware` list already includes `requestScopeMiddleware()`,\n * detection skips the auto-mount so adopters can control its position.\n * - `'manual'` — Application never mounts the wrapper. The Context\n * Contributor pipeline still runs on every route — the runner is\n * inserted by `router-builder` regardless of ALS state. What\n * degrades without an ALS frame is the *backing store*:\n * REQUEST-scoped DI throws (no `requestStore.getStore()` to read\n * from) and `RequestContext.set/get` throws. Use `'manual'` only when you\n * genuinely intend to wrap requests in your own ALS frame (rare —\n * multi-tenant adapters used to do this; post-Phase 3 they share\n * the framework's frame instead).\n */\n contextStore?: 'auto' | 'manual'\n\n /**\n * Controls whether KickJS registers process-level handlers at bootstrap.\n *\n * - `'auto'` (default) — register `uncaughtException` /\n * `unhandledRejection` loggers AND `SIGINT` / `SIGTERM` →\n * `app.shutdown()` → `process.exit(0)`.\n * - `'errors-only'` — register the error loggers; skip the signal\n * handlers. Use this when you have your own shutdown choreographer\n * (OpenTelemetry SDK, Sentry, custom orchestrator) that calls\n * `app.shutdown()` itself and you don't want two listeners racing\n * to call `process.exit`.\n * - `'manual'` — skip everything. Adopter is responsible for both\n * error logging and signal-driven shutdown.\n *\n * Background: many observability SDKs install their own SIGTERM\n * handler to flush spans/metrics before the process exits. Two\n * separate handlers calling `process.exit(0)` race each other and\n * can truncate the in-flight flush. Setting this to `'errors-only'`\n * or `'manual'` lets the SDK own the lifecycle while still letting\n * KickJS surface uncaught exceptions / rejections via the logger.\n *\n * The dev mode auto-detect (`__kickjs_httpServer` set by the Vite\n * plugin) suppresses signal registration regardless of this option,\n * since Vite owns the lifecycle in development.\n */\n processHooks?: 'auto' | 'errors-only' | 'manual'\n\n /**\n * The HTTP engine driver. Defaults to {@link expressRuntime} — Express stays\n * the zero-config default, so existing apps are unaffected.\n *\n * Any `HttpRuntime` is accepted — pass `fastifyRuntime()` (from\n * `@forinda/kickjs/fastify`) or a custom engine driver. Defaults to\n * {@link expressRuntime}. The engine-native escape hatches\n * (`getRuntimeApp()`, `AdapterContext.app`) follow the active runtime via the\n * registry (`ActiveRuntime`, spec §4.3b) — Express by default, or the augmented\n * engine once the `kick/runtime` typegen output is present.\n */\n runtime?: HttpRuntime\n\n /** Express `trust proxy` setting */\n trustProxy?: boolean | number | string | ((ip: string, hopIndex: number) => boolean)\n /** Maximum JSON body size (only used when middleware is not provided) */\n jsonLimit?: string | number\n /**\n * Print the route table on startup. Default: `false`. Set to `true`\n * to log a per-controller summary (method counts + mount paths) once\n * the app has mounted. Emitted at `info` level, so it is still subject\n * to `LOG_LEVEL` filtering (visible at the default `info`; hidden at\n * `warn`/`error`/`silent`).\n */\n logRouteTable?: boolean\n /**\n * @deprecated Use {@link ApplicationOptions.logRouteTable}. Kept as an\n * alias for back-compat; `logRouteTable` wins when both are set.\n */\n logRoutesTable?: boolean\n /**\n * Maximum time (ms) to wait for graceful shutdown before forcing exit.\n * Default: 30000 (30 seconds). Set to 0 to disable forced exit.\n */\n shutdownTimeout?: number\n\n /**\n * Enable cluster mode for multi-core utilization.\n *\n * When enabled, the primary process forks worker processes that share the\n * same port via Node's built-in `cluster` module (OS load balancing).\n *\n * - `true` — use all available CPU cores\n * - `{ workers: N }` — use exactly N workers\n *\n * Workers are auto-restarted on crash. SIGTERM/SIGINT on the primary is\n * forwarded to all workers.\n *\n * @example\n * ```ts\n * bootstrap({ modules, cluster: true })\n * bootstrap({ modules, cluster: { workers: 4 } })\n * ```\n */\n cluster?: boolean | { workers?: number }\n\n /**\n * Custom 404 handler for unmatched routes. Receives the raw Express\n * `(req, res, next)` args. When omitted, the built-in handler returns\n * `{ message: 'Not Found' }` with status 404.\n *\n * @example\n * ```ts\n * bootstrap({\n * modules,\n * onNotFound: (req, res) => {\n * res.status(404).json({ error: 'Route not found', path: req.originalUrl })\n * },\n * })\n * ```\n */\n onNotFound?: (req: any, res: any, next: any) => void\n\n /**\n * Custom global error handler. Receives `(err, req, res, next)` — the\n * standard Express error-handling signature. When omitted, the built-in\n * handler formats ZodError, HttpException, and unexpected errors.\n *\n * @example\n * ```ts\n * bootstrap({\n * modules,\n * onError: (err, req, res, next) => {\n * logger.error(err)\n * res.status(err.status ?? 500).json({ error: err.message })\n * },\n * })\n * ```\n */\n onError?: (err: any, req: any, res: any, next: any) => void\n\n /**\n * Security defaults applied automatically unless opted out.\n *\n * When not specified, secure defaults are applied:\n * - Helmet security headers are auto-injected\n * - JSON body limit defaults to 1MB\n *\n * @example\n * ```ts\n * bootstrap({\n * modules,\n * security: {\n * helmet: false, // disable auto-helmet\n * },\n * })\n * ```\n */\n security?: {\n /** Auto-inject helmet security headers. Default: true */\n helmet?: boolean\n }\n}\n\n/**\n * The main application class. Wires together Express, the DI container,\n * feature modules, adapters, and the middleware pipeline.\n */\nexport class Application {\n private app: Express\n /** The HTTP engine driver. Defaults to {@link expressRuntime}. */\n private readonly runtime: HttpRuntime\n private container: Container\n private httpServer: http.Server | null = null\n private readonly adapters: AppAdapter[]\n\n private readonly plugins: KickPlugin[]\n\n /**\n * Snapshot of every module-level Context Contributor registration\n * captured during `setup()`. The registrations themselves are\n * frozen by `defineContextDecorator`, so storing references is\n * safe — they outlive the module instances they came from.\n *\n * Used by {@link getContributors} so DevTools and adopter tooling\n * can render the module-level contributors alongside the adapter /\n * plugin / global ones. Populated once per `setup()` call; cleared\n * at the start of each invocation so a re-setup (test harnesses,\n * dev-server restarts) doesn't accumulate stale entries.\n */\n private _moduleContributors: Array<{\n registration: { key: string; dependsOn: readonly string[] }\n label: string\n }> = []\n\n /** Number of HTTP requests currently being processed */\n private _inFlightRequests = 0\n /** Whether the application is draining (shutting down gracefully) */\n private _draining = false\n /** Whether shutdown has already been initiated (prevents double-shutdown) */\n private _shutdownInitiated = false\n /** Resolvers waiting for in-flight requests to reach zero */\n private _drainResolvers: Array<() => void> = []\n\n constructor(private readonly options: ApplicationOptions) {\n this.runtime = options.runtime ?? expressRuntime()\n // `this.app` is the engine-native app; typed Express here (the default) for\n // the legacy escape hatches. Under another runtime it holds that engine's\n // app — `getRuntimeApp()` / `AdapterContext.app` expose it via ActiveRuntime.\n this.app = this.runtime.createApp({ trustProxy: options.trustProxy }) as Express\n this.container = Container.getInstance()\n\n // Sort plugins by `dependsOn` declarations BEFORE reading their adapters/etc.\n // Plugins without `dependsOn` keep their declaration order — this is a\n // pure refinement; no behaviour change for apps that don't use the field.\n this.plugins = mountSort(options.plugins ?? [], 'plugin')\n\n // Build adapter list from plugin adapters + user adapters, synthesize\n // a stable name for any anonymous adapter (so duplicate-name detection\n // and `dependsOn` resolution have something to key on), then sort by\n // adapter `dependsOn`. Plugin-shipped adapters keep their plugin's\n // relative order unless their own `dependsOn` says otherwise.\n const allAdapters = [\n ...this.plugins.flatMap((p) => p.adapters?.() ?? []),\n ...(options.adapters ?? []),\n ]\n let anonAdapterCount = 0\n const namedAdapters: Array<AppAdapter & { name: string }> = allAdapters.map((adapter) => {\n if (!adapter.name) {\n // `constructor.name === 'Object'` for plain object-literal adapters —\n // useless as an identity since two anonymous literals would collide.\n // Only borrow the constructor name when it's an actual class.\n const ctorName = adapter.constructor?.name\n const fallback =\n ctorName && ctorName !== 'Object' ? ctorName : `AnonymousAdapter#${anonAdapterCount++}`\n return Object.assign(adapter, { name: fallback })\n }\n return adapter as AppAdapter & { name: string }\n })\n this.adapters = mountSort(namedAdapters, 'adapter')\n // Wire the request store provider so Container can resolve REQUEST-scoped deps\n Container._requestStoreProvider = () => requestStore.getStore() ?? null\n }\n\n /** Whether the application is currently draining in-flight requests */\n get isDraining(): boolean {\n return this._draining\n }\n\n /** Number of HTTP requests currently being processed */\n get inFlightRequests(): number {\n return this._inFlightRequests\n }\n\n /** Get the DI container instance */\n getContainer(): Container {\n return this.container\n }\n\n /**\n * Express request handler — delegates to the internal Express app.\n *\n * Used by the Vite dev-server plugin to route requests through KickJS:\n * ```ts\n * const mod = await ssrLoadModule('virtual:kickjs/app')\n * mod.app.handle(req, res, next)\n * ```\n *\n * Also works as a standard Node.js request handler for production:\n * ```ts\n * http.createServer(app.handle.bind(app))\n * ```\n */\n handle(req: http.IncomingMessage, res: http.ServerResponse, next?: (err?: any) => void): void {\n const handler = this.runtime.nodeHandler(this.app)\n if (next) {\n handler(req, res, next)\n } else {\n handler(req, res)\n }\n }\n\n /**\n * Full setup pipeline:\n * 1. Adapter beforeMount hooks (early routes — docs, health)\n * 2. Adapter middleware (phase: beforeGlobal)\n * 3. Global middleware (user-declared or defaults)\n * 4. Adapter middleware (phase: afterGlobal)\n * 5. Module registration + DI bootstrap\n * 6. Adapter middleware (phase: beforeRoutes)\n * 7. Module route mounting\n * 8. Adapter middleware (phase: afterRoutes)\n * 9. Error handlers (notFound + global)\n * 10. Adapter beforeStart hooks\n */\n /** Build the adapter context object (shared across all hooks) */\n private adapterCtx(server?: any): AdapterContext {\n const env = process.env.NODE_ENV ?? 'development'\n return {\n http: this.adapterHttp(),\n app: this.app,\n container: this.container,\n server,\n env,\n isProduction: env === 'production',\n }\n }\n\n /**\n * The engine-agnostic HTTP surface handed to adapters as `ctx.http`. Each\n * call routes through the active runtime over the current `this.app`, so an\n * adapter written against this works under any runtime.\n */\n private adapterHttp(): AdapterHttp {\n return {\n route: (method, path, handler) => {\n const entry: RouteEntry = {\n method,\n path,\n middlewares: [],\n contributorRunner: null,\n handler,\n meta: {},\n }\n this.runtime.mountRoutes(this.app, [{ mountPath: '/', routes: [entry] }])\n },\n mount: (prefix, routes) => {\n this.runtime.mountRoutes(this.app, [{ mountPath: prefix, routes }])\n },\n serveStatic: (prefix, dir) => {\n this.runtime.serveStatic(this.app, prefix, dir)\n },\n use: (mw, opts) => {\n this.runtime.useConnect(this.app, mw, opts)\n },\n }\n }\n\n /** Call an adapter hook, awaiting async hooks and catching errors */\n private async callHook(\n hook: ((ctx: AdapterContext) => void | Promise<void>) | undefined,\n ctx: AdapterContext,\n ): Promise<void> {\n if (!hook) return\n try {\n const result = hook(ctx)\n if (result && typeof (result as Promise<void>).then === 'function') {\n await result\n }\n } catch (err) {\n log.error(err, 'Adapter hook failed')\n }\n }\n\n async setup(): Promise<void> {\n log.debug('Bootstrapping application...')\n\n // Reset module-contributor snapshot at the very top of each\n // setup pass — before anything that could throw — so a partial\n // failure doesn't leave stale entries that getContributors()\n // would surface on the next call. See _moduleContributors field\n // declaration for the use case.\n this._moduleContributors = []\n\n // Collect adapter middleware by phase\n const adapterMw = this.collectAdapterMiddleware()\n\n // Expose the Application instance on the Express app for adapter discovery\n ;(this.app as any).__kickApp = this\n\n const ctx = this.adapterCtx()\n\n // ── 1. Adapter beforeMount hooks ──────────────────────────────────\n for (const adapter of this.adapters) {\n await this.callHook(adapter.beforeMount?.bind(adapter), ctx)\n }\n\n // ── 2. Hardened defaults ──────────────────────────────────────────\n // x-powered-by disable + trust proxy now live in `runtime.createApp()`.\n\n // ── 2a. In-flight request tracking ──────────────────────────────\n this.runtime.useConnect(this.app, this.requestTrackingMiddleware())\n\n // ── 2b. Health check endpoints (before middleware, at root) ──────\n this.mountHealthEndpoints()\n\n // ── 2c. Request scope (AsyncLocalStorage) ────────────────────────\n // Auto-mounted unless the user opted out (`contextStore: 'manual'`)\n // or already included one in their middleware list.\n if (this.shouldAutoMountRequestScope()) {\n this.runtime.useConnect(this.app, requestScopeMiddleware())\n }\n\n // ── 3. Adapter middleware: beforeGlobal ───────────────────────────\n this.mountMiddlewareList(adapterMw.beforeGlobal)\n\n // ── 3b. Plugin registration ──────────────────────────────────────\n for (const plugin of this.plugins) {\n plugin.register?.(this.container)\n }\n\n // ── 3c. Plugin middleware ─────────────────────────────────────────\n for (const plugin of this.plugins) {\n try {\n const mw = plugin.middleware?.() ?? []\n for (const handler of mw) {\n this.runtime.useConnect(this.app, handler)\n }\n } catch (err) {\n log.error(err, `Plugin middleware failed: ${(plugin as any).name ?? 'unknown'}`)\n }\n }\n\n // ── 4. Global middleware ─────────────────────────────────────────\n // Auto-inject helmet unless opted out\n const autoHelmet = this.options.security?.helmet !== false\n if (autoHelmet) {\n try {\n const { helmet: helmetFn } = await import('./middleware/helmet')\n this.runtime.useConnect(this.app, helmetFn())\n } catch {\n // helmet middleware not available — skip silently\n }\n }\n\n const userMiddlewares = this.options.middlewares ?? this.options.middleware\n if (userMiddlewares) {\n // User-declared pipeline — full control\n for (const entry of userMiddlewares) {\n this.mountMiddlewareEntry(entry)\n }\n } else {\n // Sensible defaults when no middleware declared\n this.runtime.useConnect(this.app, requestId())\n // Skip express.json on engines that parse bodies natively (Fastify, h3) —\n // otherwise the body stream is read twice and the engine's parser hangs.\n if (!this.runtime.capabilities.nativeBodyParsing) {\n this.runtime.useConnect(this.app, express.json({ limit: this.options.jsonLimit ?? '1mb' }))\n }\n }\n\n // ── 5. Adapter middleware: afterGlobal ────────────────────────────\n this.mountMiddlewareList(adapterMw.afterGlobal)\n\n // ── 6. Module registration + DI bootstrap ────────────────────────\n // Module collection — the static `modules: [...]` array AND the\n // imperative `setup(registry)` callback feed into the same\n // ordered list. Plugins go first so plugin modules / setup\n // calls run before user code (existing precedence).\n //\n // Order within the registry:\n // 1. plugin static modules (`plugin.modules?()`)\n // 2. plugin setup() calls (in plugin dependsOn-sorted order)\n // 3. user static modules (`options.modules`)\n // 4. user setup() callback\n const moduleRegistry = new MutableModuleRegistry()\n for (const plugin of this.plugins) {\n for (const m of plugin.modules?.() ?? []) moduleRegistry.mount(m)\n plugin.setup?.(moduleRegistry)\n }\n for (const m of this.options.modules) moduleRegistry.mount(m)\n this.options.setup?.(moduleRegistry)\n const allModuleEntries: AppModuleEntry[] = moduleRegistry.entries\n const modules = allModuleEntries.map((entry) => {\n // Discriminate class vs instance: classes are functions whose\n // `prototype` carries the AppModule shape; defineModule output is\n // a plain object with `routes`, `register`, `contributors`. Calling\n // `new` on a plain object throws, so we branch up-front rather\n // than try/catch.\n const mod: AppModule = typeof entry === 'function' ? new (entry as AppModuleClass)() : entry\n // `register()` is optional — modules whose classes are entirely\n // decorator-managed (@Service, @Controller, @Repository) don't need it.\n mod.register?.(this.container)\n return mod\n })\n this.container.bootstrap()\n\n // Register Logger as an injectable singleton so @Inject(Logger)\n // works in constructors. Without this, Logger is just a plain\n // class with static methods and no DI binding.\n if (!this.container.has(Logger)) {\n this.container.registerInstance(Logger, new Logger())\n }\n\n // ── 7. Adapter middleware: beforeRoutes ───────────────────────────\n this.mountMiddlewareList(adapterMw.beforeRoutes)\n\n // ── 8. Mount module routes with versioning ───────────────────────\n const apiPrefix = this.options.apiPrefix ?? '/api'\n const defaultVersion = this.options.defaultVersion ?? 1\n // Opt-in, default off. `logRouteTable` is the current name;\n // `logRoutesTable` is the deprecated alias.\n const shouldLogRoutes = this.options.logRouteTable ?? this.options.logRoutesTable ?? false\n\n // Collect route metadata during mounting (avoids calling mod.routes() twice)\n const mountedRoutes: Array<{ controller: any; mountPath: string }> = []\n\n // Context Contributors (#107) — collect adapter + plugin + global once;\n // per-module sources are computed inside the loop so module isolation is\n // preserved.\n //\n // Plugin contributors merge at the same `'adapter'` precedence as adapter\n // contributors. Plugins are conceptually \"bundles of adapters + extras\",\n // so a plugin that ships a typed contributor without standing up an\n // accompanying adapter behaves identically to one that does.\n const adapterSources: SourcedRegistration[] = []\n for (const adapter of this.adapters) {\n const adapterContribs = adapter.contributors?.() ?? []\n const adapterLabel = adapter.name ?? adapter.constructor.name ?? 'adapter'\n for (const registration of adapterContribs) {\n adapterSources.push({ source: 'adapter', registration, label: adapterLabel })\n }\n }\n for (const plugin of this.plugins) {\n const pluginContribs = plugin.contributors?.() ?? []\n const pluginLabel = plugin.name ?? plugin.constructor?.name ?? 'plugin'\n for (const registration of pluginContribs) {\n adapterSources.push({ source: 'adapter', registration, label: pluginLabel })\n }\n }\n const globalSources: SourcedRegistration[] = (this.options.contributors ?? []).map(\n (registration): SourcedRegistration => ({\n source: 'global',\n registration,\n label: 'bootstrap',\n }),\n )\n\n // Reset module-contributor snapshot at the start of each setup\n // pass so re-running `setup()` (test harnesses, dev-server\n // restarts) doesn't accumulate stale entries.\n this._moduleContributors = []\n\n for (const mod of modules) {\n // Prefer the declared `name` field (set by `defineModule({ name: 'X', ... })`)\n // over `constructor.name`. Factory-built modules are plain objects whose\n // constructor is `Object` — falling straight to `constructor.name` would\n // degrade every label in the DevTools Contributors table to \"Object\".\n const declaredName = (mod as { name?: unknown }).name\n const ctorName = mod.constructor?.name\n const moduleLabel =\n typeof declaredName === 'string' && declaredName.length > 0\n ? declaredName\n : ctorName && ctorName !== 'Object'\n ? ctorName\n : 'module'\n const moduleSources: SourcedRegistration[] = (mod.contributors?.() ?? []).map(\n (registration): SourcedRegistration => ({\n source: 'module',\n registration,\n label: moduleLabel,\n }),\n )\n // Retain registrations for `getContributors()` — these would\n // otherwise be unreachable post-bootstrap (module instances\n // are not kept on the Application).\n for (const src of moduleSources) {\n this._moduleContributors.push({\n registration: src.registration as { key: string; dependsOn: readonly string[] },\n label: moduleLabel,\n })\n }\n\n // Thread per-module + adapter + global sources to buildRoutes via the\n // module-scoped slot. Module setup is sequential, so the slot is\n // race-free. The slot MUST stay populated across both `mod.routes()`\n // AND any framework-driven `buildRoutes(controller)` calls below —\n // when a module returns `{ path, controller }` (auto-derive shape),\n // buildRoutes runs here, not inside routes(). Clearing the slot in\n // the routes()-finally would drop module/adapter/global contributors\n // on the floor and surface as `MissingContributorError` for any\n // class/method-level dependsOn referencing a module-level key.\n _setExternalContributorSources([...moduleSources, ...adapterSources, ...globalSources])\n try {\n const result = mod.routes()\n if (!result) continue // Non-HTTP modules (queues, cron) may return null\n\n const routeSets = Array.isArray(result) ? result : [result]\n\n for (const route of routeSets) {\n const version = route.version ?? defaultVersion\n const mountPath = `${apiPrefix}/v${version}${normalizePath(route.path)}`\n // Common-case `{ path, controller }`: build the engine-neutral route\n // table and let the runtime materialize it natively (Express Router /\n // Fastify routes / …). Adopters who hand-build a `router` (composing\n // multiple controllers, third-party routers) pass it explicitly — that\n // is an Express-specific connect handler, mounted via `useConnect`.\n if (route.router) {\n this.runtime.useConnect(this.app, route.router, { path: mountPath })\n } else if (route.controller) {\n this.runtime.mountRoutes(this.app, [\n { mountPath, routes: buildRouteTable(route.controller) },\n ])\n } else {\n throw moduleRouteMissingControllerError(mountPath)\n }\n\n // Notify adapters (e.g. SwaggerAdapter for OpenAPI spec generation)\n if (route.controller) {\n for (const adapter of this.adapters) {\n try {\n adapter.onRouteMount?.(route.controller, mountPath)\n } catch (err) {\n log.error(err, `adapter.onRouteMount() failed for ${mountPath}`)\n }\n }\n if (shouldLogRoutes) {\n mountedRoutes.push({ controller: route.controller, mountPath })\n }\n }\n }\n } finally {\n _setExternalContributorSources([])\n }\n }\n\n // ── 8b. Log route summary ─────────────────────────────────────────\n if (shouldLogRoutes && mountedRoutes.length > 0) {\n const methodOrder = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS']\n const methodRank = (m: string) => {\n const i = methodOrder.indexOf(m)\n return i === -1 ? 99 : i\n }\n\n let totalRoutes = 0\n log.info('Routes:')\n\n for (const { controller, mountPath } of mountedRoutes) {\n const defs: RouteDefinition[] = getClassMeta<RouteDefinition[]>(\n METADATA.ROUTES,\n controller,\n [],\n )\n if (defs.length === 0) continue\n\n const counts: Record<string, number> = {}\n for (const def of defs) {\n const m = def.method.toUpperCase()\n counts[m] = (counts[m] || 0) + 1\n }\n totalRoutes += defs.length\n\n const methods = Object.entries(counts)\n .toSorted(([a], [b]) => methodRank(a) - methodRank(b))\n .map(([m, n]) => `${n} ${m}`)\n .join(', ')\n const name = controller.name || 'Controller'\n log.info(` ${name.padEnd(30)} ${mountPath.padEnd(25)} ${defs.length} routes (${methods})`)\n }\n\n log.info(` Total: ${totalRoutes} routes`)\n }\n\n // ── 9. Adapter middleware: afterRoutes ────────────────────────────\n this.mountMiddlewareList(adapterMw.afterRoutes)\n\n // ── 10. Adapter beforeStart hooks ────────────────────────────────\n // Runs BEFORE error handlers so adapters can still mount Express\n // routes (e.g. `McpAdapter` registers `/_mcp/messages` here). If\n // error handlers were registered first, the notFoundHandler — a\n // catch-all that never calls next() — would pre-empt anything an\n // adapter adds afterwards and adapter-mounted endpoints would 404.\n for (const adapter of this.adapters) {\n await this.callHook(adapter.beforeStart?.bind(adapter), ctx)\n }\n\n // ── 11. Error handlers ───────────────────────────────────────────\n // Last in the chain so any adapter-mounted route (step 10) gets\n // a chance to match before the catch-all 404 fires.\n this.runtime.setNotFound(this.app, this.options.onNotFound ?? notFoundHandler())\n this.runtime.setErrorHandler(this.app, this.options.onError ?? errorHandler())\n }\n\n /** Register modules and DI without starting the HTTP server (used by kick tinker) */\n async registerOnly(): Promise<void> {\n await this.setup()\n }\n\n /**\n * Start the HTTP server.\n *\n * In **dev mode** (Vite plugin active): reuses `globalThis.__kickjs_httpServer`\n * created by Vite. Adapters (WsAdapter, Socket.IO, etc.) receive the real\n * `http.Server` through `afterStart({ server })` — zero adapter changes needed.\n *\n * In **production**: creates its own `http.Server` and binds to the port.\n */\n async start(): Promise<void> {\n await this.setup()\n\n const g = globalThis as any\n\n if (g.__kickjs_httpServer) {\n // ── DEV MODE: Vite owns the http.Server ──────────────────────\n // Don't create a new server or listen — Vite is already listening.\n // Just wire up adapters with the Vite-created server.\n this.httpServer = g.__kickjs_httpServer\n log.debug('Attached to Vite dev server')\n\n // Dev mode suppresses our own SIGINT/SIGTERM handlers (Vite owns\n // the process lifecycle), so a Ctrl+C would otherwise skip graceful\n // shutdown entirely — `adapter.shutdown()`, request draining, and\n // any shutdown logs never run. Expose `shutdown()` on globalThis so\n // the CLI dev server (`kick dev`) can drive it before tearing down\n // Vite. Same process, so the CLI's signal handler can reach this.\n g.__kickjs_app_shutdown = () => this.shutdown()\n\n for (const adapter of this.adapters) {\n const ctx = this.adapterCtx(this.httpServer!)\n await this.callHook(adapter.afterStart?.bind(adapter), ctx)\n }\n\n for (const plugin of this.plugins) {\n await plugin.onReady?.(this.container)\n }\n\n return\n }\n\n // ── PRODUCTION: Create and own the http.Server ─────────────────\n const port = this.options.port ?? parseInt(process.env.PORT || '3000', 10)\n this.httpServer = http.createServer(this.runtime.nodeHandler(this.app))\n\n this.httpServer.on('error', (err: NodeJS.ErrnoException) => {\n if (err.code === 'EADDRINUSE') {\n log.error(\n `Port ${port} is already in use. Kill the existing process or use a different port:\\n` +\n ` PORT=${port + 1} kick dev\\n` +\n ` lsof -i :${port} # find what's using it\\n` +\n ` kill <PID> # stop it`,\n )\n process.exit(1)\n }\n throw err\n })\n\n // Wrap listen in a Promise so afterStart/onReady errors propagate\n await new Promise<void>((resolve, reject) => {\n this.httpServer!.listen(port, async () => {\n try {\n log.info(`Server running on http://localhost:${port}`)\n\n for (const adapter of this.adapters) {\n const afterCtx = this.adapterCtx(this.httpServer!)\n await this.callHook(adapter.afterStart?.bind(adapter), afterCtx)\n }\n\n // Plugin onReady hooks\n for (const plugin of this.plugins) {\n await plugin.onReady?.(this.container)\n }\n\n resolve()\n } catch (err) {\n reject(err)\n }\n })\n })\n }\n\n /** HMR rebuild: swap Express handler without restarting the server */\n async rebuild(): Promise<void> {\n // Build the new app fully before swapping — if setup() throws,\n // the old app keeps running so the server stays responsive.\n const prevApp = this.app\n const prevContainer = this.container\n // Snapshot the outgoing app's disposables (session/rate-limit store\n // intervals) BEFORE setup() registers the incoming app's. On success the\n // stale set is disposed — without this, every HMR swap leaked one live\n // interval + Map per store. On failure it's restored, and whatever the\n // failed setup() half-registered is disposed instead.\n const staleDisposables = drainDisposables()\n\n try {\n Container.reset()\n this.container = Container.getInstance()\n this.app = this.runtime.createApp({ trustProxy: this.options.trustProxy }) as Express\n await this.setup()\n } catch (err) {\n log.error(err, 'HMR rebuild failed, keeping previous app')\n // Restore previous state so the server stays responsive\n await runDisposables(drainDisposables())\n for (const d of staleDisposables) registerDisposable(d)\n this.app = prevApp\n this.container = prevContainer\n return\n }\n\n await runDisposables(staleDisposables)\n\n if (this.httpServer) {\n this.httpServer.removeAllListeners('request')\n this.httpServer.on('request', this.runtime.nodeHandler(this.app))\n log.debug('HMR: app rebuilt and swapped')\n }\n }\n\n /**\n * Graceful shutdown with request draining.\n *\n * 1. Stops accepting new connections (server.close())\n * 2. Waits for in-flight requests to complete (up to shutdownTimeout)\n * 3. Calls adapter.shutdown() for all registered adapters\n * 4. Force-closes after timeout\n *\n * Safe to call multiple times — subsequent calls return the same promise.\n */\n async shutdown(): Promise<void> {\n // Prevent double-shutdown — return immediately if already initiated\n if (this._shutdownInitiated) {\n log.debug('Shutdown already in progress, skipping duplicate call')\n return\n }\n this._shutdownInitiated = true\n this._draining = true\n\n log.debug('Shutting down — draining in-flight requests...')\n\n const timeoutMs = this.options.shutdownTimeout ?? 30_000\n let timer: ReturnType<typeof setTimeout> | undefined\n\n // Start a force-exit timer if timeout is configured\n const forceExitPromise =\n timeoutMs > 0\n ? new Promise<'timeout'>((resolve) => {\n timer = setTimeout(() => resolve('timeout'), timeoutMs)\n timer.unref()\n })\n : new Promise<never>(() => {}) // never resolves — no forced exit\n\n try {\n // Step 1: Stop accepting new connections.\n // server.close() prevents new connections. Its callback fires only when\n // ALL existing connections are fully closed, so we do NOT await it here —\n // we track request draining separately via the tracking middleware.\n if (this.httpServer) {\n this.httpServer.close(() => {})\n }\n\n // Step 2: Wait for in-flight requests to drain (or timeout)\n if (this._inFlightRequests > 0) {\n log.debug(`Waiting for ${this._inFlightRequests} in-flight request(s) to complete...`)\n const drainPromise = new Promise<'drained'>((resolve) => {\n this._drainResolvers.push(() => resolve('drained'))\n })\n\n const result = await Promise.race([drainPromise, forceExitPromise])\n if (result === 'timeout') {\n log.warn(\n `Shutdown timeout (${timeoutMs}ms) reached with ${this._inFlightRequests} request(s) still in-flight, forcing shutdown`,\n )\n } else {\n log.debug('All in-flight requests completed')\n }\n }\n\n // Step 3: Run all plugin + adapter shutdowns concurrently\n const results = await Promise.allSettled([\n ...this.plugins.map((plugin) => Promise.resolve(plugin.shutdown?.())),\n ...this.adapters.map((adapter) => Promise.resolve(adapter.shutdown?.())),\n ])\n for (const result of results) {\n if (result.status === 'rejected') {\n log.error({ err: result.reason }, 'Adapter shutdown failed')\n }\n }\n\n // Step 4: Release framework-owned resources started outside the\n // adapter lifecycle — in-memory session/rate-limit store intervals —\n // and flush any pending container change batch so its debounce timer\n // doesn't outlive the app.\n await disposeAll()\n this.container.flushChanges()\n } finally {\n if (timer) clearTimeout(timer)\n }\n }\n\n /**\n * The engine-native app instance, typed from the active runtime\n * ({@link ActiveRuntime} — Express by default). Prefer this over\n * {@link getExpressApp}; under a non-Express runtime the type follows the\n * augmented registry.\n */\n getRuntimeApp(): ActiveRuntime['app'] {\n return this.app\n }\n\n /**\n * The active HTTP runtime's identity + capabilities — `name` is `'express'`\n * (default), `'fastify'`, or `'h3'`; `capabilities` reports what the engine\n * supports (render / uploads / connectMiddleware / nativeBodyParsing).\n * Surfaced by DevTools and the VS Code extension so tooling can show which\n * engine the app is running on. Cheap, side-effect free.\n */\n getActiveRuntime(): { name: string; capabilities: RuntimeCapabilities } {\n return { name: this.runtime.name, capabilities: this.runtime.capabilities }\n }\n\n /** @deprecated Use {@link getRuntimeApp}. Returns the engine-native app. */\n getExpressApp(): Express {\n return this.app\n }\n\n /** Get registered adapters — used by DevToolsAdapter for peer discovery */\n getAdapters(): AppAdapter[] {\n return this.adapters\n }\n\n /**\n * Get registered plugins — used by DevToolsAdapter for topology\n * introspection (architecture.md §23). Read-only; returns the\n * already-sorted plugin list (post-`dependsOn` topo-sort).\n */\n getPlugins(): readonly KickPlugin[] {\n return this.plugins\n }\n\n /**\n * Snapshot of every Context Contributor reachable from this app —\n * walks **four** registration sites: adapters, plugins, modules,\n * and the bootstrap `contributors` option. The devtools Topology\n * tab consumes this for the Contributors panel; tests + adopters\n * can call it for diagnostics.\n *\n * Per-route (method/class-decorator) registrations are NOT included\n * here — they live on the route registry rather than on any of\n * the four collection sites this method walks. A future RPC will\n * surface them separately.\n *\n * Result shape stays minimal — `{ key, source, label, dependsOn }`\n * — so we don't leak `resolve` closures or other internal fields.\n * `source` matches the five-level precedence union from\n * `ContributorSource` (minus `'method'` / `'class'` which require\n * the per-route walk noted above).\n */\n getContributors(): ReadonlyArray<{\n key: string\n source: 'module' | 'adapter' | 'plugin' | 'global'\n label: string\n dependsOn: readonly string[]\n }> {\n const out: Array<{\n key: string\n source: 'module' | 'adapter' | 'plugin' | 'global'\n label: string\n dependsOn: readonly string[]\n }> = []\n const ingest = (\n list: ReadonlyArray<unknown> | null | undefined,\n source: 'module' | 'adapter' | 'plugin' | 'global',\n label: string,\n ): void => {\n if (!list) return\n for (const reg of list) {\n const r = reg as { key?: unknown; dependsOn?: unknown }\n if (r.key === undefined || r.key === null) continue\n // `key` is typically a string but createToken<T>() yields a\n // branded token object — normalise via tokenName so both\n // surfaces flow through.\n const key = typeof r.key === 'string' ? r.key : tokenName(r.key)\n out.push({\n key,\n source,\n label,\n dependsOn: Array.isArray(r.dependsOn) ? (r.dependsOn as string[]) : [],\n })\n }\n }\n for (const adapter of this.adapters) {\n ingest(adapter.contributors?.(), 'adapter', adapter.name ?? 'adapter')\n }\n for (const plugin of this.plugins) {\n ingest(plugin.contributors?.(), 'plugin', plugin.name ?? 'plugin')\n }\n // Module-level registrations — captured during `setup()` because\n // module instances are not retained on the Application. Walk the\n // snapshot rather than calling `mod.contributors()` here.\n for (const { registration, label } of this._moduleContributors) {\n ingest([registration], 'module', label)\n }\n ingest(this.options.contributors, 'global', 'bootstrap')\n return out\n }\n\n getHttpServer(): http.Server | null {\n return this.httpServer\n }\n\n // ── Internal helpers ────────────────────────────────────────────────\n\n /**\n * Decide whether {@link Application} should auto-mount the\n * {@link requestScopeMiddleware} ALS wrapper.\n *\n * Returns `false` when:\n * - `contextStore: 'manual'` was set (caller manages ALS frames), or\n * - the user-supplied `middleware` list already includes a\n * `requestScopeMiddleware()` (detected via the symbol marker stamped\n * in `middleware/request-scope.ts`).\n *\n * Otherwise `true` — preserves the historical default of \"always wrap\n * requests in an ALS frame\" so existing apps see no behavior change.\n */\n private shouldAutoMountRequestScope(): boolean {\n if (this.options.contextStore === 'manual') return false\n\n const userEntries = this.options.middlewares ?? this.options.middleware ?? []\n for (const entry of userEntries) {\n const handler = typeof entry === 'function' ? entry : entry.handler\n if (isRequestScopeMiddleware(handler)) return false\n }\n return true\n }\n\n private collectAdapterMiddleware() {\n const result = {\n beforeGlobal: [] as AdapterMiddleware[],\n afterGlobal: [] as AdapterMiddleware[],\n beforeRoutes: [] as AdapterMiddleware[],\n afterRoutes: [] as AdapterMiddleware[],\n }\n\n for (const adapter of this.adapters) {\n const entries = adapter.middleware?.() ?? []\n for (const entry of entries) {\n const phase = entry.phase ?? 'afterGlobal'\n result[phase].push(entry)\n }\n }\n\n return result\n }\n\n private mountMiddlewareList(entries: AdapterMiddleware[]): void {\n for (const entry of entries) {\n if (entry.path === undefined) {\n this.runtime.useConnect(this.app, entry.handler)\n continue\n }\n this.runtime.useConnect(this.app, entry.handler, { path: entry.path })\n }\n }\n\n private mountMiddlewareEntry(entry: MiddlewareEntry): void {\n if (typeof entry === 'function') {\n this.runtime.useConnect(this.app, entry)\n } else {\n this.runtime.useConnect(this.app, entry.handler, { path: entry.path })\n }\n }\n\n /** Middleware that tracks in-flight requests for graceful draining */\n private requestTrackingMiddleware(): RequestHandler {\n return (_req, res, next) => {\n this._inFlightRequests++\n const onFinish = () => {\n res.removeListener('finish', onFinish)\n res.removeListener('close', onFinish)\n this._inFlightRequests--\n // If draining and no more in-flight requests, resolve all waiters\n if (this._draining && this._inFlightRequests === 0) {\n for (const resolve of this._drainResolvers) {\n resolve()\n }\n this._drainResolvers = []\n }\n }\n res.on('finish', onFinish)\n res.on('close', onFinish)\n next()\n }\n }\n\n /** Mount /health/live and /health/ready endpoints at the root (no API prefix) */\n private mountHealthEndpoints(): void {\n const http = this.adapterHttp()\n\n http.route('GET', '/health/live', (ctx) => {\n if (this._draining) {\n ctx.res.status(503).json({ status: 'draining', uptime: process.uptime() })\n } else {\n ctx.json({ status: 'ok', uptime: process.uptime() })\n }\n })\n\n http.route('GET', '/health/ready', async (ctx) => {\n if (this._draining) {\n ctx.res.status(503).json({ status: 'draining', checks: [] })\n return\n }\n const adaptersWithHealth = this.adapters.filter((a) => a.onHealthCheck)\n const checks = await Promise.allSettled(adaptersWithHealth.map((a) => a.onHealthCheck!()))\n const results = checks.map((c, i) => {\n if (c.status === 'fulfilled') return c.value\n return { name: adaptersWithHealth[i].name ?? 'unknown', status: 'down' as const }\n })\n const healthy = results.every((r) => r.status === 'up')\n ctx.res.status(healthy ? 200 : 503).json({\n status: healthy ? 'ready' : 'degraded',\n checks: results,\n })\n })\n }\n}\n"],"mappings":";;;;;;;;;;6mCAuCA,SAAgB,kBAAkB,QAA+B,CAC/D,IAAM,OAAS,OAAO,EAEtB,IAAK,IAAM,SAAS,QAAS,CAC3B,IAAM,OAAS,MAAM,OAAO,YAAY,EAClC,SAA6B,CAAC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,CAAC,CACH,CACF"}
@@ -1,7 +1,7 @@
1
1
 
2
- import { t as Container } from "./container-TWOUyR_0.mjs";
3
- import { d as ContributorRegistrations, r as AppModuleEntry } from "./app-module-CuAS6hJC.mjs";
4
- import { Mt as ModuleRegistry, f as HttpRuntime, jt as KickPlugin, r as AppAdapter, s as ActiveRuntime, y as RuntimeCapabilities } from "./adapter-D_uzU-QA.mjs";
2
+ import { t as Container } from "./container-iED1swkd.mjs";
3
+ import { d as ContributorRegistrations, r as AppModuleEntry } from "./app-module-BwYtACD6.mjs";
4
+ import { Ft as KickPlugin, It as ModuleRegistry, f as HttpRuntime, r as AppAdapter, s as ActiveRuntime, y as RuntimeCapabilities } from "./adapter-stSpsUHs.mjs";
5
5
  import http from "node:http";
6
6
  import { Express, RequestHandler } from "express";
7
7
 
@@ -439,4 +439,4 @@ declare class Application {
439
439
  }
440
440
  //#endregion
441
441
  export { ApplicationOptions as n, MiddlewareEntry as r, Application as t };
442
- //# sourceMappingURL=application-CFenLjbY.d.mts.map
442
+ //# sourceMappingURL=application-C_KlrNoH.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"application-CFenLjbY.d.mts","names":[],"sources":["../src/http/application.ts"],"mappings":";;;;;;;;;;;AA6CA;KAAY,eAAA,GAAkB,cAAA;EAAmB,IAAA;EAAc,OAAA,EAAS,cAAc;AAAA;AAAA,UAErE,kBAAA;EAF8C;;;AAAuB;AAEtF;;;;;;EAWE,OAAA,EAAS,cAAA;EAwDI;;;;;;;;;;;;;;;;;EArCb,KAAA,EAAO,QAAA,EAAU,cAAA;EAqCjB;EAnCA,QAAA,GAAW,UAAA;EAsCX;EApCA,IAAA;EA0DA;EAxDA,SAAA;EA4EA;EA1EA,cAAA;EAkHA;;;;;;;;;;;;;;;;;;;;;EA3FA,WAAA,GAAc,eAAA;EA8LN;AAAA;AAQV;;;EAhME,UAAA,GAAa,eAAA;EAuRG;EApRhB,OAAA,GAAU,UAAA;EAsS6B;;;;;;;;;;;;;;;;;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;;;;;EAsBvB,eAAA,IAAmB,aAAA;IACjB,GAAA;IACA,MAAA;IACA,KAAA;IACA,SAAA;EAAA;EA6CF,aAAA,IAAiB,IAAA,CAAK,MAAA;;;;;;;;;;;;;;UAmBd,2BAAA;EAAA,QAWA,wBAAA;EAAA,QAmBA,mBAAA;EAAA,QAUA,oBAAA;;UASA,yBAAA;;UAsBA,oBAAA;AAAA"}
@@ -1,5 +1,5 @@
1
1
 
2
- import { n as ApplicationOptions, t as Application } from "./application-CFenLjbY.mjs";
2
+ import { n as ApplicationOptions, t as Application } from "./application-C_KlrNoH.mjs";
3
3
 
4
4
  //#region src/http/bootstrap.d.ts
5
5
  /**
@@ -25,4 +25,4 @@ import { n as ApplicationOptions, t as Application } from "./application-CFenLjb
25
25
  declare function bootstrap(options: ApplicationOptions): Promise<Application>;
26
26
  //#endregion
27
27
  export { bootstrap as t };
28
- //# sourceMappingURL=bootstrap-DodgsiDG.d.mts.map
28
+ //# sourceMappingURL=bootstrap-BgffgFNX.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap-DodgsiDG.d.mts","names":[],"sources":["../src/http/bootstrap.ts"],"mappings":";;;;;;AAqCA;;;;;;;;;;;;;AAAiF;;;;;iBAA3D,SAAA,CAAU,OAAA,EAAS,kBAAA,GAAqB,OAAA,CAAQ,WAAA"}
1
+ {"version":3,"file":"bootstrap-BgffgFNX.d.mts","names":[],"sources":["../src/http/bootstrap.ts"],"mappings":";;;;;;AAqCA;;;;;;;;;;;;;AAAiF;;;;;iBAA3D,SAAA,CAAU,OAAA,EAAS,kBAAA,GAAqB,OAAA,CAAQ,WAAA"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs v6.1.1
2
+ * @forinda/kickjs v6.3.0
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -8,5 +8,5 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import{t as Container}from"./container-Oy24XRnS.mjs";import{createLogger}from"./core/logger.mjs";import"./core-kmJ4y4fJ.mjs";import{reactive,ref}from"./core/reactivity.mjs";import{t as Application}from"./application-KaKi6jgi.mjs";import{o as reloadEnv}from"./env-RP8lbK-Z.mjs";import cluster from"node:cluster";import os from"node:os";const log$1=createLogger(`Cluster`);function isClusterPrimary(){return cluster.isPrimary}function setupClusterPrimary(opts){let numWorkers=opts.workers??os.cpus().length,gracefulTimeout=opts.gracefulShutdownTimeout??5e3,restartDelay=opts.restartDelay??1e3,maxFailures=opts.maxFailures??5,restartWindow=opts.restartWindow??3e4,startupTimeouts=new Map,state=reactive({failureTimestamps:[],shuttingDown:!1}),activeWorkers=ref(0);log$1.info(`Primary ${process.pid} starting ${numWorkers} worker(s)`);for(let i=0;i<numWorkers;i++)cluster.fork();cluster.on(`fork`,worker=>{let timeout=setTimeout(()=>{log$1.error(`Worker ${worker.process.pid} did not respond within 10s, killing...`),worker.kill()},1e4);startupTimeouts.set(worker.id,timeout),activeWorkers.value++,log$1.debug(`Worker ${worker.process.pid} forked (id=${worker.id})`)}),cluster.on(`listening`,(worker,address)=>{let timeout=startupTimeouts.get(worker.id);timeout&&(clearTimeout(timeout),startupTimeouts.delete(worker.id)),log$1.info(`Worker ${worker.process.pid} listening on ${address.address}:${address.port}`)}),cluster.on(`online`,worker=>{log$1.debug(`Worker ${worker.process.pid} online (id=${worker.id})`)}),cluster.on(`exit`,(worker,code,signal)=>{let timeout=startupTimeouts.get(worker.id);if(timeout&&(clearTimeout(timeout),startupTimeouts.delete(worker.id)),activeWorkers.value--,worker.exitedAfterDisconnect){log$1.info(`Worker ${worker.process.pid} exited gracefully (id=${worker.id})`);return}let now=Date.now();for(;state.failureTimestamps.length>0&&now-state.failureTimestamps[0]>=restartWindow;)state.failureTimestamps.shift();if(state.failureTimestamps.push(now),state.failureTimestamps.length>maxFailures){log$1.error(`${state.failureTimestamps.length} worker failures in ${restartWindow}ms, giving up`),activeWorkers.value===0&&(log$1.error(`All workers have crashed, exiting primary`),process.exit(1));return}log$1.warn(`Worker ${worker.process.pid} died (code=${code}, signal=${signal}), restarting in ${restartDelay}ms... (failures: ${state.failureTimestamps.length}/${maxFailures})`),setTimeout(()=>{activeWorkers.value<numWorkers&&cluster.fork()},restartDelay)}),cluster.on(`disconnect`,worker=>{log$1.debug(`Worker ${worker.process.pid} disconnected (id=${worker.id})`)});for(let signal of[`SIGTERM`,`SIGINT`])process.on(signal,()=>{state.shuttingDown||(state.shuttingDown=!0,log$1.info(`Primary received ${signal}, disconnecting workers...`),cluster.disconnect(()=>{log$1.info(`All workers disconnected, exiting primary`),process.exit(0)}),setTimeout(()=>{log$1.warn(`Graceful shutdown timed out, forcing exit`),process.exit(1)},gracefulTimeout).unref())})}function tryReloadEnv(){try{reloadEnv()}catch{}}const log=createLogger(`Process`);async function bootstrap(options){let isViteDev=!!globalThis.__kickjs_httpServer;if(options.cluster&&isViteDev&&log.warn(`Cluster mode is ignored in dev — Vite owns the server. Cluster applies in production (kick start).`),options.cluster&&cluster.isPrimary&&!isViteDev)return setupClusterPrimary(typeof options.cluster==`object`?options.cluster:{}),new Application(options);let g=globalThis,processHooks=options.processHooks??`auto`;if(!g.__kickBootstrapped){if(processHooks!==`manual`&&(process.on(`uncaughtException`,err=>{log.error(err,`Uncaught exception`)}),process.on(`unhandledRejection`,reason=>{log.error(reason,`Unhandled rejection`)})),processHooks===`auto`&&!g.__kickjs_httpServer)for(let signal of[`SIGINT`,`SIGTERM`])process.on(signal,async()=>{log.info(`Received ${signal}, shutting down...`),g.__app&&await g.__app.shutdown(),process.exit(0)});g.__kickBootstrapped=!0}if(g.__app){log.debug(`HMR rebuild triggered`),tryReloadEnv(),Container.reset();let freshApp=new Application(options);return g.__app=freshApp,g.__kickjs_container=freshApp.getContainer(),await freshApp.start(),log.debug(`HMR rebuild complete`),freshApp}let app=new Application(options);return g.__app=app,g.__kickjs_container=app.getContainer(),process.env.KICK_TINKER?(await app.registerOnly(),app):(await app.start(),app)}export{isClusterPrimary as n,bootstrap as t};
12
- //# sourceMappingURL=bootstrap-Dj96_O6j.mjs.map
11
+ import{t as Container}from"./container-C522k8AX.mjs";import{createLogger}from"./core/logger.mjs";import"./core-3S12kJ7Q.mjs";import{reactive,ref}from"./core/reactivity.mjs";import{t as Application}from"./application-CHYTI1Q_.mjs";import{o as reloadEnv}from"./env-Cj5QLqnZ.mjs";import cluster from"node:cluster";import os from"node:os";const log$1=createLogger(`Cluster`);function isClusterPrimary(){return cluster.isPrimary}function setupClusterPrimary(opts){let numWorkers=opts.workers??os.cpus().length,gracefulTimeout=opts.gracefulShutdownTimeout??5e3,restartDelay=opts.restartDelay??1e3,maxFailures=opts.maxFailures??5,restartWindow=opts.restartWindow??3e4,startupTimeouts=new Map,state=reactive({failureTimestamps:[],shuttingDown:!1}),activeWorkers=ref(0);log$1.info(`Primary ${process.pid} starting ${numWorkers} worker(s)`);for(let i=0;i<numWorkers;i++)cluster.fork();cluster.on(`fork`,worker=>{let timeout=setTimeout(()=>{log$1.error(`Worker ${worker.process.pid} did not respond within 10s, killing...`),worker.kill()},1e4);startupTimeouts.set(worker.id,timeout),activeWorkers.value++,log$1.debug(`Worker ${worker.process.pid} forked (id=${worker.id})`)}),cluster.on(`listening`,(worker,address)=>{let timeout=startupTimeouts.get(worker.id);timeout&&(clearTimeout(timeout),startupTimeouts.delete(worker.id)),log$1.info(`Worker ${worker.process.pid} listening on ${address.address}:${address.port}`)}),cluster.on(`online`,worker=>{log$1.debug(`Worker ${worker.process.pid} online (id=${worker.id})`)}),cluster.on(`exit`,(worker,code,signal)=>{let timeout=startupTimeouts.get(worker.id);if(timeout&&(clearTimeout(timeout),startupTimeouts.delete(worker.id)),activeWorkers.value--,worker.exitedAfterDisconnect){log$1.info(`Worker ${worker.process.pid} exited gracefully (id=${worker.id})`);return}let now=Date.now();for(;state.failureTimestamps.length>0&&now-state.failureTimestamps[0]>=restartWindow;)state.failureTimestamps.shift();if(state.failureTimestamps.push(now),state.failureTimestamps.length>maxFailures){log$1.error(`${state.failureTimestamps.length} worker failures in ${restartWindow}ms, giving up`),activeWorkers.value===0&&(log$1.error(`All workers have crashed, exiting primary`),process.exit(1));return}log$1.warn(`Worker ${worker.process.pid} died (code=${code}, signal=${signal}), restarting in ${restartDelay}ms... (failures: ${state.failureTimestamps.length}/${maxFailures})`),setTimeout(()=>{activeWorkers.value<numWorkers&&cluster.fork()},restartDelay)}),cluster.on(`disconnect`,worker=>{log$1.debug(`Worker ${worker.process.pid} disconnected (id=${worker.id})`)});for(let signal of[`SIGTERM`,`SIGINT`])process.on(signal,()=>{state.shuttingDown||(state.shuttingDown=!0,log$1.info(`Primary received ${signal}, disconnecting workers...`),cluster.disconnect(()=>{log$1.info(`All workers disconnected, exiting primary`),process.exit(0)}),setTimeout(()=>{log$1.warn(`Graceful shutdown timed out, forcing exit`),process.exit(1)},gracefulTimeout).unref())})}function tryReloadEnv(){try{reloadEnv()}catch{}}const log=createLogger(`Process`);async function bootstrap(options){let isViteDev=!!globalThis.__kickjs_httpServer;if(options.cluster&&isViteDev&&log.warn(`Cluster mode is ignored in dev — Vite owns the server. Cluster applies in production (kick start).`),options.cluster&&cluster.isPrimary&&!isViteDev)return setupClusterPrimary(typeof options.cluster==`object`?options.cluster:{}),new Application(options);let g=globalThis,processHooks=options.processHooks??`auto`;if(!g.__kickBootstrapped){if(processHooks!==`manual`&&(process.on(`uncaughtException`,err=>{log.error(err,`Uncaught exception`)}),process.on(`unhandledRejection`,reason=>{log.error(reason,`Unhandled rejection`)})),processHooks===`auto`&&!g.__kickjs_httpServer)for(let signal of[`SIGINT`,`SIGTERM`])process.on(signal,async()=>{log.info(`Received ${signal}, shutting down...`),g.__app&&await g.__app.shutdown(),process.exit(0)});g.__kickBootstrapped=!0}if(g.__app){log.debug(`HMR rebuild triggered`),tryReloadEnv(),Container.reset();let freshApp=new Application(options);return g.__app=freshApp,g.__kickjs_container=freshApp.getContainer(),await freshApp.start(),log.debug(`HMR rebuild complete`),freshApp}let app=new Application(options);return g.__app=app,g.__kickjs_container=app.getContainer(),process.env.KICK_TINKER?(await app.registerOnly(),app):(await app.start(),app)}export{isClusterPrimary as n,bootstrap as t};
12
+ //# sourceMappingURL=bootstrap-sB0dlLu7.mjs.map