@forinda/kickjs 3.2.0 → 4.1.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/README.md +13 -212
- package/dist/adapter-6Pp4kFdM.d.mts +296 -0
- package/dist/adapter-6Pp4kFdM.d.mts.map +1 -0
- package/dist/{app-module-ERR9jhow.d.mts → app-module-Blgz4Rti.d.mts} +4 -4
- package/dist/app-module-Blgz4Rti.d.mts.map +1 -0
- package/dist/application-Bepa-pFw.d.mts +302 -0
- package/dist/application-Bepa-pFw.d.mts.map +1 -0
- package/dist/{application-x8CXLOlv.mjs → application-DvmPMUgF.mjs} +28 -9
- package/dist/application-DvmPMUgF.mjs.map +1 -0
- package/dist/bootstrap-B4T3X2B6.d.mts +28 -0
- package/dist/bootstrap-B4T3X2B6.d.mts.map +1 -0
- package/dist/{bootstrap-CYnxozL_.mjs → bootstrap-THfr8phJ.mjs} +6 -6
- package/dist/{bootstrap-CYnxozL_.mjs.map → bootstrap-THfr8phJ.mjs.map} +1 -1
- package/dist/{cache-V91BNTIM.d.mts → cache-XrNWj1KQ.d.mts} +3 -3
- package/dist/{cache-V91BNTIM.d.mts.map → cache-XrNWj1KQ.d.mts.map} +1 -1
- package/dist/config/index.d.mts +1 -1
- package/dist/config/index.mjs +3 -3
- package/dist/{config-aWxKLk4A.mjs → config-BEjgF1fI.mjs} +4 -4
- package/dist/{config-aWxKLk4A.mjs.map → config-BEjgF1fI.mjs.map} +1 -1
- package/dist/{container-Dnk43k54.mjs → container-BYuMSnqW.mjs} +314 -9
- package/dist/container-BYuMSnqW.mjs.map +1 -0
- package/dist/{container-fIS1uLx-.d.mts → container-CnWDsxi-.d.mts} +9 -7
- package/dist/container-CnWDsxi-.d.mts.map +1 -0
- package/dist/{context-OktlOQBQ.mjs → context-CyQbqSz-.mjs} +33 -41
- package/dist/context-CyQbqSz-.mjs.map +1 -0
- package/dist/context-Ymvv-85x.d.mts +260 -0
- package/dist/context-Ymvv-85x.d.mts.map +1 -0
- package/dist/{context-decorator-GA8-hDLe.d.mts → context-decorator-DrPvQ9Ag.d.mts} +62 -12
- package/dist/context-decorator-DrPvQ9Ag.d.mts.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.d.mts +1 -1
- package/dist/core/cache.mjs +3 -3
- package/dist/core/cache.mjs.map +1 -1
- package/dist/core/container.d.mts +1 -1
- package/dist/core/container.mjs +2 -2
- package/dist/core/cron.d.mts +1 -1
- package/dist/core/cron.mjs +3 -3
- package/dist/core/cron.mjs.map +1 -1
- package/dist/core/decorators.d.mts +2 -2
- package/dist/core/decorators.mjs +48 -16
- package/dist/core/decorators.mjs.map +1 -1
- package/dist/core/errors.d.mts +1 -1
- package/dist/core/errors.mjs +1 -1
- package/dist/core/interfaces.d.mts +1 -1
- package/dist/core/interfaces.mjs +35 -18
- package/dist/core/interfaces.mjs.map +1 -1
- package/dist/core/logger.d.mts +2 -2
- package/dist/core/logger.mjs +2 -4
- package/dist/core/logger.mjs.map +1 -1
- package/dist/core/path.d.mts +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.d.mts +1 -1
- package/dist/core/reactivity.mjs +1 -1
- package/dist/{core-DANnH5-e.mjs → core-Dj3iVQ3t.mjs} +305 -8
- package/dist/core-Dj3iVQ3t.mjs.map +1 -0
- package/dist/cors-BfgqfLPd.d.mts +48 -0
- package/dist/cors-BfgqfLPd.d.mts.map +1 -0
- package/dist/{cron-CfsPdi7R.d.mts → cron-GNoYydfg.d.mts} +2 -2
- package/dist/cron-GNoYydfg.d.mts.map +1 -0
- package/dist/csrf-DiK9zept.d.mts +52 -0
- package/dist/csrf-DiK9zept.d.mts.map +1 -0
- package/dist/{decorators-H42oPg0m.d.mts → decorators-BMvaLliz.d.mts} +147 -12
- package/dist/decorators-BMvaLliz.d.mts.map +1 -0
- package/dist/{env-Cs8Wt8A_.mjs → env-DMqv56Bb.mjs} +3 -4
- package/dist/{env-Cs8Wt8A_.mjs.map → env-DMqv56Bb.mjs.map} +1 -1
- package/dist/error-handler-Xud_3Lah.d.mts +20 -0
- package/dist/error-handler-Xud_3Lah.d.mts.map +1 -0
- package/dist/{errors-D_CWI7Bl.d.mts → errors-uaHCeXRz.d.mts} +1 -1
- package/dist/{errors-D_CWI7Bl.d.mts.map → errors-uaHCeXRz.d.mts.map} +1 -1
- package/dist/{execution-context-Dl2CKqSo.d.mts → execution-context-DKnt61pY.d.mts} +1 -1
- package/dist/{execution-context-Dl2CKqSo.d.mts.map → execution-context-DKnt61pY.d.mts.map} +1 -1
- package/dist/helmet-CaMbjzBG.d.mts +41 -0
- package/dist/helmet-CaMbjzBG.d.mts.map +1 -0
- package/dist/http/application.d.mts +2 -293
- package/dist/http/application.mjs +2 -2
- package/dist/http/bootstrap.d.mts +2 -27
- package/dist/http/bootstrap.mjs +2 -2
- package/dist/http/context.d.mts +3 -251
- package/dist/http/context.mjs +2 -2
- package/dist/http/middleware/cors.d.mts +2 -47
- package/dist/http/middleware/cors.mjs +1 -1
- package/dist/http/middleware/csrf.d.mts +2 -51
- package/dist/http/middleware/csrf.mjs +2 -2
- package/dist/http/middleware/csrf.mjs.map +1 -1
- package/dist/http/middleware/error-handler.d.mts +2 -19
- package/dist/http/middleware/error-handler.mjs +2 -2
- package/dist/http/middleware/helmet.d.mts +2 -40
- package/dist/http/middleware/helmet.mjs +1 -1
- package/dist/http/middleware/rate-limit.d.mts +2 -55
- package/dist/http/middleware/rate-limit.mjs +2 -2
- package/dist/http/middleware/rate-limit.mjs.map +1 -1
- package/dist/http/middleware/request-id.d.mts +2 -9
- package/dist/http/middleware/request-id.mjs +12 -3
- package/dist/http/middleware/request-id.mjs.map +1 -1
- package/dist/http/middleware/request-logger.d.mts +2 -31
- package/dist/http/middleware/request-logger.mjs +2 -2
- package/dist/http/middleware/session.d.mts +2 -69
- package/dist/http/middleware/session.mjs +1 -1
- package/dist/http/middleware/spa.d.mts +2 -100
- package/dist/http/middleware/spa.mjs +5 -5
- package/dist/http/middleware/spa.mjs.map +1 -1
- package/dist/http/middleware/upload.d.mts +2 -78
- package/dist/http/middleware/upload.mjs +1 -1
- package/dist/http/middleware/validate.d.mts +2 -22
- package/dist/http/middleware/validate.mjs +2 -2
- package/dist/http/middleware/views.d.mts +2 -61
- package/dist/http/middleware/views.mjs +16 -15
- package/dist/http/middleware/views.mjs.map +1 -1
- package/dist/http/query/index.d.mts +1 -1
- package/dist/http/query/index.mjs +2 -2
- package/dist/http/router-builder.d.mts +2 -32
- package/dist/http/router-builder.mjs +10 -14
- package/dist/http/router-builder.mjs.map +1 -1
- package/dist/{index-RNK41JPE.d.mts → index-B9cyOQAe.d.mts} +1 -1
- package/dist/{index-RNK41JPE.d.mts.map → index-B9cyOQAe.d.mts.map} +1 -1
- package/dist/{index-Cf-MGrqT.d.mts → index-D-qhXg9M.d.mts} +3 -3
- package/dist/{index-Cf-MGrqT.d.mts.map → index-D-qhXg9M.d.mts.map} +1 -1
- package/dist/{index-BQM9pJrV.d.mts → index-Yhs9sTMW.d.mts} +241 -5
- package/dist/index-Yhs9sTMW.d.mts.map +1 -0
- package/dist/index.d.mts +34 -152
- package/dist/index.mjs +50 -14
- package/dist/index.mjs.map +1 -1
- package/dist/interfaces-B50n7dwl.d.mts +71 -0
- package/dist/{interfaces-CwcdqfNq.d.mts.map → interfaces-B50n7dwl.d.mts.map} +1 -1
- package/dist/{logger-GK8yT0BD.d.mts → logger-CLVRZf2N.d.mts} +2 -4
- package/dist/{logger-GK8yT0BD.d.mts.map → logger-CLVRZf2N.d.mts.map} +1 -1
- package/dist/{metadata-BFuoSEX6.mjs → metadata-BF1WDBOh.mjs} +2 -2
- package/dist/{metadata-BFuoSEX6.mjs.map → metadata-BF1WDBOh.mjs.map} +1 -1
- package/dist/{path-Bj3vZMUY.d.mts → path-Diviu6hv.d.mts} +1 -1
- package/dist/path-Diviu6hv.d.mts.map +1 -0
- package/dist/{plugin-3rKA0Loy.d.mts → plugin-DDjoN4XI.d.mts} +46 -8
- package/dist/plugin-DDjoN4XI.d.mts.map +1 -0
- package/dist/{query-BcYEjYyX.mjs → query-BrYRQMa5.mjs} +2 -2
- package/dist/{query-BcYEjYyX.mjs.map → query-BrYRQMa5.mjs.map} +1 -1
- package/dist/rate-limit-DUwoICtI.d.mts +56 -0
- package/dist/rate-limit-DUwoICtI.d.mts.map +1 -0
- package/dist/{reactivity-CczHu3R-.d.mts → reactivity-CfJceo4H.d.mts} +1 -1
- package/dist/{reactivity-CczHu3R-.d.mts.map → reactivity-CfJceo4H.d.mts.map} +1 -1
- package/dist/request-id-BgglvZHN.d.mts +19 -0
- package/dist/request-id-BgglvZHN.d.mts.map +1 -0
- package/dist/request-logger-CWHbAzTE.d.mts +32 -0
- package/dist/request-logger-CWHbAzTE.d.mts.map +1 -0
- package/dist/router-builder-zsX4Oq7c.d.mts +31 -0
- package/dist/router-builder-zsX4Oq7c.d.mts.map +1 -0
- package/dist/session-N0hActOO.d.mts +70 -0
- package/dist/session-N0hActOO.d.mts.map +1 -0
- package/dist/spa-CwIbdvPc.d.mts +101 -0
- package/dist/spa-CwIbdvPc.d.mts.map +1 -0
- package/dist/upload-BueOnnLw.d.mts +79 -0
- package/dist/upload-BueOnnLw.d.mts.map +1 -0
- package/dist/validate-HwAyWTwH.d.mts +23 -0
- package/dist/validate-HwAyWTwH.d.mts.map +1 -0
- package/dist/views-v05_dP1I.d.mts +181 -0
- package/dist/views-v05_dP1I.d.mts.map +1 -0
- package/package.json +6 -9
- package/dist/adapter-DLEHb0K6.d.mts +0 -151
- package/dist/adapter-DLEHb0K6.d.mts.map +0 -1
- package/dist/app-module-ERR9jhow.d.mts.map +0 -1
- package/dist/application-x8CXLOlv.mjs.map +0 -1
- package/dist/chunk-Bt-rz0Tp.mjs +0 -15
- package/dist/container-Dnk43k54.mjs.map +0 -1
- package/dist/container-fIS1uLx-.d.mts.map +0 -1
- package/dist/context-OktlOQBQ.mjs.map +0 -1
- package/dist/context-decorator-GA8-hDLe.d.mts.map +0 -1
- package/dist/core-DANnH5-e.mjs.map +0 -1
- package/dist/cron-CfsPdi7R.d.mts.map +0 -1
- package/dist/decorators-H42oPg0m.d.mts.map +0 -1
- package/dist/http/application.d.mts.map +0 -1
- package/dist/http/bootstrap.d.mts.map +0 -1
- package/dist/http/context.d.mts.map +0 -1
- package/dist/http/middleware/cors.d.mts.map +0 -1
- package/dist/http/middleware/csrf.d.mts.map +0 -1
- package/dist/http/middleware/error-handler.d.mts.map +0 -1
- package/dist/http/middleware/helmet.d.mts.map +0 -1
- package/dist/http/middleware/rate-limit.d.mts.map +0 -1
- package/dist/http/middleware/request-id.d.mts.map +0 -1
- package/dist/http/middleware/request-logger.d.mts.map +0 -1
- package/dist/http/middleware/session.d.mts.map +0 -1
- package/dist/http/middleware/spa.d.mts.map +0 -1
- package/dist/http/middleware/upload.d.mts.map +0 -1
- package/dist/http/middleware/validate.d.mts.map +0 -1
- package/dist/http/middleware/views.d.mts.map +0 -1
- package/dist/http/router-builder.d.mts.map +0 -1
- package/dist/index-BQM9pJrV.d.mts.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/interfaces-CwcdqfNq.d.mts +0 -54
- package/dist/path-Bj3vZMUY.d.mts.map +0 -1
- package/dist/plugin-3rKA0Loy.d.mts.map +0 -1
|
@@ -1,294 +1,3 @@
|
|
|
1
1
|
|
|
2
|
-
import { t as
|
|
3
|
-
|
|
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-Bepa-pFw.mjs";
|
|
3
|
+
export { Application, ApplicationOptions, MiddlewareEntry };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs
|
|
2
|
+
* @forinda/kickjs v4.1.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-
|
|
11
|
+
import { t as Application } from "../application-DvmPMUgF.mjs";
|
|
12
12
|
export { Application };
|
|
@@ -1,28 +1,3 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
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-B4T3X2B6.mjs";
|
|
3
|
+
export { bootstrap };
|
package/dist/http/bootstrap.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs
|
|
2
|
+
* @forinda/kickjs v4.1.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-
|
|
11
|
+
import { t as bootstrap } from "../bootstrap-THfr8phJ.mjs";
|
|
12
12
|
export { bootstrap };
|
package/dist/http/context.d.mts
CHANGED
|
@@ -1,252 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
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 };
|
package/dist/http/context.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs
|
|
2
|
+
* @forinda/kickjs v4.1.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-
|
|
11
|
+
import { t as RequestContext } from "../context-CyQbqSz-.mjs";
|
|
12
12
|
export { RequestContext };
|
|
@@ -1,48 +1,3 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
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 };
|