@forinda/kickjs 3.2.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/README.md +13 -212
  2. package/dist/{adapter-DLEHb0K6.d.mts → adapter-BNw2pGbg.d.mts} +117 -7
  3. package/dist/adapter-BNw2pGbg.d.mts.map +1 -0
  4. package/dist/{app-module-ERR9jhow.d.mts → app-module-CO0ksPCm.d.mts} +3 -3
  5. package/dist/{app-module-ERR9jhow.d.mts.map → app-module-CO0ksPCm.d.mts.map} +1 -1
  6. package/dist/{application-x8CXLOlv.mjs → application-Ce4DQN6m.mjs} +28 -9
  7. package/dist/application-Ce4DQN6m.mjs.map +1 -0
  8. package/dist/application-Czwm7Gty.d.mts +302 -0
  9. package/dist/application-Czwm7Gty.d.mts.map +1 -0
  10. package/dist/{bootstrap-CYnxozL_.mjs → bootstrap-CB7bJeJG.mjs} +6 -6
  11. package/dist/{bootstrap-CYnxozL_.mjs.map → bootstrap-CB7bJeJG.mjs.map} +1 -1
  12. package/dist/bootstrap-NxFRaNTh.d.mts +28 -0
  13. package/dist/bootstrap-NxFRaNTh.d.mts.map +1 -0
  14. package/dist/{cache-V91BNTIM.d.mts → cache-BStrqXSZ.d.mts} +2 -2
  15. package/dist/{cache-V91BNTIM.d.mts.map → cache-BStrqXSZ.d.mts.map} +1 -1
  16. package/dist/config/index.d.mts +1 -1
  17. package/dist/config/index.mjs +3 -3
  18. package/dist/{config-aWxKLk4A.mjs → config-wZ_TgBfs.mjs} +4 -4
  19. package/dist/{config-aWxKLk4A.mjs.map → config-wZ_TgBfs.mjs.map} +1 -1
  20. package/dist/{container-fIS1uLx-.d.mts → container-CnWDsxi-.d.mts} +9 -7
  21. package/dist/container-CnWDsxi-.d.mts.map +1 -0
  22. package/dist/{container-Dnk43k54.mjs → container-DYYSu58w.mjs} +313 -9
  23. package/dist/container-DYYSu58w.mjs.map +1 -0
  24. package/dist/{context-OktlOQBQ.mjs → context-BAGzqT7-.mjs} +33 -41
  25. package/dist/context-BAGzqT7-.mjs.map +1 -0
  26. package/dist/context-Ymvv-85x.d.mts +260 -0
  27. package/dist/context-Ymvv-85x.d.mts.map +1 -0
  28. package/dist/{context-decorator-GA8-hDLe.d.mts → context-decorator-B5v3VQCN.d.mts} +4 -4
  29. package/dist/{context-decorator-GA8-hDLe.d.mts.map → context-decorator-B5v3VQCN.d.mts.map} +1 -1
  30. package/dist/core/adapter.d.mts +1 -1
  31. package/dist/core/adapter.mjs +1 -1
  32. package/dist/core/app-module.d.mts +1 -1
  33. package/dist/core/app-module.mjs +1 -1
  34. package/dist/core/cache.d.mts +1 -1
  35. package/dist/core/cache.mjs +2 -2
  36. package/dist/core/cache.mjs.map +1 -1
  37. package/dist/core/container.d.mts +1 -1
  38. package/dist/core/container.mjs +2 -2
  39. package/dist/core/cron.d.mts +1 -1
  40. package/dist/core/cron.mjs +2 -2
  41. package/dist/core/decorators.d.mts +2 -2
  42. package/dist/core/decorators.mjs +48 -16
  43. package/dist/core/decorators.mjs.map +1 -1
  44. package/dist/core/errors.d.mts +1 -1
  45. package/dist/core/errors.mjs +1 -1
  46. package/dist/core/interfaces.d.mts +1 -1
  47. package/dist/core/interfaces.mjs +35 -18
  48. package/dist/core/interfaces.mjs.map +1 -1
  49. package/dist/core/logger.d.mts +2 -2
  50. package/dist/core/logger.mjs +2 -4
  51. package/dist/core/logger.mjs.map +1 -1
  52. package/dist/core/path.d.mts +1 -1
  53. package/dist/core/path.mjs +1 -1
  54. package/dist/core/plugin.d.mts +1 -1
  55. package/dist/core/plugin.mjs +1 -1
  56. package/dist/core/reactivity.d.mts +1 -1
  57. package/dist/core/reactivity.mjs +1 -1
  58. package/dist/{core-DANnH5-e.mjs → core-DBcoqPHM.mjs} +282 -8
  59. package/dist/core-DBcoqPHM.mjs.map +1 -0
  60. package/dist/cors-BfgqfLPd.d.mts +48 -0
  61. package/dist/cors-BfgqfLPd.d.mts.map +1 -0
  62. package/dist/{cron-CfsPdi7R.d.mts → cron-7zqvsmMI.d.mts} +1 -1
  63. package/dist/{cron-CfsPdi7R.d.mts.map → cron-7zqvsmMI.d.mts.map} +1 -1
  64. package/dist/csrf-DiK9zept.d.mts +52 -0
  65. package/dist/csrf-DiK9zept.d.mts.map +1 -0
  66. package/dist/{decorators-H42oPg0m.d.mts → decorators-BMvaLliz.d.mts} +147 -12
  67. package/dist/decorators-BMvaLliz.d.mts.map +1 -0
  68. package/dist/{env-Cs8Wt8A_.mjs → env-CdH5-dM_.mjs} +3 -4
  69. package/dist/{env-Cs8Wt8A_.mjs.map → env-CdH5-dM_.mjs.map} +1 -1
  70. package/dist/error-handler-Xud_3Lah.d.mts +20 -0
  71. package/dist/error-handler-Xud_3Lah.d.mts.map +1 -0
  72. package/dist/{errors-D_CWI7Bl.d.mts → errors-uaHCeXRz.d.mts} +1 -1
  73. package/dist/{errors-D_CWI7Bl.d.mts.map → errors-uaHCeXRz.d.mts.map} +1 -1
  74. package/dist/{execution-context-Dl2CKqSo.d.mts → execution-context-DKnt61pY.d.mts} +1 -1
  75. package/dist/{execution-context-Dl2CKqSo.d.mts.map → execution-context-DKnt61pY.d.mts.map} +1 -1
  76. package/dist/helmet-CaMbjzBG.d.mts +41 -0
  77. package/dist/helmet-CaMbjzBG.d.mts.map +1 -0
  78. package/dist/http/application.d.mts +2 -293
  79. package/dist/http/application.mjs +2 -2
  80. package/dist/http/bootstrap.d.mts +2 -27
  81. package/dist/http/bootstrap.mjs +2 -2
  82. package/dist/http/context.d.mts +3 -251
  83. package/dist/http/context.mjs +2 -2
  84. package/dist/http/middleware/cors.d.mts +2 -47
  85. package/dist/http/middleware/cors.mjs +1 -1
  86. package/dist/http/middleware/csrf.d.mts +2 -51
  87. package/dist/http/middleware/csrf.mjs +2 -2
  88. package/dist/http/middleware/csrf.mjs.map +1 -1
  89. package/dist/http/middleware/error-handler.d.mts +2 -19
  90. package/dist/http/middleware/error-handler.mjs +2 -2
  91. package/dist/http/middleware/helmet.d.mts +2 -40
  92. package/dist/http/middleware/helmet.mjs +1 -1
  93. package/dist/http/middleware/rate-limit.d.mts +2 -55
  94. package/dist/http/middleware/rate-limit.mjs +2 -2
  95. package/dist/http/middleware/rate-limit.mjs.map +1 -1
  96. package/dist/http/middleware/request-id.d.mts +2 -9
  97. package/dist/http/middleware/request-id.mjs +12 -3
  98. package/dist/http/middleware/request-id.mjs.map +1 -1
  99. package/dist/http/middleware/request-logger.d.mts +2 -31
  100. package/dist/http/middleware/request-logger.mjs +2 -2
  101. package/dist/http/middleware/session.d.mts +2 -69
  102. package/dist/http/middleware/session.mjs +1 -1
  103. package/dist/http/middleware/spa.d.mts +2 -100
  104. package/dist/http/middleware/spa.mjs +5 -5
  105. package/dist/http/middleware/spa.mjs.map +1 -1
  106. package/dist/http/middleware/upload.d.mts +2 -78
  107. package/dist/http/middleware/upload.mjs +1 -1
  108. package/dist/http/middleware/validate.d.mts +2 -22
  109. package/dist/http/middleware/validate.mjs +2 -2
  110. package/dist/http/middleware/views.d.mts +2 -61
  111. package/dist/http/middleware/views.mjs +16 -15
  112. package/dist/http/middleware/views.mjs.map +1 -1
  113. package/dist/http/query/index.d.mts +1 -1
  114. package/dist/http/query/index.mjs +2 -2
  115. package/dist/http/router-builder.d.mts +2 -32
  116. package/dist/http/router-builder.mjs +10 -14
  117. package/dist/http/router-builder.mjs.map +1 -1
  118. package/dist/{index-RNK41JPE.d.mts → index-B9cyOQAe.d.mts} +1 -1
  119. package/dist/{index-RNK41JPE.d.mts.map → index-B9cyOQAe.d.mts.map} +1 -1
  120. package/dist/{index-Cf-MGrqT.d.mts → index-D-qhXg9M.d.mts} +3 -3
  121. package/dist/{index-Cf-MGrqT.d.mts.map → index-D-qhXg9M.d.mts.map} +1 -1
  122. package/dist/{index-BQM9pJrV.d.mts → index-DQyWtyp0.d.mts} +241 -5
  123. package/dist/index-DQyWtyp0.d.mts.map +1 -0
  124. package/dist/index.d.mts +34 -152
  125. package/dist/index.mjs +14 -14
  126. package/dist/interfaces-B50n7dwl.d.mts +71 -0
  127. package/dist/{interfaces-CwcdqfNq.d.mts.map → interfaces-B50n7dwl.d.mts.map} +1 -1
  128. package/dist/{logger-GK8yT0BD.d.mts → logger-CLVRZf2N.d.mts} +2 -4
  129. package/dist/{logger-GK8yT0BD.d.mts.map → logger-CLVRZf2N.d.mts.map} +1 -1
  130. package/dist/{metadata-BFuoSEX6.mjs → metadata-VQM9wChy.mjs} +2 -2
  131. package/dist/{metadata-BFuoSEX6.mjs.map → metadata-VQM9wChy.mjs.map} +1 -1
  132. package/dist/{path-Bj3vZMUY.d.mts → path-Diviu6hv.d.mts} +1 -1
  133. package/dist/path-Diviu6hv.d.mts.map +1 -0
  134. package/dist/{plugin-3rKA0Loy.d.mts → plugin-WdrDgNzk.d.mts} +45 -7
  135. package/dist/plugin-WdrDgNzk.d.mts.map +1 -0
  136. package/dist/{query-BcYEjYyX.mjs → query-DJMxdx5r.mjs} +2 -2
  137. package/dist/{query-BcYEjYyX.mjs.map → query-DJMxdx5r.mjs.map} +1 -1
  138. package/dist/rate-limit-DUwoICtI.d.mts +56 -0
  139. package/dist/rate-limit-DUwoICtI.d.mts.map +1 -0
  140. package/dist/{reactivity-CczHu3R-.d.mts → reactivity-CfJceo4H.d.mts} +1 -1
  141. package/dist/{reactivity-CczHu3R-.d.mts.map → reactivity-CfJceo4H.d.mts.map} +1 -1
  142. package/dist/request-id-BgglvZHN.d.mts +19 -0
  143. package/dist/request-id-BgglvZHN.d.mts.map +1 -0
  144. package/dist/request-logger-CWHbAzTE.d.mts +32 -0
  145. package/dist/request-logger-CWHbAzTE.d.mts.map +1 -0
  146. package/dist/router-builder-C799BAf0.d.mts +31 -0
  147. package/dist/router-builder-C799BAf0.d.mts.map +1 -0
  148. package/dist/session-N0hActOO.d.mts +70 -0
  149. package/dist/session-N0hActOO.d.mts.map +1 -0
  150. package/dist/spa-CrFR2_cz.d.mts +101 -0
  151. package/dist/spa-CrFR2_cz.d.mts.map +1 -0
  152. package/dist/upload-BueOnnLw.d.mts +79 -0
  153. package/dist/upload-BueOnnLw.d.mts.map +1 -0
  154. package/dist/validate-HwAyWTwH.d.mts +23 -0
  155. package/dist/validate-HwAyWTwH.d.mts.map +1 -0
  156. package/dist/views-DhQSXV2P.d.mts +176 -0
  157. package/dist/views-DhQSXV2P.d.mts.map +1 -0
  158. package/package.json +6 -9
  159. package/dist/adapter-DLEHb0K6.d.mts.map +0 -1
  160. package/dist/application-x8CXLOlv.mjs.map +0 -1
  161. package/dist/chunk-Bt-rz0Tp.mjs +0 -15
  162. package/dist/container-Dnk43k54.mjs.map +0 -1
  163. package/dist/container-fIS1uLx-.d.mts.map +0 -1
  164. package/dist/context-OktlOQBQ.mjs.map +0 -1
  165. package/dist/core-DANnH5-e.mjs.map +0 -1
  166. package/dist/decorators-H42oPg0m.d.mts.map +0 -1
  167. package/dist/http/application.d.mts.map +0 -1
  168. package/dist/http/bootstrap.d.mts.map +0 -1
  169. package/dist/http/context.d.mts.map +0 -1
  170. package/dist/http/middleware/cors.d.mts.map +0 -1
  171. package/dist/http/middleware/csrf.d.mts.map +0 -1
  172. package/dist/http/middleware/error-handler.d.mts.map +0 -1
  173. package/dist/http/middleware/helmet.d.mts.map +0 -1
  174. package/dist/http/middleware/rate-limit.d.mts.map +0 -1
  175. package/dist/http/middleware/request-id.d.mts.map +0 -1
  176. package/dist/http/middleware/request-logger.d.mts.map +0 -1
  177. package/dist/http/middleware/session.d.mts.map +0 -1
  178. package/dist/http/middleware/spa.d.mts.map +0 -1
  179. package/dist/http/middleware/upload.d.mts.map +0 -1
  180. package/dist/http/middleware/validate.d.mts.map +0 -1
  181. package/dist/http/middleware/views.d.mts.map +0 -1
  182. package/dist/http/router-builder.d.mts.map +0 -1
  183. package/dist/index-BQM9pJrV.d.mts.map +0 -1
  184. package/dist/index.d.mts.map +0 -1
  185. package/dist/interfaces-CwcdqfNq.d.mts +0 -54
  186. package/dist/path-Bj3vZMUY.d.mts.map +0 -1
  187. package/dist/plugin-3rKA0Loy.d.mts.map +0 -1
