@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
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
|
|
2
|
+
import { r as AppAdapter, t as AdapterContext } from "./adapter-6Pp4kFdM.mjs";
|
|
3
|
+
//#region src/http/middleware/spa.d.ts
|
|
4
|
+
interface SpaAdapterOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Directory containing the built SPA files (index.html, assets, etc.)
|
|
7
|
+
* Default: 'dist/client'
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* // Vue: 'dist'
|
|
12
|
+
* // React (Vite): 'dist'
|
|
13
|
+
* // React (CRA): 'build'
|
|
14
|
+
* // Svelte: 'build'
|
|
15
|
+
* // Angular: 'dist/my-app/browser'
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
clientDir?: string;
|
|
19
|
+
/**
|
|
20
|
+
* URL prefix for API routes. SPA fallback only applies to
|
|
21
|
+
* non-API routes (routes NOT starting with this prefix).
|
|
22
|
+
* Default: '/api'
|
|
23
|
+
*
|
|
24
|
+
* Set to an array for multiple prefixes:
|
|
25
|
+
* ```ts
|
|
26
|
+
* apiPrefix: ['/api', '/graphql', '/_debug']
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
apiPrefix?: string | string[];
|
|
30
|
+
/**
|
|
31
|
+
* Additional paths to exclude from SPA fallback.
|
|
32
|
+
* These paths will NOT serve index.html.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* exclude: ['/health', '/metrics', '/ws']
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
exclude?: string[];
|
|
40
|
+
/**
|
|
41
|
+
* Cache-Control header for static assets (default: 'public, max-age=31536000, immutable')
|
|
42
|
+
* Set to false to disable caching headers.
|
|
43
|
+
*/
|
|
44
|
+
cacheControl?: string | false;
|
|
45
|
+
/**
|
|
46
|
+
* Cache-Control for index.html (default: 'no-cache')
|
|
47
|
+
* index.html should not be cached to ensure clients get fresh builds.
|
|
48
|
+
*/
|
|
49
|
+
indexCacheControl?: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* SPA adapter — serve a Vue, React, Svelte, or Angular build alongside
|
|
53
|
+
* your KickJS API. API routes are handled by controllers; everything else
|
|
54
|
+
* falls back to index.html for client-side routing.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* import { SpaAdapter } from '@forinda/kickjs/spa'
|
|
59
|
+
*
|
|
60
|
+
* bootstrap({
|
|
61
|
+
* modules,
|
|
62
|
+
* adapters: [
|
|
63
|
+
* new SpaAdapter({
|
|
64
|
+
* clientDir: 'dist/client', // or 'build', 'dist', etc.
|
|
65
|
+
* apiPrefix: '/api',
|
|
66
|
+
* }),
|
|
67
|
+
* ],
|
|
68
|
+
* })
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* File structure:
|
|
72
|
+
* ```
|
|
73
|
+
* dist/
|
|
74
|
+
* client/ ← SPA build output
|
|
75
|
+
* index.html
|
|
76
|
+
* assets/
|
|
77
|
+
* app.js
|
|
78
|
+
* style.css
|
|
79
|
+
* server/ ← KickJS server
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
declare class SpaAdapter implements AppAdapter {
|
|
83
|
+
private options;
|
|
84
|
+
name: string;
|
|
85
|
+
private clientDir;
|
|
86
|
+
private apiPrefixes;
|
|
87
|
+
private excludePaths;
|
|
88
|
+
private cacheControl;
|
|
89
|
+
private indexCacheControl;
|
|
90
|
+
private indexHtml;
|
|
91
|
+
constructor(options?: SpaAdapterOptions);
|
|
92
|
+
beforeMount({
|
|
93
|
+
app
|
|
94
|
+
}: AdapterContext): void;
|
|
95
|
+
beforeStart({
|
|
96
|
+
app
|
|
97
|
+
}: AdapterContext): void;
|
|
98
|
+
}
|
|
99
|
+
//#endregion
|
|
100
|
+
export { SpaAdapterOptions as n, SpaAdapter as t };
|
|
101
|
+
//# sourceMappingURL=spa-CwIbdvPc.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spa-CwIbdvPc.d.mts","names":[],"sources":["../src/http/middleware/spa.ts"],"mappings":";;;UAMiB,iBAAA;;;AAAjB;;;;;;;;;;;EAcE,SAAA;EAqEsB;;;;;;;;;;EAzDtB,SAAA;EAkEoB;;;;;;;;;EAvDpB,OAAA;EAuDoB;;;;EAjDpB,YAAA;EAoGA;;;;EA9FA,iBAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAkCW,UAAA,YAAsB,UAAA;EAAA,QASb,OAAA;EARpB,IAAA;EAAA,QACQ,SAAA;EAAA,QACA,WAAA;EAAA,QACA,YAAA;EAAA,QACA,YAAA;EAAA,QACA,iBAAA;EAAA,QACA,SAAA;cAEY,OAAA,GAAS,iBAAA;EAU7B,WAAA,CAAA;IAAc;EAAA,GAAO,cAAA;EAyCrB,WAAA,CAAA;IAAc;EAAA,GAAO,cAAA;AAAA"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
|
|
2
|
+
import { g as FileUploadConfig, o as BaseUploadOptions } from "./decorators-BMvaLliz.mjs";
|
|
3
|
+
import { NextFunction, Request, RequestHandler, Response } from "express";
|
|
4
|
+
import { Options } from "multer";
|
|
5
|
+
|
|
6
|
+
//#region src/http/middleware/upload.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Resolves a list of file type identifiers to MIME type strings.
|
|
9
|
+
* Accepts short extensions (`'jpg'`, `'pdf'`) or full MIME types (`'image/jpeg'`).
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* resolveMimeTypes(['jpg', 'png', 'application/pdf'])
|
|
14
|
+
* // → ['image/jpeg', 'image/png', 'application/pdf']
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
declare function resolveMimeTypes(types: string[]): string[];
|
|
18
|
+
/**
|
|
19
|
+
* Upload options for the middleware.
|
|
20
|
+
* Extends BaseUploadOptions from core (shared with @FileUpload decorator)
|
|
21
|
+
* and adds Multer-specific storage options.
|
|
22
|
+
*/
|
|
23
|
+
interface UploadOptions extends BaseUploadOptions {
|
|
24
|
+
/** Multer storage config (default: memory storage) */
|
|
25
|
+
storage?: Options['storage'];
|
|
26
|
+
/** Multer dest for disk storage shorthand */
|
|
27
|
+
dest?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Single file upload middleware. Attaches the file to `req.file`.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* @Post('/avatar')
|
|
35
|
+
* @Middleware(upload.single('avatar', { maxSize: 2 * 1024 * 1024, allowedTypes: ['jpg', 'png'] }))
|
|
36
|
+
* async uploadAvatar(ctx: RequestContext) {
|
|
37
|
+
* ctx.json({ filename: ctx.file.originalname })
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
declare function single(fieldName: string, options?: UploadOptions): RequestHandler;
|
|
42
|
+
/**
|
|
43
|
+
* Multiple file upload middleware. Attaches files to `req.files`.
|
|
44
|
+
*/
|
|
45
|
+
declare function array(fieldName: string, maxCount?: number, options?: UploadOptions): RequestHandler;
|
|
46
|
+
/**
|
|
47
|
+
* No file upload — just parse multipart form data without file fields.
|
|
48
|
+
*/
|
|
49
|
+
declare function none(options?: UploadOptions): RequestHandler;
|
|
50
|
+
/**
|
|
51
|
+
* Removes temporary files from disk after the response is sent.
|
|
52
|
+
* Attach this as Express middleware after the upload middleware.
|
|
53
|
+
* Works with both `req.file` (single) and `req.files` (array).
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* @Post('/process')
|
|
58
|
+
* @Middleware(upload.single('document', { dest: '/tmp/uploads' }), cleanupFiles())
|
|
59
|
+
* async processDocument(ctx: RequestContext) {
|
|
60
|
+
* ctx.json({ ok: true })
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
declare function cleanupFiles(): (req: Request, res: Response, next: NextFunction) => void;
|
|
65
|
+
/**
|
|
66
|
+
* Build upload middleware from a @FileUpload decorator config.
|
|
67
|
+
* Used internally by the router builder when it detects FILE_UPLOAD metadata.
|
|
68
|
+
* Accepts the same FileUploadConfig interface used by the @FileUpload decorator.
|
|
69
|
+
*/
|
|
70
|
+
declare function buildUploadMiddleware(config: FileUploadConfig): RequestHandler;
|
|
71
|
+
/** Upload middleware factory with `.single()`, `.array()`, `.none()` methods */
|
|
72
|
+
declare const upload: {
|
|
73
|
+
single: typeof single;
|
|
74
|
+
array: typeof array;
|
|
75
|
+
none: typeof none;
|
|
76
|
+
};
|
|
77
|
+
//#endregion
|
|
78
|
+
export { upload as a, resolveMimeTypes as i, buildUploadMiddleware as n, cleanupFiles as r, UploadOptions as t };
|
|
79
|
+
//# sourceMappingURL=upload-BueOnnLw.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload-BueOnnLw.d.mts","names":[],"sources":["../src/http/middleware/upload.ts"],"mappings":";;;;;;;;;AAsEA;;;;;AAYA;;iBAZgB,gBAAA,CAAiB,KAAA;;;;;;UAYhB,aAAA,SAAsB,iBAAA;EAIjC;EAFJ,OAAA,GAAU,OAAA;EAmEG;EAjEb,IAAA;AAAA;;;;;;;AAiE6E;;;;;;iBAAtE,MAAA,CAAO,SAAA,UAAmB,OAAA,GAAS,aAAA,GAAqB,cAAA;;;;iBAQxD,KAAA,CAAM,SAAA,UAAmB,QAAA,WAAe,OAAA,GAAS,aAAA,GAAqB,cAAA;AAAc;;;AAAA,iBAQpF,IAAA,CAAK,OAAA,GAAS,aAAA,GAAqB,cAAA;;;;;;AAmB5C;;;;;;;;;iBAAgB,YAAA,CAAA,IACN,GAAA,EAAK,OAAA,EAAS,GAAA,EAAK,QAAA,EAAU,IAAA,EAAM,YAAA;;;;;;iBA+B7B,qBAAA,CAAsB,MAAA,EAAQ,gBAAA,GAAmB,cAAA;AAAjE;AAAA,cAmBa,MAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
import { NextFunction, Request, Response } from "express";
|
|
3
|
+
|
|
4
|
+
//#region src/http/middleware/validate.d.ts
|
|
5
|
+
interface ValidationSchema {
|
|
6
|
+
body?: any;
|
|
7
|
+
query?: any;
|
|
8
|
+
params?: any;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Express middleware that validates request body/query/params against schemas.
|
|
12
|
+
* Works with any validation library that exposes `.safeParse(data)` returning
|
|
13
|
+
* `{ success: true, data }` or `{ success: false, error: { issues } }`.
|
|
14
|
+
*
|
|
15
|
+
* Validation failures are forwarded via `next(err)` as an `HttpException`, so
|
|
16
|
+
* they flow through the application's global error handler (`onError`) and
|
|
17
|
+
* produce a uniform response envelope. Apps that keep the built-in handler
|
|
18
|
+
* continue to see the same `{ message, errors: [{ field, message }] }` body.
|
|
19
|
+
*/
|
|
20
|
+
declare function validate(schema: ValidationSchema): (req: Request, _res: Response, next: NextFunction) => void;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { validate as n, ValidationSchema as t };
|
|
23
|
+
//# sourceMappingURL=validate-HwAyWTwH.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-HwAyWTwH.d.mts","names":[],"sources":["../src/http/middleware/validate.ts"],"mappings":";;;;UAGiB,gBAAA;EACf,IAAA;EACA,KAAA;EACA,MAAA;AAAA;;;;;;;AA8CF;;;;iBAAgB,QAAA,CAAS,MAAA,EAAQ,gBAAA,IACvB,GAAA,EAAK,OAAA,EAAS,IAAA,EAAM,QAAA,EAAU,IAAA,EAAM,YAAA"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
|
|
2
|
+
import { n as ContextDecorator, r as ContextDecoratorSpec, s as DepValue } from "./context-decorator-DrPvQ9Ag.mjs";
|
|
3
|
+
import { n as AdapterFactory } from "./index-Yhs9sTMW.mjs";
|
|
4
|
+
import { n as RequestContext } from "./context-Ymvv-85x.mjs";
|
|
5
|
+
import { NextFunction, Request, Response } from "express";
|
|
6
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
7
|
+
|
|
8
|
+
//#region src/http/cluster.d.ts
|
|
9
|
+
interface ClusterOptions {
|
|
10
|
+
/** Number of worker processes (default: os.cpus().length) */
|
|
11
|
+
workers?: number;
|
|
12
|
+
/** Delay before forcefully killing a worker during shutdown (ms), default: 5000 */
|
|
13
|
+
gracefulShutdownTimeout?: number;
|
|
14
|
+
/** Delay between worker restarts (ms), default: 1000 */
|
|
15
|
+
restartDelay?: number;
|
|
16
|
+
/** Max failures in restartWindow before refusing to restart, default: 5 */
|
|
17
|
+
maxFailures?: number;
|
|
18
|
+
/** Time window for counting failures (ms), default: 30000 */
|
|
19
|
+
restartWindow?: number;
|
|
20
|
+
}
|
|
21
|
+
/** Returns true if the current process is the cluster primary */
|
|
22
|
+
declare function isClusterPrimary(): boolean;
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/http/define-http-context-decorator.d.ts
|
|
25
|
+
declare function defineHttpContextDecorator<K extends string, D extends Record<string, DepValue> = Record<string, never>>(spec: ContextDecoratorSpec<K, D, RequestContext>): ContextDecorator<K, D, RequestContext>;
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/http/request-store.d.ts
|
|
28
|
+
/** Per-request storage for REQUEST-scoped DI and request context propagation */
|
|
29
|
+
interface RequestStore {
|
|
30
|
+
/** Unique request identifier */
|
|
31
|
+
requestId: string;
|
|
32
|
+
/**
|
|
33
|
+
* Per-request singleton cache for REQUEST-scoped services. Keys are
|
|
34
|
+
* heterogeneous (class constructors, `InjectionToken` objects, raw
|
|
35
|
+
* strings), so the map type stays `Map<any, any>`.
|
|
36
|
+
*/
|
|
37
|
+
instances: Map<any, any>;
|
|
38
|
+
/**
|
|
39
|
+
* Per-request key/value bag. Canonical backing store for
|
|
40
|
+
* `RequestContext.set/get` and the Context Contributor pipeline (#107)
|
|
41
|
+
* since Phase 3. Anything written here is visible to every concrete
|
|
42
|
+
* execution context constructed for the same request, regardless of
|
|
43
|
+
* which middleware/contributor wrote it.
|
|
44
|
+
*
|
|
45
|
+
* Keys are constrained to `string` per the locked decision in
|
|
46
|
+
* `architecture.md` §20.12 (#4); the value type is `unknown` because
|
|
47
|
+
* the concrete shape at each key is determined by the consumer's
|
|
48
|
+
* `ContextMeta` augmentation, not by the store itself.
|
|
49
|
+
*/
|
|
50
|
+
values: Map<string, unknown>;
|
|
51
|
+
}
|
|
52
|
+
/** AsyncLocalStorage instance shared across the framework */
|
|
53
|
+
declare const requestStore: AsyncLocalStorage<RequestStore>;
|
|
54
|
+
/**
|
|
55
|
+
* Get the current request store. Throws if called outside a request context.
|
|
56
|
+
* Used by the Container to resolve REQUEST-scoped dependencies.
|
|
57
|
+
*/
|
|
58
|
+
declare function getRequestStore(): RequestStore;
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/http/middleware/request-scope.d.ts
|
|
61
|
+
/**
|
|
62
|
+
* Wraps each request in an AsyncLocalStorage context.
|
|
63
|
+
* Enables REQUEST-scoped DI and automatic requestId propagation to logs.
|
|
64
|
+
*
|
|
65
|
+
* Should be mounted early in the middleware pipeline (before route handlers).
|
|
66
|
+
* `Application` mounts this automatically unless `contextStore: 'manual'` is set
|
|
67
|
+
* or the user already includes one in their middleware list.
|
|
68
|
+
*/
|
|
69
|
+
declare function requestScopeMiddleware(): (req: Request, _res: Response, next: NextFunction) => void;
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/http/middleware/trace-context.d.ts
|
|
72
|
+
/**
|
|
73
|
+
* W3C Trace Context header name.
|
|
74
|
+
* @see https://www.w3.org/TR/trace-context/#traceparent-header
|
|
75
|
+
*/
|
|
76
|
+
declare const TRACEPARENT_HEADER = "traceparent";
|
|
77
|
+
interface TraceContextOptions {
|
|
78
|
+
/**
|
|
79
|
+
* When true, respond with a `traceresponse` header containing the trace ID.
|
|
80
|
+
* Useful for debugging. Default: false.
|
|
81
|
+
*/
|
|
82
|
+
propagateResponse?: boolean;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Parsed W3C trace context fields.
|
|
86
|
+
*/
|
|
87
|
+
interface TraceContext {
|
|
88
|
+
/** W3C traceparent version (usually '00') */
|
|
89
|
+
version: string;
|
|
90
|
+
/** 32-hex-char distributed trace ID */
|
|
91
|
+
traceId: string;
|
|
92
|
+
/** 16-hex-char parent span ID */
|
|
93
|
+
parentSpanId: string;
|
|
94
|
+
/** 2-hex-char trace flags */
|
|
95
|
+
flags: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Parse a W3C traceparent header value.
|
|
99
|
+
* Returns null if the format is invalid.
|
|
100
|
+
*/
|
|
101
|
+
declare function parseTraceparent(header: string): TraceContext | null;
|
|
102
|
+
/**
|
|
103
|
+
* Middleware that extracts W3C `traceparent` header and stores trace context
|
|
104
|
+
* in the request's AsyncLocalStorage store.
|
|
105
|
+
*
|
|
106
|
+
* If no valid `traceparent` header is present, a new traceId is generated
|
|
107
|
+
* so that every request always has a trace ID available for correlation.
|
|
108
|
+
*
|
|
109
|
+
* Must be mounted **after** `requestScopeMiddleware()` (which creates the store).
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```ts
|
|
113
|
+
* bootstrap({
|
|
114
|
+
* middleware: [
|
|
115
|
+
* requestScopeMiddleware(),
|
|
116
|
+
* traceContext(), // extracts or generates traceId
|
|
117
|
+
* requestLogger(),
|
|
118
|
+
* express.json(),
|
|
119
|
+
* ],
|
|
120
|
+
* })
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
declare function traceContext(options?: TraceContextOptions): (req: Request, res: Response, next: NextFunction) => void;
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/http/middleware/views.d.ts
|
|
126
|
+
interface ViewAdapterOptions {
|
|
127
|
+
/**
|
|
128
|
+
* Template engine — pass the engine module or a render function.
|
|
129
|
+
* Supported engines: ejs, pug, handlebars, nunjucks, or any
|
|
130
|
+
* Express-compatible engine with a __express property.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```ts
|
|
134
|
+
* import ejs from 'ejs'
|
|
135
|
+
* ViewAdapter({ engine: ejs, ext: 'ejs' })
|
|
136
|
+
*
|
|
137
|
+
* import pug from 'pug'
|
|
138
|
+
* ViewAdapter({ engine: pug, ext: 'pug' })
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
engine: any;
|
|
142
|
+
/** File extension for templates (e.g., 'ejs', 'pug', 'hbs') */
|
|
143
|
+
ext: string;
|
|
144
|
+
/** Directory containing template files (default: 'src/views') */
|
|
145
|
+
viewsDir?: string;
|
|
146
|
+
/** Default layout template (optional — depends on engine) */
|
|
147
|
+
layout?: string;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* View/template adapter — pluggable template engine support for KickJS.
|
|
151
|
+
*
|
|
152
|
+
* Registers an Express view engine and sets the views directory.
|
|
153
|
+
* Use `ctx.render()` in controllers to render templates.
|
|
154
|
+
*
|
|
155
|
+
* Migrated to the `defineAdapter()` factory in v4 — call without `new`.
|
|
156
|
+
* The pre-v4 `new ViewAdapter({...})` form is gone; see
|
|
157
|
+
* `docs/guide/migration-v3-to-v4.md` for the rename.
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```ts
|
|
161
|
+
* import ejs from 'ejs'
|
|
162
|
+
* import { ViewAdapter } from '@forinda/kickjs'
|
|
163
|
+
*
|
|
164
|
+
* bootstrap({
|
|
165
|
+
* modules,
|
|
166
|
+
* adapters: [
|
|
167
|
+
* ViewAdapter({ engine: ejs, ext: 'ejs', viewsDir: 'src/views' }),
|
|
168
|
+
* ],
|
|
169
|
+
* })
|
|
170
|
+
*
|
|
171
|
+
* // In a controller:
|
|
172
|
+
* @Get('/dashboard')
|
|
173
|
+
* async dashboard(ctx: RequestContext) {
|
|
174
|
+
* ctx.render('dashboard', { user: currentUser, title: 'Dashboard' })
|
|
175
|
+
* }
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
declare const ViewAdapter: AdapterFactory<ViewAdapterOptions, unknown>;
|
|
179
|
+
//#endregion
|
|
180
|
+
export { TraceContextOptions as a, requestScopeMiddleware as c, requestStore as d, defineHttpContextDecorator as f, TraceContext as i, RequestStore as l, isClusterPrimary as m, ViewAdapterOptions as n, parseTraceparent as o, ClusterOptions as p, TRACEPARENT_HEADER as r, traceContext as s, ViewAdapter as t, getRequestStore as u };
|
|
181
|
+
//# sourceMappingURL=views-v05_dP1I.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"views-v05_dP1I.d.mts","names":[],"sources":["../src/http/cluster.ts","../src/http/define-http-context-decorator.ts","../src/http/request-store.ts","../src/http/middleware/request-scope.ts","../src/http/middleware/trace-context.ts","../src/http/middleware/views.ts"],"mappings":";;;;;;;;UAOiB,cAAA;;EAEf,OAAA;;EAEA,uBAAA;;EAEA,YAAA;;EAEA,WAAA;;EAEA,aAAA;AAAA;;iBAIc,gBAAA,CAAA;;;iBCmBA,0BAAA,6BAEJ,MAAA,SAAe,QAAA,IAAY,MAAA,gBAAA,CACrC,IAAA,EAAM,oBAAA,CAAqB,CAAA,EAAG,CAAA,EAAG,cAAA,IAAkB,gBAAA,CAAiB,CAAA,EAAG,CAAA,EAAG,cAAA;;;;UCxC3D,YAAA;;EAEf,SAAA;;;;;;EAMA,SAAA,EAAW,GAAA;;;;;;;;;;;;AFJb;EEiBE,MAAA,EAAQ,GAAA;AAAA;;cAIG,YAAA,EAAY,iBAAA,CAAA,YAAA;;;;;iBAMT,eAAA,CAAA,GAAmB,YAAA;;;;;;;;;;;iBCRnB,sBAAA,CAAA,IAAsB,GAAA,EACnB,OAAA,EAAO,IAAA,EAAQ,QAAA,EAAQ,IAAA,EAAQ,YAAA;;;;;;;cCnBrC,kBAAA;AAAA,UAKI,mBAAA;;;;;EAKf,iBAAA;AAAA;;;;UAMe,YAAA;;EAEf,OAAA;;EAEA,OAAA;;EAEA,YAAA;EJvB6B;EIyB7B,KAAA;AAAA;;;;;iBAqBc,gBAAA,CAAiB,MAAA,WAAiB,YAAA;;;AJhClD;;;;;;;;ACmBA;;;;;;;;;;;iBGuDgB,YAAA,CAAa,OAAA,GAAS,mBAAA,IAC5B,GAAA,EAAK,OAAA,EAAS,GAAA,EAAK,QAAA,EAAU,IAAA,EAAM,YAAA;;;UC3F5B,kBAAA;;;;;;;;;;;;;;;EAef,MAAA;;EAGA,GAAA;;EAGA,QAAA;;EAGA,MAAA;AAAA;;;;;;;;;;;ALRF;;;;;;;;ACmBA;;;;;;;;;;;cIqBa,WAAA,EAAW,cAAA,CAAA,kBAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forinda/kickjs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "A production-grade, decorator-driven Node.js framework built on Express 5 and TypeScript.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"kickjs",
|
|
@@ -22,13 +22,10 @@
|
|
|
22
22
|
"@forinda/kickjs",
|
|
23
23
|
"@forinda/kickjs-auth",
|
|
24
24
|
"@forinda/kickjs-cli",
|
|
25
|
-
"@forinda/kickjs-config",
|
|
26
|
-
"@forinda/kickjs-core",
|
|
27
25
|
"@forinda/kickjs-cron",
|
|
28
26
|
"@forinda/kickjs-devtools",
|
|
29
27
|
"@forinda/kickjs-drizzle",
|
|
30
28
|
"@forinda/kickjs-graphql",
|
|
31
|
-
"@forinda/kickjs-http",
|
|
32
29
|
"@forinda/kickjs-mailer",
|
|
33
30
|
"@forinda/kickjs-multi-tenant",
|
|
34
31
|
"@forinda/kickjs-notifications",
|
|
@@ -150,14 +147,14 @@
|
|
|
150
147
|
}
|
|
151
148
|
},
|
|
152
149
|
"devDependencies": {
|
|
153
|
-
"@swc/core": "^1.15.
|
|
150
|
+
"@swc/core": "^1.15.30",
|
|
154
151
|
"@types/cookie-parser": "^1.4.10",
|
|
155
152
|
"@types/express": "^5.0.6",
|
|
156
153
|
"@types/multer": "^2.1.0",
|
|
157
|
-
"@types/node": "^25.
|
|
158
|
-
"typescript": "^
|
|
159
|
-
"vite": "^8.0.
|
|
160
|
-
"vitest": "^4.1.
|
|
154
|
+
"@types/node": "^25.6.0",
|
|
155
|
+
"typescript": "^6.0.3",
|
|
156
|
+
"vite": "^8.0.9",
|
|
157
|
+
"vitest": "^4.1.5"
|
|
161
158
|
},
|
|
162
159
|
"publishConfig": {
|
|
163
160
|
"access": "public"
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { i as Constructor, o as MaybePromise } from "./interfaces-CwcdqfNq.mjs";
|
|
3
|
-
import { t as Container } from "./container-fIS1uLx-.mjs";
|
|
4
|
-
import { r as ContributorRegistration } from "./context-decorator-GA8-hDLe.mjs";
|
|
5
|
-
import http from "node:http";
|
|
6
|
-
import { Express } from "express";
|
|
7
|
-
|
|
8
|
-
//#region src/core/adapter.d.ts
|
|
9
|
-
/**
|
|
10
|
-
* Where in the middleware pipeline an adapter's middleware should be inserted.
|
|
11
|
-
*
|
|
12
|
-
* beforeGlobal → runs before any user-defined global middleware
|
|
13
|
-
* afterGlobal → runs after global middleware, before module routes
|
|
14
|
-
* beforeRoutes → just before module routes are mounted
|
|
15
|
-
* afterRoutes → after module routes but before error handlers
|
|
16
|
-
*/
|
|
17
|
-
type MiddlewarePhase = 'beforeGlobal' | 'afterGlobal' | 'beforeRoutes' | 'afterRoutes';
|
|
18
|
-
/** A middleware entry contributed by an adapter */
|
|
19
|
-
interface AdapterMiddleware {
|
|
20
|
-
/** Express-compatible handler: (req, res, next) => void */
|
|
21
|
-
handler: any;
|
|
22
|
-
/** Which phase to insert into (default: 'afterGlobal') */
|
|
23
|
-
phase?: MiddlewarePhase;
|
|
24
|
-
/** Optional path to scope the middleware to (e.g. '/api/v1/auth') */
|
|
25
|
-
path?: string;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Context passed to adapter lifecycle hooks.
|
|
29
|
-
* Populated by the Application — provides access to the Express app,
|
|
30
|
-
* DI container, http.Server, and environment info without requiring
|
|
31
|
-
* external type imports. Cast `app` or `server` if you need specific types.
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```ts
|
|
35
|
-
* beforeMount({ app, container }: AdapterContext) {
|
|
36
|
-
* app.use(myMiddleware())
|
|
37
|
-
* }
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
interface AdapterContext {
|
|
41
|
-
/** Express application instance — fully typed */
|
|
42
|
-
app: Express;
|
|
43
|
-
/** DI container */
|
|
44
|
-
container: Container;
|
|
45
|
-
/** Node.js http.Server — only available in afterStart */
|
|
46
|
-
server?: http.Server;
|
|
47
|
-
/** Current NODE_ENV value (default: 'development') */
|
|
48
|
-
env: string;
|
|
49
|
-
/** true when NODE_ENV === 'production' */
|
|
50
|
-
isProduction: boolean;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Adapters plug into the Application lifecycle.
|
|
54
|
-
* Implement this to add WebSocket, database, rate limiting, docs, etc.
|
|
55
|
-
*
|
|
56
|
-
* All hooks receive an `AdapterContext` populated by the framework.
|
|
57
|
-
* No external type imports needed — the context is fully typed from KickJS internals.
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* ```ts
|
|
61
|
-
* import type { AppAdapter, AdapterContext } from '@forinda/kickjs-core/adapter'
|
|
62
|
-
*
|
|
63
|
-
* class SentryAdapter implements AppAdapter {
|
|
64
|
-
* name = 'SentryAdapter'
|
|
65
|
-
*
|
|
66
|
-
* beforeMount({ app, container }: AdapterContext) {
|
|
67
|
-
* app.use(Sentry.expressRequestHandler())
|
|
68
|
-
* }
|
|
69
|
-
*
|
|
70
|
-
* afterStart({ server }: AdapterContext) {
|
|
71
|
-
* // server is the http.Server — available after listen()
|
|
72
|
-
* }
|
|
73
|
-
*
|
|
74
|
-
* async shutdown() {
|
|
75
|
-
* await Sentry.close(2000)
|
|
76
|
-
* }
|
|
77
|
-
* }
|
|
78
|
-
* ```
|
|
79
|
-
*/
|
|
80
|
-
interface AppAdapter {
|
|
81
|
-
/** Human-readable name for logging */
|
|
82
|
-
name?: string;
|
|
83
|
-
/**
|
|
84
|
-
* Return middleware entries to be inserted into the pipeline.
|
|
85
|
-
* The `phase` controls ordering relative to global middleware and routes.
|
|
86
|
-
*/
|
|
87
|
-
middleware?(): AdapterMiddleware[];
|
|
88
|
-
/**
|
|
89
|
-
* Return Context Contributors (#107) that apply to every route in the
|
|
90
|
-
* application. Adapter-level contributors merge into the per-route
|
|
91
|
-
* pipeline at the `'adapter'` precedence level — they win over global
|
|
92
|
-
* contributors but lose to module, class, and method decorators.
|
|
93
|
-
*
|
|
94
|
-
* Useful for cross-cutting concerns: an auth adapter contributing
|
|
95
|
-
* `user`, a multi-tenant adapter contributing `tenant`, etc. Optional.
|
|
96
|
-
*/
|
|
97
|
-
contributors?(): ContributorRegistration[] | readonly ContributorRegistration[];
|
|
98
|
-
/**
|
|
99
|
-
* Called before global middleware — register early routes (docs UI, health).
|
|
100
|
-
* May return a Promise — async rejections are caught and logged.
|
|
101
|
-
*/
|
|
102
|
-
beforeMount?(ctx: AdapterContext): void | Promise<void>;
|
|
103
|
-
/**
|
|
104
|
-
* Called for each module route that gets mounted.
|
|
105
|
-
* Use this to collect route metadata (e.g. for OpenAPI spec generation).
|
|
106
|
-
*/
|
|
107
|
-
onRouteMount?(controllerClass: Constructor, mountPath: string): void;
|
|
108
|
-
/**
|
|
109
|
-
* Called after modules are registered and the DI container is bootstrapped,
|
|
110
|
-
* before the HTTP server starts listening. **This is the correct hook for
|
|
111
|
-
* adapters that register DI bindings, resolve services, or otherwise prepare
|
|
112
|
-
* container-side state** (e.g. `container.registerInstance(MAILER, ...)`).
|
|
113
|
-
*
|
|
114
|
-
* `beforeStart` runs inside `app.setup()`, which means it also fires under
|
|
115
|
-
* `createTestApp` — adapters using this hook work in unit tests without
|
|
116
|
-
* needing a live HTTP server. See {@link afterStart} for the contrast.
|
|
117
|
-
*
|
|
118
|
-
* May return a Promise — async rejections are caught and logged.
|
|
119
|
-
*/
|
|
120
|
-
beforeStart?(ctx: AdapterContext): void | Promise<void>;
|
|
121
|
-
/**
|
|
122
|
-
* Called after the HTTP server is listening — `ctx.server` is the live
|
|
123
|
-
* `http.Server`. **Use this hook only for work that genuinely needs a
|
|
124
|
-
* listening server**: attaching Socket.IO / WS upgrades, reading the bound
|
|
125
|
-
* port via `server.address()`, dispatching to the local server over HTTP,
|
|
126
|
-
* etc.
|
|
127
|
-
*
|
|
128
|
-
* `afterStart` does NOT fire under `createTestApp`, since tests call
|
|
129
|
-
* `app.setup()` and never `app.start()`. If your adapter only registers DI
|
|
130
|
-
* bindings or resolves services, use {@link beforeStart} — that hook runs
|
|
131
|
-
* in both production (`start()`) and tests (`setup()`).
|
|
132
|
-
*
|
|
133
|
-
* May return a Promise — async rejections are caught and logged.
|
|
134
|
-
*/
|
|
135
|
-
afterStart?(ctx: AdapterContext): void | Promise<void>;
|
|
136
|
-
/**
|
|
137
|
-
* Called by the /health/ready endpoint. Return the health status of your adapter's
|
|
138
|
-
* backing service (database, Redis, queue, etc.).
|
|
139
|
-
*/
|
|
140
|
-
onHealthCheck?(): Promise<{
|
|
141
|
-
name: string;
|
|
142
|
-
status: 'up' | 'down';
|
|
143
|
-
}>;
|
|
144
|
-
/** Called on shutdown — clean up connections */
|
|
145
|
-
shutdown?(): MaybePromise;
|
|
146
|
-
}
|
|
147
|
-
/** Constructor type for AppAdapter classes */
|
|
148
|
-
type AppAdapterClass = new () => AppAdapter;
|
|
149
|
-
//#endregion
|
|
150
|
-
export { MiddlewarePhase as a, AppAdapterClass as i, AdapterMiddleware as n, AppAdapter as r, AdapterContext as t };
|
|
151
|
-
//# sourceMappingURL=adapter-DLEHb0K6.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapter-DLEHb0K6.d.mts","names":[],"sources":["../src/core/adapter.ts"],"mappings":";;;;;;;;;;AAcA;;;;;AAGA;KAHY,eAAA;;UAGK,iBAAA;EAEf;EAAA,OAAA;EAEQ;EAAR,KAAA,GAAQ,eAAA;EAEJ;EAAJ,IAAA;AAAA;;;;;;;;;;;;;;UAgBe,cAAA;EAQf;EANA,GAAA,EAAK,OAAA;EAQO;EANZ,SAAA,EAAW,SAAA;EAqCI;EAnCf,MAAA,GAAS,IAAA,CAAK,MAAA;;EAEd,GAAA;EAoDiB;EAlDjB,YAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA+Be,UAAA;EA6DE;EA3DjB,IAAA;EA2DyC;;;;EArDzC,UAAA,KAAe,iBAAA;EA8Df;;;;AAIF;;;;;EAvDE,YAAA,KAAiB,uBAAA,cAAqC,uBAAA;;;;;EAMtD,WAAA,EAAa,GAAA,EAAK,cAAA,UAAwB,OAAA;;;;;EAM1C,YAAA,EAAc,eAAA,EAAiB,WAAA,EAAa,SAAA;;;;;;;;;;;;;EAc5C,WAAA,EAAa,GAAA,EAAK,cAAA,UAAwB,OAAA;;;;;;;;;;;;;;;EAgB1C,UAAA,EAAY,GAAA,EAAK,cAAA,UAAwB,OAAA;;;;;EAMzC,aAAA,KAAkB,OAAA;IAAU,IAAA;IAAc,MAAA;EAAA;;EAG1C,QAAA,KAAa,YAAA;AAAA;;KAIH,eAAA,aAA4B,UAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app-module-ERR9jhow.d.mts","names":[],"sources":["../src/core/app-module.ts"],"mappings":";;;;;;;AAOA;;UAAiB,YAAA;EAAY;EAE3B,IAAA;EAEA;EAAA,MAAA;EAIA;EAFA,OAAA;EAEU;EAAV,UAAA;AAAA;;;;;;;;;;;;UAce,SAAA;EAWE;EATjB,QAAA,EAAU,SAAA,EAAW,SAAA;EAWrB;;;;;AAIF;;;EANE,YAAA,KAAiB,uBAAA,cAAqC,uBAAA;EAMR;EAJ9C,MAAA,IAAU,YAAA,GAAe,YAAA;AAAA;;KAIf,cAAA,aAA2B,SAAA"}
|