@forinda/kickjs 3.1.3 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -212
- package/dist/adapter-BNw2pGbg.d.mts +261 -0
- package/dist/adapter-BNw2pGbg.d.mts.map +1 -0
- package/dist/{app-module-Cotu9TIC.d.mts → app-module-CO0ksPCm.d.mts} +12 -2
- package/dist/app-module-CO0ksPCm.d.mts.map +1 -0
- package/dist/{application-BVl6L8xo.mjs → application-Ce4DQN6m.mjs} +114 -25
- package/dist/application-Ce4DQN6m.mjs.map +1 -0
- package/dist/application-Czwm7Gty.d.mts +302 -0
- package/dist/application-Czwm7Gty.d.mts.map +1 -0
- package/dist/{bootstrap-D6leYXz2.mjs → bootstrap-CB7bJeJG.mjs} +6 -6
- package/dist/{bootstrap-D6leYXz2.mjs.map → bootstrap-CB7bJeJG.mjs.map} +1 -1
- package/dist/bootstrap-NxFRaNTh.d.mts +28 -0
- package/dist/bootstrap-NxFRaNTh.d.mts.map +1 -0
- package/dist/{cache-CcTzzNdr.d.mts → cache-BStrqXSZ.d.mts} +2 -2
- package/dist/{cache-CcTzzNdr.d.mts.map → cache-BStrqXSZ.d.mts.map} +1 -1
- package/dist/config/index.d.mts +1 -1
- package/dist/config/index.mjs +3 -3
- package/dist/{config-gkVEnxVm.mjs → config-wZ_TgBfs.mjs} +4 -4
- package/dist/{config-gkVEnxVm.mjs.map → config-wZ_TgBfs.mjs.map} +1 -1
- package/dist/{container-BJb34faa.d.mts → container-CnWDsxi-.d.mts} +9 -7
- package/dist/container-CnWDsxi-.d.mts.map +1 -0
- package/dist/{container-BBZLlK6y.mjs → container-DYYSu58w.mjs} +313 -9
- package/dist/container-DYYSu58w.mjs.map +1 -0
- package/dist/context-BAGzqT7-.mjs +319 -0
- package/dist/context-BAGzqT7-.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-B5v3VQCN.d.mts +111 -0
- package/dist/context-decorator-B5v3VQCN.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 +2 -2
- 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 +2 -2
- 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 -16
- 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-DBcoqPHM.mjs +709 -0
- package/dist/core-DBcoqPHM.mjs.map +1 -0
- package/dist/cors-BfgqfLPd.d.mts +48 -0
- package/dist/cors-BfgqfLPd.d.mts.map +1 -0
- package/dist/{cron-H-IyLcOr.d.mts → cron-7zqvsmMI.d.mts} +1 -1
- package/dist/{cron-H-IyLcOr.d.mts.map → cron-7zqvsmMI.d.mts.map} +1 -1
- package/dist/csrf-DiK9zept.d.mts +52 -0
- package/dist/csrf-DiK9zept.d.mts.map +1 -0
- package/dist/{decorators-C9_SN7ge.d.mts → decorators-BMvaLliz.d.mts} +147 -12
- package/dist/decorators-BMvaLliz.d.mts.map +1 -0
- package/dist/{env-Cu5hWsuE.mjs → env-CdH5-dM_.mjs} +3 -4
- package/dist/{env-Cu5hWsuE.mjs.map → env-CdH5-dM_.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-BOUCRl-p.d.mts → errors-uaHCeXRz.d.mts} +1 -1
- package/dist/{errors-BOUCRl-p.d.mts.map → errors-uaHCeXRz.d.mts.map} +1 -1
- package/dist/execution-context-DKnt61pY.d.mts +57 -0
- package/dist/execution-context-DKnt61pY.d.mts.map +1 -0
- package/dist/helmet-CaMbjzBG.d.mts +41 -0
- package/dist/helmet-CaMbjzBG.d.mts.map +1 -0
- package/dist/http/application.d.mts +2 -239
- 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 -262
- package/dist/http/context.mjs +2 -271
- 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 -20
- package/dist/http/router-builder.mjs +58 -10
- package/dist/http/router-builder.mjs.map +1 -1
- package/dist/{index-Co7a3Zat.d.mts → index-B9cyOQAe.d.mts} +1 -1
- package/dist/{index-Co7a3Zat.d.mts.map → index-B9cyOQAe.d.mts.map} +1 -1
- package/dist/{index-DNVfGjF9.d.mts → index-D-qhXg9M.d.mts} +3 -3
- package/dist/{index-DNVfGjF9.d.mts.map → index-D-qhXg9M.d.mts.map} +1 -1
- package/dist/index-DQyWtyp0.d.mts +511 -0
- package/dist/index-DQyWtyp0.d.mts.map +1 -0
- package/dist/index.d.mts +34 -133
- package/dist/index.mjs +14 -14
- package/dist/interfaces-B50n7dwl.d.mts +71 -0
- package/dist/{interfaces-DXjE8Re1.d.mts.map → interfaces-B50n7dwl.d.mts.map} +1 -1
- package/dist/{logger-CW6FHtvU.d.mts → logger-CLVRZf2N.d.mts} +2 -4
- package/dist/{logger-CW6FHtvU.d.mts.map → logger-CLVRZf2N.d.mts.map} +1 -1
- package/dist/{metadata-BwRJ69bC.mjs → metadata-VQM9wChy.mjs} +2 -2
- package/dist/{metadata-BwRJ69bC.mjs.map → metadata-VQM9wChy.mjs.map} +1 -1
- package/dist/{path-B4JcbwKX.d.mts → path-Diviu6hv.d.mts} +1 -1
- package/dist/path-Diviu6hv.d.mts.map +1 -0
- package/dist/plugin-WdrDgNzk.d.mts +165 -0
- package/dist/plugin-WdrDgNzk.d.mts.map +1 -0
- package/dist/{query-BQ2UT3oi.mjs → query-DJMxdx5r.mjs} +2 -2
- package/dist/{query-BQ2UT3oi.mjs.map → query-DJMxdx5r.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-I8nDlg4c.d.mts → reactivity-CfJceo4H.d.mts} +1 -1
- package/dist/{reactivity-I8nDlg4c.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-C799BAf0.d.mts +31 -0
- package/dist/router-builder-C799BAf0.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-CrFR2_cz.d.mts +101 -0
- package/dist/spa-CrFR2_cz.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-DhQSXV2P.d.mts +176 -0
- package/dist/views-DhQSXV2P.d.mts.map +1 -0
- package/package.json +6 -9
- package/dist/adapter-DjL8ql5d.d.mts +0 -140
- package/dist/adapter-DjL8ql5d.d.mts.map +0 -1
- package/dist/app-module-Cotu9TIC.d.mts.map +0 -1
- package/dist/application-BVl6L8xo.mjs.map +0 -1
- package/dist/chunk-CVPG7JJl.mjs +0 -15
- package/dist/container-BBZLlK6y.mjs.map +0 -1
- package/dist/container-BJb34faa.d.mts.map +0 -1
- package/dist/core-qyPNtpKp.mjs +0 -121
- package/dist/core-qyPNtpKp.mjs.map +0 -1
- package/dist/decorators-C9_SN7ge.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/context.mjs.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-CwqjAF6I.d.mts +0 -112
- package/dist/index-CwqjAF6I.d.mts.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/interfaces-DXjE8Re1.d.mts +0 -52
- package/dist/path-B4JcbwKX.d.mts.map +0 -1
- package/dist/plugin-Cvacmm7N.d.mts +0 -95
- package/dist/plugin-Cvacmm7N.d.mts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-id.mjs","names":[],"sources":["../../../src/http/middleware/request-id.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto'\nimport type { Request, Response, NextFunction } from 'express'\n\nexport const REQUEST_ID_HEADER = 'x-request-id'\n\n
|
|
1
|
+
{"version":3,"file":"request-id.mjs","names":[],"sources":["../../../src/http/middleware/request-id.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto'\nimport type { Request, Response, NextFunction } from 'express'\n\nexport const REQUEST_ID_HEADER = 'x-request-id'\n\n/**\n * Middleware that generates or propagates a unique request ID.\n *\n * Idempotent: if `req.requestId` is already set (e.g. by\n * `requestScopeMiddleware` earlier in the pipeline), this middleware reuses\n * it instead of generating a divergent second value. Keeps the\n * X-Request-Id response header, the ALS store's `requestId`, and\n * `RequestContext.requestId` in agreement for every request, regardless of\n * mounting order.\n */\nexport function requestId() {\n return (req: Request, res: Response, next: NextFunction) => {\n const existing = (req as Request & { requestId?: string }).requestId\n const id = existing || (req.headers[REQUEST_ID_HEADER] as string) || randomUUID()\n ;(req as any).requestId = id\n res.setHeader(REQUEST_ID_HEADER, id)\n next()\n }\n}\n"],"mappings":";;;;;;;;;;;;AAGA,MAAa,oBAAoB;;;;;;;;;;;AAYjC,SAAgB,YAAY;AAC1B,SAAQ,KAAc,KAAe,SAAuB;EAE1D,MAAM,KADY,IAAyC,aACnC,IAAI,QAAA,mBAAyC,YAAY;AAC/E,MAAY,YAAY;AAC1B,MAAI,UAAU,mBAAmB,GAAG;AACpC,QAAM"}
|
|
@@ -1,32 +1,3 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
//#region src/http/middleware/request-logger.d.ts
|
|
5
|
-
interface RequestLoggerOptions {
|
|
6
|
-
/** Logger name (default: 'HTTP') */
|
|
7
|
-
name?: string;
|
|
8
|
-
/** Log level for successful requests (default: 'info') */
|
|
9
|
-
level?: 'info' | 'debug' | 'trace';
|
|
10
|
-
/** Skip logging for paths matching these prefixes (e.g. ['/health', '/_debug']) */
|
|
11
|
-
skip?: string[];
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Middleware that logs every request with method, URL, status, duration, and request ID.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```ts
|
|
18
|
-
* bootstrap({
|
|
19
|
-
* middleware: [requestId(), requestLogger(), express.json()],
|
|
20
|
-
* })
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* Output:
|
|
24
|
-
* ```
|
|
25
|
-
* [HTTP] GET /api/v1/users 200 12ms req-abc123
|
|
26
|
-
* [HTTP] POST /api/v1/users 201 45ms req-def456
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
declare function requestLogger(options?: RequestLoggerOptions): (req: Request, res: Response, next: NextFunction) => void;
|
|
30
|
-
//#endregion
|
|
31
|
-
export { RequestLoggerOptions, requestLogger };
|
|
32
|
-
//# sourceMappingURL=request-logger.d.mts.map
|
|
2
|
+
import { n as requestLogger, t as RequestLoggerOptions } from "../../request-logger-CWHbAzTE.mjs";
|
|
3
|
+
export { RequestLoggerOptions, requestLogger };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs
|
|
2
|
+
* @forinda/kickjs v4.0.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
11
|
import { createLogger } from "../../core/logger.mjs";
|
|
12
|
-
import "../../core-
|
|
12
|
+
import "../../core-DBcoqPHM.mjs";
|
|
13
13
|
//#region src/http/middleware/request-logger.ts
|
|
14
14
|
/**
|
|
15
15
|
* Middleware that logs every request with method, URL, status, duration, and request ID.
|
|
@@ -1,70 +1,3 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
//#region src/http/middleware/session.d.ts
|
|
5
|
-
interface SessionData {
|
|
6
|
-
[key: string]: unknown;
|
|
7
|
-
}
|
|
8
|
-
interface SessionStore {
|
|
9
|
-
get(sid: string): Promise<SessionData | null>;
|
|
10
|
-
set(sid: string, data: SessionData, maxAge: number): Promise<void>;
|
|
11
|
-
destroy(sid: string): Promise<void>;
|
|
12
|
-
touch?(sid: string, maxAge: number): Promise<void>;
|
|
13
|
-
}
|
|
14
|
-
interface Session {
|
|
15
|
-
id: string;
|
|
16
|
-
data: SessionData;
|
|
17
|
-
regenerate(): Promise<void>;
|
|
18
|
-
destroy(): Promise<void>;
|
|
19
|
-
save(): Promise<void>;
|
|
20
|
-
}
|
|
21
|
-
interface SessionOptions {
|
|
22
|
-
/** Secret used to sign the session cookie (required) */
|
|
23
|
-
secret: string;
|
|
24
|
-
/** Cookie name (default: 'kick.sid') */
|
|
25
|
-
cookieName?: string;
|
|
26
|
-
/** Session max age in milliseconds (default: 86400000 = 24h) */
|
|
27
|
-
maxAge?: number;
|
|
28
|
-
/** Reset maxAge on every response (default: false) */
|
|
29
|
-
rolling?: boolean;
|
|
30
|
-
/** Save new sessions that have not been modified (default: true) */
|
|
31
|
-
saveUninitialized?: boolean;
|
|
32
|
-
/** Cookie options */
|
|
33
|
-
cookie?: {
|
|
34
|
-
httpOnly?: boolean;
|
|
35
|
-
secure?: boolean;
|
|
36
|
-
sameSite?: 'strict' | 'lax' | 'none';
|
|
37
|
-
path?: string;
|
|
38
|
-
domain?: string;
|
|
39
|
-
};
|
|
40
|
-
/** Custom session store (default: in-memory store with TTL cleanup) */
|
|
41
|
-
store?: SessionStore;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Session management middleware.
|
|
45
|
-
*
|
|
46
|
-
* Attaches a `req.session` object with `id`, `data`, `regenerate()`,
|
|
47
|
-
* `destroy()`, and `save()` methods. Session IDs are signed with
|
|
48
|
-
* HMAC-SHA256 to prevent cookie tampering.
|
|
49
|
-
*
|
|
50
|
-
* Reads the session cookie from `req.cookies` when an upstream cookie
|
|
51
|
-
* parser is present; otherwise parses `req.headers.cookie` directly, so
|
|
52
|
-
* no cookie parser is required upstream.
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```ts
|
|
56
|
-
* import { session } from '@forinda/kickjs'
|
|
57
|
-
*
|
|
58
|
-
* bootstrap({
|
|
59
|
-
* modules,
|
|
60
|
-
* middleware: [
|
|
61
|
-
* session({ secret: process.env.SESSION_SECRET! }),
|
|
62
|
-
* // ... other middleware
|
|
63
|
-
* ],
|
|
64
|
-
* })
|
|
65
|
-
* ```
|
|
66
|
-
*/
|
|
67
|
-
declare function session(options: SessionOptions): (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
68
|
-
//#endregion
|
|
69
|
-
export { Session, SessionData, SessionOptions, SessionStore, session };
|
|
70
|
-
//# sourceMappingURL=session.d.mts.map
|
|
2
|
+
import { a as session, i as SessionStore, n as SessionData, r as SessionOptions, t as Session } from "../../session-N0hActOO.mjs";
|
|
3
|
+
export { Session, SessionData, SessionOptions, SessionStore, session };
|
|
@@ -1,101 +1,3 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
3
|
-
|
|
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-http/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 { SpaAdapter, SpaAdapterOptions };
|
|
101
|
-
//# sourceMappingURL=spa.d.mts.map
|
|
2
|
+
import { n as SpaAdapterOptions, t as SpaAdapter } from "../../spa-CrFR2_cz.mjs";
|
|
3
|
+
export { SpaAdapter, SpaAdapterOptions };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs
|
|
2
|
+
* @forinda/kickjs v4.0.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import {
|
|
11
|
+
import { p as __require } from "../../container-DYYSu58w.mjs";
|
|
12
12
|
import { Logger } from "../../core/logger.mjs";
|
|
13
|
-
import "../../core-
|
|
14
|
-
import { join, resolve } from "node:path";
|
|
13
|
+
import "../../core-DBcoqPHM.mjs";
|
|
15
14
|
import { existsSync, readFileSync } from "node:fs";
|
|
15
|
+
import { join, resolve } from "node:path";
|
|
16
16
|
//#region src/http/middleware/spa.ts
|
|
17
17
|
const log = Logger.for("SpaAdapter");
|
|
18
18
|
/**
|
|
@@ -22,7 +22,7 @@ const log = Logger.for("SpaAdapter");
|
|
|
22
22
|
*
|
|
23
23
|
* @example
|
|
24
24
|
* ```ts
|
|
25
|
-
* import { SpaAdapter } from '@forinda/kickjs
|
|
25
|
+
* import { SpaAdapter } from '@forinda/kickjs/spa'
|
|
26
26
|
*
|
|
27
27
|
* bootstrap({
|
|
28
28
|
* modules,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spa.mjs","names":[],"sources":["../../../src/http/middleware/spa.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs'\nimport { resolve, join } from 'node:path'\nimport { Logger, type AppAdapter, type AdapterContext } from '../../core'\n\nconst log = Logger.for('SpaAdapter')\n\nexport interface SpaAdapterOptions {\n /**\n * Directory containing the built SPA files (index.html, assets, etc.)\n * Default: 'dist/client'\n *\n * @example\n * ```ts\n * // Vue: 'dist'\n * // React (Vite): 'dist'\n * // React (CRA): 'build'\n * // Svelte: 'build'\n * // Angular: 'dist/my-app/browser'\n * ```\n */\n clientDir?: string\n\n /**\n * URL prefix for API routes. SPA fallback only applies to\n * non-API routes (routes NOT starting with this prefix).\n * Default: '/api'\n *\n * Set to an array for multiple prefixes:\n * ```ts\n * apiPrefix: ['/api', '/graphql', '/_debug']\n * ```\n */\n apiPrefix?: string | string[]\n\n /**\n * Additional paths to exclude from SPA fallback.\n * These paths will NOT serve index.html.\n *\n * @example\n * ```ts\n * exclude: ['/health', '/metrics', '/ws']\n * ```\n */\n exclude?: string[]\n\n /**\n * Cache-Control header for static assets (default: 'public, max-age=31536000, immutable')\n * Set to false to disable caching headers.\n */\n cacheControl?: string | false\n\n /**\n * Cache-Control for index.html (default: 'no-cache')\n * index.html should not be cached to ensure clients get fresh builds.\n */\n indexCacheControl?: string\n}\n\n/**\n * SPA adapter — serve a Vue, React, Svelte, or Angular build alongside\n * your KickJS API. API routes are handled by controllers; everything else\n * falls back to index.html for client-side routing.\n *\n * @example\n * ```ts\n * import { SpaAdapter } from '@forinda/kickjs
|
|
1
|
+
{"version":3,"file":"spa.mjs","names":[],"sources":["../../../src/http/middleware/spa.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs'\nimport { resolve, join } from 'node:path'\nimport { Logger, type AppAdapter, type AdapterContext } from '../../core'\n\nconst log = Logger.for('SpaAdapter')\n\nexport interface SpaAdapterOptions {\n /**\n * Directory containing the built SPA files (index.html, assets, etc.)\n * Default: 'dist/client'\n *\n * @example\n * ```ts\n * // Vue: 'dist'\n * // React (Vite): 'dist'\n * // React (CRA): 'build'\n * // Svelte: 'build'\n * // Angular: 'dist/my-app/browser'\n * ```\n */\n clientDir?: string\n\n /**\n * URL prefix for API routes. SPA fallback only applies to\n * non-API routes (routes NOT starting with this prefix).\n * Default: '/api'\n *\n * Set to an array for multiple prefixes:\n * ```ts\n * apiPrefix: ['/api', '/graphql', '/_debug']\n * ```\n */\n apiPrefix?: string | string[]\n\n /**\n * Additional paths to exclude from SPA fallback.\n * These paths will NOT serve index.html.\n *\n * @example\n * ```ts\n * exclude: ['/health', '/metrics', '/ws']\n * ```\n */\n exclude?: string[]\n\n /**\n * Cache-Control header for static assets (default: 'public, max-age=31536000, immutable')\n * Set to false to disable caching headers.\n */\n cacheControl?: string | false\n\n /**\n * Cache-Control for index.html (default: 'no-cache')\n * index.html should not be cached to ensure clients get fresh builds.\n */\n indexCacheControl?: string\n}\n\n/**\n * SPA adapter — serve a Vue, React, Svelte, or Angular build alongside\n * your KickJS API. API routes are handled by controllers; everything else\n * falls back to index.html for client-side routing.\n *\n * @example\n * ```ts\n * import { SpaAdapter } from '@forinda/kickjs/spa'\n *\n * bootstrap({\n * modules,\n * adapters: [\n * new SpaAdapter({\n * clientDir: 'dist/client', // or 'build', 'dist', etc.\n * apiPrefix: '/api',\n * }),\n * ],\n * })\n * ```\n *\n * File structure:\n * ```\n * dist/\n * client/ ← SPA build output\n * index.html\n * assets/\n * app.js\n * style.css\n * server/ ← KickJS server\n * ```\n */\nexport class SpaAdapter implements AppAdapter {\n name = 'SpaAdapter'\n private clientDir: string\n private apiPrefixes: string[]\n private excludePaths: string[]\n private cacheControl: string | false\n private indexCacheControl: string\n private indexHtml: string | null = null\n\n constructor(private options: SpaAdapterOptions = {}) {\n this.clientDir = resolve(options.clientDir ?? 'dist/client')\n this.excludePaths = options.exclude ?? []\n this.cacheControl = options.cacheControl ?? 'public, max-age=31536000, immutable'\n this.indexCacheControl = options.indexCacheControl ?? 'no-cache'\n\n const prefix = options.apiPrefix ?? '/api'\n this.apiPrefixes = Array.isArray(prefix) ? prefix : [prefix]\n }\n\n beforeMount({ app }: AdapterContext): void {\n if (!existsSync(this.clientDir)) {\n log.warn(`SPA client directory not found: ${this.clientDir}`)\n log.warn('Build your frontend first, or set clientDir to the correct path.')\n return\n }\n\n // Read index.html into memory\n const indexPath = join(this.clientDir, 'index.html')\n if (existsSync(indexPath)) {\n this.indexHtml = readFileSync(indexPath, 'utf-8')\n } else {\n log.warn(`index.html not found in ${this.clientDir}`)\n return\n }\n\n // Serve static files with cache headers\n try {\n // Dynamic import to avoid hard dependency on express.static\n const express = require('express')\n const staticOpts: any = {}\n\n if (this.cacheControl) {\n staticOpts.setHeaders = (res: any, filePath: string) => {\n if (filePath.endsWith('.html')) {\n res.setHeader('Cache-Control', this.indexCacheControl)\n } else {\n res.setHeader('Cache-Control', this.cacheControl as string)\n }\n }\n }\n\n app.use(express.static(this.clientDir, staticOpts))\n } catch {\n log.error('express.static not available — SPA static file serving disabled')\n return\n }\n\n log.debug(`Serving SPA from ${this.clientDir}`)\n }\n\n beforeStart({ app }: AdapterContext): void {\n if (!this.indexHtml) return\n\n // SPA fallback: serve index.html for all non-API, non-file routes\n app.use((req: any, res: any, next: any) => {\n // Skip API routes\n for (const prefix of this.apiPrefixes) {\n if (req.path.startsWith(prefix)) return next()\n }\n\n // Skip excluded paths\n for (const path of this.excludePaths) {\n if (req.path.startsWith(path)) return next()\n }\n\n // Skip requests for files (have an extension)\n if (req.path.includes('.')) return next()\n\n // Skip non-GET requests\n if (req.method !== 'GET') return next()\n\n // Serve index.html\n res.setHeader('Content-Type', 'text/html')\n res.setHeader('Cache-Control', this.indexCacheControl)\n res.send(this.indexHtml)\n })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAIA,MAAM,MAAM,OAAO,IAAI,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqFpC,IAAa,aAAb,MAA8C;CAC5C,OAAO;CACP;CACA;CACA;CACA;CACA;CACA,YAAmC;CAEnC,YAAY,UAAqC,EAAE,EAAE;AAAjC,OAAA,UAAA;AAClB,OAAK,YAAY,QAAQ,QAAQ,aAAa,cAAc;AAC5D,OAAK,eAAe,QAAQ,WAAW,EAAE;AACzC,OAAK,eAAe,QAAQ,gBAAgB;AAC5C,OAAK,oBAAoB,QAAQ,qBAAqB;EAEtD,MAAM,SAAS,QAAQ,aAAa;AACpC,OAAK,cAAc,MAAM,QAAQ,OAAO,GAAG,SAAS,CAAC,OAAO;;CAG9D,YAAY,EAAE,OAA6B;AACzC,MAAI,CAAC,WAAW,KAAK,UAAU,EAAE;AAC/B,OAAI,KAAK,mCAAmC,KAAK,YAAY;AAC7D,OAAI,KAAK,mEAAmE;AAC5E;;EAIF,MAAM,YAAY,KAAK,KAAK,WAAW,aAAa;AACpD,MAAI,WAAW,UAAU,CACvB,MAAK,YAAY,aAAa,WAAW,QAAQ;OAC5C;AACL,OAAI,KAAK,2BAA2B,KAAK,YAAY;AACrD;;AAIF,MAAI;GAEF,MAAM,UAAA,UAAkB,UAAU;GAClC,MAAM,aAAkB,EAAE;AAE1B,OAAI,KAAK,aACP,YAAW,cAAc,KAAU,aAAqB;AACtD,QAAI,SAAS,SAAS,QAAQ,CAC5B,KAAI,UAAU,iBAAiB,KAAK,kBAAkB;QAEtD,KAAI,UAAU,iBAAiB,KAAK,aAAuB;;AAKjE,OAAI,IAAI,QAAQ,OAAO,KAAK,WAAW,WAAW,CAAC;UAC7C;AACN,OAAI,MAAM,kEAAkE;AAC5E;;AAGF,MAAI,MAAM,oBAAoB,KAAK,YAAY;;CAGjD,YAAY,EAAE,OAA6B;AACzC,MAAI,CAAC,KAAK,UAAW;AAGrB,MAAI,KAAK,KAAU,KAAU,SAAc;AAEzC,QAAK,MAAM,UAAU,KAAK,YACxB,KAAI,IAAI,KAAK,WAAW,OAAO,CAAE,QAAO,MAAM;AAIhD,QAAK,MAAM,QAAQ,KAAK,aACtB,KAAI,IAAI,KAAK,WAAW,KAAK,CAAE,QAAO,MAAM;AAI9C,OAAI,IAAI,KAAK,SAAS,IAAI,CAAE,QAAO,MAAM;AAGzC,OAAI,IAAI,WAAW,MAAO,QAAO,MAAM;AAGvC,OAAI,UAAU,gBAAgB,YAAY;AAC1C,OAAI,UAAU,iBAAiB,KAAK,kBAAkB;AACtD,OAAI,KAAK,KAAK,UAAU;IACxB"}
|
|
@@ -1,79 +1,3 @@
|
|
|
1
1
|
|
|
2
|
-
import { i as
|
|
3
|
-
|
|
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 { UploadOptions, buildUploadMiddleware, cleanupFiles, resolveMimeTypes, upload };
|
|
79
|
-
//# sourceMappingURL=upload.d.mts.map
|
|
2
|
+
import { a as upload, i as resolveMimeTypes, n as buildUploadMiddleware, r as cleanupFiles, t as UploadOptions } from "../../upload-BueOnnLw.mjs";
|
|
3
|
+
export { UploadOptions, buildUploadMiddleware, cleanupFiles, resolveMimeTypes, upload };
|
|
@@ -1,23 +1,3 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
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 { ValidationSchema, validate };
|
|
23
|
-
//# sourceMappingURL=validate.d.mts.map
|
|
2
|
+
import { n as validate, t as ValidationSchema } from "../../validate-HwAyWTwH.mjs";
|
|
3
|
+
export { ValidationSchema, validate };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs
|
|
2
|
+
* @forinda/kickjs v4.0.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
11
|
import { HttpException, HttpStatus } from "../../core/errors.mjs";
|
|
12
|
-
import "../../core-
|
|
12
|
+
import "../../core-DBcoqPHM.mjs";
|
|
13
13
|
//#region src/http/middleware/validate.ts
|
|
14
14
|
function toValidationException(error, message, useFirstIssueMessage) {
|
|
15
15
|
const issues = error.issues || [];
|
|
@@ -1,62 +1,3 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
interface ViewAdapterOptions {
|
|
5
|
-
/**
|
|
6
|
-
* Template engine — pass the engine module or a render function.
|
|
7
|
-
* Supported engines: ejs, pug, handlebars, nunjucks, or any
|
|
8
|
-
* Express-compatible engine with a __express property.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* import ejs from 'ejs'
|
|
13
|
-
* new ViewAdapter({ engine: ejs, ext: 'ejs' })
|
|
14
|
-
*
|
|
15
|
-
* import pug from 'pug'
|
|
16
|
-
* new ViewAdapter({ engine: pug, ext: 'pug' })
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
engine: any;
|
|
20
|
-
/** File extension for templates (e.g., 'ejs', 'pug', 'hbs') */
|
|
21
|
-
ext: string;
|
|
22
|
-
/** Directory containing template files (default: 'src/views') */
|
|
23
|
-
viewsDir?: string;
|
|
24
|
-
/** Default layout template (optional — depends on engine) */
|
|
25
|
-
layout?: string;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* View/template adapter — pluggable template engine support for KickJS.
|
|
29
|
-
*
|
|
30
|
-
* Registers an Express view engine and sets the views directory.
|
|
31
|
-
* Use `ctx.render()` in controllers to render templates.
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```ts
|
|
35
|
-
* import ejs from 'ejs'
|
|
36
|
-
* import { ViewAdapter } from '@forinda/kickjs-http/views'
|
|
37
|
-
*
|
|
38
|
-
* bootstrap({
|
|
39
|
-
* modules,
|
|
40
|
-
* adapters: [
|
|
41
|
-
* new ViewAdapter({ engine: ejs, ext: 'ejs', viewsDir: 'src/views' }),
|
|
42
|
-
* ],
|
|
43
|
-
* })
|
|
44
|
-
*
|
|
45
|
-
* // In a controller:
|
|
46
|
-
* @Get('/dashboard')
|
|
47
|
-
* async dashboard(ctx: RequestContext) {
|
|
48
|
-
* ctx.render('dashboard', { user: currentUser, title: 'Dashboard' })
|
|
49
|
-
* }
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
declare class ViewAdapter implements AppAdapter {
|
|
53
|
-
private options;
|
|
54
|
-
name: string;
|
|
55
|
-
constructor(options: ViewAdapterOptions);
|
|
56
|
-
beforeMount({
|
|
57
|
-
app
|
|
58
|
-
}: AdapterContext): void;
|
|
59
|
-
}
|
|
60
|
-
//#endregion
|
|
61
|
-
export { ViewAdapter, ViewAdapterOptions };
|
|
62
|
-
//# sourceMappingURL=views.d.mts.map
|
|
2
|
+
import { n as ViewAdapterOptions, t as ViewAdapter } from "../../views-DhQSXV2P.mjs";
|
|
3
|
+
export { ViewAdapter, ViewAdapterOptions };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs
|
|
2
|
+
* @forinda/kickjs v4.0.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
11
|
import { Logger } from "../../core/logger.mjs";
|
|
12
|
-
import "../../core-
|
|
12
|
+
import { n as defineAdapter } from "../../core-DBcoqPHM.mjs";
|
|
13
13
|
import { resolve } from "node:path";
|
|
14
14
|
//#region src/http/middleware/views.ts
|
|
15
15
|
const log = Logger.for("ViewEngine");
|
|
@@ -19,15 +19,19 @@ const log = Logger.for("ViewEngine");
|
|
|
19
19
|
* Registers an Express view engine and sets the views directory.
|
|
20
20
|
* Use `ctx.render()` in controllers to render templates.
|
|
21
21
|
*
|
|
22
|
+
* Migrated to the `defineAdapter()` factory in v4 — call without `new`.
|
|
23
|
+
* The pre-v4 `new ViewAdapter({...})` form is gone; see
|
|
24
|
+
* `docs/guide/migration-v3-to-v4.md` for the rename.
|
|
25
|
+
*
|
|
22
26
|
* @example
|
|
23
27
|
* ```ts
|
|
24
28
|
* import ejs from 'ejs'
|
|
25
|
-
* import { ViewAdapter } from '@forinda/kickjs
|
|
29
|
+
* import { ViewAdapter } from '@forinda/kickjs'
|
|
26
30
|
*
|
|
27
31
|
* bootstrap({
|
|
28
32
|
* modules,
|
|
29
33
|
* adapters: [
|
|
30
|
-
*
|
|
34
|
+
* ViewAdapter({ engine: ejs, ext: 'ejs', viewsDir: 'src/views' }),
|
|
31
35
|
* ],
|
|
32
36
|
* })
|
|
33
37
|
*
|
|
@@ -38,16 +42,13 @@ const log = Logger.for("ViewEngine");
|
|
|
38
42
|
* }
|
|
39
43
|
* ```
|
|
40
44
|
*/
|
|
41
|
-
|
|
42
|
-
name
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
beforeMount({ app }) {
|
|
47
|
-
const { engine, ext, viewsDir = "src/views" } = this.options;
|
|
45
|
+
const ViewAdapter = defineAdapter({
|
|
46
|
+
name: "ViewAdapter",
|
|
47
|
+
build: (options) => ({ beforeMount({ app }) {
|
|
48
|
+
const { engine, ext, viewsDir = "src/views" } = options;
|
|
48
49
|
if (engine.__express) app.engine(ext, engine.__express);
|
|
49
|
-
else if (typeof engine.renderFile === "function") app.engine(ext, (path,
|
|
50
|
-
engine.renderFile(path,
|
|
50
|
+
else if (typeof engine.renderFile === "function") app.engine(ext, (path, opts, callback) => {
|
|
51
|
+
engine.renderFile(path, opts, callback);
|
|
51
52
|
});
|
|
52
53
|
else if (typeof engine === "function") app.engine(ext, engine);
|
|
53
54
|
else {
|
|
@@ -57,8 +58,8 @@ var ViewAdapter = class {
|
|
|
57
58
|
app.set("view engine", ext);
|
|
58
59
|
app.set("views", resolve(viewsDir));
|
|
59
60
|
log.debug(`View engine: ${ext} (${resolve(viewsDir)})`);
|
|
60
|
-
}
|
|
61
|
-
};
|
|
61
|
+
} })
|
|
62
|
+
});
|
|
62
63
|
//#endregion
|
|
63
64
|
export { ViewAdapter };
|
|
64
65
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"views.mjs","names":[],"sources":["../../../src/http/middleware/views.ts"],"sourcesContent":["import { resolve } from 'node:path'\nimport { Logger,
|
|
1
|
+
{"version":3,"file":"views.mjs","names":[],"sources":["../../../src/http/middleware/views.ts"],"sourcesContent":["import { resolve } from 'node:path'\nimport { Logger, defineAdapter } from '../../core'\n\nconst log = Logger.for('ViewEngine')\n\nexport interface ViewAdapterOptions {\n /**\n * Template engine — pass the engine module or a render function.\n * Supported engines: ejs, pug, handlebars, nunjucks, or any\n * Express-compatible engine with a __express property.\n *\n * @example\n * ```ts\n * import ejs from 'ejs'\n * ViewAdapter({ engine: ejs, ext: 'ejs' })\n *\n * import pug from 'pug'\n * ViewAdapter({ engine: pug, ext: 'pug' })\n * ```\n */\n engine: any\n\n /** File extension for templates (e.g., 'ejs', 'pug', 'hbs') */\n ext: string\n\n /** Directory containing template files (default: 'src/views') */\n viewsDir?: string\n\n /** Default layout template (optional — depends on engine) */\n layout?: string\n}\n\n/**\n * View/template adapter — pluggable template engine support for KickJS.\n *\n * Registers an Express view engine and sets the views directory.\n * Use `ctx.render()` in controllers to render templates.\n *\n * Migrated to the `defineAdapter()` factory in v4 — call without `new`.\n * The pre-v4 `new ViewAdapter({...})` form is gone; see\n * `docs/guide/migration-v3-to-v4.md` for the rename.\n *\n * @example\n * ```ts\n * import ejs from 'ejs'\n * import { ViewAdapter } from '@forinda/kickjs'\n *\n * bootstrap({\n * modules,\n * adapters: [\n * ViewAdapter({ engine: ejs, ext: 'ejs', viewsDir: 'src/views' }),\n * ],\n * })\n *\n * // In a controller:\n * @Get('/dashboard')\n * async dashboard(ctx: RequestContext) {\n * ctx.render('dashboard', { user: currentUser, title: 'Dashboard' })\n * }\n * ```\n */\nexport const ViewAdapter = defineAdapter<ViewAdapterOptions>({\n name: 'ViewAdapter',\n build: (options) => ({\n beforeMount({ app }) {\n const { engine, ext, viewsDir = 'src/views' } = options\n\n // Register the engine. Three resolution paths cover every\n // mainstream template engine + a fall-through for custom ones.\n if (engine.__express) {\n // EJS, Pug — have __express method\n app.engine(ext, engine.__express)\n } else if (typeof engine.renderFile === 'function') {\n // Engines with renderFile (nunjucks-style)\n app.engine(\n ext,\n (path: string, opts: any, callback: (err: Error | null, html?: string) => void) => {\n engine.renderFile(path, opts, callback)\n },\n )\n } else if (typeof engine === 'function') {\n // Custom render function: (path, options, callback) => void\n app.engine(ext, engine)\n } else {\n log.warn(`Engine for .${ext} does not have __express or renderFile. Trying as-is.`)\n app.engine(ext, engine)\n }\n\n app.set('view engine', ext)\n app.set('views', resolve(viewsDir))\n\n log.debug(`View engine: ${ext} (${resolve(viewsDir)})`)\n },\n }),\n})\n"],"mappings":";;;;;;;;;;;;;;AAGA,MAAM,MAAM,OAAO,IAAI,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DpC,MAAa,cAAc,cAAkC;CAC3D,MAAM;CACN,QAAQ,aAAa,EACnB,YAAY,EAAE,OAAO;EACnB,MAAM,EAAE,QAAQ,KAAK,WAAW,gBAAgB;AAIhD,MAAI,OAAO,UAET,KAAI,OAAO,KAAK,OAAO,UAAU;WACxB,OAAO,OAAO,eAAe,WAEtC,KAAI,OACF,MACC,MAAc,MAAW,aAAyD;AACjF,UAAO,WAAW,MAAM,MAAM,SAAS;IAE1C;WACQ,OAAO,WAAW,WAE3B,KAAI,OAAO,KAAK,OAAO;OAClB;AACL,OAAI,KAAK,eAAe,IAAI,uDAAuD;AACnF,OAAI,OAAO,KAAK,OAAO;;AAGzB,MAAI,IAAI,eAAe,IAAI;AAC3B,MAAI,IAAI,SAAS,QAAQ,SAAS,CAAC;AAEnC,MAAI,MAAM,gBAAgB,IAAI,IAAI,QAAQ,SAAS,CAAC,GAAG;IAE1D;CACF,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
|
|
2
|
-
import { _ as SortItem, a as parseSearchQuery, c as FILTER_OPERATORS, d as FilterOperator, f as PaginatedResponse, g as QueryFieldConfig, h as QueryBuilderAdapter, i as parseQuery, l as FieldsOf, m as ParsedQuery, n as parseFilters, o as parseSort, p as PaginationParams, r as parsePagination, s as ColumnQueryFieldConfig, t as buildQueryParams, u as FilterItem, v as StringQueryFieldConfig, y as TypedParsedQuery } from "../../index-
|
|
2
|
+
import { _ as SortItem, a as parseSearchQuery, c as FILTER_OPERATORS, d as FilterOperator, f as PaginatedResponse, g as QueryFieldConfig, h as QueryBuilderAdapter, i as parseQuery, l as FieldsOf, m as ParsedQuery, n as parseFilters, o as parseSort, p as PaginationParams, r as parsePagination, s as ColumnQueryFieldConfig, t as buildQueryParams, u as FilterItem, v as StringQueryFieldConfig, y as TypedParsedQuery } from "../../index-B9cyOQAe.mjs";
|
|
3
3
|
export { ColumnQueryFieldConfig, FILTER_OPERATORS, FieldsOf, FilterItem, FilterOperator, PaginatedResponse, PaginationParams, ParsedQuery, QueryBuilderAdapter, QueryFieldConfig, SortItem, StringQueryFieldConfig, TypedParsedQuery, buildQueryParams, parseFilters, parsePagination, parseQuery, parseSearchQuery, parseSort };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs
|
|
2
|
+
* @forinda/kickjs v4.0.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import { a as parseSearchQuery, i as parseQuery, n as parseFilters, o as parseSort, r as parsePagination, s as FILTER_OPERATORS, t as buildQueryParams } from "../../query-
|
|
11
|
+
import { a as parseSearchQuery, i as parseQuery, n as parseFilters, o as parseSort, r as parsePagination, s as FILTER_OPERATORS, t as buildQueryParams } from "../../query-DJMxdx5r.mjs";
|
|
12
12
|
export { FILTER_OPERATORS, buildQueryParams, parseFilters, parsePagination, parseQuery, parseSearchQuery, parseSort };
|
|
@@ -1,21 +1,3 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
//#region src/http/router-builder.d.ts
|
|
5
|
-
/** Get the controller path set by @Controller('/path') */
|
|
6
|
-
declare function getControllerPath(controllerClass: any): string;
|
|
7
|
-
/**
|
|
8
|
-
* Build an Express Router from a controller class decorated with @Get, @Post, etc.
|
|
9
|
-
* Resolves the controller from the DI container, wraps handlers in RequestContext,
|
|
10
|
-
* and applies class-level and method-level middleware.
|
|
11
|
-
*
|
|
12
|
-
* Routes are registered using only the method-level decorator paths (e.g. @Get('/me') → '/me').
|
|
13
|
-
* The @Controller path is NOT baked into the router — it serves as metadata only
|
|
14
|
-
* (used by Swagger and other adapters for introspection).
|
|
15
|
-
* The module's routes().path is the single source of truth for the mount prefix,
|
|
16
|
-
* which avoids path doubling when both the module and controller specify the same path.
|
|
17
|
-
*/
|
|
18
|
-
declare function buildRoutes(controllerClass: any): Router;
|
|
19
|
-
//#endregion
|
|
20
|
-
export { buildRoutes, getControllerPath };
|
|
21
|
-
//# sourceMappingURL=router-builder.d.mts.map
|
|
2
|
+
import { n as _setExternalContributorSources, r as buildRoutes, t as BuildRoutesOptions } from "../router-builder-C799BAf0.mjs";
|
|
3
|
+
export { BuildRoutesOptions, _setExternalContributorSources, buildRoutes };
|