@@ -1,294 +1,3 @@
1
1
 
2
- import { t as Container } from "../container-fIS1uLx-.mjs";
3
- import { r as ContributorRegistration } from "../context-decorator-GA8-hDLe.mjs";
4
- import { r as AppAdapter } from "../adapter-DLEHb0K6.mjs";
5
- import { n as AppModuleClass } from "../app-module-ERR9jhow.mjs";
6
- import { t as KickPlugin } from "../plugin-3rKA0Loy.mjs";
7
- import http from "node:http";
8
- import { Express, RequestHandler } from "express";
9
-
10
- //#region src/http/application.d.ts
11
- /**
12
- * A middleware entry in the declarative pipeline.
13
- * Can be a bare handler or an object with path scoping.
14
- */
15
- type MiddlewareEntry = RequestHandler | {
16
- path: string;
17
- handler: RequestHandler;
18
- };
19
- interface ApplicationOptions {
20
- /** Feature modules to load */
21
- modules: AppModuleClass[];
22
- /** Adapters that hook into the lifecycle (DB, Redis, Swagger, etc.) */
23
- adapters?: AppAdapter[];
24
- /** Server port (falls back to PORT env var, then 3000) */
25
- port?: number;
26
- /** Global API prefix (default: '/api') */
27
- apiPrefix?: string;
28
- /** Default API version (default: 1) — routes become /{prefix}/v{version}/{path} */
29
- defaultVersion?: number;
30
- /**
31
- * Global middleware pipeline. Declared in order.
32
- * Replaces the hardcoded middleware stack — you control exactly what runs.
33
- *
34
- * @example
35
- * ```ts
36
- * bootstrap({
37
- * modules,
38
- * middleware: [
39
- * helmet(),
40
- * cors(),
41
- * compression(),
42
- * morgan('dev'),
43
- * express.json({ limit: '1mb' }),
44
- * ],
45
- * })
46
- * ```
47
- *
48
- * If omitted, a sensible default is applied:
49
- * requestId(), express.json({ limit: '100kb' })
50
- */
51
- middleware?: MiddlewareEntry[];
52
- /** Plugins that bundle modules, adapters, middleware, and DI bindings */
53
- plugins?: KickPlugin[];
54
- /**
55
- * Global Context Contributors (#107) that apply to every route in the
56
- * application. Merge into the per-route pipeline at the `'global'`
57
- * precedence level — they lose to module, adapter, class, and method
58
- * contributors with the same key, providing app-wide defaults that any
59
- * narrower scope can override.
60
- *
61
- * @example
62
- * ```ts
63
- * const StartedAt = defineContextDecorator({
64
- * key: 'requestStartedAt',
65
- * resolve: () => Date.now(),
66
- * })
67
- *
68
- * bootstrap({
69
- * modules,
70
- * contributors: [StartedAt.registration],
71
- * })
72
- * ```
73
- */
74
- contributors?: ContributorRegistration[] | readonly ContributorRegistration[];
75
- /**
76
- * Backing store strategy for {@link RequestContext} `set/get` and the
77
- * Context Contributor pipeline (#107).
78
- *
79
- * - `'auto'` (default) — Application mounts {@link requestScopeMiddleware}
80
- * automatically before any user middleware. If the user-supplied
81
- * `middleware` list already includes `requestScopeMiddleware()`,
82
- * detection skips the auto-mount so adopters can control its position.
83
- * - `'manual'` — Application never mounts the wrapper. The caller is
84
- * responsible for ensuring an `AsyncLocalStorage` frame surrounds
85
- * each request, otherwise contributors won't run and `ctx.set/get`
86
- * falls back to the deprecated `req.__ctxMeta` path.
87
- *
88
- * Use `'manual'` only when wrapping requests in your own ALS frame
89
- * (rare — multi-tenant adapters used to do this; post-Phase 3 they
90
- * share the framework's frame instead).
91
- */
92
- contextStore?: 'auto' | 'manual';
93
- /** Express `trust proxy` setting */
94
- trustProxy?: boolean | number | string | ((ip: string, hopIndex: number) => boolean);
95
- /** Maximum JSON body size (only used when middleware is not provided) */
96
- jsonLimit?: string | number;
97
- /**
98
- * Log route summary on startup. Default: true in dev, false in production.
99
- * Set to `true` to always log, `false` to always suppress.
100
- */
101
- logRoutesTable?: boolean;
102
- /**
103
- * Maximum time (ms) to wait for graceful shutdown before forcing exit.
104
- * Default: 30000 (30 seconds). Set to 0 to disable forced exit.
105
- */
106
- shutdownTimeout?: number;
107
- /**
108
- * Enable cluster mode for multi-core utilization.
109
- *
110
- * When enabled, the primary process forks worker processes that share the
111
- * same port via Node's built-in `cluster` module (OS load balancing).
112
- *
113
- * - `true` — use all available CPU cores
114
- * - `{ workers: N }` — use exactly N workers
115
- *
116
- * Workers are auto-restarted on crash. SIGTERM/SIGINT on the primary is
117
- * forwarded to all workers.
118
- *
119
- * @example
120
- * ```ts
121
- * bootstrap({ modules, cluster: true })
122
- * bootstrap({ modules, cluster: { workers: 4 } })
123
- * ```
124
- */
125
- cluster?: boolean | {
126
- workers?: number;
127
- };
128
- /**
129
- * Custom 404 handler for unmatched routes. Receives the raw Express
130
- * `(req, res, next)` args. When omitted, the built-in handler returns
131
- * `{ message: 'Not Found' }` with status 404.
132
- *
133
- * @example
134
- * ```ts
135
- * bootstrap({
136
- * modules,
137
- * onNotFound: (req, res) => {
138
- * res.status(404).json({ error: 'Route not found', path: req.originalUrl })
139
- * },
140
- * })
141
- * ```
142
- */
143
- onNotFound?: (req: any, res: any, next: any) => void;
144
- /**
145
- * Custom global error handler. Receives `(err, req, res, next)` — the
146
- * standard Express error-handling signature. When omitted, the built-in
147
- * handler formats ZodError, HttpException, and unexpected errors.
148
- *
149
- * @example
150
- * ```ts
151
- * bootstrap({
152
- * modules,
153
- * onError: (err, req, res, next) => {
154
- * logger.error(err)
155
- * res.status(err.status ?? 500).json({ error: err.message })
156
- * },
157
- * })
158
- * ```
159
- */
160
- onError?: (err: any, req: any, res: any, next: any) => void;
161
- /**
162
- * Security defaults applied automatically unless opted out.
163
- *
164
- * When not specified, secure defaults are applied:
165
- * - Helmet security headers are auto-injected
166
- * - JSON body limit defaults to 1MB
167
- *
168
- * @example
169
- * ```ts
170
- * bootstrap({
171
- * modules,
172
- * security: {
173
- * helmet: false, // disable auto-helmet
174
- * },
175
- * })
176
- * ```
177
- */
178
- security?: {
179
- /** Auto-inject helmet security headers. Default: true */helmet?: boolean;
180
- };
181
- }
182
- /**
183
- * The main application class. Wires together Express, the DI container,
184
- * feature modules, adapters, and the middleware pipeline.
185
- */
186
- declare class Application {
187
- private readonly options;
188
- private app;
189
- private container;
190
- private httpServer;
191
- private readonly adapters;
192
- private readonly plugins;
193
- /** Number of HTTP requests currently being processed */
194
- private _inFlightRequests;
195
- /** Whether the application is draining (shutting down gracefully) */
196
- private _draining;
197
- /** Whether shutdown has already been initiated (prevents double-shutdown) */
198
- private _shutdownInitiated;
199
- /** Resolvers waiting for in-flight requests to reach zero */
200
- private _drainResolvers;
201
- constructor(options: ApplicationOptions);
202
- /** Whether the application is currently draining in-flight requests */
203
- get isDraining(): boolean;
204
- /** Number of HTTP requests currently being processed */
205
- get inFlightRequests(): number;
206
- /** Get the DI container instance */
207
- getContainer(): Container;
208
- /**
209
- * Express request handler — delegates to the internal Express app.
210
- *
211
- * Used by the Vite dev-server plugin to route requests through KickJS:
212
- * ```ts
213
- * const mod = await ssrLoadModule('virtual:kickjs/app')
214
- * mod.app.handle(req, res, next)
215
- * ```
216
- *
217
- * Also works as a standard Node.js request handler for production:
218
- * ```ts
219
- * http.createServer(app.handle.bind(app))
220
- * ```
221
- */
222
- handle(req: http.IncomingMessage, res: http.ServerResponse, next?: (err?: any) => void): void;
223
- /**
224
- * Full setup pipeline:
225
- * 1. Adapter beforeMount hooks (early routes — docs, health)
226
- * 2. Adapter middleware (phase: beforeGlobal)
227
- * 3. Global middleware (user-declared or defaults)
228
- * 4. Adapter middleware (phase: afterGlobal)
229
- * 5. Module registration + DI bootstrap
230
- * 6. Adapter middleware (phase: beforeRoutes)
231
- * 7. Module route mounting
232
- * 8. Adapter middleware (phase: afterRoutes)
233
- * 9. Error handlers (notFound + global)
234
- * 10. Adapter beforeStart hooks
235
- */
236
- /** Build the adapter context object (shared across all hooks) */
237
- private adapterCtx;
238
- /** Call an adapter hook, awaiting async hooks and catching errors */
239
- private callHook;
240
- setup(): Promise<void>;
241
- /** Register modules and DI without starting the HTTP server (used by kick tinker) */
242
- registerOnly(): Promise<void>;
243
- /**
244
- * Start the HTTP server.
245
- *
246
- * In **dev mode** (Vite plugin active): reuses `globalThis.__kickjs_httpServer`
247
- * created by Vite. Adapters (WsAdapter, Socket.IO, etc.) receive the real
248
- * `http.Server` through `afterStart({ server })` — zero adapter changes needed.
249
- *
250
- * In **production**: creates its own `http.Server` and binds to the port.
251
- */
252
- start(): Promise<void>;
253
- /** HMR rebuild: swap Express handler without restarting the server */
254
- rebuild(): Promise<void>;
255
- /**
256
- * Graceful shutdown with request draining.
257
- *
258
- * 1. Stops accepting new connections (server.close())
259
- * 2. Waits for in-flight requests to complete (up to shutdownTimeout)
260
- * 3. Calls adapter.shutdown() for all registered adapters
261
- * 4. Force-closes after timeout
262
- *
263
- * Safe to call multiple times — subsequent calls return the same promise.
264
- */
265
- shutdown(): Promise<void>;
266
- getExpressApp(): Express;
267
- /** Get registered adapters — used by DevToolsAdapter for peer discovery */
268
- getAdapters(): AppAdapter[];
269
- getHttpServer(): http.Server | null;
270
- /**
271
- * Decide whether {@link Application} should auto-mount the
272
- * {@link requestScopeMiddleware} ALS wrapper.
273
- *
274
- * Returns `false` when:
275
- * - `contextStore: 'manual'` was set (caller manages ALS frames), or
276
- * - the user-supplied `middleware` list already includes a
277
- * `requestScopeMiddleware()` (detected via the symbol marker stamped
278
- * in `middleware/request-scope.ts`).
279
- *
280
- * Otherwise `true` — preserves the historical default of "always wrap
281
- * requests in an ALS frame" so existing apps see no behavior change.
282
- */
283
- private shouldAutoMountRequestScope;
284
- private collectAdapterMiddleware;
285
- private mountMiddlewareList;
286
- private mountMiddlewareEntry;
287
- /** Middleware that tracks in-flight requests for graceful draining */
288
- private requestTrackingMiddleware;
289
- /** Mount /health/live and /health/ready endpoints at the root (no API prefix) */
290
- private mountHealthEndpoints;
291
- }
292
- //#endregion
293
- export { Application, ApplicationOptions, MiddlewareEntry };
294
- //# sourceMappingURL=application.d.mts.map
2
+ import { n as ApplicationOptions, r as MiddlewareEntry, t as Application } from "../application-Czwm7Gty.mjs";
3
+ export { Application, ApplicationOptions, MiddlewareEntry };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs v3.2.0
2
+ * @forinda/kickjs v4.0.0
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -8,5 +8,5 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import { t as Application } from "../application-x8CXLOlv.mjs";
11
+ import { t as Application } from "../application-Ce4DQN6m.mjs";
12
12
  export { Application };
