@forinda/kickjs 2.0.1 → 2.2.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 +63 -20
- package/dist/adapter-wuoBNkNs.d.mts +122 -0
- package/dist/adapter-wuoBNkNs.d.mts.map +1 -0
- package/dist/app-module-DOBmxARW.d.mts +40 -0
- package/dist/app-module-DOBmxARW.d.mts.map +1 -0
- package/dist/application-C5Q720a2.mjs +449 -0
- package/dist/application-C5Q720a2.mjs.map +1 -0
- package/dist/bootstrap-dEN6SjBl.mjs +205 -0
- package/dist/bootstrap-dEN6SjBl.mjs.map +1 -0
- package/dist/{core/cache.d.ts → cache-PufEhr0n.d.mts} +33 -31
- package/dist/cache-PufEhr0n.d.mts.map +1 -0
- package/dist/chunk-C9tIbwLT.mjs +15 -0
- package/dist/container-B7jFEbPE.mjs +496 -0
- package/dist/container-B7jFEbPE.mjs.map +1 -0
- package/dist/container-CcgV8eHL.d.mts +253 -0
- package/dist/container-CcgV8eHL.d.mts.map +1 -0
- package/dist/core/adapter.d.mts +3 -0
- package/dist/core/adapter.mjs +11 -0
- package/dist/core/app-module.d.mts +3 -0
- package/dist/core/app-module.mjs +11 -0
- package/dist/core/cache.d.mts +3 -0
- package/dist/core/cache.mjs +113 -0
- package/dist/core/cache.mjs.map +1 -0
- package/dist/core/container.d.mts +3 -0
- package/dist/core/container.mjs +12 -0
- package/dist/core/cron.d.mts +3 -0
- package/dist/core/cron.mjs +42 -0
- package/dist/core/cron.mjs.map +1 -0
- package/dist/core/decorators.d.mts +3 -0
- package/dist/core/decorators.mjs +219 -0
- package/dist/core/decorators.mjs.map +1 -0
- package/dist/core/errors.d.mts +3 -0
- package/dist/core/errors.mjs +97 -0
- package/dist/core/errors.mjs.map +1 -0
- package/dist/core/interfaces.d.mts +3 -0
- package/dist/core/interfaces.mjs +44 -0
- package/dist/core/interfaces.mjs.map +1 -0
- package/dist/core/logger.d.mts +3 -0
- package/dist/core/logger.mjs +217 -0
- package/dist/core/logger.mjs.map +1 -0
- package/dist/core/path.d.mts +3 -0
- package/dist/core/path.mjs +45 -0
- package/dist/core/path.mjs.map +1 -0
- package/dist/core/plugin.d.mts +3 -0
- package/dist/core/plugin.mjs +11 -0
- package/dist/core/reactivity.d.mts +3 -0
- package/dist/core/reactivity.mjs +189 -0
- package/dist/core/reactivity.mjs.map +1 -0
- package/dist/core-CMgIoRvg.mjs +121 -0
- package/dist/core-CMgIoRvg.mjs.map +1 -0
- package/dist/{core/cron.d.ts → cron-C29iHvHT.d.mts} +16 -14
- package/dist/cron-C29iHvHT.d.mts.map +1 -0
- package/dist/decorators-D3lBlmud.d.mts +204 -0
- package/dist/decorators-D3lBlmud.d.mts.map +1 -0
- package/dist/errors-BZUdxtjC.d.mts +68 -0
- package/dist/errors-BZUdxtjC.d.mts.map +1 -0
- package/dist/http/application.d.mts +220 -0
- package/dist/http/application.d.mts.map +1 -0
- package/dist/http/application.mjs +12 -0
- package/dist/http/bootstrap.d.mts +43 -0
- package/dist/http/bootstrap.d.mts.map +1 -0
- package/dist/http/bootstrap.mjs +12 -0
- package/dist/http/context.d.mts +190 -0
- package/dist/http/context.d.mts.map +1 -0
- package/dist/http/context.mjs +225 -0
- package/dist/http/context.mjs.map +1 -0
- package/dist/http/middleware/cors.d.mts +48 -0
- package/dist/http/middleware/cors.d.mts.map +1 -0
- package/dist/http/middleware/cors.mjs +83 -0
- package/dist/http/middleware/cors.mjs.map +1 -0
- package/dist/http/middleware/csrf.d.mts +52 -0
- package/dist/http/middleware/csrf.d.mts.map +1 -0
- package/dist/http/middleware/csrf.mjs +72 -0
- package/dist/http/middleware/csrf.mjs.map +1 -0
- package/dist/http/middleware/error-handler.d.mts +11 -0
- package/dist/http/middleware/error-handler.d.mts.map +1 -0
- package/dist/http/middleware/error-handler.mjs +52 -0
- package/dist/http/middleware/error-handler.mjs.map +1 -0
- package/dist/http/middleware/helmet.d.mts +41 -0
- package/dist/http/middleware/helmet.d.mts.map +1 -0
- package/dist/http/middleware/helmet.mjs +51 -0
- package/dist/http/middleware/helmet.mjs.map +1 -0
- package/dist/http/middleware/rate-limit.d.mts +56 -0
- package/dist/http/middleware/rate-limit.d.mts.map +1 -0
- package/dist/http/middleware/rate-limit.mjs +101 -0
- package/dist/http/middleware/rate-limit.mjs.map +1 -0
- package/dist/http/middleware/request-id.d.mts +10 -0
- package/dist/http/middleware/request-id.d.mts.map +1 -0
- package/dist/http/middleware/request-id.mjs +26 -0
- package/dist/http/middleware/request-id.mjs.map +1 -0
- package/dist/http/middleware/request-logger.d.mts +32 -0
- package/dist/http/middleware/request-logger.d.mts.map +1 -0
- package/dist/http/middleware/request-logger.mjs +49 -0
- package/dist/http/middleware/request-logger.mjs.map +1 -0
- package/dist/http/middleware/session.d.mts +67 -0
- package/dist/http/middleware/session.d.mts.map +1 -0
- package/dist/http/middleware/session.mjs +152 -0
- package/dist/http/middleware/session.mjs.map +1 -0
- package/dist/http/middleware/spa.d.mts +101 -0
- package/dist/http/middleware/spa.d.mts.map +1 -0
- package/dist/http/middleware/spa.mjs +108 -0
- package/dist/http/middleware/spa.mjs.map +1 -0
- package/dist/http/middleware/{upload.d.ts → upload.d.mts} +21 -17
- package/dist/http/middleware/upload.d.mts.map +1 -0
- package/dist/http/middleware/upload.mjs +191 -0
- package/dist/http/middleware/upload.mjs.map +1 -0
- package/dist/http/middleware/validate.d.mts +18 -0
- package/dist/http/middleware/validate.d.mts.map +1 -0
- package/dist/http/middleware/validate.mjs +62 -0
- package/dist/http/middleware/validate.mjs.map +1 -0
- package/dist/http/middleware/views.d.mts +62 -0
- package/dist/http/middleware/views.d.mts.map +1 -0
- package/dist/http/middleware/views.mjs +65 -0
- package/dist/http/middleware/views.mjs.map +1 -0
- package/dist/http/query/index.d.mts +3 -0
- package/dist/http/query/index.mjs +12 -0
- package/dist/http/{router-builder.d.ts → router-builder.d.mts} +9 -5
- package/dist/http/router-builder.d.mts.map +1 -0
- package/dist/http/router-builder.mjs +67 -0
- package/dist/http/router-builder.mjs.map +1 -0
- package/dist/index-4VM4dUJf.d.mts +107 -0
- package/dist/index-4VM4dUJf.d.mts.map +1 -0
- package/dist/index-rnK23QBD.d.mts +184 -0
- package/dist/index-rnK23QBD.d.mts.map +1 -0
- package/dist/index.d.mts +133 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +126 -0
- package/dist/index.mjs.map +1 -0
- package/dist/interfaces-D5ohYl6D.d.mts +52 -0
- package/dist/interfaces-D5ohYl6D.d.mts.map +1 -0
- package/dist/logger-BLdfUF5b.d.mts +119 -0
- package/dist/logger-BLdfUF5b.d.mts.map +1 -0
- package/dist/metadata-BqXgNTOf.mjs +76 -0
- package/dist/metadata-BqXgNTOf.mjs.map +1 -0
- package/dist/{core/path.d.ts → path-Dq5V-i-x.d.mts} +7 -3
- package/dist/path-Dq5V-i-x.d.mts.map +1 -0
- package/dist/plugin-D20muJwC.d.mts +95 -0
- package/dist/plugin-D20muJwC.d.mts.map +1 -0
- package/dist/query-vljPDFaZ.mjs +164 -0
- package/dist/query-vljPDFaZ.mjs.map +1 -0
- package/dist/{core/reactivity.d.ts → reactivity-CMAQh0gi.d.mts} +21 -20
- package/dist/reactivity-CMAQh0gi.d.mts.map +1 -0
- package/package.json +73 -43
- package/dist/chunk-DVVP7zzD.js +0 -7
- package/dist/core/adapter.d.ts +0 -109
- package/dist/core/adapter.d.ts.map +0 -1
- package/dist/core/adapter.js +0 -0
- package/dist/core/app-module.d.ts +0 -28
- package/dist/core/app-module.d.ts.map +0 -1
- package/dist/core/app-module.js +0 -0
- package/dist/core/cache.d.ts.map +0 -1
- package/dist/core/cache.js +0 -57
- package/dist/core/container.d.ts +0 -63
- package/dist/core/container.d.ts.map +0 -1
- package/dist/core/container.js +0 -117
- package/dist/core/cron.d.ts.map +0 -1
- package/dist/core/cron.js +0 -22
- package/dist/core/decorators.d.ts +0 -153
- package/dist/core/decorators.d.ts.map +0 -1
- package/dist/core/decorators.js +0 -141
- package/dist/core/errors.d.ts +0 -64
- package/dist/core/errors.d.ts.map +0 -1
- package/dist/core/errors.js +0 -67
- package/dist/core/index.d.ts +0 -14
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/interfaces.d.ts +0 -44
- package/dist/core/interfaces.d.ts.map +0 -1
- package/dist/core/interfaces.js +0 -25
- package/dist/core/logger.d.ts +0 -43
- package/dist/core/logger.d.ts.map +0 -1
- package/dist/core/logger.js +0 -54
- package/dist/core/path.d.ts.map +0 -1
- package/dist/core/path.js +0 -12
- package/dist/core/plugin.d.ts +0 -90
- package/dist/core/plugin.d.ts.map +0 -1
- package/dist/core/plugin.js +0 -0
- package/dist/core/reactivity.d.ts.map +0 -1
- package/dist/core/reactivity.js +0 -101
- package/dist/core-B6Okew3W.js +0 -7
- package/dist/http/application.d.ts +0 -103
- package/dist/http/application.d.ts.map +0 -1
- package/dist/http/application.js +0 -167
- package/dist/http/bootstrap.d.ts +0 -22
- package/dist/http/bootstrap.d.ts.map +0 -1
- package/dist/http/bootstrap.js +0 -40
- package/dist/http/context.d.ts +0 -129
- package/dist/http/context.d.ts.map +0 -1
- package/dist/http/context.js +0 -115
- package/dist/http/index.d.ts +0 -16
- package/dist/http/index.d.ts.map +0 -1
- package/dist/http/middleware/cors.d.ts +0 -43
- package/dist/http/middleware/cors.d.ts.map +0 -1
- package/dist/http/middleware/cors.js +0 -31
- package/dist/http/middleware/csrf.d.ts +0 -47
- package/dist/http/middleware/csrf.d.ts.map +0 -1
- package/dist/http/middleware/csrf.js +0 -25
- package/dist/http/middleware/error-handler.d.ts +0 -6
- package/dist/http/middleware/error-handler.d.ts.map +0 -1
- package/dist/http/middleware/error-handler.js +0 -37
- package/dist/http/middleware/helmet.d.ts +0 -36
- package/dist/http/middleware/helmet.d.ts.map +0 -1
- package/dist/http/middleware/helmet.js +0 -20
- package/dist/http/middleware/rate-limit.d.ts +0 -51
- package/dist/http/middleware/rate-limit.d.ts.map +0 -1
- package/dist/http/middleware/rate-limit.js +0 -46
- package/dist/http/middleware/request-id.d.ts +0 -5
- package/dist/http/middleware/request-id.d.ts.map +0 -1
- package/dist/http/middleware/request-id.js +0 -12
- package/dist/http/middleware/request-logger.d.ts +0 -27
- package/dist/http/middleware/request-logger.d.ts.map +0 -1
- package/dist/http/middleware/request-logger.js +0 -16
- package/dist/http/middleware/session.d.ts +0 -62
- package/dist/http/middleware/session.d.ts.map +0 -1
- package/dist/http/middleware/session.js +0 -76
- package/dist/http/middleware/spa.d.ts +0 -93
- package/dist/http/middleware/spa.d.ts.map +0 -1
- package/dist/http/middleware/spa.js +0 -52
- package/dist/http/middleware/upload.d.ts.map +0 -1
- package/dist/http/middleware/upload.js +0 -119
- package/dist/http/middleware/validate.d.ts +0 -13
- package/dist/http/middleware/validate.d.ts.map +0 -1
- package/dist/http/middleware/validate.js +0 -45
- package/dist/http/middleware/views.d.ts +0 -56
- package/dist/http/middleware/views.d.ts.map +0 -1
- package/dist/http/middleware/views.js +0 -18
- package/dist/http/query/index.d.ts +0 -4
- package/dist/http/query/index.d.ts.map +0 -1
- package/dist/http/query/index.js +0 -10
- package/dist/http/query/parse-query.d.ts +0 -44
- package/dist/http/query/parse-query.d.ts.map +0 -1
- package/dist/http/query/types.d.ts +0 -100
- package/dist/http/query/types.d.ts.map +0 -1
- package/dist/http/router-builder.d.ts.map +0 -1
- package/dist/http/router-builder.js +0 -37
- package/dist/index.d.ts +0 -25
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -103
- package/dist/query-Bym31XRp.js +0 -88
package/dist/core/plugin.d.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import type { Container } from './container';
|
|
2
|
-
import type { AppAdapter } from './adapter';
|
|
3
|
-
import type { AppModuleClass } from './app-module';
|
|
4
|
-
/**
|
|
5
|
-
* Plugin interface for extending KickJS applications.
|
|
6
|
-
*
|
|
7
|
-
* Plugins bundle modules, adapters, middleware, and DI bindings into a single
|
|
8
|
-
* reusable unit. They run before the application bootstraps, so they can
|
|
9
|
-
* register services and configure the app before any module loads.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```ts
|
|
13
|
-
* import type { KickPlugin } from '@forinda/kickjs-core'
|
|
14
|
-
*
|
|
15
|
-
* export class CorsPlugin implements KickPlugin {
|
|
16
|
-
* name = 'CorsPlugin'
|
|
17
|
-
*
|
|
18
|
-
* middleware() {
|
|
19
|
-
* return [cors({ origin: '*' })]
|
|
20
|
-
* }
|
|
21
|
-
* }
|
|
22
|
-
*
|
|
23
|
-
* // Usage:
|
|
24
|
-
* bootstrap({
|
|
25
|
-
* modules,
|
|
26
|
-
* plugins: [new CorsPlugin()],
|
|
27
|
-
* })
|
|
28
|
-
* ```
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```ts
|
|
32
|
-
* // A more complex plugin that bundles modules and adapters
|
|
33
|
-
* export class AuthPlugin implements KickPlugin {
|
|
34
|
-
* name = 'AuthPlugin'
|
|
35
|
-
*
|
|
36
|
-
* constructor(private config: AuthConfig) {}
|
|
37
|
-
*
|
|
38
|
-
* register(container: Container) {
|
|
39
|
-
* container.registerFactory(AUTH_SERVICE, () => new JwtAuthService(this.config))
|
|
40
|
-
* }
|
|
41
|
-
*
|
|
42
|
-
* modules() {
|
|
43
|
-
* return [AuthModule]
|
|
44
|
-
* }
|
|
45
|
-
*
|
|
46
|
-
* adapters() {
|
|
47
|
-
* return [new AuthGuardAdapter(this.config)]
|
|
48
|
-
* }
|
|
49
|
-
*
|
|
50
|
-
* middleware() {
|
|
51
|
-
* return [passport.initialize()]
|
|
52
|
-
* }
|
|
53
|
-
* }
|
|
54
|
-
* ```
|
|
55
|
-
*/
|
|
56
|
-
export interface KickPlugin {
|
|
57
|
-
/** Human-readable name for logging and debugging */
|
|
58
|
-
name: string;
|
|
59
|
-
/**
|
|
60
|
-
* Register DI bindings before modules load.
|
|
61
|
-
* Use this to provide services that modules depend on.
|
|
62
|
-
*/
|
|
63
|
-
register?(container: Container): void;
|
|
64
|
-
/**
|
|
65
|
-
* Return module classes to be loaded alongside user modules.
|
|
66
|
-
* Plugin modules are loaded before user modules.
|
|
67
|
-
*/
|
|
68
|
-
modules?(): AppModuleClass[];
|
|
69
|
-
/**
|
|
70
|
-
* Return adapter instances to be added to the application.
|
|
71
|
-
* Plugin adapters are added before user adapters.
|
|
72
|
-
*/
|
|
73
|
-
adapters?(): AppAdapter[];
|
|
74
|
-
/**
|
|
75
|
-
* Return Express middleware to be added to the global pipeline.
|
|
76
|
-
* Plugin middleware runs before user-defined middleware.
|
|
77
|
-
*/
|
|
78
|
-
middleware?(): any[];
|
|
79
|
-
/**
|
|
80
|
-
* Called after the application has fully bootstrapped.
|
|
81
|
-
* Use for post-startup logic like logging, health registration, etc.
|
|
82
|
-
*/
|
|
83
|
-
onReady?(container: Container): void | Promise<void>;
|
|
84
|
-
/**
|
|
85
|
-
* Called during application shutdown.
|
|
86
|
-
* Clean up plugin resources (connections, intervals, etc.).
|
|
87
|
-
*/
|
|
88
|
-
shutdown?(): void | Promise<void>;
|
|
89
|
-
}
|
|
90
|
-
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/core/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,MAAM,WAAW,UAAU;IACzB,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAA;IAEZ;;;OAGG;IACH,QAAQ,CAAC,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAAA;IAErC;;;OAGG;IACH,OAAO,CAAC,IAAI,cAAc,EAAE,CAAA;IAE5B;;;OAGG;IACH,QAAQ,CAAC,IAAI,UAAU,EAAE,CAAA;IAEzB;;;OAGG;IACH,UAAU,CAAC,IAAI,GAAG,EAAE,CAAA;IAEpB;;;OAGG;IACH,OAAO,CAAC,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEpD;;;OAGG;IACH,QAAQ,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAClC"}
|
package/dist/core/plugin.js
DELETED
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reactivity.d.ts","sourceRoot":"","sources":["../../src/core/reactivity.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAmCH,MAAM,WAAW,GAAG,CAAC,CAAC,GAAG,GAAG;IAC1B,KAAK,EAAE,CAAC,CAAA;IACR,0DAA0D;IAC1D,SAAS,CAAC,EAAE,EAAE,CAAC,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAAA;CAC9D;AAED;;;;;;;;;GASG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAuB9C;AAID,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,GAAG;IAClC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;CAClB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CA2B3D;AAID,MAAM,WAAW,YAAY;IAC3B,2EAA2E;IAC3E,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED,KAAK,WAAW,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;AAEzD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,KAAK,CAAC,CAAC,EACrB,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,EACtB,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,IAAI,EAC5C,OAAO,CAAC,EAAE,YAAY,GACrB,MAAM,IAAI,CA+BZ;AAID;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAqBpE;AAID,gCAAgC;AAChC,wBAAgB,KAAK,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,GAAG,CAE9C;AAED,6CAA6C;AAC7C,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAE7C;AAED,kDAAkD;AAClD,wBAAgB,MAAM,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAM3F"}
|
package/dist/core/reactivity.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
var o = null, i = /* @__PURE__ */ new WeakMap();
|
|
2
|
-
function l(n, r) {
|
|
3
|
-
if (!o) return;
|
|
4
|
-
let e = i.get(n);
|
|
5
|
-
e || (e = /* @__PURE__ */ new Map(), i.set(n, e));
|
|
6
|
-
let t = e.get(r);
|
|
7
|
-
t || (t = /* @__PURE__ */ new Set(), e.set(r, t)), t.add(o);
|
|
8
|
-
}
|
|
9
|
-
function a(n, r) {
|
|
10
|
-
const e = i.get(n);
|
|
11
|
-
if (!e) return;
|
|
12
|
-
const t = e.get(r);
|
|
13
|
-
if (t)
|
|
14
|
-
for (const u of t) u();
|
|
15
|
-
}
|
|
16
|
-
function d(n) {
|
|
17
|
-
const r = /* @__PURE__ */ new Set(), e = { _value: n };
|
|
18
|
-
return {
|
|
19
|
-
get value() {
|
|
20
|
-
return l(e, "_value"), e._value;
|
|
21
|
-
},
|
|
22
|
-
set value(t) {
|
|
23
|
-
const u = e._value;
|
|
24
|
-
if (!Object.is(u, t)) {
|
|
25
|
-
e._value = t, a(e, "_value");
|
|
26
|
-
for (const f of r) f(t, u);
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
subscribe(t) {
|
|
30
|
-
return r.add(t), () => r.delete(t);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
function y(n) {
|
|
35
|
-
let r, e = !0;
|
|
36
|
-
const t = { _value: void 0 }, u = () => {
|
|
37
|
-
e = !0, a(t, "_value");
|
|
38
|
-
};
|
|
39
|
-
return { get value() {
|
|
40
|
-
if (l(t, "_value"), e) {
|
|
41
|
-
const f = o;
|
|
42
|
-
o = u;
|
|
43
|
-
try {
|
|
44
|
-
r = n();
|
|
45
|
-
} finally {
|
|
46
|
-
o = f;
|
|
47
|
-
}
|
|
48
|
-
t._value = r, e = !1;
|
|
49
|
-
}
|
|
50
|
-
return r;
|
|
51
|
-
} };
|
|
52
|
-
}
|
|
53
|
-
function _(n, r, e) {
|
|
54
|
-
let t, u = !1;
|
|
55
|
-
const f = typeof n == "function" ? n : () => n.value, s = () => {
|
|
56
|
-
if (u) return;
|
|
57
|
-
const c = f();
|
|
58
|
-
Object.is(c, t) || (r(c, t), t = c);
|
|
59
|
-
}, p = o;
|
|
60
|
-
o = s;
|
|
61
|
-
try {
|
|
62
|
-
t = f();
|
|
63
|
-
} finally {
|
|
64
|
-
o = p;
|
|
65
|
-
}
|
|
66
|
-
return e?.immediate && r(t, void 0), () => {
|
|
67
|
-
u = !0;
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
function v(n) {
|
|
71
|
-
return new Proxy(n, {
|
|
72
|
-
get(r, e, t) {
|
|
73
|
-
const u = Reflect.get(r, e, t);
|
|
74
|
-
return typeof e == "symbol" ? u : (l(r, e), u !== null && typeof u == "object" && !Array.isArray(u) ? v(u) : u);
|
|
75
|
-
},
|
|
76
|
-
set(r, e, t, u) {
|
|
77
|
-
const f = Reflect.get(r, e, u), s = Reflect.set(r, e, t, u);
|
|
78
|
-
return !Object.is(f, t) && typeof e != "symbol" && a(r, e), s;
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
function g(n) {
|
|
83
|
-
return n !== null && typeof n == "object" && "subscribe" in n && "value" in n;
|
|
84
|
-
}
|
|
85
|
-
function b(n) {
|
|
86
|
-
return g(n) ? n.value : n;
|
|
87
|
-
}
|
|
88
|
-
function w(n) {
|
|
89
|
-
const r = {};
|
|
90
|
-
for (const e in n) r[e] = d(n[e]);
|
|
91
|
-
return r;
|
|
92
|
-
}
|
|
93
|
-
export {
|
|
94
|
-
y as computed,
|
|
95
|
-
g as isRef,
|
|
96
|
-
v as reactive,
|
|
97
|
-
d as ref,
|
|
98
|
-
w as toRefs,
|
|
99
|
-
b as unref,
|
|
100
|
-
_ as watch
|
|
101
|
-
};
|
package/dist/core-B6Okew3W.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import http from 'node:http';
|
|
2
|
-
import { type Express, type RequestHandler } from 'express';
|
|
3
|
-
import { type AppModuleClass, type AppAdapter, type KickPlugin } from '../core';
|
|
4
|
-
/**
|
|
5
|
-
* A middleware entry in the declarative pipeline.
|
|
6
|
-
* Can be a bare handler or an object with path scoping.
|
|
7
|
-
*/
|
|
8
|
-
export type MiddlewareEntry = RequestHandler | {
|
|
9
|
-
path: string;
|
|
10
|
-
handler: RequestHandler;
|
|
11
|
-
};
|
|
12
|
-
export interface ApplicationOptions {
|
|
13
|
-
/** Feature modules to load */
|
|
14
|
-
modules: AppModuleClass[];
|
|
15
|
-
/** Adapters that hook into the lifecycle (DB, Redis, Swagger, etc.) */
|
|
16
|
-
adapters?: AppAdapter[];
|
|
17
|
-
/** Server port (falls back to PORT env var, then 3000) */
|
|
18
|
-
port?: number;
|
|
19
|
-
/** Global API prefix (default: '/api') */
|
|
20
|
-
apiPrefix?: string;
|
|
21
|
-
/** Default API version (default: 1) — routes become /{prefix}/v{version}/{path} */
|
|
22
|
-
defaultVersion?: number;
|
|
23
|
-
/**
|
|
24
|
-
* Global middleware pipeline. Declared in order.
|
|
25
|
-
* Replaces the hardcoded middleware stack — you control exactly what runs.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```ts
|
|
29
|
-
* bootstrap({
|
|
30
|
-
* modules,
|
|
31
|
-
* middleware: [
|
|
32
|
-
* helmet(),
|
|
33
|
-
* cors(),
|
|
34
|
-
* compression(),
|
|
35
|
-
* morgan('dev'),
|
|
36
|
-
* express.json({ limit: '1mb' }),
|
|
37
|
-
* ],
|
|
38
|
-
* })
|
|
39
|
-
* ```
|
|
40
|
-
*
|
|
41
|
-
* If omitted, a sensible default is applied:
|
|
42
|
-
* requestId(), express.json({ limit: '100kb' })
|
|
43
|
-
*/
|
|
44
|
-
middleware?: MiddlewareEntry[];
|
|
45
|
-
/** Plugins that bundle modules, adapters, middleware, and DI bindings */
|
|
46
|
-
plugins?: KickPlugin[];
|
|
47
|
-
/** Express `trust proxy` setting */
|
|
48
|
-
trustProxy?: boolean | number | string | ((ip: string, hopIndex: number) => boolean);
|
|
49
|
-
/** Maximum JSON body size (only used when middleware is not provided) */
|
|
50
|
-
jsonLimit?: string | number;
|
|
51
|
-
/**
|
|
52
|
-
* Log route summary on startup. Default: true in dev, false in production.
|
|
53
|
-
* Set to `true` to always log, `false` to always suppress.
|
|
54
|
-
*/
|
|
55
|
-
logRoutesTable?: boolean;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* The main application class. Wires together Express, the DI container,
|
|
59
|
-
* feature modules, adapters, and the middleware pipeline.
|
|
60
|
-
*/
|
|
61
|
-
export declare class Application {
|
|
62
|
-
private readonly options;
|
|
63
|
-
private app;
|
|
64
|
-
private container;
|
|
65
|
-
private httpServer;
|
|
66
|
-
private adapters;
|
|
67
|
-
private plugins;
|
|
68
|
-
constructor(options: ApplicationOptions);
|
|
69
|
-
/**
|
|
70
|
-
* Full setup pipeline:
|
|
71
|
-
* 1. Adapter beforeMount hooks (early routes — docs, health)
|
|
72
|
-
* 2. Adapter middleware (phase: beforeGlobal)
|
|
73
|
-
* 3. Global middleware (user-declared or defaults)
|
|
74
|
-
* 4. Adapter middleware (phase: afterGlobal)
|
|
75
|
-
* 5. Module registration + DI bootstrap
|
|
76
|
-
* 6. Adapter middleware (phase: beforeRoutes)
|
|
77
|
-
* 7. Module route mounting
|
|
78
|
-
* 8. Adapter middleware (phase: afterRoutes)
|
|
79
|
-
* 9. Error handlers (notFound + global)
|
|
80
|
-
* 10. Adapter beforeStart hooks
|
|
81
|
-
*/
|
|
82
|
-
/** Build the adapter context object (shared across all hooks) */
|
|
83
|
-
private adapterCtx;
|
|
84
|
-
/** Call an adapter hook, catching sync errors and async rejections */
|
|
85
|
-
private callHook;
|
|
86
|
-
setup(): void;
|
|
87
|
-
/** Register modules and DI without starting the HTTP server (used by kick tinker) */
|
|
88
|
-
registerOnly(): void;
|
|
89
|
-
/** Start the HTTP server — fails fast if port is in use */
|
|
90
|
-
start(): void;
|
|
91
|
-
/** HMR rebuild: swap Express handler without restarting the server */
|
|
92
|
-
rebuild(): void;
|
|
93
|
-
/** Graceful shutdown — runs all adapter shutdowns in parallel, resilient to failures */
|
|
94
|
-
shutdown(): Promise<void>;
|
|
95
|
-
getExpressApp(): Express;
|
|
96
|
-
/** Get registered adapters — used by DevToolsAdapter for peer discovery */
|
|
97
|
-
getAdapters(): AppAdapter[];
|
|
98
|
-
getHttpServer(): http.Server | null;
|
|
99
|
-
private collectAdapterMiddleware;
|
|
100
|
-
private mountMiddlewareList;
|
|
101
|
-
private mountMiddlewareEntry;
|
|
102
|
-
}
|
|
103
|
-
//# sourceMappingURL=application.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../../src/http/application.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAgB,EAAE,KAAK,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAA;AACpE,OAAO,EAKL,KAAK,cAAc,EACnB,KAAK,UAAU,EAGf,KAAK,UAAU,EAEhB,MAAM,SAAS,CAAA;AAMhB;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,cAAc,CAAA;CAAE,CAAA;AAExF,MAAM,WAAW,kBAAkB;IACjC,8BAA8B;IAC9B,OAAO,EAAE,cAAc,EAAE,CAAA;IACzB,uEAAuE;IACvE,QAAQ,CAAC,EAAE,UAAU,EAAE,CAAA;IACvB,0DAA0D;IAC1D,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,mFAAmF;IACnF,cAAc,CAAC,EAAE,MAAM,CAAA;IAEvB;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,UAAU,CAAC,EAAE,eAAe,EAAE,CAAA;IAE9B,yEAAyE;IACzE,OAAO,CAAC,EAAE,UAAU,EAAE,CAAA;IAEtB,oCAAoC;IACpC,UAAU,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,CAAA;IACpF,yEAAyE;IACzE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC3B;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB;AAED;;;GAGG;AACH,qBAAa,WAAW;IAQV,OAAO,CAAC,QAAQ,CAAC,OAAO;IAPpC,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,SAAS,CAAW;IAC5B,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,QAAQ,CAAc;IAE9B,OAAO,CAAC,OAAO,CAAc;gBAEA,OAAO,EAAE,kBAAkB;IAWxD;;;;;;;;;;;;OAYG;IACH,iEAAiE;IACjE,OAAO,CAAC,UAAU;IAWlB,sEAAsE;IACtE,OAAO,CAAC,QAAQ;IAgBhB,KAAK,IAAI,IAAI;IAgJb,qFAAqF;IACrF,YAAY,IAAI,IAAI;IAIpB,2DAA2D;IAC3D,KAAK,IAAI,IAAI;IAkCb,sEAAsE;IACtE,OAAO,IAAI,IAAI;IAef,wFAAwF;IAClF,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAmB/B,aAAa,IAAI,OAAO;IAIxB,2EAA2E;IAC3E,WAAW,IAAI,UAAU,EAAE;IAI3B,aAAa,IAAI,IAAI,CAAC,MAAM,GAAG,IAAI;IAMnC,OAAO,CAAC,wBAAwB;IAmBhC,OAAO,CAAC,mBAAmB;IAU3B,OAAO,CAAC,oBAAoB;CAO7B"}
|
package/dist/http/application.js
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import { METADATA as A } from "../core/interfaces.js";
|
|
2
|
-
import { Container as m } from "../core/container.js";
|
|
3
|
-
import { createLogger as E } from "../core/logger.js";
|
|
4
|
-
import { normalizePath as P } from "../core/path.js";
|
|
5
|
-
import "../core-B6Okew3W.js";
|
|
6
|
-
import { requestId as R } from "./middleware/request-id.js";
|
|
7
|
-
import { errorHandler as x, notFoundHandler as M } from "./middleware/error-handler.js";
|
|
8
|
-
import y from "node:http";
|
|
9
|
-
import g from "express";
|
|
10
|
-
var n = E("Application"), G = class {
|
|
11
|
-
app;
|
|
12
|
-
container;
|
|
13
|
-
httpServer = null;
|
|
14
|
-
adapters;
|
|
15
|
-
plugins;
|
|
16
|
-
constructor(e) {
|
|
17
|
-
this.options = e, this.app = g(), this.container = m.getInstance(), this.plugins = e.plugins ?? [], this.adapters = [...this.plugins.flatMap((t) => t.adapters?.() ?? []), ...e.adapters ?? []];
|
|
18
|
-
}
|
|
19
|
-
adapterCtx(e) {
|
|
20
|
-
const t = process.env.NODE_ENV ?? "development";
|
|
21
|
-
return {
|
|
22
|
-
app: this.app,
|
|
23
|
-
container: this.container,
|
|
24
|
-
server: e,
|
|
25
|
-
env: t,
|
|
26
|
-
isProduction: t === "production"
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
callHook(e, t) {
|
|
30
|
-
if (e)
|
|
31
|
-
try {
|
|
32
|
-
const r = e(t);
|
|
33
|
-
r && typeof r.catch == "function" && r.catch((p) => n.error(p, "Adapter async hook failed"));
|
|
34
|
-
} catch (r) {
|
|
35
|
-
n.error(r, "Adapter hook failed");
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
setup() {
|
|
39
|
-
n.info("Bootstrapping application...");
|
|
40
|
-
const e = this.collectAdapterMiddleware();
|
|
41
|
-
this.app.__kickApp = this;
|
|
42
|
-
const t = this.adapterCtx();
|
|
43
|
-
for (const o of this.adapters) this.callHook(o.beforeMount?.bind(o), t);
|
|
44
|
-
this.app.disable("x-powered-by"), this.app.set("trust proxy", this.options.trustProxy ?? !1), this.mountMiddlewareList(e.beforeGlobal);
|
|
45
|
-
for (const o of this.plugins) o.register?.(this.container);
|
|
46
|
-
for (const o of this.plugins) {
|
|
47
|
-
const s = o.middleware?.() ?? [];
|
|
48
|
-
for (const l of s) this.app.use(l);
|
|
49
|
-
}
|
|
50
|
-
if (this.options.middleware) for (const o of this.options.middleware) this.mountMiddlewareEntry(o);
|
|
51
|
-
else
|
|
52
|
-
this.app.use(R()), this.app.use(g.json({ limit: this.options.jsonLimit ?? "100kb" }));
|
|
53
|
-
this.mountMiddlewareList(e.afterGlobal);
|
|
54
|
-
const r = [...this.plugins.flatMap((o) => o.modules?.() ?? []), ...this.options.modules].map((o) => {
|
|
55
|
-
const s = new o();
|
|
56
|
-
return s.register(this.container), s;
|
|
57
|
-
});
|
|
58
|
-
this.container.bootstrap(), this.mountMiddlewareList(e.beforeRoutes);
|
|
59
|
-
const p = this.options.apiPrefix ?? "/api", v = this.options.defaultVersion ?? 1, w = this.options.logRoutesTable ?? process.env.NODE_ENV !== "production", u = [];
|
|
60
|
-
for (const o of r) {
|
|
61
|
-
const s = o.routes();
|
|
62
|
-
if (!s) continue;
|
|
63
|
-
const l = Array.isArray(s) ? s : [s];
|
|
64
|
-
for (const i of l) {
|
|
65
|
-
const a = `${p}/v${i.version ?? v}${P(i.path)}`;
|
|
66
|
-
if (this.app.use(a, i.router), i.controller) {
|
|
67
|
-
for (const h of this.adapters) h.onRouteMount?.(i.controller, a);
|
|
68
|
-
w && u.push({
|
|
69
|
-
controller: i.controller,
|
|
70
|
-
mountPath: a
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
if (w && u.length > 0) {
|
|
76
|
-
const o = [
|
|
77
|
-
"GET",
|
|
78
|
-
"POST",
|
|
79
|
-
"PUT",
|
|
80
|
-
"PATCH",
|
|
81
|
-
"DELETE",
|
|
82
|
-
"HEAD",
|
|
83
|
-
"OPTIONS"
|
|
84
|
-
], s = (i) => {
|
|
85
|
-
const a = o.indexOf(i);
|
|
86
|
-
return a === -1 ? 99 : a;
|
|
87
|
-
};
|
|
88
|
-
let l = 0;
|
|
89
|
-
n.info("Routes:");
|
|
90
|
-
for (const { controller: i, mountPath: a } of u) {
|
|
91
|
-
const h = Reflect.getMetadata(A.ROUTES, i) || [];
|
|
92
|
-
if (h.length === 0) continue;
|
|
93
|
-
const f = {};
|
|
94
|
-
for (const c of h) {
|
|
95
|
-
const d = c.method.toUpperCase();
|
|
96
|
-
f[d] = (f[d] || 0) + 1;
|
|
97
|
-
}
|
|
98
|
-
l += h.length;
|
|
99
|
-
const S = Object.entries(f).sort(([c], [d]) => s(c) - s(d)).map(([c, d]) => `${d} ${c}`).join(", "), b = i.name || "Controller";
|
|
100
|
-
n.info(` ${b.padEnd(30)} ${a.padEnd(25)} ${h.length} routes (${S})`);
|
|
101
|
-
}
|
|
102
|
-
n.info(` Total: ${l} routes`);
|
|
103
|
-
}
|
|
104
|
-
this.mountMiddlewareList(e.afterRoutes), this.app.use(M()), this.app.use(x());
|
|
105
|
-
for (const o of this.adapters) this.callHook(o.beforeStart?.bind(o), t);
|
|
106
|
-
}
|
|
107
|
-
registerOnly() {
|
|
108
|
-
this.setup();
|
|
109
|
-
}
|
|
110
|
-
start() {
|
|
111
|
-
this.setup();
|
|
112
|
-
const e = this.options.port ?? parseInt(process.env.PORT || "3000", 10);
|
|
113
|
-
this.httpServer = y.createServer(this.app), this.httpServer.on("error", (t) => {
|
|
114
|
-
throw t.code === "EADDRINUSE" && (n.error(`Port ${e} is already in use. Kill the existing process or use a different port:
|
|
115
|
-
PORT=${e + 1} kick dev
|
|
116
|
-
lsof -i :${e} # find what's using it
|
|
117
|
-
kill <PID> # stop it`), process.exit(1)), t;
|
|
118
|
-
}), this.httpServer.listen(e, async () => {
|
|
119
|
-
n.info(`Server running on http://localhost:${e}`);
|
|
120
|
-
for (const t of this.adapters) {
|
|
121
|
-
const r = this.adapterCtx(this.httpServer);
|
|
122
|
-
this.callHook(t.afterStart?.bind(t), r);
|
|
123
|
-
}
|
|
124
|
-
for (const t of this.plugins) await t.onReady?.(this.container);
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
rebuild() {
|
|
128
|
-
m.reset(), this.container = m.getInstance(), this.app = g(), this.setup(), this.httpServer && (this.httpServer.removeAllListeners("request"), this.httpServer.on("request", this.app), n.info("HMR: Express app rebuilt and swapped"));
|
|
129
|
-
}
|
|
130
|
-
async shutdown() {
|
|
131
|
-
n.info("Shutting down...");
|
|
132
|
-
const e = await Promise.allSettled([...this.plugins.map((t) => Promise.resolve(t.shutdown?.())), ...this.adapters.map((t) => Promise.resolve(t.shutdown?.()))]);
|
|
133
|
-
for (const t of e) t.status === "rejected" && n.error({ err: t.reason }, "Adapter shutdown failed");
|
|
134
|
-
this.httpServer && await new Promise((t) => this.httpServer.close(() => t()));
|
|
135
|
-
}
|
|
136
|
-
getExpressApp() {
|
|
137
|
-
return this.app;
|
|
138
|
-
}
|
|
139
|
-
getAdapters() {
|
|
140
|
-
return this.adapters;
|
|
141
|
-
}
|
|
142
|
-
getHttpServer() {
|
|
143
|
-
return this.httpServer;
|
|
144
|
-
}
|
|
145
|
-
collectAdapterMiddleware() {
|
|
146
|
-
const e = {
|
|
147
|
-
beforeGlobal: [],
|
|
148
|
-
afterGlobal: [],
|
|
149
|
-
beforeRoutes: [],
|
|
150
|
-
afterRoutes: []
|
|
151
|
-
};
|
|
152
|
-
for (const t of this.adapters) {
|
|
153
|
-
const r = t.middleware?.() ?? [];
|
|
154
|
-
for (const p of r) e[p.phase ?? "afterGlobal"].push(p);
|
|
155
|
-
}
|
|
156
|
-
return e;
|
|
157
|
-
}
|
|
158
|
-
mountMiddlewareList(e) {
|
|
159
|
-
for (const t of e) t.path ? this.app.use(t.path, t.handler) : this.app.use(t.handler);
|
|
160
|
-
}
|
|
161
|
-
mountMiddlewareEntry(e) {
|
|
162
|
-
typeof e == "function" ? this.app.use(e) : this.app.use(e.path, e.handler);
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
export {
|
|
166
|
-
G as Application
|
|
167
|
-
};
|
package/dist/http/bootstrap.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { type ApplicationOptions } from './application';
|
|
2
|
-
/**
|
|
3
|
-
* Bootstrap a KickJS application with zero boilerplate.
|
|
4
|
-
*
|
|
5
|
-
* Handles:
|
|
6
|
-
* - Vite HMR (hot-swaps Express handler without restarting the server)
|
|
7
|
-
* - Graceful shutdown on SIGINT / SIGTERM
|
|
8
|
-
* - Global uncaughtException / unhandledRejection handlers
|
|
9
|
-
* - globalThis app storage for HMR rebuild
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```ts
|
|
13
|
-
* // src/index.ts — that's it, the whole file
|
|
14
|
-
* import 'reflect-metadata'
|
|
15
|
-
* import { bootstrap } from '@forinda/kickjs-http'
|
|
16
|
-
* import { modules } from './modules'
|
|
17
|
-
*
|
|
18
|
-
* bootstrap({ modules })
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
export declare function bootstrap(options: ApplicationOptions): void;
|
|
22
|
-
//# sourceMappingURL=bootstrap.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../src/http/bootstrap.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAcpE;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAiD3D"}
|
package/dist/http/bootstrap.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { t as p } from "../chunk-DVVP7zzD.js";
|
|
2
|
-
import { createLogger as a } from "../core/logger.js";
|
|
3
|
-
import "../core-B6Okew3W.js";
|
|
4
|
-
import { Application as c } from "./application.js";
|
|
5
|
-
function s() {
|
|
6
|
-
try {
|
|
7
|
-
p("@forinda/kickjs-config").reloadEnv?.();
|
|
8
|
-
} catch {
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
var r = a("Process");
|
|
12
|
-
function l(i) {
|
|
13
|
-
const o = globalThis;
|
|
14
|
-
if (!o.__kickBootstrapped) {
|
|
15
|
-
process.on("uncaughtException", (t) => {
|
|
16
|
-
r.error(t, "Uncaught exception");
|
|
17
|
-
}), process.on("unhandledRejection", (t) => {
|
|
18
|
-
r.error(t, "Unhandled rejection");
|
|
19
|
-
});
|
|
20
|
-
for (const t of ["SIGINT", "SIGTERM"]) process.on(t, async () => {
|
|
21
|
-
r.info(`Received ${t}, shutting down...`), o.__app && await o.__app.shutdown(), process.exit(0);
|
|
22
|
-
});
|
|
23
|
-
o.__kickBootstrapped = !0;
|
|
24
|
-
}
|
|
25
|
-
if (o.__app) {
|
|
26
|
-
r.info("HMR: Rebuilding application..."), s(), o.__app.rebuild();
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const e = new c(i);
|
|
30
|
-
if (o.__app = e, process.env.KICK_TINKER) {
|
|
31
|
-
e.registerOnly();
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
e.start();
|
|
35
|
-
const n = import.meta;
|
|
36
|
-
n.hot && n.hot.accept();
|
|
37
|
-
}
|
|
38
|
-
export {
|
|
39
|
-
l as bootstrap
|
|
40
|
-
};
|
package/dist/http/context.d.ts
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import type { Request, Response, NextFunction } from 'express';
|
|
2
|
-
import { type ParsedQuery, type QueryFieldConfig } from './query';
|
|
3
|
-
/**
|
|
4
|
-
* Unified request/response abstraction passed to every controller method.
|
|
5
|
-
* Shields handlers from raw Express objects and provides convenience methods.
|
|
6
|
-
*/
|
|
7
|
-
export declare class RequestContext<TBody = any, TParams = any, TQuery = any> {
|
|
8
|
-
readonly req: Request;
|
|
9
|
-
readonly res: Response;
|
|
10
|
-
readonly next: NextFunction;
|
|
11
|
-
constructor(req: Request, res: Response, next: NextFunction);
|
|
12
|
-
/**
|
|
13
|
-
* Per-request metadata map shared across all RequestContext instances
|
|
14
|
-
* for the same request. Stored on `req` so middleware can pass data
|
|
15
|
-
* to handlers via `ctx.set()` / `ctx.get()`.
|
|
16
|
-
*/
|
|
17
|
-
private get metadata();
|
|
18
|
-
get body(): TBody;
|
|
19
|
-
get params(): TParams;
|
|
20
|
-
get query(): TQuery;
|
|
21
|
-
get headers(): import("node:http").IncomingHttpHeaders;
|
|
22
|
-
get requestId(): string | undefined;
|
|
23
|
-
/** Session data (requires session middleware) */
|
|
24
|
-
get session(): any;
|
|
25
|
-
/**
|
|
26
|
-
* Parse the request query string into structured filters, sort, pagination, and search.
|
|
27
|
-
* Pass the result to an ORM query builder adapter (Drizzle, Prisma, Sequelize, etc.).
|
|
28
|
-
*
|
|
29
|
-
* @param fieldConfig - Optional whitelist for filterable, sortable, and searchable fields
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```ts
|
|
33
|
-
* @Get('/')
|
|
34
|
-
* async list(ctx: RequestContext) {
|
|
35
|
-
* const parsed = ctx.qs({
|
|
36
|
-
* filterable: ['status', 'priority'],
|
|
37
|
-
* sortable: ['createdAt', 'title'],
|
|
38
|
-
* })
|
|
39
|
-
* const q = drizzleAdapter.build(parsed, { columns })
|
|
40
|
-
* // ... use q.where, q.orderBy, q.limit, q.offset
|
|
41
|
-
* }
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
qs(fieldConfig?: QueryFieldConfig): ParsedQuery;
|
|
45
|
-
/** Single uploaded file (requires @FileUpload({ mode: 'single' })) */
|
|
46
|
-
get file(): any;
|
|
47
|
-
/** Array of uploaded files (requires @FileUpload({ mode: 'array' })) */
|
|
48
|
-
get files(): any[] | undefined;
|
|
49
|
-
get<T = any>(key: string): T | undefined;
|
|
50
|
-
set(key: string, value: any): void;
|
|
51
|
-
json(data: any, status?: number): Response<any, Record<string, any>>;
|
|
52
|
-
created(data: any): Response<any, Record<string, any>>;
|
|
53
|
-
noContent(): Response<any, Record<string, any>>;
|
|
54
|
-
notFound(message?: string): Response<any, Record<string, any>>;
|
|
55
|
-
badRequest(message: string): Response<any, Record<string, any>>;
|
|
56
|
-
html(content: string, status?: number): Response<any, Record<string, any>>;
|
|
57
|
-
download(buffer: Buffer, filename: string, contentType?: string): Response<any, Record<string, any>>;
|
|
58
|
-
/**
|
|
59
|
-
* Render a template using the registered view engine (EJS, Pug, Handlebars, etc.).
|
|
60
|
-
* Requires a ViewAdapter to be configured in bootstrap().
|
|
61
|
-
*
|
|
62
|
-
* @param template - Template name (without extension, relative to viewsDir)
|
|
63
|
-
* @param data - Data to pass to the template
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* ```ts
|
|
67
|
-
* ctx.render('dashboard', { user, title: 'Dashboard' })
|
|
68
|
-
* ctx.render('emails/welcome', { name: 'Alice' })
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
|
-
render(template: string, data?: Record<string, any>): void;
|
|
72
|
-
/**
|
|
73
|
-
* Parse query params and return a standardized paginated response.
|
|
74
|
-
* Calls `ctx.qs()` internally, then wraps your data with pagination meta.
|
|
75
|
-
*
|
|
76
|
-
* @param fetcher - Async function that receives ParsedQuery and returns `{ data, total }`
|
|
77
|
-
* @param fieldConfig - Optional whitelist for filterable, sortable, searchable fields
|
|
78
|
-
*
|
|
79
|
-
* @example
|
|
80
|
-
* ```ts
|
|
81
|
-
* @Get('/')
|
|
82
|
-
* async list(ctx: RequestContext) {
|
|
83
|
-
* return ctx.paginate(
|
|
84
|
-
* async (parsed) => {
|
|
85
|
-
* const data = await db.select().from(users)
|
|
86
|
-
* .where(query.where).limit(parsed.pagination.limit)
|
|
87
|
-
* .offset(parsed.pagination.offset).all()
|
|
88
|
-
* const total = await db.select({ count: count() }).from(users).get()
|
|
89
|
-
* return { data, total: total?.count ?? 0 }
|
|
90
|
-
* },
|
|
91
|
-
* { filterable: ['name', 'role'], sortable: ['createdAt'] },
|
|
92
|
-
* )
|
|
93
|
-
* }
|
|
94
|
-
* ```
|
|
95
|
-
*/
|
|
96
|
-
paginate<T>(fetcher: (parsed: ParsedQuery) => Promise<{
|
|
97
|
-
data: T[];
|
|
98
|
-
total: number;
|
|
99
|
-
}>, fieldConfig?: QueryFieldConfig): Promise<Response<any, Record<string, any>>>;
|
|
100
|
-
/**
|
|
101
|
-
* Start an SSE (Server-Sent Events) stream.
|
|
102
|
-
* Sets the correct headers and returns helpers to send events.
|
|
103
|
-
*
|
|
104
|
-
* @example
|
|
105
|
-
* ```ts
|
|
106
|
-
* @Get('/events')
|
|
107
|
-
* async stream(ctx: RequestContext) {
|
|
108
|
-
* const sse = ctx.sse()
|
|
109
|
-
*
|
|
110
|
-
* const interval = setInterval(() => {
|
|
111
|
-
* sse.send({ time: new Date().toISOString() }, 'tick')
|
|
112
|
-
* }, 1000)
|
|
113
|
-
*
|
|
114
|
-
* sse.onClose(() => clearInterval(interval))
|
|
115
|
-
* }
|
|
116
|
-
* ```
|
|
117
|
-
*/
|
|
118
|
-
sse(): {
|
|
119
|
-
/** Send an SSE event with optional event name and id */
|
|
120
|
-
send: (data: any, event?: string, id?: string) => void;
|
|
121
|
-
/** Send a comment (keeps connection alive) */
|
|
122
|
-
comment: (text: string) => void;
|
|
123
|
-
/** Register a callback when the client disconnects */
|
|
124
|
-
onClose: (fn: () => void) => void;
|
|
125
|
-
/** End the SSE stream */
|
|
126
|
-
close: () => void;
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
//# sourceMappingURL=context.d.ts.map
|