@forinda/kickjs 6.6.1 → 6.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/dist/{adapter-CbMq-NBf.d.mts → adapter-diFqgxGR.d.mts} +25 -13
  2. package/dist/{adapter-CbMq-NBf.d.mts.map → adapter-diFqgxGR.d.mts.map} +1 -1
  3. package/dist/{app-module-DtoySG6l.d.mts → app-module-DtNJpj0r.d.mts} +35 -36
  4. package/dist/app-module-DtNJpj0r.d.mts.map +1 -0
  5. package/dist/{application-zlzYGgKD.d.mts → application-D_mReBi_.d.mts} +3 -3
  6. package/dist/{application-zlzYGgKD.d.mts.map → application-D_mReBi_.d.mts.map} +1 -1
  7. package/dist/{application-C2SrI5f8.mjs → application-VxxP88FH.mjs} +3 -3
  8. package/dist/{application-C2SrI5f8.mjs.map → application-VxxP88FH.mjs.map} +1 -1
  9. package/dist/{bootstrap-Nzgi7K2d.d.mts → bootstrap-CytCvAnr.d.mts} +2 -2
  10. package/dist/bootstrap-CytCvAnr.d.mts.map +1 -0
  11. package/dist/{bootstrap-DiRoG6j9.mjs → bootstrap-F6IShJ1f.mjs} +3 -3
  12. package/dist/{bootstrap-DiRoG6j9.mjs.map → bootstrap-F6IShJ1f.mjs.map} +1 -1
  13. package/dist/config/index.mjs +2 -2
  14. package/dist/{config-BSFg58Cw.mjs → config-D035b21X.mjs} +3 -3
  15. package/dist/{config-BSFg58Cw.mjs.map → config-D035b21X.mjs.map} +1 -1
  16. package/dist/{container-CSxotdD4.mjs → container-CFVAdwXa.mjs} +3 -3
  17. package/dist/{container-CSxotdD4.mjs.map → container-CFVAdwXa.mjs.map} +1 -1
  18. package/dist/{context-A-vHOCow.mjs → context-CAN3t2jg.mjs} +3 -3
  19. package/dist/context-CAN3t2jg.mjs.map +1 -0
  20. package/dist/{context-errors-BN6Kbb22.mjs → context-errors-Ce44238b.mjs} +2 -2
  21. package/dist/{context-errors-BN6Kbb22.mjs.map → context-errors-Ce44238b.mjs.map} +1 -1
  22. package/dist/core/adapter.d.mts +1 -1
  23. package/dist/core/adapter.mjs +1 -1
  24. package/dist/core/app-module.d.mts +1 -1
  25. package/dist/core/app-module.mjs +1 -1
  26. package/dist/core/cache.mjs +1 -1
  27. package/dist/core/container.mjs +2 -2
  28. package/dist/core/cron.mjs +2 -2
  29. package/dist/core/decorators.mjs +2 -2
  30. package/dist/core/errors.mjs +1 -1
  31. package/dist/core/interfaces.mjs +1 -1
  32. package/dist/core/logger.mjs +1 -1
  33. package/dist/core/path.mjs +1 -1
  34. package/dist/core/plugin.d.mts +1 -1
  35. package/dist/core/plugin.mjs +1 -1
  36. package/dist/core/reactivity.mjs +1 -1
  37. package/dist/{core-OXbl534_.mjs → core-DW5uoNhO.mjs} +3 -3
  38. package/dist/core-DW5uoNhO.mjs.map +1 -0
  39. package/dist/{csrf-CY_WY-VY.mjs → csrf-MbsM7-58.mjs} +2 -2
  40. package/dist/{csrf-CY_WY-VY.mjs.map → csrf-MbsM7-58.mjs.map} +1 -1
  41. package/dist/{disposables-DlLzYI40.mjs → disposables-QYOU5_Eg.mjs} +2 -2
  42. package/dist/{disposables-DlLzYI40.mjs.map → disposables-QYOU5_Eg.mjs.map} +1 -1
  43. package/dist/{env-B_ay2OjK.mjs → env-DPEhlEC4.mjs} +3 -3
  44. package/dist/{env-B_ay2OjK.mjs.map → env-DPEhlEC4.mjs.map} +1 -1
  45. package/dist/{handler-BTz5BPXI.mjs → handler-DcxBY95X.mjs} +3 -3
  46. package/dist/{handler-BTz5BPXI.mjs.map → handler-DcxBY95X.mjs.map} +1 -1
  47. package/dist/http/application.d.mts +1 -1
  48. package/dist/http/application.mjs +2 -2
  49. package/dist/http/bootstrap.d.mts +1 -1
  50. package/dist/http/bootstrap.mjs +2 -2
  51. package/dist/http/context.d.mts +2 -2
  52. package/dist/http/context.mjs +2 -2
  53. package/dist/http/middleware/cors.mjs +1 -1
  54. package/dist/http/middleware/csrf.mjs +2 -2
  55. package/dist/http/middleware/error-handler.mjs +2 -2
  56. package/dist/http/middleware/helmet.mjs +1 -1
  57. package/dist/http/middleware/rate-limit.mjs +2 -2
  58. package/dist/http/middleware/request-id.mjs +1 -1
  59. package/dist/http/middleware/request-logger.mjs +2 -2
  60. package/dist/http/middleware/session.mjs +2 -2
  61. package/dist/http/middleware/spa.d.mts +1 -1
  62. package/dist/http/middleware/spa.mjs +2 -2
  63. package/dist/http/middleware/upload.d.mts +1 -1
  64. package/dist/http/middleware/upload.mjs +2 -2
  65. package/dist/http/middleware/validate.mjs +1 -1
  66. package/dist/http/middleware/views.d.mts +1 -1
  67. package/dist/http/middleware/views.mjs +2 -2
  68. package/dist/http/query/index.mjs +2 -2
  69. package/dist/http/router-builder.d.mts +1 -1
  70. package/dist/http/router-builder.mjs +2 -2
  71. package/dist/http/runtimes/fastify.d.mts +1 -1
  72. package/dist/http/runtimes/fastify.mjs +2 -2
  73. package/dist/http/runtimes/h3-web.d.mts +1 -1
  74. package/dist/http/runtimes/h3-web.mjs +2 -2
  75. package/dist/http/runtimes/h3.d.mts +1 -1
  76. package/dist/http/runtimes/h3.mjs +2 -2
  77. package/dist/index.d.mts +10 -10
  78. package/dist/index.mjs +2 -2
  79. package/dist/index.mjs.map +1 -1
  80. package/dist/{kv-stores-CHowq8VP.d.mts → kv-stores-D2kSUAEP.d.mts} +2 -2
  81. package/dist/{kv-stores-CHowq8VP.d.mts.map → kv-stores-D2kSUAEP.d.mts.map} +1 -1
  82. package/dist/{kv-stores-CcD6HvGV.mjs → kv-stores-VfJbg9Gs.mjs} +2 -2
  83. package/dist/{kv-stores-CcD6HvGV.mjs.map → kv-stores-VfJbg9Gs.mjs.map} +1 -1
  84. package/dist/{metadata-Ct03gV65.mjs → metadata-DjW8JOQZ.mjs} +2 -2
  85. package/dist/{metadata-Ct03gV65.mjs.map → metadata-DjW8JOQZ.mjs.map} +1 -1
  86. package/dist/{module-registry-DDdtsQld.mjs → module-registry-cbndPnlY.mjs} +2 -2
  87. package/dist/{module-registry-DDdtsQld.mjs.map → module-registry-cbndPnlY.mjs.map} +1 -1
  88. package/dist/{query-D6XQVnUA.mjs → query-B_YnIZ2-.mjs} +2 -2
  89. package/dist/{query-D6XQVnUA.mjs.map → query-B_YnIZ2-.mjs.map} +1 -1
  90. package/dist/{reply-Dcq46cVC.mjs → reply-Y50qUtDy.mjs} +3 -3
  91. package/dist/{reply-Dcq46cVC.mjs.map → reply-Y50qUtDy.mjs.map} +1 -1
  92. package/dist/{router-builder-CMGhEBU2.d.mts → router-builder-C6E11Grf.d.mts} +2 -2
  93. package/dist/{router-builder-CMGhEBU2.d.mts.map → router-builder-C6E11Grf.d.mts.map} +1 -1
  94. package/dist/{router-builder-C6Qmb3rB.mjs → router-builder-DtonR20n.mjs} +3 -3
  95. package/dist/{router-builder-C6Qmb3rB.mjs.map → router-builder-DtonR20n.mjs.map} +1 -1
  96. package/dist/{spa-DsRUrm69.d.mts → spa-CCi-hC2M.d.mts} +2 -2
  97. package/dist/{spa-DsRUrm69.d.mts.map → spa-CCi-hC2M.d.mts.map} +1 -1
  98. package/dist/{upload-XVTyQcNN.d.mts → upload-Wck12jE5.d.mts} +2 -2
  99. package/dist/{upload-XVTyQcNN.d.mts.map → upload-Wck12jE5.d.mts.map} +1 -1
  100. package/dist/{upload-config-DXxieUa0.mjs → upload-config-Dxr2BxTi.mjs} +2 -2
  101. package/dist/{upload-config-DXxieUa0.mjs.map → upload-config-Dxr2BxTi.mjs.map} +1 -1
  102. package/dist/{views-D_LVXJWs.mjs → views-3TYTcdyF.mjs} +3 -3
  103. package/dist/{views-D_LVXJWs.mjs.map → views-3TYTcdyF.mjs.map} +1 -1
  104. package/dist/{views-DsfBT1fR.d.mts → views-BBY9_PUV.d.mts} +12 -12
  105. package/dist/{views-DsfBT1fR.d.mts.map → views-BBY9_PUV.d.mts.map} +1 -1
  106. package/dist/web.d.mts +3 -3
  107. package/dist/web.mjs +2 -2
  108. package/package.json +2 -2
  109. package/dist/app-module-DtoySG6l.d.mts.map +0 -1
  110. package/dist/bootstrap-Nzgi7K2d.d.mts.map +0 -1
  111. package/dist/context-A-vHOCow.mjs.map +0 -1
  112. package/dist/core-OXbl534_.mjs.map +0 -1
@@ -2,7 +2,7 @@
2
2
  import { i as Constructor, o as MaybePromise } from "./interfaces-BTTBdkvG.mjs";
3
3
  import { s as InjectionToken, t as Container } from "./container-BW_MlgLj.mjs";
4
4
  import { g as FileUploadConfig, k as RouteDefinition, x as MiddlewareHandler } from "./decorators-Bks7cgBJ.mjs";
5
- import { _ as ExecutionContext, a as AnyContributorRegistration, d as ContributorRegistrations, r as AppModuleEntry, t as AppModule, v as MetaValue } from "./app-module-DtoySG6l.mjs";
5
+ import { S as MetaValue, a as AnyContributorRegistration, b as ContextMetaKey, p as ContributorRegistrations, r as AppModuleEntry, t as AppModule, x as ExecutionContext } from "./app-module-DtNJpj0r.mjs";
6
6
  import "./cache-C0qL0NSD.mjs";
7
7
  import { i as ProblemDetails } from "./errors-By6UueCm.mjs";
8
8
  import { S as QueryFieldConfig, T as TypedParsedQuery, t as ParseQueryOptions } from "./index-BfT5KZ-M.mjs";
@@ -1025,12 +1025,14 @@ interface RouteShape {
1025
1025
  */
1026
1026
  declare class RequestContext<TBody = any, TParams = any, TQuery = any,
1027
1027
  /**
1028
- * Context keys proven present for this route. Defaults to `string`, so
1029
- * a handler typed as plain `RequestContext` keeps today's unnarrowed
1030
- * behaviour — which is also the deliberate escape hatch when typegen's
1031
- * view is incomplete.
1028
+ * Context keys proven present for this route. Defaults to
1029
+ * {@link ContextMetaKey} — every key the project has registered — which
1030
+ * collapses to `string` when neither registry has been augmented, so a
1031
+ * handler typed as plain `RequestContext` keeps today's behaviour. That
1032
+ * default is also the deliberate escape hatch when typegen's view of a
1033
+ * route is incomplete.
1032
1034
  */
1033
- TKeys extends string = string> implements ExecutionContext<TKeys> {
1035
+ TKeys extends ContextMetaKey = ContextMetaKey> implements ExecutionContext<TKeys> {
1034
1036
  readonly req: ActiveRuntime['request'];
1035
1037
  readonly res: ActiveRuntime['response'];
1036
1038
  readonly next: NextFunction;
@@ -1213,11 +1215,21 @@ TKeys extends string = string> implements ExecutionContext<TKeys> {
1213
1215
  /**
1214
1216
  * Read a value from the per-request metadata store.
1215
1217
  *
1216
- * When `ContextMeta` has been augmented with a matching key, the return
1217
- * type is inferred automatically. For ad-hoc keys, pass a generic:
1218
- * `ctx.get<MyType>('custom')`.
1218
+ * The key is constrained to {@link ContextMetaKey} — the keys registered in
1219
+ * `ContextMeta` / `ContextKeys` — so a typo is a compile error rather than a
1220
+ * permanent `undefined`. Projects that have augmented neither registry get
1221
+ * `string`, exactly as before.
1222
+ *
1223
+ * Constrained by `ContextMetaKey` and deliberately NOT by `TKeys`: "does this
1224
+ * key exist in the app" is a different question from "does this route carry
1225
+ * it", and narrowing by the latter would turn an incomplete typegen view into
1226
+ * false errors for keys written by middleware. Presence is `require`'s job;
1227
+ * this always returns `| undefined`.
1228
+ *
1229
+ * When `ContextMeta` has a matching key the return type is inferred
1230
+ * automatically. For ad-hoc keys, pass a generic: `ctx.get<MyType>('custom')`.
1219
1231
  */
1220
- get<K extends string>(key: K): MetaValue<K> | undefined;
1232
+ get<K extends ContextMetaKey>(key: K): MetaValue<K> | undefined;
1221
1233
  /**
1222
1234
  * Read a value that a contributor is expected to have produced, and
1223
1235
  * throw {@link MissingContextValueError} when it hasn't.
@@ -1267,7 +1279,7 @@ TKeys extends string = string> implements ExecutionContext<TKeys> {
1267
1279
  * AsyncLocalStorage frame is active — see {@link metadataForWrite}
1268
1280
  * for why a silent fallback is the wrong default.
1269
1281
  */
1270
- set<K extends string>(key: K, value: MetaValue<K>): void;
1282
+ set<K extends ContextMetaKey>(key: K, value: MetaValue<K>): void;
1271
1283
  /**
1272
1284
  * Set a response header. Runtime-neutral — works on every engine and on
1273
1285
  * the web/edge entry. No-op guards are the runtime's job (headers set
@@ -1453,7 +1465,7 @@ type Ctx<TRoute extends RouteShape = RouteShape> = RequestContext<TRoute extends
1453
1465
  query: infer Q;
1454
1466
  } ? Q : any, TRoute extends {
1455
1467
  contextKeys: infer K;
1456
- } ? (K extends string ? K : string) : string>;
1468
+ } ? K extends ContextMetaKey ? K : ContextMetaKey : ContextMetaKey>;
1457
1469
  /**
1458
1470
  * Global ambient registry of typed routes, populated by `kick typegen`.
1459
1471
  *
@@ -1924,4 +1936,4 @@ interface AppAdapter {
1924
1936
  type AppAdapterClass = new () => AppAdapter;
1925
1937
  //#endregion
1926
1938
  export { defineModules as $, DefineAdapterOptions as A, getClassMetaOrUndefined as B, Ctx as C, SseHandler as D, RouteShape as E, ContributorPipeline as F, hasClassMeta as G, getMetaRecord as H, ContributorSource as I, setClassMeta as J, pushClassMeta as K, SourcedRegistration as L, RunContributorsOptions as M, runContributors as N, AdapterAsyncOptions as O, BuildPipelineOptions as P, ModuleList as Q, buildPipeline as R, UseConnectOptions as S, RequestContext as T, getMethodMeta as U, getMetaMap as V, getMethodMetaOrUndefined as W, setInMetaRecord as X, setInMetaMap as Y, setMethodMeta as Z, RouteTable as _, IntrospectionSnapshot as _t, MiddlewarePath as a, PluginAsyncOptions as at, RuntimeResponse as b, AdapterHttp as c, KickPlugin as ct, ExpressRuntimeTypes as d, AugmentationMeta as dt, DefineModuleOptions as et, HttpRuntime as f, KickJsPluginName as ft, RouteMethod as g, IntrospectionKind as gt, RouteMeta as h, IntrospectFn as ht, AppAdapterClass as i, DefinePluginOptions as it, defineAdapter as j, AdapterFactory as k, ConnectMiddleware as l, ModuleRegistry as lt, RouteEntry as m, defineAugmentation as mt, AdapterMiddleware as n, defineModule as nt, MiddlewarePhase as o, PluginFactory as ot, KickRuntimeRegister as p, KickJsPluginRegistry as pt, pushMethodMeta as q, AppAdapter as r, BuildContext as rt, ActiveRuntime as s, definePlugin as st, AdapterContext as t, ModuleFactory as tt, CtxHandler as u, MutableModuleRegistry as ut, RuntimeAppOptions as v, DeepReadonly as w, RuntimeTypeMap as x, RuntimeCapabilities as y, getClassMeta as z };
1927
- //# sourceMappingURL=adapter-CbMq-NBf.d.mts.map
1939
+ //# sourceMappingURL=adapter-diFqgxGR.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"adapter-CbMq-NBf.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/metadata.ts","../src/core/contributor-pipeline.ts","../src/core/contributor-runner.ts","../src/core/define-adapter.ts","../src/http/context.ts","../src/http/runtime.ts","../src/core/adapter.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAkBiB;;;;;;;;;;EAUf;;EAEA;;EAEA,MAAM;;EAEN;;;;;EAKA,QAAQ;;EAER;IAAW;IAA6B;;;;;;EAKxC,UAAU;;EAEV;;;;;;;;KASU;;;;;;KAOA,qBAAqB,wBAAwB,QAAQ;;;;;;;;;;;;;;;;;;;;;;;UC3ChD;;;;;;;;;KAUL,yBAAyB,oDAE3B;;;;;;;;;;;UAYO;;;;;EAKf;;;;;;;EAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAmDc,mBAAmB,cAAc,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UC3EvC;;;;;;;;;;;EAWf,MAAM,QAAQ;;;;;;;;;;;cAYH,iCAAiC;WACnC,SAAS;EAElB,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UCCC;;EAEf;;;;;;;;;;;;;;;;;;;EAoBA,qBAAqB;;;;;EAMrB,UAAU,WAAW;;;;;;;;;;;;;;EAerB,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;EA2BZ,OAAO,UAAU;;;;;EAMjB,aAAa;;;;;EAMb;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgCA,iBAAiB;;;;;EAMjB,SAAS,WAAW,mBA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;;;;;;;;;;;;KCxOxB;;;;;;;;;;;;;KAcA,0BAA0B,SAAS,uBAAuB;;UAGrD;;;;;;;EAOf,SAAS,iBAAiB;;EAE1B,QAAQ;;;;;;EAMR,OAAO;;;;;;;;;;;;;;;UAgBQ;;;;;;EAMf,MAAM;;;;;;;EAON,KAAK;;EAEL,WAAW;;EAEX,SAAS,KAAK;;EAEd;;EAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA+Be;;;;;;EAMf;;;;;;;;;;;;;;;;;;;;EAqBA,qBAAqB;;;;;EAMrB,eAAe;;;;;;;;;;EAWf,iBAAiB;;;;;EAMjB,aAAa,KAAK,wBAAwB;;;;;EAM1C,cAAc,iBAAiB,aAAa;;;;;;;;;;;;;EAc5C,aAAa,KAAK,wBAAwB;;;;;;;;;;;;;;;EAgB1C,YAAY,KAAK,wBAAwB;;;;;EAMzC,kBAAkB;IAAU;IAAc;;;EAG1C,aAAa;;;;;;;;;;;;;EAcb,eAAe,wBAAwB,QAAQ;;;;;;;;;;;EAY/C;;;KAIU,4BAA4B"}
1
+ {"version":3,"file":"adapter-diFqgxGR.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/metadata.ts","../src/core/contributor-pipeline.ts","../src/core/contributor-runner.ts","../src/core/define-adapter.ts","../src/http/context.ts","../src/http/runtime.ts","../src/core/adapter.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAkBiB;;;;;;;;;;EAUf;;EAEA;;EAEA,MAAM;;EAEN;;;;;EAKA,QAAQ;;EAER;IAAW;IAA6B;;;;;;EAKxC,UAAU;;EAEV;;;;;;;;KASU;;;;;;KAOA,qBAAqB,wBAAwB,QAAQ;;;;;;;;;;;;;;;;;;;;;;;UC3ChD;;;;;;;;;KAUL,yBAAyB,oDAE3B;;;;;;;;;;;UAYO;;;;;EAKf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AwB,QAAQ;;;;;;;;;;;EAY/C;;;KAIU,4BAA4B"}
@@ -78,6 +78,28 @@ interface ContextMeta {}
78
78
  * ```
79
79
  */
80
80
  interface ContextKeys {}
81
+ /**
82
+ * Every context key the project has registered — the union of the
83
+ * {@link ContextKeys} (dependsOn-only) and {@link ContextMeta} (value-type)
84
+ * registries. Resolves to `string` when neither has been augmented, so a
85
+ * first-day project keeps compiling, and narrows to the concrete keys once
86
+ * `declare module '@forinda/kickjs' { interface ContextKeys/ContextMeta { … } }`
87
+ * lands.
88
+ *
89
+ * Unioning BOTH registries is deliberate: adding a value type via
90
+ * `ContextMeta` automatically makes that key a valid `dependsOn` target, and
91
+ * a key can be registered in `ContextKeys` without being forced to carry a
92
+ * value type. (Before the split, `dependsOn` keyed off `ContextMeta` alone,
93
+ * so augmenting it for some keys broke `dependsOn` for every key you had not
94
+ * added there.)
95
+ *
96
+ * Lives here, beside the two registries it reads, so `ExecutionContext` can
97
+ * use it without importing from `context-decorator` — which imports THIS
98
+ * module, and would make the pair circular. Re-exported from
99
+ * `context-decorator` for back-compat.
100
+ */
101
+ type KnownContextKey = keyof ContextMeta | keyof ContextKeys;
102
+ type ContextMetaKey = [KnownContextKey] extends [never] ? string : KnownContextKey & string;
81
103
  /** Resolve a {@link ContextMeta} value type, falling back to `Fallback` for unknown keys. */
82
104
  type MetaValue<K extends string, Fallback = unknown> = K extends keyof ContextMeta ? ContextMeta[K] : Fallback;
83
105
  /**
@@ -88,7 +110,7 @@ type MetaValue<K extends string, Fallback = unknown> = K extends keyof ContextMe
88
110
  * pipeline only depends on this interface — contributors authored against
89
111
  * `ExecutionContext` work across every transport that adopts it.
90
112
  */
91
- interface ExecutionContext<TKeys extends string = string> {
113
+ interface ExecutionContext<TKeys extends ContextMetaKey = ContextMetaKey> {
92
114
  /**
93
115
  * Read a typed value from per-request metadata.
94
116
  *
@@ -97,7 +119,7 @@ interface ExecutionContext<TKeys extends string = string> {
97
119
  * is present, and a wrong claim there fails open — exactly the silent
98
120
  * failure `require` exists to prevent.
99
121
  */
100
- get<K extends string>(key: K): MetaValue<K> | undefined;
122
+ get<K extends ContextMetaKey>(key: K): MetaValue<K> | undefined;
101
123
  /**
102
124
  * Read a value that must be present, throwing `MissingContextValueError`
103
125
  * when it isn't. Use for preconditions (permissions, tenant, resolved
@@ -113,35 +135,12 @@ interface ExecutionContext<TKeys extends string = string> {
113
135
  */
114
136
  require<K extends TKeys>(key: K): Exclude<MetaValue<K>, undefined>;
115
137
  /** Write a typed value into per-request metadata. */
116
- set<K extends string>(key: K, value: MetaValue<K>): void;
138
+ set<K extends ContextMetaKey>(key: K, value: MetaValue<K>): void;
117
139
  /** Unique per-request identifier (HTTP: x-request-id; WS/queue/cron: transport-defined). */
118
140
  readonly requestId: string | undefined;
119
141
  }
120
142
  //#endregion
121
143
  //#region src/core/context-decorator.d.ts
122
- /**
123
- * String-literal union of every known context key — the union of the
124
- * keys declared on {@link ContextKeys} (key-only registry) and
125
- * {@link ContextMeta} (value-type registry). Resolves to `string` when
126
- * the project hasn't augmented either yet (so a first-day project keeps
127
- * compiling), and narrows to the concrete keys once the
128
- * `declare module '@forinda/kickjs' { interface ContextKeys/ContextMeta { ... } }`
129
- * blocks land.
130
- *
131
- * Used as the element type of `dependsOn`, so a typo like
132
- * `dependsOn: ['tenent']` becomes a TS error instead of a boot-time
133
- * `MissingContributorError`.
134
- *
135
- * Unioning BOTH registries is deliberate: it means adding a value type
136
- * via `ContextMeta` automatically makes that key a valid `dependsOn`
137
- * target, and you can register a dependsOn-able key in `ContextKeys`
138
- * without being forced to give it a value type. (Before the split,
139
- * `dependsOn` was keyed off `ContextMeta` alone, so augmenting
140
- * `ContextMeta` for some keys broke `dependsOn` for every key you
141
- * hadn't added there.)
142
- */
143
- type KnownContextKey = keyof ContextMeta | keyof ContextKeys;
144
- type ContextMetaKey = [KnownContextKey] extends [never] ? string : KnownContextKey & string;
145
144
  /**
146
145
  * What a single `deps` entry is allowed to be — the runtime calls
147
146
  * `container.resolve(value)`, which accepts an injection token brand
@@ -196,7 +195,7 @@ type CallSiteParams<P, PD> = [MissingParamKeys<P, PD>] extends [never] ? Partial
196
195
  * call site is required to supply — see {@link CallSiteParams}.
197
196
  * Never spell this by hand.
198
197
  */
199
- interface ContextDecoratorSpec<K extends string = string, D extends Record<string, DepValue> = Record<string, never>, P extends Record<string, unknown> = Record<string, never>, Ctx extends ExecutionContext = ExecutionContext, PD extends Partial<P> = Partial<P>> {
198
+ interface ContextDecoratorSpec<K extends ContextMetaKey = ContextMetaKey, D extends Record<string, DepValue> = Record<string, never>, P extends Record<string, unknown> = Record<string, never>, Ctx extends ExecutionContext = ExecutionContext, PD extends Partial<P> = Partial<P>> {
200
199
  /** ContextMeta key the resolved value is written to. */
201
200
  key: K;
202
201
  /**
@@ -296,7 +295,7 @@ interface ContextDecoratorSpec<K extends string = string, D extends Record<strin
296
295
  * module, adapter, global). The pipeline builder dedupes by `key` using
297
296
  * the precedence rule defined in §20.4 of `architecture.md`.
298
297
  */
299
- interface ContributorRegistration<K extends string = string, D extends Record<string, DepValue> = Record<string, never>, Ctx extends ExecutionContext = ExecutionContext> {
298
+ interface ContributorRegistration<K extends ContextMetaKey = ContextMetaKey, D extends Record<string, DepValue> = Record<string, never>, Ctx extends ExecutionContext = ExecutionContext> {
300
299
  readonly key: K;
301
300
  readonly deps: D;
302
301
  readonly dependsOn: readonly ContextMetaKey[];
@@ -349,7 +348,7 @@ interface ContributorRegistration<K extends string = string, D extends Record<st
349
348
  * (or any future transport-specific ctx) in the same array without
350
349
  * casting.
351
350
  */
352
- type AnyContributorRegistration = ContributorRegistration<string, any, any>;
351
+ type AnyContributorRegistration = ContributorRegistration<ContextMetaKey, any, any>;
353
352
  /** Convenience alias for `AnyContributorRegistration[]` collections. */
354
353
  type ContributorRegistrations = AnyContributorRegistration[] | readonly AnyContributorRegistration[];
355
354
  /**
@@ -383,14 +382,14 @@ interface ContextDecoratorTarget {
383
382
  * (`Partial<P>`) keeps hand-written `ContextDecorator<K, D, P>`
384
383
  * annotations resolving to the permissive shape as before.
385
384
  */
386
- type ContextDecorator<K extends string = string, D extends Record<string, DepValue> = Record<string, never>, P extends Record<string, unknown> = Record<string, never>, Ctx extends ExecutionContext = ExecutionContext, PD = Partial<P>> = [MissingParamKeys<P, PD>] extends [never] ? ContextDecoratorWithDefaults<K, D, P, Ctx> : ContextDecoratorRequiringParams<K, D, P, Ctx, PD>;
385
+ type ContextDecorator<K extends ContextMetaKey = ContextMetaKey, D extends Record<string, DepValue> = Record<string, never>, P extends Record<string, unknown> = Record<string, never>, Ctx extends ExecutionContext = ExecutionContext, PD = Partial<P>> = [MissingParamKeys<P, PD>] extends [never] ? ContextDecoratorWithDefaults<K, D, P, Ctx> : ContextDecoratorRequiringParams<K, D, P, Ctx, PD>;
387
386
  /**
388
387
  * Decorator whose params are fully defaulted (or which takes none).
389
388
  * Callable as a class or method decorator directly, as a factory, or
390
389
  * via `.with(params)` / `.registration` at non-decorator registration
391
390
  * sites.
392
391
  */
393
- interface ContextDecoratorWithDefaults<K extends string = string, D extends Record<string, DepValue> = Record<string, never>, P extends Record<string, unknown> = Record<string, never>, Ctx extends ExecutionContext = ExecutionContext> {
392
+ interface ContextDecoratorWithDefaults<K extends ContextMetaKey = ContextMetaKey, D extends Record<string, DepValue> = Record<string, never>, P extends Record<string, unknown> = Record<string, never>, Ctx extends ExecutionContext = ExecutionContext> {
394
393
  /**
395
394
  * Class decorator usage with `paramDefaults` — `@Foo class C {}`.
396
395
  * The class constructor is a `Function`, so this overload only
@@ -479,7 +478,7 @@ interface ContextDecoratorWithDefaults<K extends string = string, D extends Reco
479
478
  * `paramDefaults` — but only when the default is genuinely correct for
480
479
  * an undecorated route, which for a permission string it usually isn't.
481
480
  */
482
- interface ContextDecoratorRequiringParams<K extends string = string, D extends Record<string, DepValue> = Record<string, never>, P extends Record<string, unknown> = Record<string, never>, Ctx extends ExecutionContext = ExecutionContext, PD = Partial<P>> {
481
+ interface ContextDecoratorRequiringParams<K extends ContextMetaKey = ContextMetaKey, D extends Record<string, DepValue> = Record<string, never>, P extends Record<string, unknown> = Record<string, never>, Ctx extends ExecutionContext = ExecutionContext, PD = Partial<P>> {
483
482
  /**
484
483
  * Factory usage — the only decorator form available here. The
485
484
  * argument type carries every required field `paramDefaults` didn't
@@ -524,7 +523,7 @@ interface ContextDecoratorRequiringParams<K extends string = string, D extends R
524
523
  * positional form when there are no params (the common case).
525
524
  */
526
525
  interface DefineContextDecoratorWithParams<P extends Record<string, unknown>> {
527
- <K extends string, D extends Record<string, DepValue> = Record<string, never>, Ctx extends ExecutionContext = ExecutionContext, PD extends Partial<P> = Record<never, never>>(spec: ContextDecoratorSpec<K, D, P, Ctx, PD>): ContextDecorator<K, D, P, Ctx, PD>;
526
+ <K extends ContextMetaKey, D extends Record<string, DepValue> = Record<string, never>, Ctx extends ExecutionContext = ExecutionContext, PD extends Partial<P> = Record<never, never>>(spec: ContextDecoratorSpec<K, D, P, Ctx, PD>): ContextDecorator<K, D, P, Ctx, PD>;
528
527
  }
529
528
  /**
530
529
  * The public shape of {@link defineContextDecorator}. Combines the
@@ -533,7 +532,7 @@ interface DefineContextDecoratorWithParams<P extends Record<string, unknown>> {
533
532
  * parameterised case.
534
533
  */
535
534
  interface DefineContextDecoratorFn {
536
- <K extends string, D extends Record<string, DepValue> = Record<string, never>, P extends Record<string, unknown> = Record<string, never>, Ctx extends ExecutionContext = ExecutionContext, PD extends Partial<P> = Record<never, never>>(spec: ContextDecoratorSpec<K, D, P, Ctx, PD>): ContextDecorator<K, D, P, Ctx, PD>;
535
+ <K extends ContextMetaKey, D extends Record<string, DepValue> = Record<string, never>, P extends Record<string, unknown> = Record<string, never>, Ctx extends ExecutionContext = ExecutionContext, PD extends Partial<P> = Record<never, never>>(spec: ContextDecoratorSpec<K, D, P, Ctx, PD>): ContextDecorator<K, D, P, Ctx, PD>;
537
536
  /**
538
537
  * Curried entry point. Spell only the per-call params shape `P`;
539
538
  * `K`, `D`, and `Ctx` are inferred from the spec passed to the
@@ -643,5 +642,5 @@ type AppModuleClass = new () => AppModule;
643
642
  */
644
643
  type AppModuleEntry = AppModuleClass | AppModule;
645
644
  //#endregion
646
- 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 };
647
- //# sourceMappingURL=app-module-DtoySG6l.d.mts.map
645
+ export { MetaValue as S, defineContextDecorator as _, AnyContributorRegistration as a, ContextMetaKey as b, ContextDecoratorRequiringParams as c, ContextDecoratorWithDefaults as d, ContributorRegistration as f, ResolvedDeps as g, MissingParamKeys as h, ModuleRoutes as i, ContextDecoratorSpec as l, DepValue as m, AppModuleClass as n, CallSiteParams as o, ContributorRegistrations as p, AppModuleEntry as r, ContextDecorator as s, AppModule as t, ContextDecoratorTarget as u, ContextKeys as v, ExecutionContext as x, ContextMeta as y };
646
+ //# sourceMappingURL=app-module-DtNJpj0r.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-module-DtNJpj0r.d.mts","names":[],"sources":["../src/core/execution-context.ts","../src/core/context-decorator.ts","../src/core/app-module.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA8CiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAgCA;;;;;;;;;;;;;;;;;;;;;KAsBZ,wBAAwB,oBAAoB;KACrC,kBAAkB,4CAA4C;;KAG9D,UAAU,kBAAkB,sBAAsB,gBAAgB,cAC1E,YAAY,KACZ;;;;;;;;;UAUa,iBAAiB,cAAc,iBAAiB;;;;;;;;;EAS/D,IAAI,UAAU,gBAAgB,KAAK,IAAI,UAAU;;;;;;;;;;;;;;EAcjD,QAAQ,UAAU,OAAO,KAAK,IAA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AAmB,kBAC/B,WAAW,QAAQ,KAAK,sBAExB,MAAM,qBAAqB,GAAG,GAAG,GAAG,KAAK,MACxC,iBAAiB,GAAG,GAAG,GAAG,KAAK;;;;;;;EAQlC,WAAW,UAAU,4BAA4B,iCAAiC;;;;;;;;;;;;;;;cA8YvE,wBAAwB;;;;;;;;;;;;;UCp4BpB;;EAEf;;;;;;;EAOA;;EAEA;;;;;;EAMA;;;;;;;;;;;;;UAce;;EAEf,UAAU,WAAW;;;;;;;;;EASrB,iBAAiB;;EAEjB,UAAU,eAAe;;;;;;;;;;;;;;;KAgBf,2BAA2B;;;;;;;;;;;;;;;KAgB3B,iBAAiB,iBAAiB"}
@@ -1,7 +1,7 @@
1
1
 
2
2
  import { t as Container } from "./container-BW_MlgLj.mjs";
3
- import { d as ContributorRegistrations, r as AppModuleEntry } from "./app-module-DtoySG6l.mjs";
4
- import { ct as KickPlugin, f as HttpRuntime, lt as ModuleRegistry, r as AppAdapter, s as ActiveRuntime, y as RuntimeCapabilities } from "./adapter-CbMq-NBf.mjs";
3
+ import { p as ContributorRegistrations, r as AppModuleEntry } from "./app-module-DtNJpj0r.mjs";
4
+ import { ct as KickPlugin, f as HttpRuntime, lt as ModuleRegistry, r as AppAdapter, s as ActiveRuntime, y as RuntimeCapabilities } from "./adapter-diFqgxGR.mjs";
5
5
  import http from "node:http";
6
6
  import { Express, RequestHandler } from "express";
7
7
  //#region src/http/application.d.ts
@@ -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-zlzYGgKD.d.mts.map
442
+ //# sourceMappingURL=application-D_mReBi_.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"application-zlzYGgKD.d.mts","names":[],"sources":["../src/http/application.ts"],"mappings":";;;;;;;;;;;KAwDY,kBAAkB;EAAmB;EAAc,SAAS;;UAEvD;;;;;;;;;;;EAWf,SAAS;;;;;;;;;;;;;;;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
+ * @forinda/kickjs v6.7.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{METADATA}from"./core/interfaces.mjs";import{n as tokenName,s as moduleRouteMissingControllerError,t as Container}from"./container-CSxotdD4.mjs";import{Logger,createLogger}from"./core/logger.mjs";import{t as getClassMeta}from"./metadata-Ct03gV65.mjs";import{t as MutableModuleRegistry}from"./module-registry-DDdtsQld.mjs";import{i as runDisposables,n as drainDisposables,r as registerDisposable,t as disposeAll}from"./disposables-DlLzYI40.mjs";import{joinPaths,normalizePath}from"./core/path.mjs";import"./core-OXbl534_.mjs";import{n as assertRouteUnique,r as buildRouteTable,t as _setExternalContributorSources}from"./router-builder-C6Qmb3rB.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-A-vHOCow.mjs";import{o as isRequestScopeMiddleware,s as requestScopeMiddleware,t as applyHandlerResult}from"./reply-Dcq46cVC.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";var DuplicateMountNameError=class extends Error{kind;mountName;constructor(kind,mountName){super(`Duplicate ${kind} name '${mountName}' — every ${kind} must declare a unique name`),this.name=`DuplicateMountNameError`,this.kind=kind,this.mountName=mountName}},MissingMountDepError=class extends Error{kind;missing;dependent;constructor(kind,missing,dependent){super(`Missing ${kind} dependency '${missing}' required by '${dependent}' — is the ${kind} installed and named correctly?`),this.name=`MissingMountDepError`,this.kind=kind,this.missing=missing,this.dependent=dependent}},MountCycleError=class extends Error{kind;cycle;constructor(kind,cycle){super(`Cycle in ${kind} dependsOn declarations: ${cycle.join(` → `)}`),this.name=`MountCycleError`,this.kind=kind,this.cycle=Object.freeze([...cycle])}};function mountSort(items,kind){let byName=new Map;for(let item of items){if(byName.has(item.name))throw new DuplicateMountNameError(kind,item.name);byName.set(item.name,item)}let indegree=new Map,dependents=new Map;for(let item of items)indegree.set(item.name,item.dependsOn?.length??0);for(let item of items)for(let dep of item.dependsOn??[]){if(!byName.has(dep))throw new MissingMountDepError(kind,dep,item.name);let list=dependents.get(dep)??[];list.push(item),dependents.set(dep,list)}let queue=[];for(let item of items)indegree.get(item.name)===0&&queue.push(item);let sorted=[];for(;queue.length>0;){let node=queue.shift();sorted.push(node);for(let dependent of dependents.get(node.name)??[]){let next=(indegree.get(dependent.name)??0)-1;indegree.set(dependent.name,next),next===0&&queue.push(dependent)}}if(sorted.length!==items.length)throw new MountCycleError(kind,reconstructCycle(items.filter(it=>(indegree.get(it.name)??0)>0),byName));return sorted}function reconstructCycle(residual,byName){let residualNames=new Set(residual.map(r=>r.name)),start=residual[0].name,path=[start],seen=new Set([start]),cursor=start;for(;;){let nextDep=byName.get(cursor).dependsOn?.find(d=>residualNames.has(d));if(nextDep===void 0)break;if(seen.has(nextDep)){let cycleStart=path.indexOf(nextDep);return[...path.slice(cycleStart),nextDep]}path.push(nextDep),seen.add(nextDep),cursor=nextDep}return path}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=[];let seenRoutes=new Map;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){let routeTable=buildRouteTable(route.controller),ctrl=route.controller.name??`controller`;for(let entry of routeTable){let owner=`${ctrl}.${String(entry.meta.handlerName??`?`)}`;assertRouteUnique(seenRoutes,entry.method,joinPaths(mountPath,entry.path),owner)}this.runtime.mountRoutes(this.app,[{mountPath,routes:routeTable}])}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{DuplicateMountNameError as a,mountSort as c,materializeRouter as i,buildRoutes as n,MissingMountDepError as o,expressRuntime as r,MountCycleError as s,Application as t};
12
- //# sourceMappingURL=application-C2SrI5f8.mjs.map
11
+ import{METADATA}from"./core/interfaces.mjs";import{n as tokenName,s as moduleRouteMissingControllerError,t as Container}from"./container-CFVAdwXa.mjs";import{Logger,createLogger}from"./core/logger.mjs";import{t as getClassMeta}from"./metadata-DjW8JOQZ.mjs";import{t as MutableModuleRegistry}from"./module-registry-cbndPnlY.mjs";import{i as runDisposables,n as drainDisposables,r as registerDisposable,t as disposeAll}from"./disposables-QYOU5_Eg.mjs";import{joinPaths,normalizePath}from"./core/path.mjs";import"./core-DW5uoNhO.mjs";import{n as assertRouteUnique,r as buildRouteTable,t as _setExternalContributorSources}from"./router-builder-DtonR20n.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-CAN3t2jg.mjs";import{o as isRequestScopeMiddleware,s as requestScopeMiddleware,t as applyHandlerResult}from"./reply-Y50qUtDy.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";var DuplicateMountNameError=class extends Error{kind;mountName;constructor(kind,mountName){super(`Duplicate ${kind} name '${mountName}' — every ${kind} must declare a unique name`),this.name=`DuplicateMountNameError`,this.kind=kind,this.mountName=mountName}},MissingMountDepError=class extends Error{kind;missing;dependent;constructor(kind,missing,dependent){super(`Missing ${kind} dependency '${missing}' required by '${dependent}' — is the ${kind} installed and named correctly?`),this.name=`MissingMountDepError`,this.kind=kind,this.missing=missing,this.dependent=dependent}},MountCycleError=class extends Error{kind;cycle;constructor(kind,cycle){super(`Cycle in ${kind} dependsOn declarations: ${cycle.join(` → `)}`),this.name=`MountCycleError`,this.kind=kind,this.cycle=Object.freeze([...cycle])}};function mountSort(items,kind){let byName=new Map;for(let item of items){if(byName.has(item.name))throw new DuplicateMountNameError(kind,item.name);byName.set(item.name,item)}let indegree=new Map,dependents=new Map;for(let item of items)indegree.set(item.name,item.dependsOn?.length??0);for(let item of items)for(let dep of item.dependsOn??[]){if(!byName.has(dep))throw new MissingMountDepError(kind,dep,item.name);let list=dependents.get(dep)??[];list.push(item),dependents.set(dep,list)}let queue=[];for(let item of items)indegree.get(item.name)===0&&queue.push(item);let sorted=[];for(;queue.length>0;){let node=queue.shift();sorted.push(node);for(let dependent of dependents.get(node.name)??[]){let next=(indegree.get(dependent.name)??0)-1;indegree.set(dependent.name,next),next===0&&queue.push(dependent)}}if(sorted.length!==items.length)throw new MountCycleError(kind,reconstructCycle(items.filter(it=>(indegree.get(it.name)??0)>0),byName));return sorted}function reconstructCycle(residual,byName){let residualNames=new Set(residual.map(r=>r.name)),start=residual[0].name,path=[start],seen=new Set([start]),cursor=start;for(;;){let nextDep=byName.get(cursor).dependsOn?.find(d=>residualNames.has(d));if(nextDep===void 0)break;if(seen.has(nextDep)){let cycleStart=path.indexOf(nextDep);return[...path.slice(cycleStart),nextDep]}path.push(nextDep),seen.add(nextDep),cursor=nextDep}return path}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=[];let seenRoutes=new Map;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){let routeTable=buildRouteTable(route.controller),ctrl=route.controller.name??`controller`;for(let entry of routeTable){let owner=`${ctrl}.${String(entry.meta.handlerName??`?`)}`;assertRouteUnique(seenRoutes,entry.method,joinPaths(mountPath,entry.path),owner)}this.runtime.mountRoutes(this.app,[{mountPath,routes:routeTable}])}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{DuplicateMountNameError as a,mountSort as c,materializeRouter as i,buildRoutes as n,MissingMountDepError as o,expressRuntime as r,MountCycleError as s,Application as t};
12
+ //# sourceMappingURL=application-VxxP88FH.mjs.map