@@ -1,28 +1,3 @@
1
1
 
2
- import { Application, ApplicationOptions } from "./application.mjs";
3
-
4
- //#region src/http/bootstrap.d.ts
5
- /**
6
- * Bootstrap a KickJS application.
7
- *
8
- * Creates the Express app, registers modules and adapters, and starts
9
- * the HTTP server. In dev mode (`kick dev`), the Vite plugin manages
10
- * the server and HMR — source changes are picked up instantly without
11
- * losing database connections or WebSocket state.
12
- *
13
- * @returns The {@link Application} instance.
14
- *
15
- * @example
16
- * ```ts
17
- * // src/index.ts
18
- * import 'reflect-metadata'
19
- * import { bootstrap } from '@forinda/kickjs'
20
- * import { modules } from './modules'
21
- *
22
- * export const app = await bootstrap({ modules })
23
- * ```
24
- */
25
- declare function bootstrap(options: ApplicationOptions): Promise<Application>;
26
- //#endregion
27
- export { bootstrap };
28
- //# sourceMappingURL=bootstrap.d.mts.map
2
+ import { t as bootstrap } from "../bootstrap-NxFRaNTh.mjs";
3
+ export { bootstrap };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs v3.2.0
2
+ * @forinda/kickjs v4.0.0
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -8,5 +8,5 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import { t as bootstrap } from "../bootstrap-CYnxozL_.mjs";
11
+ import { t as bootstrap } from "../bootstrap-CB7bJeJG.mjs";
12
12
  export { bootstrap };
