@forinda/kickjs 6.4.0 → 6.5.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.
- package/dist/{adapter-BjxEv8oW.d.mts → adapter-CEt1MEdF.d.mts} +120 -10
- package/dist/adapter-CEt1MEdF.d.mts.map +1 -0
- package/dist/{app-module-BwYtACD6.d.mts → app-module-BSpHKlhE.d.mts} +149 -28
- package/dist/app-module-BSpHKlhE.d.mts.map +1 -0
- package/dist/{application-Bo3jSfmL.d.mts → application-Bzdzl5wP.d.mts} +3 -3
- package/dist/{application-Bo3jSfmL.d.mts.map → application-Bzdzl5wP.d.mts.map} +1 -1
- package/dist/{application-TiHVcGRL.mjs → application-C-r79XqD.mjs} +3 -3
- package/dist/{application-TiHVcGRL.mjs.map → application-C-r79XqD.mjs.map} +1 -1
- package/dist/{bootstrap-DW2yzKh6.mjs → bootstrap-C1VGQQVF.mjs} +3 -3
- package/dist/{bootstrap-DW2yzKh6.mjs.map → bootstrap-C1VGQQVF.mjs.map} +1 -1
- package/dist/{bootstrap-DUUxZXvF.d.mts → bootstrap-DYexY169.d.mts} +2 -2
- package/dist/{bootstrap-DUUxZXvF.d.mts.map → bootstrap-DYexY169.d.mts.map} +1 -1
- package/dist/config/index.mjs +2 -2
- package/dist/{config-BTDTXaeZ.mjs → config-BeIZJBXA.mjs} +3 -3
- package/dist/{config-BTDTXaeZ.mjs.map → config-BeIZJBXA.mjs.map} +1 -1
- package/dist/{container-Da9BLMHy.mjs → container-CBaL5lus.mjs} +3 -3
- package/dist/{container-Da9BLMHy.mjs.map → container-CBaL5lus.mjs.map} +1 -1
- package/dist/context-BS5o1IuU.mjs +12 -0
- package/dist/context-BS5o1IuU.mjs.map +1 -0
- package/dist/context-errors-CwD27Vbj.mjs +13 -0
- package/dist/context-errors-CwD27Vbj.mjs.map +1 -0
- package/dist/contributor-runner-Cu13cDQp.mjs +12 -0
- package/dist/contributor-runner-Cu13cDQp.mjs.map +1 -0
- package/dist/core/adapter.d.mts +1 -1
- package/dist/core/adapter.mjs +1 -1
- package/dist/core/app-module.d.mts +1 -1
- package/dist/core/app-module.mjs +1 -1
- package/dist/core/cache.mjs +1 -1
- package/dist/core/container.mjs +2 -2
- package/dist/core/cron.mjs +2 -2
- package/dist/core/decorators.mjs +2 -2
- package/dist/core/errors.mjs +1 -1
- package/dist/core/interfaces.mjs +1 -1
- package/dist/core/logger.d.mts +2 -2
- package/dist/core/logger.mjs +2 -2
- package/dist/core/logger.mjs.map +1 -1
- package/dist/core/path.mjs +1 -1
- package/dist/core/plugin.d.mts +1 -1
- package/dist/core/plugin.mjs +1 -1
- package/dist/core/reactivity.mjs +1 -1
- package/dist/core-TDR0XGzO.mjs +12 -0
- package/dist/core-TDR0XGzO.mjs.map +1 -0
- package/dist/{csrf-Dlo-P8Il.mjs → csrf-DNh_7aOk.mjs} +2 -2
- package/dist/{csrf-Dlo-P8Il.mjs.map → csrf-DNh_7aOk.mjs.map} +1 -1
- package/dist/{disposables-rPSyh69r.mjs → disposables-mnjJuaVx.mjs} +2 -2
- package/dist/{disposables-rPSyh69r.mjs.map → disposables-mnjJuaVx.mjs.map} +1 -1
- package/dist/{env-Ce-aYRxQ.mjs → env-Dgtjncd5.mjs} +3 -3
- package/dist/{env-Ce-aYRxQ.mjs.map → env-Dgtjncd5.mjs.map} +1 -1
- package/dist/{error-handler-3ih4E-QZ.d.mts → error-handler-DR01K_rI.d.mts} +5 -1
- package/dist/error-handler-DR01K_rI.d.mts.map +1 -0
- package/dist/handler-UvmjQGYc.mjs +13 -0
- package/dist/handler-UvmjQGYc.mjs.map +1 -0
- package/dist/http/application.d.mts +1 -1
- package/dist/http/application.mjs +2 -2
- package/dist/http/bootstrap.d.mts +1 -1
- package/dist/http/bootstrap.mjs +2 -2
- package/dist/http/context.d.mts +2 -2
- package/dist/http/context.mjs +2 -2
- package/dist/http/middleware/cors.mjs +1 -1
- package/dist/http/middleware/csrf.mjs +2 -2
- package/dist/http/middleware/error-handler.d.mts +1 -1
- package/dist/http/middleware/error-handler.mjs +3 -2
- package/dist/http/middleware/error-handler.mjs.map +1 -1
- package/dist/http/middleware/helmet.mjs +1 -1
- package/dist/http/middleware/rate-limit.mjs +2 -2
- package/dist/http/middleware/request-id.mjs +1 -1
- package/dist/http/middleware/request-logger.mjs +2 -2
- package/dist/http/middleware/session.mjs +2 -2
- package/dist/http/middleware/spa.d.mts +1 -1
- package/dist/http/middleware/spa.mjs +2 -2
- package/dist/http/middleware/upload.mjs +2 -2
- package/dist/http/middleware/validate.mjs +1 -1
- package/dist/http/middleware/views.d.mts +1 -1
- package/dist/http/middleware/views.mjs +2 -2
- package/dist/http/query/index.mjs +2 -2
- package/dist/http/router-builder.d.mts +1 -1
- package/dist/http/router-builder.mjs +2 -2
- package/dist/http/runtimes/fastify.d.mts +1 -1
- package/dist/http/runtimes/fastify.mjs +2 -2
- package/dist/http/runtimes/h3-web.d.mts +1 -1
- package/dist/http/runtimes/h3-web.d.mts.map +1 -1
- package/dist/http/runtimes/h3-web.mjs +2 -2
- package/dist/http/runtimes/h3-web.mjs.map +1 -1
- package/dist/http/runtimes/h3.d.mts +1 -1
- package/dist/http/runtimes/h3.mjs +2 -2
- package/dist/index.d.mts +11 -11
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/{kv-stores-CAYc5VKm.mjs → kv-stores-O8HUSwpv.mjs} +2 -2
- package/dist/{kv-stores-CAYc5VKm.mjs.map → kv-stores-O8HUSwpv.mjs.map} +1 -1
- package/dist/{kv-stores-gQrfH0KQ.d.mts → kv-stores-duYHIEr1.d.mts} +2 -2
- package/dist/{kv-stores-gQrfH0KQ.d.mts.map → kv-stores-duYHIEr1.d.mts.map} +1 -1
- package/dist/{logger-COlEkn_C.d.mts → logger-DA43DvNY.d.mts} +18 -3
- package/dist/logger-DA43DvNY.d.mts.map +1 -0
- package/dist/{metadata-BhKXlN2F.mjs → metadata-CUDfhy4e.mjs} +2 -2
- package/dist/{metadata-BhKXlN2F.mjs.map → metadata-CUDfhy4e.mjs.map} +1 -1
- package/dist/{module-registry-CvP9mee-.mjs → module-registry-Mv5FqVlq.mjs} +2 -2
- package/dist/{module-registry-CvP9mee-.mjs.map → module-registry-Mv5FqVlq.mjs.map} +1 -1
- package/dist/{query-Cs_Llg77.mjs → query-gMAVXzx2.mjs} +2 -2
- package/dist/{query-Cs_Llg77.mjs.map → query-gMAVXzx2.mjs.map} +1 -1
- package/dist/{reply-edT8RGBB.mjs → reply-BMBvs-FB.mjs} +3 -3
- package/dist/{reply-edT8RGBB.mjs.map → reply-BMBvs-FB.mjs.map} +1 -1
- package/dist/{rolldown-runtime-Bzotz84Y.mjs → rolldown-runtime-CuwksmWW.mjs} +1 -1
- package/dist/{router-builder-CiS2ASTJ.d.mts → router-builder-GWgxoOdC.d.mts} +2 -2
- package/dist/{router-builder-CiS2ASTJ.d.mts.map → router-builder-GWgxoOdC.d.mts.map} +1 -1
- package/dist/{spa-Dp9onKJt.d.mts → spa-DWzSWAzx.d.mts} +2 -2
- package/dist/{spa-Dp9onKJt.d.mts.map → spa-DWzSWAzx.d.mts.map} +1 -1
- package/dist/{upload-config-C3MSF7RF.mjs → upload-config-CFfHvoHF.mjs} +2 -2
- package/dist/{upload-config-C3MSF7RF.mjs.map → upload-config-CFfHvoHF.mjs.map} +1 -1
- package/dist/{views-DjgUXRdu.d.mts → views-Kp8Z3AO1.d.mts} +4 -4
- package/dist/{views-DjgUXRdu.d.mts.map → views-Kp8Z3AO1.d.mts.map} +1 -1
- package/dist/web.d.mts +3 -3
- package/dist/web.d.mts.map +1 -1
- package/dist/web.mjs +2 -2
- package/package.json +1 -1
- package/dist/adapter-BjxEv8oW.d.mts.map +0 -1
- package/dist/app-module-BwYtACD6.d.mts.map +0 -1
- package/dist/context-Cs0939u1.mjs +0 -12
- package/dist/context-Cs0939u1.mjs.map +0 -1
- package/dist/contributor-runner-B3Z3Q7J5.mjs +0 -13
- package/dist/contributor-runner-B3Z3Q7J5.mjs.map +0 -1
- package/dist/core-CQ6u5kOq.mjs +0 -12
- package/dist/core-CQ6u5kOq.mjs.map +0 -1
- package/dist/error-handler-3ih4E-QZ.d.mts.map +0 -1
- package/dist/handler-D8Zyie-B.mjs +0 -12
- package/dist/handler-D8Zyie-B.mjs.map +0 -1
- package/dist/logger-COlEkn_C.d.mts.map +0 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { i as Constructor, o as MaybePromise } from "./interfaces-CayXPOAf.mjs";
|
|
3
3
|
import { s as InjectionToken, t as Container } from "./container-iED1swkd.mjs";
|
|
4
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-
|
|
5
|
+
import { _ as ExecutionContext, a as AnyContributorRegistration, d as ContributorRegistrations, r as AppModuleEntry, t as AppModule, v as MetaValue } from "./app-module-BSpHKlhE.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";
|
|
@@ -875,11 +875,18 @@ declare class CircuitBreaker {
|
|
|
875
875
|
/**
|
|
876
876
|
* Errors thrown by the Context Contributor pipeline.
|
|
877
877
|
*
|
|
878
|
-
*
|
|
879
|
-
*
|
|
880
|
-
*
|
|
881
|
-
*
|
|
882
|
-
*
|
|
878
|
+
* `MissingContributorError`, `ContributorCycleError`, and
|
|
879
|
+
* `DuplicateContributorError` are startup-time errors raised during
|
|
880
|
+
* pipeline build (topo-sort + validation), not per-request — a
|
|
881
|
+
* misconfigured app fails to boot rather than fails a request. Per the
|
|
882
|
+
* locked design in `architecture.md` §20.4, the pipeline is validated
|
|
883
|
+
* once when each route is mounted and the resolved order is cached on
|
|
884
|
+
* the route.
|
|
885
|
+
*
|
|
886
|
+
* `MissingContextValueError` is the one request-time error here: it is
|
|
887
|
+
* raised by `ctx.require(key)` when a value a handler declared it needs
|
|
888
|
+
* is absent. See its doc comment for why that case can't be caught at
|
|
889
|
+
* startup today.
|
|
883
890
|
*/
|
|
884
891
|
/**
|
|
885
892
|
* A contributor declared `dependsOn: ['<key>']` but no other contributor
|
|
@@ -898,6 +905,41 @@ declare class MissingContributorError extends Error {
|
|
|
898
905
|
readonly dependentDefinedAt?: string;
|
|
899
906
|
constructor(key: string, dependent: string, route?: string, dependentDefinedAt?: string);
|
|
900
907
|
}
|
|
908
|
+
/**
|
|
909
|
+
* `ctx.require(key)` found no value under `key` in the per-request
|
|
910
|
+
* metadata store.
|
|
911
|
+
*
|
|
912
|
+
* Thrown at request time, by design. `ctx.get(key)` returns
|
|
913
|
+
* `T | undefined` for every key, so the usual workaround is a
|
|
914
|
+
* non-null assertion — `ctx.get('tenant')!` — which compiles whether or
|
|
915
|
+
* not the route actually carries the contributor that produces it. On
|
|
916
|
+
* an authorization value that is the worst possible thing to leave
|
|
917
|
+
* untypeable: dropping the decorator produces no diagnostic anywhere,
|
|
918
|
+
* and the handler reads `undefined` as though it were a real value.
|
|
919
|
+
*
|
|
920
|
+
* `ctx.require()` converts that silent hole into a loud, named failure
|
|
921
|
+
* that points at the missing contributor.
|
|
922
|
+
*
|
|
923
|
+
* A handler typed with a generated route type (`Ctx<KickRoutes…>`) also
|
|
924
|
+
* gets compile-time narrowing, so a dropped decorator fails `tsc` rather
|
|
925
|
+
* than reaching this error at all. This error remains the backstop for
|
|
926
|
+
* routes typegen couldn't prove (module/adapter/bootstrap registrations),
|
|
927
|
+
* handlers typed as plain `RequestContext`, and contributors that ran but
|
|
928
|
+
* resolved to `undefined`. See `architecture.md` §20.14.
|
|
929
|
+
*
|
|
930
|
+
* @example
|
|
931
|
+
* ```text
|
|
932
|
+
* MissingContextValueError: No context value for 'tenantPerm' on GET /projects/:id
|
|
933
|
+
* Nothing wrote this key before the handler ran. Either the contributor
|
|
934
|
+
* that produces it isn't applied to this route, or it ran and resolved
|
|
935
|
+
* to undefined (check `optional: true` contributors).
|
|
936
|
+
* ```
|
|
937
|
+
*/
|
|
938
|
+
declare class MissingContextValueError extends Error {
|
|
939
|
+
readonly key: string;
|
|
940
|
+
readonly route?: string;
|
|
941
|
+
constructor(key: string, route?: string);
|
|
942
|
+
}
|
|
901
943
|
/**
|
|
902
944
|
* Topo-sort detected a cycle in `dependsOn` declarations. The `cycle` field
|
|
903
945
|
* lists the keys in the order they form the loop, with the first key
|
|
@@ -1326,6 +1368,21 @@ interface RouteShape {
|
|
|
1326
1368
|
body?: unknown;
|
|
1327
1369
|
query?: unknown;
|
|
1328
1370
|
response?: unknown;
|
|
1371
|
+
/**
|
|
1372
|
+
* Union of context keys `kick typegen` proved are populated for this
|
|
1373
|
+
* route — the keys of every context contributor applied at method or
|
|
1374
|
+
* class level. Drives {@link RequestContext.require} narrowing, so
|
|
1375
|
+
* calling `ctx.require()` for a key this route doesn't carry is a
|
|
1376
|
+
* compile error instead of a request-time throw.
|
|
1377
|
+
*
|
|
1378
|
+
* `string` (the default) means "not proven", not "no keys". Typegen
|
|
1379
|
+
* emits `string` whenever it cannot see the full picture — a
|
|
1380
|
+
* contributor registered at module / adapter / bootstrap level, or an
|
|
1381
|
+
* unrecognised decorator that might bundle contributors of its own.
|
|
1382
|
+
* Narrowing an unprovable route would produce compile errors for keys
|
|
1383
|
+
* that really are present.
|
|
1384
|
+
*/
|
|
1385
|
+
contextKeys?: string;
|
|
1329
1386
|
}
|
|
1330
1387
|
/**
|
|
1331
1388
|
* Unified request/response abstraction passed to every controller method.
|
|
@@ -1335,7 +1392,14 @@ interface RouteShape {
|
|
|
1335
1392
|
* Contributor pipeline (#107) can run against this concrete HTTP context
|
|
1336
1393
|
* the same way it will run against future WS / queue / cron contexts.
|
|
1337
1394
|
*/
|
|
1338
|
-
declare class RequestContext<TBody = any, TParams = any, TQuery = any
|
|
1395
|
+
declare class RequestContext<TBody = any, TParams = any, TQuery = any,
|
|
1396
|
+
/**
|
|
1397
|
+
* Context keys proven present for this route. Defaults to `string`, so
|
|
1398
|
+
* a handler typed as plain `RequestContext` keeps today's unnarrowed
|
|
1399
|
+
* behaviour — which is also the deliberate escape hatch when typegen's
|
|
1400
|
+
* view is incomplete.
|
|
1401
|
+
*/
|
|
1402
|
+
TKeys extends string = string> implements ExecutionContext<TKeys> {
|
|
1339
1403
|
readonly req: ActiveRuntime['request'];
|
|
1340
1404
|
readonly res: ActiveRuntime['response'];
|
|
1341
1405
|
readonly next: NextFunction;
|
|
@@ -1523,6 +1587,50 @@ declare class RequestContext<TBody = any, TParams = any, TQuery = any> implement
|
|
|
1523
1587
|
* `ctx.get<MyType>('custom')`.
|
|
1524
1588
|
*/
|
|
1525
1589
|
get<K extends string>(key: K): MetaValue<K> | undefined;
|
|
1590
|
+
/**
|
|
1591
|
+
* Read a value that a contributor is expected to have produced, and
|
|
1592
|
+
* throw {@link MissingContextValueError} when it hasn't.
|
|
1593
|
+
*
|
|
1594
|
+
* Use this instead of `ctx.get(key)!` anywhere the value is a
|
|
1595
|
+
* precondition rather than an optional extra — permissions, tenants,
|
|
1596
|
+
* the resolved subject of the route. The non-null assertion compiles
|
|
1597
|
+
* whether or not the producing contributor is actually applied to the
|
|
1598
|
+
* route, so a dropped `@LoadTenant` turns into `undefined` flowing
|
|
1599
|
+
* silently into an auth check. `require()` fails loudly at that point
|
|
1600
|
+
* instead, naming the key.
|
|
1601
|
+
*
|
|
1602
|
+
* ```ts
|
|
1603
|
+
* // before — compiles even if @OperatorPerm was never applied
|
|
1604
|
+
* const perm = ctx.get('operatorPerm')!
|
|
1605
|
+
*
|
|
1606
|
+
* // after — throws MissingContextValueError naming the key + route
|
|
1607
|
+
* const perm = ctx.require('operatorPerm')
|
|
1608
|
+
* ```
|
|
1609
|
+
*
|
|
1610
|
+
* When `TKeys` is narrowed — which it is for a handler typed as
|
|
1611
|
+
* `Ctx<KickRoutes…>`, from typegen's per-route `contextKeys` — asking
|
|
1612
|
+
* for a key the route doesn't carry is a compile error, so a dropped
|
|
1613
|
+
* decorator fails the build. `TKeys` stays `string` (no narrowing) for
|
|
1614
|
+
* a plain `RequestContext` and for any route typegen couldn't prove
|
|
1615
|
+
* complete; there this is a runtime guarantee only.
|
|
1616
|
+
* See `architecture.md` §20.14.
|
|
1617
|
+
*
|
|
1618
|
+
* `null` counts as present; only `undefined` (or a missing entry)
|
|
1619
|
+
* throws. A contributor that deliberately resolves to `null` is
|
|
1620
|
+
* expressing "looked, found nothing", which is a real value — which
|
|
1621
|
+
* is why the return type is `Exclude<…, undefined>` and NOT
|
|
1622
|
+
* `NonNullable<…>`. The latter would strip `null` from the type while
|
|
1623
|
+
* the runtime still hands it back, so a caller would be told a value
|
|
1624
|
+
* is non-null and then get `null`.
|
|
1625
|
+
*/
|
|
1626
|
+
require<K extends TKeys>(key: K): Exclude<MetaValue<K>, undefined>;
|
|
1627
|
+
/**
|
|
1628
|
+
* Best-effort `"GET /path"` label for error messages. Runtime-agnostic:
|
|
1629
|
+
* express/fastify requests and web-standard `Request` all expose
|
|
1630
|
+
* `method` + `url`, but none of them are guaranteed here, so every
|
|
1631
|
+
* access is defensive and the whole thing is optional.
|
|
1632
|
+
*/
|
|
1633
|
+
private routeLabel;
|
|
1526
1634
|
/**
|
|
1527
1635
|
* Write a value to the per-request metadata store. Throws when no
|
|
1528
1636
|
* AsyncLocalStorage frame is active — see {@link metadataForWrite}
|
|
@@ -1699,7 +1807,9 @@ type Ctx<TRoute extends RouteShape = RouteShape> = RequestContext<TRoute extends
|
|
|
1699
1807
|
params: infer P;
|
|
1700
1808
|
} ? P : any, TRoute extends {
|
|
1701
1809
|
query: infer Q;
|
|
1702
|
-
} ? Q : any
|
|
1810
|
+
} ? Q : any, TRoute extends {
|
|
1811
|
+
contextKeys: infer K;
|
|
1812
|
+
} ? (K extends string ? K : string) : string>;
|
|
1703
1813
|
/**
|
|
1704
1814
|
* Global ambient registry of typed routes, populated by `kick typegen`.
|
|
1705
1815
|
*
|
|
@@ -2169,5 +2279,5 @@ interface AppAdapter {
|
|
|
2169
2279
|
/** Constructor type for AppAdapter classes */
|
|
2170
2280
|
type AppAdapterClass = new () => AppAdapter;
|
|
2171
2281
|
//#endregion
|
|
2172
|
-
export {
|
|
2173
|
-
//# sourceMappingURL=adapter-
|
|
2282
|
+
export { MissingContextValueError as $, GroupAssetKeysOptions as A, defineModule as At, MountCycleError as B, KickJsPluginName as Bt, Ctx as C, Disposable as Ct, SseHandler as D, defineModules as Dt, RouteShape as E, ModuleList as Et, AdapterFactory as F, definePlugin as Ft, runContributors as G, IntrospectionSnapshot as Gt, MountSortItem as H, defineAugmentation as Ht, DefineAdapterOptions as I, KickPlugin as It, ContributorSource as J, BuildPipelineOptions as K, defineAdapter as L, ModuleRegistry as Lt, groupAssetKeys as M, DefinePluginOptions as Mt, stripExt as N, PluginAsyncOptions as Nt, AssetKeyPair as O, DefineModuleOptions as Ot, AdapterAsyncOptions as P, PluginFactory as Pt, DuplicateContributorError as Q, DuplicateMountNameError as R, MutableModuleRegistry as Rt, UseConnectOptions as S, formatKickError as St, RequestContext as T, registerDisposable as Tt, mountSort as U, IntrospectFn as Ut, MountKind as V, KickJsPluginRegistry as Vt, RunContributorsOptions as W, IntrospectionKind as Wt, buildPipeline as X, SourcedRegistration as Y, ContributorCycleError as Z, RouteTable as _, setInMetaRecord as _t, MiddlewarePath as a, CircuitOpenError as at, RuntimeResponse as b, KickError as bt, AdapterHttp as c, getMetaMap as ct, ExpressRuntimeTypes as d, getMethodMetaOrUndefined as dt, MissingContributorError as et, HttpRuntime as f, hasClassMeta as ft, RouteMethod as g, setInMetaMap as gt, RouteMeta as h, setClassMeta as ht, AppAdapterClass as i, CircuitBreakerStats as it, GroupAssetKeysResult as j, BuildContext as jt, AssetKeyStrategy as k, ModuleFactory as kt, ConnectMiddleware as l, getMetaRecord as lt, RouteEntry as m, pushMethodMeta as mt, AdapterMiddleware as n, CircuitBreakerOptions as nt, MiddlewarePhase as o, getClassMeta as ot, KickRuntimeRegister as p, pushClassMeta as pt, ContributorPipeline as q, AppAdapter as r, CircuitBreakerState as rt, ActiveRuntime as s, getClassMetaOrUndefined as st, AdapterContext as t, CircuitBreaker as tt, CtxHandler as u, getMethodMeta as ut, RuntimeAppOptions as v, setMethodMeta as vt, DeepReadonly as w, disposeAll as wt, RuntimeTypeMap as x, KickErrorInit as xt, RuntimeCapabilities as y, FormatKickErrorOptions as yt, MissingMountDepError as z, AugmentationMeta as zt };
|
|
2283
|
+
//# sourceMappingURL=adapter-CEt1MEdF.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter-CEt1MEdF.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,qBAAA;EA4BC;;;;;;;;;EAlBhB,eAAA;EAawC;EAXxC,IAAA;EAgBU;EAdV,IAAA,EAAM,iBAAA;EAgBK;EAdX,OAAA;EAuBU;;;;EAlBV,KAAA,GAAQ,MAAA;EAyBE;EAvBV,MAAA;IAAW,QAAA;IAA6B,QAAA;EAAA;EAuBe;;;;EAlBvD,OAAA,GAAU,MAAA;EAkBqD;EAhB/D,WAAA;AAAA;;;;AC3BF;;;KDoCY,iBAAA;ACpCyB;AAUrC;;;;AAVqC,KD2CzB,YAAA,SAAqB,qBAAA,GAAwB,OAAA,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UAAA,EAAY,GAAA,EAAK,cAAA,UAAwB,OAAA;EfxKzC;;;;Ee8KA,aAAA,KAAkB,OAAA;IAAU,IAAA;IAAc,MAAA;EAAA;EftKd;EeyK5B,QAAA,KAAa,YAAA;EfxKK;;;;;;;;;;;;EesLlB,UAAA,KAAe,qBAAA,GAAwB,OAAA,CAAQ,qBAAA;EflLlB;;;;;;;;;;Ee8L7B,YAAA;AAAA;;KAIU,eAAA,aAA4B,UAAU"}
|
|
@@ -87,9 +87,30 @@ type MetaValue<K extends string, Fallback = unknown> = K extends keyof ContextMe
|
|
|
87
87
|
* pipeline only depends on this interface — contributors authored against
|
|
88
88
|
* `ExecutionContext` work across every transport that adopts it.
|
|
89
89
|
*/
|
|
90
|
-
interface ExecutionContext {
|
|
91
|
-
/**
|
|
90
|
+
interface ExecutionContext<TKeys extends string = string> {
|
|
91
|
+
/**
|
|
92
|
+
* Read a typed value from per-request metadata.
|
|
93
|
+
*
|
|
94
|
+
* Deliberately NOT narrowed by `TKeys`: `get` accepts any key and
|
|
95
|
+
* always returns `| undefined`. Narrowing it would mean claiming a key
|
|
96
|
+
* is present, and a wrong claim there fails open — exactly the silent
|
|
97
|
+
* failure `require` exists to prevent.
|
|
98
|
+
*/
|
|
92
99
|
get<K extends string>(key: K): MetaValue<K> | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* Read a value that must be present, throwing `MissingContextValueError`
|
|
102
|
+
* when it isn't. Use for preconditions (permissions, tenant, resolved
|
|
103
|
+
* subject) where `get(key)!` would silently paper over a contributor
|
|
104
|
+
* that never ran. Only `undefined` throws — `null` is a real value,
|
|
105
|
+
* hence `Exclude<…, undefined>` rather than `NonNullable<…>`.
|
|
106
|
+
*
|
|
107
|
+
* When `TKeys` is narrowed (via a typegen'd `Ctx<KickRoutes…>`), asking
|
|
108
|
+
* for a key the route doesn't carry is a compile error — which is how a
|
|
109
|
+
* dropped decorator stops being invisible. The narrowing direction is
|
|
110
|
+
* deliberate: an incomplete typegen view produces a false *error*, not
|
|
111
|
+
* a false guarantee.
|
|
112
|
+
*/
|
|
113
|
+
require<K extends TKeys>(key: K): Exclude<MetaValue<K>, undefined>;
|
|
93
114
|
/** Write a typed value into per-request metadata. */
|
|
94
115
|
set<K extends string>(key: K, value: MetaValue<K>): void;
|
|
95
116
|
/** Unique per-request identifier (HTTP: x-request-id; WS/queue/cron: transport-defined). */
|
|
@@ -137,6 +158,30 @@ type DepValue = InjectionToken<unknown> | Constructor<unknown>;
|
|
|
137
158
|
* against the DI container and hands the result to `resolve()`.
|
|
138
159
|
*/
|
|
139
160
|
type ResolvedDeps<D extends Record<string, DepValue>> = { [K in keyof D]: D[K] extends InjectionToken<infer T> ? T : D[K] extends Constructor<infer T> ? T : never };
|
|
161
|
+
/**
|
|
162
|
+
* Keys of `T` that are declared required (i.e. not `?`-optional).
|
|
163
|
+
*/
|
|
164
|
+
type RequiredParamKeys<T> = { [K in keyof T]-?: {} extends Pick<T, K> ? never : K }[keyof T];
|
|
165
|
+
/**
|
|
166
|
+
* Params a call site MUST supply: the required keys of `P` that
|
|
167
|
+
* `paramDefaults` (type `PD`) doesn't already provide.
|
|
168
|
+
*
|
|
169
|
+
* The `string extends keyof P` guard short-circuits the index-signature
|
|
170
|
+
* case — `P` defaults to `Record<string, never>` for the overwhelmingly
|
|
171
|
+
* common zero-params contributor, and a mapped type over `string` would
|
|
172
|
+
* otherwise report "every key is required" and break `@Foo` for every
|
|
173
|
+
* existing decorator in the wild.
|
|
174
|
+
*/
|
|
175
|
+
type MissingParamKeys<P, PD> = string extends keyof P ? never : Exclude<RequiredParamKeys<P>, keyof PD>;
|
|
176
|
+
/**
|
|
177
|
+
* The argument type for a call site (`@Foo({...})`, `.with({...})`).
|
|
178
|
+
*
|
|
179
|
+
* `Partial<P>` when every required field has a default, so adopters keep
|
|
180
|
+
* overriding just the fields they care about. Otherwise `Partial<P>`
|
|
181
|
+
* intersected with the undefaulted required fields, making those
|
|
182
|
+
* mandatory at each call site.
|
|
183
|
+
*/
|
|
184
|
+
type CallSiteParams<P, PD> = [MissingParamKeys<P, PD>] extends [never] ? Partial<P> : Partial<P> & Pick<P, MissingParamKeys<P, PD> & keyof P>;
|
|
140
185
|
/**
|
|
141
186
|
* Spec passed to {@link defineContextDecorator}. Describes one entry in
|
|
142
187
|
* the per-request contributor pipeline.
|
|
@@ -146,8 +191,11 @@ type ResolvedDeps<D extends Record<string, DepValue>> = { [K in keyof D]: D[K] e
|
|
|
146
191
|
* @typeParam Ctx - Concrete execution-context type. Defaults to the abstract
|
|
147
192
|
* {@link ExecutionContext}; HTTP contributors typically
|
|
148
193
|
* default to `RequestContext` at the call site.
|
|
194
|
+
* @typeParam PD - Inferred from `paramDefaults`. Drives which params each
|
|
195
|
+
* call site is required to supply — see {@link CallSiteParams}.
|
|
196
|
+
* Never spell this by hand.
|
|
149
197
|
*/
|
|
150
|
-
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> {
|
|
198
|
+
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>> {
|
|
151
199
|
/** ContextMeta key the resolved value is written to. */
|
|
152
200
|
key: K;
|
|
153
201
|
/**
|
|
@@ -186,23 +234,36 @@ interface ContextDecoratorSpec<K extends string = string, D extends Record<strin
|
|
|
186
234
|
* validator-agnostic so projects can plug Zod / Valibot / hand-rolled
|
|
187
235
|
* checks without the framework caring.
|
|
188
236
|
*
|
|
189
|
-
* **Required
|
|
190
|
-
* `
|
|
191
|
-
*
|
|
192
|
-
* `
|
|
193
|
-
*
|
|
194
|
-
*
|
|
237
|
+
* **Required fields are enforced at the call site.** A required field
|
|
238
|
+
* of `P` that has no entry here must be supplied wherever the
|
|
239
|
+
* decorator is applied — `@Foo({ action: 'audit:read' })`. The bare
|
|
240
|
+
* `@Foo` form and `.registration` stop type-checking for such a
|
|
241
|
+
* decorator, because neither can supply the value.
|
|
242
|
+
*
|
|
243
|
+
* This exists so nobody has to invent a meaningless default just to
|
|
244
|
+
* satisfy the type (`action: 'settings:read'` on a permission
|
|
245
|
+
* contributor every call site overrides anyway). A default that is
|
|
246
|
+
* never correct is worse than no default: forget the argument at one
|
|
247
|
+
* call site and the route silently gates on the placeholder instead
|
|
248
|
+
* of failing to compile.
|
|
195
249
|
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
|
|
199
|
-
|
|
250
|
+
* Omit this entirely for the common zero-params case — `P` defaults
|
|
251
|
+
* to `Record<string, never>`, which requires nothing.
|
|
252
|
+
*/
|
|
253
|
+
paramDefaults?: PD;
|
|
254
|
+
/**
|
|
255
|
+
* Runtime mirror of the compile-time requirement above: param names
|
|
256
|
+
* that must be present after merging call-site params over
|
|
257
|
+
* `paramDefaults`. A missing one throws `TypeError` at the point of
|
|
258
|
+
* use (decoration time for `@Foo`, call time for `@Foo({...})` /
|
|
259
|
+
* `.with({...})`), naming the decorator and the field.
|
|
200
260
|
*
|
|
201
|
-
* The
|
|
202
|
-
*
|
|
203
|
-
*
|
|
261
|
+
* The type-level check already covers TypeScript call sites, so this
|
|
262
|
+
* is for the paths types can't reach: plain-JS adopters, `as any`
|
|
263
|
+
* escapes, and params assembled dynamically. Optional — list only
|
|
264
|
+
* fields whose absence is a correctness bug rather than a default.
|
|
204
265
|
*/
|
|
205
|
-
|
|
266
|
+
requiredParams?: readonly (keyof P & string)[];
|
|
206
267
|
/**
|
|
207
268
|
* Hook invoked when `resolve()` throws and `optional` is `false`.
|
|
208
269
|
* Returning a value writes it to `ctx.set(key, …)`; returning
|
|
@@ -303,15 +364,32 @@ interface ContextDecoratorTarget {
|
|
|
303
364
|
(target: object, propertyKey: string | symbol, descriptor?: PropertyDescriptor): void;
|
|
304
365
|
}
|
|
305
366
|
/**
|
|
306
|
-
* The value returned by {@link defineContextDecorator}.
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
*
|
|
310
|
-
*
|
|
311
|
-
*
|
|
312
|
-
*
|
|
367
|
+
* The value returned by {@link defineContextDecorator}.
|
|
368
|
+
*
|
|
369
|
+
* Resolves to one of two shapes depending on whether every required
|
|
370
|
+
* field of `P` has a `paramDefaults` entry:
|
|
371
|
+
*
|
|
372
|
+
* - {@link ContextDecoratorWithDefaults} — the classic shape. Usable
|
|
373
|
+
* bare (`@Foo`), as a factory (`@Foo({...})`), via `.with(params)`,
|
|
374
|
+
* and via `.registration`.
|
|
375
|
+
* - {@link ContextDecoratorRequiringParams} — when `P` has required
|
|
376
|
+
* fields `paramDefaults` doesn't cover. Only the factory and
|
|
377
|
+
* `.with(params)` forms exist, because the others have no way to
|
|
378
|
+
* supply the missing values. Applying such a decorator bare is a
|
|
379
|
+
* compile error rather than a silent `undefined` at request time.
|
|
380
|
+
*
|
|
381
|
+
* `PD` is inferred from the spec's `paramDefaults`; the default here
|
|
382
|
+
* (`Partial<P>`) keeps hand-written `ContextDecorator<K, D, P>`
|
|
383
|
+
* annotations resolving to the permissive shape as before.
|
|
313
384
|
*/
|
|
314
|
-
|
|
385
|
+
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>;
|
|
386
|
+
/**
|
|
387
|
+
* Decorator whose params are fully defaulted (or which takes none).
|
|
388
|
+
* Callable as a class or method decorator directly, as a factory, or
|
|
389
|
+
* via `.with(params)` / `.registration` at non-decorator registration
|
|
390
|
+
* sites.
|
|
391
|
+
*/
|
|
392
|
+
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> {
|
|
315
393
|
/**
|
|
316
394
|
* Class decorator usage with `paramDefaults` — `@Foo class C {}`.
|
|
317
395
|
* The class constructor is a `Function`, so this overload only
|
|
@@ -372,6 +450,49 @@ interface ContextDecorator<K extends string = string, D extends Record<string, D
|
|
|
372
450
|
readonly registration: ContributorRegistration<K, D, Ctx>;
|
|
373
451
|
};
|
|
374
452
|
}
|
|
453
|
+
/**
|
|
454
|
+
* Decorator with at least one required param that `paramDefaults`
|
|
455
|
+
* doesn't cover. Deliberately narrower than
|
|
456
|
+
* {@link ContextDecoratorWithDefaults}: the bare `@Foo` form, the
|
|
457
|
+
* zero-arg `@Foo()` form, and the `.registration` accessor are all
|
|
458
|
+
* absent, because none of them can supply the missing value.
|
|
459
|
+
*
|
|
460
|
+
* ```ts
|
|
461
|
+
* const OperatorPerm = defineContextDecorator.withParams<{ action: string }>()({
|
|
462
|
+
* key: 'operatorPerm',
|
|
463
|
+
* resolve: (ctx, _deps, { action }) => check(ctx, action),
|
|
464
|
+
* })
|
|
465
|
+
*
|
|
466
|
+
* class Ops {
|
|
467
|
+
* @OperatorPerm // ✗ compile error — `action` missing
|
|
468
|
+
* @Get('/a')
|
|
469
|
+
* a(ctx: RequestContext) {}
|
|
470
|
+
*
|
|
471
|
+
* @OperatorPerm({ action: 'read' }) // ✓
|
|
472
|
+
* @Get('/b')
|
|
473
|
+
* b(ctx: RequestContext) {}
|
|
474
|
+
* }
|
|
475
|
+
* ```
|
|
476
|
+
*
|
|
477
|
+
* If you want the bare form back, give `action` a default in
|
|
478
|
+
* `paramDefaults` — but only when the default is genuinely correct for
|
|
479
|
+
* an undecorated route, which for a permission string it usually isn't.
|
|
480
|
+
*/
|
|
481
|
+
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>> {
|
|
482
|
+
/**
|
|
483
|
+
* Factory usage — the only decorator form available here. The
|
|
484
|
+
* argument type carries every required field `paramDefaults` didn't
|
|
485
|
+
* provide, so omitting one is a compile error at this call site.
|
|
486
|
+
*/
|
|
487
|
+
(params: CallSiteParams<P, PD>): ContextDecoratorTarget;
|
|
488
|
+
/**
|
|
489
|
+
* Build a registration for non-decorator registration sites. Same
|
|
490
|
+
* required-field rule as the factory form.
|
|
491
|
+
*/
|
|
492
|
+
with(params: CallSiteParams<P, PD>): {
|
|
493
|
+
readonly registration: ContributorRegistration<K, D, Ctx>;
|
|
494
|
+
};
|
|
495
|
+
}
|
|
375
496
|
/**
|
|
376
497
|
* Curried params-first helper for {@link defineContextDecorator}.
|
|
377
498
|
*
|
|
@@ -402,7 +523,7 @@ interface ContextDecorator<K extends string = string, D extends Record<string, D
|
|
|
402
523
|
* positional form when there are no params (the common case).
|
|
403
524
|
*/
|
|
404
525
|
interface DefineContextDecoratorWithParams<P extends Record<string, unknown>> {
|
|
405
|
-
<K extends string, D extends Record<string, DepValue> = Record<string, never>, Ctx extends ExecutionContext = ExecutionContext>(spec: ContextDecoratorSpec<K, D, P, Ctx>): ContextDecorator<K, D, P, Ctx>;
|
|
526
|
+
<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>;
|
|
406
527
|
}
|
|
407
528
|
/**
|
|
408
529
|
* The public shape of {@link defineContextDecorator}. Combines the
|
|
@@ -411,7 +532,7 @@ interface DefineContextDecoratorWithParams<P extends Record<string, unknown>> {
|
|
|
411
532
|
* parameterised case.
|
|
412
533
|
*/
|
|
413
534
|
interface DefineContextDecoratorFn {
|
|
414
|
-
<K extends string, D extends Record<string, DepValue> = Record<string, never>, P extends Record<string, unknown> = Record<string, never>, Ctx extends ExecutionContext = ExecutionContext>(spec: ContextDecoratorSpec<K, D, P, Ctx>): ContextDecorator<K, D, P, Ctx>;
|
|
535
|
+
<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>;
|
|
415
536
|
/**
|
|
416
537
|
* Curried entry point. Spell only the per-call params shape `P`;
|
|
417
538
|
* `K`, `D`, and `Ctx` are inferred from the spec passed to the
|
|
@@ -522,4 +643,4 @@ type AppModuleClass = new () => AppModule;
|
|
|
522
643
|
type AppModuleEntry = AppModuleClass | AppModule;
|
|
523
644
|
//#endregion
|
|
524
645
|
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-
|
|
646
|
+
//# sourceMappingURL=app-module-BSpHKlhE.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-module-BSpHKlhE.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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0EG;UA1CH,WAAA;;KAGL,SAAA,yCAAkD,CAAA,eAAgB,WAAA,GAC1E,WAAA,CAAY,CAAA,IACZ,QAAA;;;;ACxDwD;AAC5D;;;;UDiEiB,gBAAA;ECvDL;;;;AAAgD;AAS5D;;;EDuDE,GAAA,mBAAsB,GAAA,EAAK,CAAA,GAAI,SAAA,CAAU,CAAA;ECvDR;;;;;;;;;;;;;EDqEjC,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,MAAA,IAAU,YAAA,GAAe,YAAA;AAAA;;;;;;;;;;;;;;KAgBf,cAAA,aAA2B,SAAS;;;;AF+C5B;;;;ACpH4E;;;;AAuBpC;AAC5D;;KC6DY,cAAA,GAAiB,cAAA,GAAiB,SAAS"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import { t as Container } from "./container-iED1swkd.mjs";
|
|
3
|
-
import { d as ContributorRegistrations, r as AppModuleEntry } from "./app-module-
|
|
4
|
-
import {
|
|
3
|
+
import { d as ContributorRegistrations, r as AppModuleEntry } from "./app-module-BSpHKlhE.mjs";
|
|
4
|
+
import { It as KickPlugin, Lt as ModuleRegistry, f as HttpRuntime, r as AppAdapter, s as ActiveRuntime, y as RuntimeCapabilities } from "./adapter-CEt1MEdF.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-
|
|
442
|
+
//# sourceMappingURL=application-Bzdzl5wP.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application-
|
|
1
|
+
{"version":3,"file":"application-Bzdzl5wP.d.mts","names":[],"sources":["../src/http/application.ts"],"mappings":";;;;;;;;;;;AAwDA;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;;;;;;;;;;;;;;;;;;;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R,KAAA,IAAS,OAAA;;EA0UT,YAAA,IAAgB,OAAA;;;;;;;;;;EAahB,KAAA,IAAS,OAAA;;EA0ET,OAAA,IAAW,OAAA;;;;;;;;;;;EA8CX,QAAA,IAAY,OAAA;;;;;;;EA6ElB,aAAA,IAAiB,aAAA;;;;;;;;EAWjB,gBAAA;IAAsB,IAAA;IAAc,YAAA,EAAc,mBAAA;EAAA;;EAKlD,aAAA,IAAiB,OAAA;;EAKjB,WAAA,IAAe,UAAA;;;;;;EASf,UAAA,aAAuB,UAAA;;;;;;;;;;;;;;;;;;;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
|
-
* @forinda/kickjs v6.
|
|
2
|
+
* @forinda/kickjs v6.5.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-Da9BLMHy.mjs";import{Logger,createLogger}from"./core/logger.mjs";import{t as getClassMeta}from"./metadata-BhKXlN2F.mjs";import{g as mountSort}from"./core-CQ6u5kOq.mjs";import{t as MutableModuleRegistry}from"./module-registry-CvP9mee-.mjs";import{i as runDisposables,n as drainDisposables,r as registerDisposable,t as disposeAll}from"./disposables-rPSyh69r.mjs";import{joinPaths,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-Cs0939u1.mjs";import{o as isRequestScopeMiddleware,s as requestScopeMiddleware,t as applyHandlerResult}from"./reply-edT8RGBB.mjs";import{_setExternalContributorSources,assertRouteUnique,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=[];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{materializeRouter as i,buildRoutes as n,expressRuntime as r,Application as t};
|
|
12
|
-
//# sourceMappingURL=application-
|
|
11
|
+
import{METADATA}from"./core/interfaces.mjs";import{n as tokenName,s as moduleRouteMissingControllerError,t as Container}from"./container-CBaL5lus.mjs";import{Logger,createLogger}from"./core/logger.mjs";import{t as getClassMeta}from"./metadata-CUDfhy4e.mjs";import{g as mountSort}from"./core-TDR0XGzO.mjs";import{t as MutableModuleRegistry}from"./module-registry-Mv5FqVlq.mjs";import{i as runDisposables,n as drainDisposables,r as registerDisposable,t as disposeAll}from"./disposables-mnjJuaVx.mjs";import{joinPaths,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-BS5o1IuU.mjs";import{o as isRequestScopeMiddleware,s as requestScopeMiddleware,t as applyHandlerResult}from"./reply-BMBvs-FB.mjs";import{_setExternalContributorSources,assertRouteUnique,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=[];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{materializeRouter as i,buildRoutes as n,expressRuntime as r,Application as t};
|
|
12
|
+
//# sourceMappingURL=application-C-r79XqD.mjs.map
|