@@ -1,252 +1,4 @@
1
1
 
2
- import { n as ExecutionContext, r as MetaValue, t as ContextMeta } from "../execution-context-Dl2CKqSo.mjs";
3
- import { g as QueryFieldConfig, y as TypedParsedQuery } from "../index-RNK41JPE.mjs";
4
- import * as _$node_http0 from "node:http";
5
- import { NextFunction, Request, Response } from "express";
6
-
7
- //#region src/http/context.d.ts
8
- /**
9
- * The shape of a single route entry in `KickRoutes`. Generated by
10
- * `kick typegen` and consumed via the `Ctx<T>` helper. Each field is
11
- * `unknown` by default and is filled in as the typegen learns more
12
- * about the route (URL params from the path, body/query from validation
13
- * schemas, etc.).
14
- */
15
- interface RouteShape {
16
- params?: unknown;
17
- body?: unknown;
18
- query?: unknown;
19
- response?: unknown;
20
- }
21
- /**
22
- * Unified request/response abstraction passed to every controller method.
23
- * Shields handlers from raw Express objects and provides convenience methods.
24
- *
25
- * Implements {@link ExecutionContext} so the transport-agnostic Context
26
- * Contributor pipeline (#107) can run against this concrete HTTP context
27
- * the same way it will run against future WS / queue / cron contexts.
28
- */
29
- declare class RequestContext<TBody = any, TParams = any, TQuery = any> implements ExecutionContext {
30
- readonly req: Request;
31
- readonly res: Response;
32
- readonly next: NextFunction;
33
- constructor(req: Request, res: Response, next: NextFunction);
34
- /**
35
- * Per-request metadata map shared across all RequestContext instances
36
- * for the same request.
37
- *
38
- * Backed by `requestStore.getStore()?.values` (the AsyncLocalStorage
39
- * map shared with the Context Contributor pipeline) when an ALS frame
40
- * is active — the canonical, supported path.
41
- *
42
- * Falls back to a lazily-attached `req.__ctxMeta` Map for ad-hoc
43
- * construction outside any frame — typically test code that builds a
44
- * RequestContext directly without mounting `requestScopeMiddleware()`.
45
- * That fallback path is **deprecated** and will be removed in the next
46
- * major; a one-time non-production warning fires the first time it is
47
- * hit so adopters can migrate to ALS-backed contexts.
48
- */
49
- private get metadata();
50
- get body(): TBody;
51
- get params(): TParams;
52
- get query(): TQuery;
53
- get headers(): _$node_http0.IncomingHttpHeaders;
54
- get requestId(): string | undefined;
55
- /** Session data (requires session middleware) */
56
- get session(): any;
57
- /**
58
- * The authenticated user set by AuthAdapter.
59
- * Reads from the per-request metadata store first (`ctx.set('user', ...)`),
60
- * then falls back to `req.user` (set directly by AuthAdapter middleware).
61
- *
62
- * Extend the `AuthUser` interface via module augmentation in `@forinda/kickjs-auth`
63
- * to get full typing.
64
- *
65
- * @example
66
- * ```ts
67
- * @Get('/me')
68
- * @Authenticated()
69
- * getProfile(ctx: RequestContext) {
70
- * const user = ctx.user
71
- * if (!user) return ctx.notFound()
72
- * return ctx.json({ user })
73
- * }
74
- * ```
75
- */
76
- get user(): MetaValue<'user', Record<string, any>> | undefined;
77
- /**
78
- * Tenant identifier for multi-tenant apps. Reads `user.tenantId` —
79
- * populated either by `AuthAdapter.testMode({ tenantId })`, a tenant
80
- * resolver middleware, or manually on the strategy's `mapPayload`.
81
- *
82
- * Augment `AuthUser` (or `ContextMeta['user']`) to widen the return
83
- * type if your user shape guarantees a non-`string | undefined` id.
84
- */
85
- get tenantId(): string | undefined;
86
- /**
87
- * Effective role list for the current user. Prefers `user.tenantRoles`
88
- * (populated by `AuthAdapterOptions.roleResolver` under a tenant) and
89
- * falls back to `user.roles`. Returns an empty array when the user is
90
- * absent or the shape has neither field.
91
- */
92
- get roles(): string[];
93
- /**
94
- * Parse the request query string into structured filters, sort, pagination, and search.
95
- * Pass the result to an ORM query builder adapter (Drizzle, Prisma, Sequelize, etc.).
96
- *
97
- * Generic over the field config: when passed an inline literal (or
98
- * `as const`), `filters[].field` and `sort[].field` are narrowed to
99
- * the exact whitelisted field names. Pass nothing or a non-literal
100
- * config and you get the loose `string` fallback.
101
- *
102
- * @param fieldConfig - Optional whitelist for filterable, sortable, and searchable fields
103
- *
104
- * @example
105
- * ```ts
106
- * @Get('/')
107
- * async list(ctx: RequestContext) {
108
- * const parsed = ctx.qs({
109
- * filterable: ['status', 'priority'],
110
- * sortable: ['createdAt', 'title'],
111
- * } as const)
112
- * parsed.filters[0].field // typed as 'status' | 'priority'
113
- * parsed.sort[0].field // typed as 'createdAt' | 'title'
114
- * }
115
- * ```
116
- */
117
- qs<TConfig extends QueryFieldConfig | undefined = undefined>(fieldConfig?: TConfig): TypedParsedQuery<TConfig>;
118
- /** Single uploaded file (requires @FileUpload({ mode: 'single' })) */
119
- get file(): any;
120
- /** Array of uploaded files (requires @FileUpload({ mode: 'array' })) */
121
- get files(): any[] | undefined;
122
- /**
123
- * Read a value from the per-request metadata store.
124
- *
125
- * When `ContextMeta` has been augmented with a matching key, the return
126
- * type is inferred automatically. For ad-hoc keys, pass a generic:
127
- * `ctx.get<MyType>('custom')`.
128
- */
129
- get<K extends string>(key: K): MetaValue<K> | undefined;
130
- /**
131
- * Write a value to the per-request metadata store.
132
- *
133
- * When `ContextMeta` has been augmented with a matching key, the value
134
- * type is checked at compile time.
135
- */
136
- set<K extends string>(key: K, value: MetaValue<K>): void;
137
- json(data: any, status?: number): Response<any, Record<string, any>>;
138
- created(data: any): Response<any, Record<string, any>>;
139
- noContent(): Response<any, Record<string, any>>;
140
- notFound(message?: string): Response<any, Record<string, any>>;
141
- badRequest(message: string): Response<any, Record<string, any>>;
142
- html(content: string, status?: number): Response<any, Record<string, any>>;
143
- download(buffer: Buffer, filename: string, contentType?: string): Response<any, Record<string, any>>;
144
- /**
145
- * Render a template using the registered view engine (EJS, Pug, Handlebars, etc.).
146
- * Requires a ViewAdapter to be configured in bootstrap().
147
- *
148
- * @param template - Template name (without extension, relative to viewsDir)
149
- * @param data - Data to pass to the template
150
- *
151
- * @example
152
- * ```ts
153
- * ctx.render('dashboard', { user, title: 'Dashboard' })
154
- * ctx.render('emails/welcome', { name: 'Alice' })
155
- * ```
156
- */
157
- render(template: string, data?: Record<string, any>): void;
158
- /**
159
- * Parse query params and return a standardized paginated response.
160
- * Calls `ctx.qs()` internally, then wraps your data with pagination meta.
161
- *
162
- * @param fetcher - Async function that receives ParsedQuery and returns `{ data, total }`
163
- * @param fieldConfig - Optional whitelist for filterable, sortable, searchable fields
164
- *
165
- * @example
166
- * ```ts
167
- * @Get('/')
168
- * async list(ctx: RequestContext) {
169
- * return ctx.paginate(
170
- * async (parsed) => {
171
- * const data = await db.select().from(users)
172
- * .where(query.where).limit(parsed.pagination.limit)
173
- * .offset(parsed.pagination.offset).all()
174
- * const total = await db.select({ count: count() }).from(users).get()
175
- * return { data, total: total?.count ?? 0 }
176
- * },
177
- * { filterable: ['name', 'role'], sortable: ['createdAt'] },
178
- * )
179
- * }
180
- * ```
181
- */
182
- paginate<T, TConfig extends QueryFieldConfig | undefined = undefined>(fetcher: (parsed: TypedParsedQuery<TConfig>) => Promise<{
183
- data: T[];
184
- total: number;
185
- }>, fieldConfig?: TConfig): Promise<Response<any, Record<string, any>>>;
186
- /**
187
- * Start an SSE (Server-Sent Events) stream.
188
- * Sets the correct headers and returns helpers to send events.
189
- *
190
- * @example
191
- * ```ts
192
- * @Get('/events')
193
- * async stream(ctx: RequestContext) {
194
- * const sse = ctx.sse()
195
- *
196
- * const interval = setInterval(() => {
197
- * sse.send({ time: new Date().toISOString() }, 'tick')
198
- * }, 1000)
199
- *
200
- * sse.onClose(() => clearInterval(interval))
201
- * }
202
- * ```
203
- */
204
- sse(): {
205
- /** Send an SSE event with optional event name and id */send: (data: any, event?: string, id?: string) => void; /** Send a comment (keeps connection alive) */
206
- comment: (text: string) => void; /** Register a callback when the client disconnects */
207
- onClose: (fn: () => void) => void; /** End the SSE stream */
208
- close: () => void;
209
- };
210
- }
211
- /**
212
- * Short alias for `RequestContext` parameterised by a route shape.
213
- *
214
- * Use with `kick typegen`'s generated `KickRoutes` namespace for
215
- * fully-typed `ctx.params`, `ctx.body`, and `ctx.query`. Metadata
216
- * typing (`ctx.get()`, `ctx.set()`, `ctx.user`) comes from
217
- * `ContextMeta` augmentation and works on all `RequestContext` instances.
218
- *
219
- * @example
220
- * ```ts
221
- * @Get('/:id')
222
- * getUser(ctx: Ctx<KickRoutes.UserController['getUser']>) {
223
- * ctx.params.id // typed from RouteShape
224
- * ctx.body // typed from RouteShape
225
- * ctx.user // typed from ContextMeta
226
- * ctx.get('tenant') // typed from ContextMeta
227
- * }
228
- * ```
229
- */
230
- type Ctx<TRoute extends RouteShape = RouteShape> = RequestContext<TRoute extends {
231
- body: infer B;
232
- } ? B : any, TRoute extends {
233
- params: infer P;
234
- } ? P : any, TRoute extends {
235
- query: infer Q;
236
- } ? Q : any>;
237
- /**
238
- * Global ambient registry of typed routes, populated by `kick typegen`.
239
- *
240
- * Each interface inside `KickRoutes` corresponds to a controller class;
241
- * each property is one route method on that controller. The values
242
- * conform to `RouteShape`.
243
- *
244
- * Empty by default — declarations come from `.kickjs/types/routes.d.ts`
245
- * generated alongside the rest of the typegen output.
246
- */
247
- declare global {
248
- namespace KickRoutes {}
249
- } //# sourceMappingURL=context.d.ts.map
250
- //#endregion
251
- export { type ContextMeta, Ctx, RequestContext, RouteShape };
252
- //# sourceMappingURL=context.d.mts.map
2
+ import { t as ContextMeta } from "../execution-context-DKnt61pY.mjs";
3
+ import { n as RequestContext, r as RouteShape, t as Ctx } from "../context-Ymvv-85x.mjs";
4
+ export { ContextMeta, Ctx, RequestContext, RouteShape };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs v3.2.0
2
+ * @forinda/kickjs v4.0.0
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -8,5 +8,5 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import { t as RequestContext } from "../context-OktlOQBQ.mjs";
11
+ import { t as RequestContext } from "../context-BAGzqT7-.mjs";
12
12
  export { RequestContext };
@@ -1,48 +1,3 @@
1
1
 
2
- import { NextFunction, Request, Response } from "express";
3
-
4
- //#region src/http/middleware/cors.d.ts
5
- interface CorsOptions {
6
- /** Allowed origin(s). `true` reflects request origin, `'*'` allows all, `false` rejects all. Default: `false` (restrictive) */
7
- origin?: boolean | string | RegExp | (string | RegExp)[];
8
- /** Allowed HTTP methods. Default: `['GET','HEAD','PUT','PATCH','POST','DELETE']` */
9
- methods?: string[];
10
- /** Allowed request headers. Default: reflects `Access-Control-Request-Headers` */
11
- allowedHeaders?: string[];
12
- /** Headers exposed to the browser. Default: none */
13
- exposedHeaders?: string[];
14
- /** Allow credentials (cookies, authorization). Default: false */
15
- credentials?: boolean;
16
- /** Preflight cache duration in seconds. Default: 86400 (24h) */
17
- maxAge?: number;
18
- /** Handle preflight OPTIONS requests. Default: true */
19
- preflight?: boolean;
20
- }
21
- /**
22
- * CORS middleware with correct spec behavior.
23
- *
24
- * - Reflects origin from allowlist (sets `Vary: Origin`)
25
- * - Handles preflight `OPTIONS` with `204 No Content`
26
- * - Supports string, regex, and array origin matching
27
- *
28
- * @example
29
- * ```ts
30
- * // Allow all origins
31
- * bootstrap({ middleware: [cors(), express.json()] })
32
- *
33
- * // Allowlist specific origins
34
- * bootstrap({
35
- * middleware: [
36
- * cors({
37
- * origin: ['https://app.example.com', /\.example\.com$/],
38
- * credentials: true,
39
- * }),
40
- * express.json(),
41
- * ],
42
- * })
43
- * ```
44
- */
45
- declare function cors(options?: CorsOptions): (req: Request, res: Response, next: NextFunction) => void;
46
- //#endregion
47
- export { CorsOptions, cors };
48
- //# sourceMappingURL=cors.d.mts.map
2
+ import { n as cors, t as CorsOptions } from "../../cors-BfgqfLPd.mjs";
3
+ export { CorsOptions, cors };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs v3.2.0
2
+ * @forinda/kickjs v4.0.0
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *