@forinda/kickjs 5.12.1 → 5.13.1
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/dist/{adapter-BRvrS9xR.d.mts → adapter-D1NzavIt.d.mts} +4 -4
- package/dist/{adapter-BRvrS9xR.d.mts.map → adapter-D1NzavIt.d.mts.map} +1 -1
- package/dist/{app-module-BE7hAASB.d.mts → app-module-iAA20Cc6.d.mts} +3 -3
- package/dist/{app-module-BE7hAASB.d.mts.map → app-module-iAA20Cc6.d.mts.map} +1 -1
- package/dist/application-BTlWEKp2.mjs +12 -0
- package/dist/application-BTlWEKp2.mjs.map +1 -0
- package/dist/{application-BNxhBgji.d.mts → application-ChL6ufgq.d.mts} +6 -6
- package/dist/application-ChL6ufgq.d.mts.map +1 -0
- package/dist/{bootstrap-qvftPBfr.d.mts → bootstrap-Cgt_j-0Q.d.mts} +2 -2
- package/dist/{bootstrap-qvftPBfr.d.mts.map → bootstrap-Cgt_j-0Q.d.mts.map} +1 -1
- package/dist/{bootstrap-BjqQJii4.mjs → bootstrap-DoEPezno.mjs} +3 -3
- package/dist/{bootstrap-BjqQJii4.mjs.map → bootstrap-DoEPezno.mjs.map} +1 -1
- package/dist/config/index.d.mts +1 -1
- package/dist/config/index.mjs +2 -2
- package/dist/{config-Co2RfVca.mjs → config-Bbk1PLGo.mjs} +3 -3
- package/dist/{config-Co2RfVca.mjs.map → config-Bbk1PLGo.mjs.map} +1 -1
- package/dist/{container-BZKeHc5X.d.mts → container-B51bkskE.d.mts} +2 -2
- package/dist/container-B51bkskE.d.mts.map +1 -0
- package/dist/container-Bq8VjG_Y.mjs +108 -0
- package/dist/container-Bq8VjG_Y.mjs.map +1 -0
- package/dist/context-CnyTYykn.mjs +12 -0
- package/dist/context-CnyTYykn.mjs.map +1 -0
- package/dist/{context-C2yPZ22U.d.mts → context-D7sGbb8E.d.mts} +98 -1
- package/dist/context-D7sGbb8E.d.mts.map +1 -0
- package/dist/{context-decorator-BYf8HdMl.d.mts → context-decorator-BzcOhlej.d.mts} +3 -3
- package/dist/{context-decorator-BYf8HdMl.d.mts.map → context-decorator-BzcOhlej.d.mts.map} +1 -1
- 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.mjs +1 -1
- package/dist/core/container.d.mts +1 -1
- package/dist/core/container.mjs +2 -2
- package/dist/core/cron.mjs +2 -2
- package/dist/core/decorators.d.mts +1 -1
- package/dist/core/decorators.mjs +2 -2
- package/dist/core/errors.d.mts +2 -2
- package/dist/core/errors.mjs +2 -2
- package/dist/core/errors.mjs.map +1 -1
- package/dist/core/interfaces.d.mts +1 -1
- package/dist/core/interfaces.mjs +1 -1
- package/dist/core/logger.d.mts +1 -1
- package/dist/core/logger.mjs +2 -2
- package/dist/core/logger.mjs.map +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.mjs +1 -1
- package/dist/{core-BmdHkGCN.mjs → core-CGEbLIPv.mjs} +3 -3
- package/dist/{core-BmdHkGCN.mjs.map → core-CGEbLIPv.mjs.map} +1 -1
- package/dist/cors-BfgqfLPd.d.mts.map +1 -1
- package/dist/csrf-DiK9zept.d.mts.map +1 -1
- package/dist/{decorators-BYi8lB37.d.mts → decorators-KbaPUBXd.d.mts} +8 -8
- package/dist/decorators-KbaPUBXd.d.mts.map +1 -0
- package/dist/{env-9jac5_v-.mjs → env-BvCyDZYf.mjs} +3 -3
- package/dist/{env-9jac5_v-.mjs.map → env-BvCyDZYf.mjs.map} +1 -1
- package/dist/{error-handler-Xud_3Lah.d.mts → error-handler-C4SG5o_i.d.mts} +6 -1
- package/dist/error-handler-C4SG5o_i.d.mts.map +1 -0
- package/dist/errors-DytV77Hb.d.mts +241 -0
- package/dist/errors-DytV77Hb.d.mts.map +1 -0
- package/dist/helmet-CaMbjzBG.d.mts.map +1 -1
- package/dist/http/application.d.mts +1 -1
- package/dist/http/application.mjs +2 -2
- package/dist/http/bootstrap.d.mts +1 -1
- package/dist/http/bootstrap.mjs +2 -2
- package/dist/http/context.d.mts +1 -1
- package/dist/http/context.mjs +2 -2
- package/dist/http/middleware/cors.mjs +1 -1
- package/dist/http/middleware/csrf.mjs +1 -1
- package/dist/http/middleware/error-handler.d.mts +1 -1
- package/dist/http/middleware/error-handler.mjs +2 -2
- package/dist/http/middleware/error-handler.mjs.map +1 -1
- package/dist/http/middleware/helmet.mjs +1 -1
- package/dist/http/middleware/rate-limit.mjs +1 -1
- package/dist/http/middleware/request-id.mjs +1 -1
- package/dist/http/middleware/request-logger.mjs +2 -2
- package/dist/http/middleware/session.mjs +1 -1
- package/dist/http/middleware/spa.d.mts +1 -1
- package/dist/http/middleware/spa.mjs +2 -2
- package/dist/http/middleware/upload.d.mts +1 -1
- package/dist/http/middleware/upload.mjs +1 -1
- package/dist/http/middleware/validate.mjs +2 -2
- package/dist/http/middleware/views.d.mts +1 -1
- package/dist/http/middleware/views.mjs +2 -2
- package/dist/http/query/index.mjs +2 -2
- package/dist/http/router-builder.d.mts +1 -1
- package/dist/http/router-builder.mjs +2 -2
- package/dist/{index-DM1PteZT.d.mts → index-BM32LMqZ.d.mts} +4 -4
- package/dist/{index-DM1PteZT.d.mts.map → index-BM32LMqZ.d.mts.map} +1 -1
- package/dist/{index-qZqR_Mxr.d.mts → index-BYLVLFA8.d.mts} +63 -7
- package/dist/index-BYLVLFA8.d.mts.map +1 -0
- package/dist/index.d.mts +20 -20
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/{interfaces-B50n7dwl.d.mts → interfaces-ClcFeDhd.d.mts} +20 -20
- package/dist/{interfaces-B50n7dwl.d.mts.map → interfaces-ClcFeDhd.d.mts.map} +1 -1
- package/dist/{logger-SKhhzmU2.d.mts → logger-DyTCk-v1.d.mts} +2 -1
- package/dist/logger-DyTCk-v1.d.mts.map +1 -0
- package/dist/{metadata-CrnOurKc.mjs → metadata-pbYET01G.mjs} +2 -2
- package/dist/{metadata-CrnOurKc.mjs.map → metadata-pbYET01G.mjs.map} +1 -1
- package/dist/{plugin-CyoGnRbq.d.mts → plugin-DG_jFA6h.d.mts} +5 -5
- package/dist/{plugin-CyoGnRbq.d.mts.map → plugin-DG_jFA6h.d.mts.map} +1 -1
- package/dist/{query-NwPcYRbW.mjs → query-NrahUI9e.mjs} +2 -2
- package/dist/{query-NwPcYRbW.mjs.map → query-NrahUI9e.mjs.map} +1 -1
- package/dist/rate-limit-DUwoICtI.d.mts.map +1 -1
- package/dist/request-id-BgglvZHN.d.mts.map +1 -1
- package/dist/request-logger-CWHbAzTE.d.mts.map +1 -1
- package/dist/{router-builder-R6dyZ-A3.d.mts → router-builder-CSAOc9MR.d.mts} +2 -2
- package/dist/{router-builder-R6dyZ-A3.d.mts.map → router-builder-CSAOc9MR.d.mts.map} +1 -1
- package/dist/session-N0hActOO.d.mts.map +1 -1
- package/dist/{spa-DFxiK7jQ.d.mts → spa-DNOAvuFy.d.mts} +2 -2
- package/dist/{spa-DFxiK7jQ.d.mts.map → spa-DNOAvuFy.d.mts.map} +1 -1
- package/dist/{upload-5goxbO9A.d.mts → upload-7RRWSKkI.d.mts} +2 -2
- package/dist/{upload-5goxbO9A.d.mts.map → upload-7RRWSKkI.d.mts.map} +1 -1
- package/dist/validate-HwAyWTwH.d.mts.map +1 -1
- package/dist/{views-BvKu3uGv.d.mts → views-srW0E4Ll.d.mts} +4 -4
- package/dist/{views-BvKu3uGv.d.mts.map → views-srW0E4Ll.d.mts.map} +1 -1
- package/package.json +2 -2
- package/dist/application-BMANdf_K.mjs +0 -12
- package/dist/application-BMANdf_K.mjs.map +0 -1
- package/dist/application-BNxhBgji.d.mts.map +0 -1
- package/dist/container-B0UjUZ_7.mjs +0 -12
- package/dist/container-B0UjUZ_7.mjs.map +0 -1
- package/dist/container-BZKeHc5X.d.mts.map +0 -1
- package/dist/context-Br6PrKkN.mjs +0 -12
- package/dist/context-Br6PrKkN.mjs.map +0 -1
- package/dist/context-C2yPZ22U.d.mts.map +0 -1
- package/dist/decorators-BYi8lB37.d.mts.map +0 -1
- package/dist/error-handler-Xud_3Lah.d.mts.map +0 -1
- package/dist/errors-uaHCeXRz.d.mts +0 -81
- package/dist/errors-uaHCeXRz.d.mts.map +0 -1
- package/dist/index-qZqR_Mxr.d.mts.map +0 -1
- package/dist/logger-SKhhzmU2.d.mts.map +0 -1
|
@@ -13,8 +13,13 @@ declare function notFoundHandler(): (_req: Request, res: Response, _next: NextFu
|
|
|
13
13
|
* expose details in production — for client-facing field-level validation,
|
|
14
14
|
* for example — should pass their own `onError` to `bootstrap()` and decide
|
|
15
15
|
* the policy explicitly.
|
|
16
|
+
*
|
|
17
|
+
* {@link ProblemException} is dispatched first and emits an
|
|
18
|
+
* `application/problem+json` response per RFC 9457. Plain
|
|
19
|
+
* {@link HttpException} keeps the existing `{ message, errors? }` shape
|
|
20
|
+
* for backward compatibility.
|
|
16
21
|
*/
|
|
17
22
|
declare function errorHandler(): (err: any, req: Request, res: Response, _next: NextFunction) => Response<any, Record<string, any>> | undefined;
|
|
18
23
|
//#endregion
|
|
19
24
|
export { notFoundHandler as n, errorHandler as t };
|
|
20
|
-
//# sourceMappingURL=error-handler-
|
|
25
|
+
//# sourceMappingURL=error-handler-C4SG5o_i.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handler-C4SG5o_i.d.mts","names":[],"sources":["../src/http/middleware/error-handler.ts"],"mappings":";;;;;iBAMgB,eAAA,CAAA,IAAe,IAAA,EACf,OAAA,EAAO,GAAA,EAAO,QAAA,EAAQ,KAAA,EAAS,YAAA;AAD/C;;;;;;;;;;;;;;;AAAA,iBAqBgB,YAAA,CAAA,IAAY,GAAA,OAEV,GAAA,EAAO,OAAA,EAAO,GAAA,EAAO,QAAA,EAAQ,KAAA,EAAS,YAAA,KAAY,QAAA,MAAA,MAAA"}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/core/errors.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Standard HTTP status codes as a const enum.
|
|
5
|
+
* Use instead of raw numbers for readability and type safety.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* throw new HttpException(HttpStatus.NOT_FOUND, 'User not found')
|
|
10
|
+
* ctx.res.status(HttpStatus.CREATED).json(data)
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
declare const HttpStatus: {
|
|
14
|
+
readonly OK: 200;
|
|
15
|
+
readonly CREATED: 201;
|
|
16
|
+
readonly ACCEPTED: 202;
|
|
17
|
+
readonly NO_CONTENT: 204;
|
|
18
|
+
readonly MOVED_PERMANENTLY: 301;
|
|
19
|
+
readonly FOUND: 302;
|
|
20
|
+
readonly NOT_MODIFIED: 304;
|
|
21
|
+
readonly TEMPORARY_REDIRECT: 307;
|
|
22
|
+
readonly PERMANENT_REDIRECT: 308;
|
|
23
|
+
readonly BAD_REQUEST: 400;
|
|
24
|
+
readonly UNAUTHORIZED: 401;
|
|
25
|
+
readonly PAYMENT_REQUIRED: 402;
|
|
26
|
+
readonly FORBIDDEN: 403;
|
|
27
|
+
readonly NOT_FOUND: 404;
|
|
28
|
+
readonly METHOD_NOT_ALLOWED: 405;
|
|
29
|
+
readonly NOT_ACCEPTABLE: 406;
|
|
30
|
+
readonly CONFLICT: 409;
|
|
31
|
+
readonly GONE: 410;
|
|
32
|
+
readonly UNPROCESSABLE_ENTITY: 422;
|
|
33
|
+
readonly TOO_MANY_REQUESTS: 429;
|
|
34
|
+
readonly INTERNAL_SERVER_ERROR: 500;
|
|
35
|
+
readonly NOT_IMPLEMENTED: 501;
|
|
36
|
+
readonly BAD_GATEWAY: 502;
|
|
37
|
+
readonly SERVICE_UNAVAILABLE: 503;
|
|
38
|
+
readonly GATEWAY_TIMEOUT: 504;
|
|
39
|
+
};
|
|
40
|
+
type HttpStatusCode = (typeof HttpStatus)[keyof typeof HttpStatus];
|
|
41
|
+
/** Validation error detail — shape used by `unprocessable()` and `fromZodError()`. */
|
|
42
|
+
interface ValidationError {
|
|
43
|
+
field: string;
|
|
44
|
+
message: string;
|
|
45
|
+
code?: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* RFC 9457 — Problem Details for HTTP APIs.
|
|
49
|
+
* https://datatracker.ietf.org/doc/html/rfc9457
|
|
50
|
+
*
|
|
51
|
+
* Canonical error shape for HTTP responses. Only `status` is required;
|
|
52
|
+
* everything else has a sensible default. Extension members (any other
|
|
53
|
+
* JSON-compatible field) are allowed per §3.2 — pass them on the same
|
|
54
|
+
* object and the framework forwards them through.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* const problem: ProblemDetails = {
|
|
59
|
+
* type: 'https://api.example.com/problems/out-of-credit',
|
|
60
|
+
* status: 403,
|
|
61
|
+
* title: 'You do not have enough credit',
|
|
62
|
+
* detail: 'Your balance is 30, but that costs 50.',
|
|
63
|
+
* instance: '/account/12345/messages/abc',
|
|
64
|
+
* // extension members per §3.2
|
|
65
|
+
* balance: 30,
|
|
66
|
+
* }
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
interface ProblemDetails {
|
|
70
|
+
/**
|
|
71
|
+
* URI reference identifying the problem type. Per §4.2.1, when
|
|
72
|
+
* dereferenced it SHOULD return human-readable documentation. Defaults
|
|
73
|
+
* to `about:blank` when omitted (RFC 9457 §3.1.1).
|
|
74
|
+
*/
|
|
75
|
+
type?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Short human-readable summary, advisable to be the same regardless of
|
|
78
|
+
* the occurrence (§3.1.4). Defaults to the IANA reason phrase for
|
|
79
|
+
* `status` when omitted.
|
|
80
|
+
*/
|
|
81
|
+
title?: string;
|
|
82
|
+
/** HTTP status code generated by the origin server. Required. */
|
|
83
|
+
status: number;
|
|
84
|
+
/**
|
|
85
|
+
* Human-readable explanation specific to this occurrence (§3.1.5).
|
|
86
|
+
* Per the RFC's safety guidance, do not include sensitive information
|
|
87
|
+
* (tokens, full SQL, stack traces) — those belong in logs.
|
|
88
|
+
*/
|
|
89
|
+
detail?: string;
|
|
90
|
+
/**
|
|
91
|
+
* URI reference identifying the specific occurrence (§3.1.6).
|
|
92
|
+
* Typically the request path. Adopters set this explicitly — the
|
|
93
|
+
* framework does not auto-populate it to avoid leaking unexpected
|
|
94
|
+
* structure.
|
|
95
|
+
*/
|
|
96
|
+
instance?: string;
|
|
97
|
+
/**
|
|
98
|
+
* Extension members per §3.2 — any other JSON-compatible field.
|
|
99
|
+
* Common examples: `balance`, `errors`, `traceId`, `accounts`.
|
|
100
|
+
*/
|
|
101
|
+
[key: string]: unknown;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Typed HTTP exception with status code, free-form details, and optional
|
|
105
|
+
* response headers. Provides static factory methods for common HTTP errors.
|
|
106
|
+
*
|
|
107
|
+
* `details` is intentionally typed as `unknown` — it serializes straight into
|
|
108
|
+
* the response body's `errors` field, so any JSON-compatible shape works
|
|
109
|
+
* (string, object, array of mixed values, ValidationError[]).
|
|
110
|
+
*
|
|
111
|
+
* `headers` are merged into the response by the global error handler so
|
|
112
|
+
* spec-mandated headers (Retry-After, WWW-Authenticate, Allow, Location)
|
|
113
|
+
* stay on the exception, not on ad-hoc try/catch chains.
|
|
114
|
+
*
|
|
115
|
+
* For RFC 9457 — Problem Details responses, throw {@link ProblemException}
|
|
116
|
+
* instead — the global error handler emits `application/problem+json` for
|
|
117
|
+
* those automatically.
|
|
118
|
+
*/
|
|
119
|
+
declare class HttpException extends Error {
|
|
120
|
+
readonly status: number;
|
|
121
|
+
readonly details?: unknown;
|
|
122
|
+
readonly headers?: Record<string, string> | undefined;
|
|
123
|
+
constructor(status: number, message: string, details?: unknown, headers?: Record<string, string> | undefined);
|
|
124
|
+
/** Return a new exception with `headers` shallow-merged onto this one. */
|
|
125
|
+
withHeaders(headers: Record<string, string>): HttpException;
|
|
126
|
+
/** Create from a Zod error */
|
|
127
|
+
static fromZodError(error: any, message?: string): HttpException;
|
|
128
|
+
static badRequest(message?: string): HttpException;
|
|
129
|
+
static unauthorized(message?: string, wwwAuthenticate?: string): HttpException;
|
|
130
|
+
static forbidden(message?: string): HttpException;
|
|
131
|
+
static notFound(message?: string): HttpException;
|
|
132
|
+
static methodNotAllowed(allowedMethods: string[], message?: string): HttpException;
|
|
133
|
+
static conflict(message?: string): HttpException;
|
|
134
|
+
static unprocessable(message?: string, details?: ValidationError[]): HttpException;
|
|
135
|
+
static tooManyRequests(message?: string, retryAfterSeconds?: number): HttpException;
|
|
136
|
+
static serviceUnavailable(message?: string, retryAfterSeconds?: number): HttpException;
|
|
137
|
+
static internal(message?: string): HttpException;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Default `title` for an RFC 9457 problem with the given status — the IANA
|
|
141
|
+
* reason phrase, or `'Error'` for codes outside the framework's table.
|
|
142
|
+
* Exposed so {@link ProblemException} construction and {@link RequestContext}'s
|
|
143
|
+
* `problem` helpers share a single source of truth.
|
|
144
|
+
*/
|
|
145
|
+
declare function defaultProblemTitle(status: number): string;
|
|
146
|
+
/**
|
|
147
|
+
* Exception that carries an RFC 9457 — Problem Details payload. When
|
|
148
|
+
* thrown, the framework error handler emits `application/problem+json`
|
|
149
|
+
* with the canonical shape; `type` defaults to `about:blank`, `title`
|
|
150
|
+
* to the IANA reason phrase for `status`.
|
|
151
|
+
*
|
|
152
|
+
* Extends {@link HttpException} so existing `instanceof HttpException`
|
|
153
|
+
* catches still see it. Use `new ProblemException(...)` directly for
|
|
154
|
+
* full control, or {@link Problems} for the pre-filled-status
|
|
155
|
+
* convenience factories.
|
|
156
|
+
*
|
|
157
|
+
* Static factories deliberately live on {@link Problems} rather than
|
|
158
|
+
* this class — putting them here would shadow `HttpException`'s
|
|
159
|
+
* same-named statics with incompatible (object vs string) signatures,
|
|
160
|
+
* which TypeScript correctly rejects.
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```ts
|
|
164
|
+
* throw new ProblemException({
|
|
165
|
+
* type: 'https://api.example.com/problems/out-of-credit',
|
|
166
|
+
* status: 403,
|
|
167
|
+
* title: 'You do not have enough credit',
|
|
168
|
+
* detail: 'Your balance is 30, but that costs 50.',
|
|
169
|
+
* instance: '/account/12345/messages/abc',
|
|
170
|
+
* balance: 30, // extension
|
|
171
|
+
* })
|
|
172
|
+
*
|
|
173
|
+
* // Or via the Problems convenience factory:
|
|
174
|
+
* throw Problems.forbidden({
|
|
175
|
+
* type: 'https://api.example.com/problems/out-of-credit',
|
|
176
|
+
* detail: 'Your balance is 30, but that costs 50.',
|
|
177
|
+
* balance: 30,
|
|
178
|
+
* })
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
declare class ProblemException extends HttpException {
|
|
182
|
+
readonly problem: ProblemDetails;
|
|
183
|
+
constructor(problem: ProblemDetails, headers?: Record<string, string>);
|
|
184
|
+
/** Return a new exception with `headers` shallow-merged onto this one. */
|
|
185
|
+
withHeaders(headers: Record<string, string>): ProblemException;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Convenience factories for {@link ProblemException}. Pre-fill `status`
|
|
189
|
+
* (and `title` via {@link defaultProblemTitle}) for the common HTTP
|
|
190
|
+
* codes — same shortcut set the `ctx.problem.*` response helpers cover.
|
|
191
|
+
*
|
|
192
|
+
* Lives in a separate namespace rather than as statics on
|
|
193
|
+
* {@link ProblemException} to avoid shadowing {@link HttpException}'s
|
|
194
|
+
* same-named statics, which would create a TypeScript variance
|
|
195
|
+
* conflict (parent's `notFound(message?: string)` vs the child's
|
|
196
|
+
* desired `notFound(input?: ProblemInput)`).
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```ts
|
|
200
|
+
* throw Problems.notFound({ detail: 'User abc not found' })
|
|
201
|
+
* throw Problems.tooManyRequests({}, 60) // sets Retry-After: 60
|
|
202
|
+
* throw Problems.fromZodError(zodResult.error)
|
|
203
|
+
* ```
|
|
204
|
+
*/
|
|
205
|
+
declare const Problems: {
|
|
206
|
+
/** 400 Bad Request with optional detail / instance / extensions. */readonly badRequest: (input?: Omit<ProblemDetails, 'status'>) => ProblemException; /** 401 Unauthorized. Pass a `WWW-Authenticate` challenge via the headers arg. */
|
|
207
|
+
readonly unauthorized: (input?: Omit<ProblemDetails, 'status'>, wwwAuthenticate?: string) => ProblemException; /** 403 Forbidden. */
|
|
208
|
+
readonly forbidden: (input?: Omit<ProblemDetails, 'status'>) => ProblemException; /** 404 Not Found. */
|
|
209
|
+
readonly notFound: (input?: Omit<ProblemDetails, 'status'>) => ProblemException; /** 405 Method Not Allowed. Pass the allowed methods so the Allow header is set. */
|
|
210
|
+
readonly methodNotAllowed: (allowedMethods: string[], input?: Omit<ProblemDetails, 'status'>) => ProblemException; /** 409 Conflict. */
|
|
211
|
+
readonly conflict: (input?: Omit<ProblemDetails, 'status'>) => ProblemException;
|
|
212
|
+
/**
|
|
213
|
+
* 422 Unprocessable Entity. Pass per-field issues via the `errors`
|
|
214
|
+
* extension — keep the array shape per the RFC's recommended convention
|
|
215
|
+
* (`{ field, message, code }`).
|
|
216
|
+
*/
|
|
217
|
+
readonly unprocessable: (input?: Omit<ProblemDetails, 'status'>) => ProblemException; /** 429 Too Many Requests. Pass `retryAfterSeconds` to set the Retry-After header. */
|
|
218
|
+
readonly tooManyRequests: (input?: Omit<ProblemDetails, 'status'>, retryAfterSeconds?: number) => ProblemException; /** 503 Service Unavailable. */
|
|
219
|
+
readonly serviceUnavailable: (input?: Omit<ProblemDetails, 'status'>, retryAfterSeconds?: number) => ProblemException; /** 500 Internal Server Error. */
|
|
220
|
+
readonly internal: (input?: Omit<ProblemDetails, 'status'>) => ProblemException;
|
|
221
|
+
/**
|
|
222
|
+
* Build from a Zod error — 422 with the issues serialized into the
|
|
223
|
+
* `errors` extension per RFC 9457 §3.2's array convention.
|
|
224
|
+
*/
|
|
225
|
+
readonly fromZodError: (error: any, input?: Omit<ProblemDetails, 'status'>) => ProblemException;
|
|
226
|
+
};
|
|
227
|
+
/**
|
|
228
|
+
* Normalize an RFC 9457 problem into the wire shape — fill in `type` →
|
|
229
|
+
* `'about:blank'` and `title` → IANA reason phrase. The same function is
|
|
230
|
+
* used by {@link RequestContext}'s `problem` helpers and the global
|
|
231
|
+
* error handler so the response is identical regardless of entry point.
|
|
232
|
+
*
|
|
233
|
+
* Defaults are applied **after** the spread, so a caller passing
|
|
234
|
+
* `{ type: undefined }` (e.g. a partial built up from optional fields)
|
|
235
|
+
* still gets `'about:blank'` on the wire — `...input` would otherwise
|
|
236
|
+
* re-overwrite the fallback with the explicit `undefined`.
|
|
237
|
+
*/
|
|
238
|
+
declare function normalizeProblem(input: ProblemDetails): ProblemDetails;
|
|
239
|
+
//#endregion
|
|
240
|
+
export { ProblemException as a, defaultProblemTitle as c, ProblemDetails as i, normalizeProblem as l, HttpStatus as n, Problems as o, HttpStatusCode as r, ValidationError as s, HttpException as t };
|
|
241
|
+
//# sourceMappingURL=errors-DytV77Hb.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-DytV77Hb.d.mts","names":[],"sources":["../src/core/errors.ts"],"mappings":";;;AAUA;;;;;;;;;cAAa,UAAA;EAAA,SAEX,EAAA;EAAA,SACA,OAAA;EAAA,SACA,QAAA;EAAA,SACA,UAAA;EAAA,SAGA,iBAAA;EAAA,SACA,KAAA;EAAA,SACA,YAAA;EAAA,SACA,kBAAA;EAAA,SACA,kBAAA;EAAA,SAGA,WAAA;EAAA,SACA,YAAA;EAAA,SACA,gBAAA;EAAA,SACA,SAAA;EAAA,SACA,SAAA;EAAA,SACA,kBAAA;EAAA,SACA,cAAA;EAAA,SACA,QAAA;EAAA,SACA,IAAA;EAAA,SACA,oBAAA;EAAA,SACA,iBAAA;EAAA,SAGA,qBAAA;EAAA,SACA,eAAA;E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AAA,OAAW,KAAA,GAAS,IAAA,CAAK,cAAA,gBAAiC,gBAAA;AAAA;;;;;;;;;;;;iBA0BxD,gBAAA,CAAiB,KAAA,EAAO,cAAA,GAAiB,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helmet-CaMbjzBG.d.mts","names":[],"sources":["../src/http/middleware/helmet.ts"],"mappings":";;;;UAEiB,aAAA;;EAEf,qBAAA,aAAkC,MAAM;EAFZ;EAI5B,OAAA;EAFwC;EAIxC,UAAA;EAJkC;EAMlC,IAAA;IAAiB,MAAA;IAAiB,iBAAA;IAA6B,OAAA;EAAA;EAAA;EAE/D,WAAA;EAEA;EAAA,aAAA;EAIA;EAFA,cAAA;EAES;EAAT,SAAA;AAAA;;;;;;;;;;;;iBAcc,MAAA,CAAO,OAAA,GAAS,aAAA,
|
|
1
|
+
{"version":3,"file":"helmet-CaMbjzBG.d.mts","names":[],"sources":["../src/http/middleware/helmet.ts"],"mappings":";;;;UAEiB,aAAA;;EAEf,qBAAA,aAAkC,MAAM;EAFZ;EAI5B,OAAA;EAFwC;EAIxC,UAAA;EAJkC;EAMlC,IAAA;IAAiB,MAAA;IAAiB,iBAAA;IAA6B,OAAA;EAAA;EAAA;EAE/D,WAAA;EAEA;EAAA,aAAA;EAIA;EAFA,cAAA;EAES;EAAT,SAAA;AAAA;;;;;;;;;;;;iBAcc,MAAA,CAAO,OAAA,GAAS,aAAA,IAAkB,GAAA,EAYnC,OAAA,EAAO,GAAA,EAAO,QAAA,EAAQ,IAAA,EAAQ,YAAA"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
|
|
2
|
-
import { n as ApplicationOptions, r as MiddlewareEntry, t as Application } from "../application-
|
|
2
|
+
import { n as ApplicationOptions, r as MiddlewareEntry, t as Application } from "../application-ChL6ufgq.mjs";
|
|
3
3
|
export { Application, ApplicationOptions, MiddlewareEntry };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs v5.
|
|
2
|
+
* @forinda/kickjs v5.13.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{t as Application}from"../application-
|
|
11
|
+
import{t as Application}from"../application-BTlWEKp2.mjs";export{Application};
|
package/dist/http/bootstrap.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs v5.
|
|
2
|
+
* @forinda/kickjs v5.13.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{t as bootstrap}from"../bootstrap-
|
|
11
|
+
import{t as bootstrap}from"../bootstrap-DoEPezno.mjs";export{bootstrap};
|
package/dist/http/context.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
2
|
import { t as ContextMeta } from "../execution-context-DKnt61pY.mjs";
|
|
3
|
-
import { i as RouteShape, n as DeepReadonly, r as RequestContext, t as Ctx } from "../context-
|
|
3
|
+
import { i as RouteShape, n as DeepReadonly, r as RequestContext, t as Ctx } from "../context-D7sGbb8E.mjs";
|
|
4
4
|
export { ContextMeta, Ctx, DeepReadonly, RequestContext, RouteShape };
|
package/dist/http/context.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs v5.
|
|
2
|
+
* @forinda/kickjs v5.13.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{t as RequestContext}from"../context-
|
|
11
|
+
import{t as RequestContext}from"../context-CnyTYykn.mjs";export{RequestContext};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs v5.
|
|
2
|
+
* @forinda/kickjs v5.13.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{createLogger}from"../../core/logger.mjs";import"../../core-
|
|
11
|
+
import{createLogger}from"../../core/logger.mjs";import"../../core-CGEbLIPv.mjs";import{HttpException,ProblemException,normalizeProblem}from"../../core/errors.mjs";const log=createLogger(`ErrorHandler`);function notFoundHandler(){return(_req,res,_next)=>{res.status(404).json({message:`Not Found`})}}function errorHandler(){let isProduction=process.env.NODE_ENV===`production`;return(err,req,res,_next)=>{if(res.headersSent){log.warn(`Error after headers sent: ${err?.message||`Unknown`}`);return}if(err instanceof ProblemException){if(err.problem.status>=500&&log.error(err,err.message),err.headers)for(let[k,v]of Object.entries(err.headers))res.setHeader(k,v);let body=normalizeProblem(err.problem);return res.setHeader(`Content-Type`,`application/problem+json`),res.status(body.status).json(body)}if(err?.name===`ZodError`){let firstIssue=err.issues?.[0];return res.status(422).json({message:firstIssue?.message||`Validation failed`,...isProduction?{}:{errors:err.issues}})}if(err instanceof HttpException){if(err.status>=500&&log.error(err,err.message),err.headers)for(let[k,v]of Object.entries(err.headers))res.setHeader(k,v);let exposeDetails=!isProduction&&err.details!==void 0;return res.status(err.status).json({message:err.message,...exposeDetails?{errors:err.details}:{}})}let status=err.status||err.statusCode||500;log.error(err,`${req.method} ${req.originalUrl} — ${err.message||`Unhandled error`}`);let message=status===500?`Internal Server Error`:err.message||`Error`;res.status(status).json({message})}}export{errorHandler,notFoundHandler};
|
|
12
12
|
//# sourceMappingURL=error-handler.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-handler.mjs","names":[],"sources":["../../../src/http/middleware/error-handler.ts"],"sourcesContent":["import type { Request, Response, NextFunction } from 'express'\nimport { HttpException, createLogger } from '../../core'\n\nconst log = createLogger('ErrorHandler')\n\n/** Catch-all for unmatched routes */\nexport function notFoundHandler() {\n return (_req: Request, res: Response, _next: NextFunction) => {\n res.status(404).json({ message: 'Not Found' })\n }\n}\n\n/**\n * Global error handler.\n *\n * Default behavior strips error `details` from the response in production\n * (NODE_ENV === 'production') so internal context (DB errors, validation\n * issues, custom payloads) does not leak to clients. Apps that want to\n * expose details in production — for client-facing field-level validation,\n * for example — should pass their own `onError` to `bootstrap()` and decide\n * the policy explicitly.\n */\nexport function errorHandler() {\n const isProduction = process.env.NODE_ENV === 'production'\n return (err: any, req: Request, res: Response, _next: NextFunction) => {\n // Don't write after headers are already sent\n if (res.headersSent) {\n log.warn(`Error after headers sent: ${err?.message || 'Unknown'}`)\n return\n }\n\n // Zod validation errors\n if (err?.name === 'ZodError') {\n const firstIssue = err.issues?.[0]\n return res.status(422).json({\n message: firstIssue?.message || 'Validation failed',\n ...(isProduction ? {} : { errors: err.issues }),\n })\n }\n\n // HttpException (expected application errors)\n if (err instanceof HttpException) {\n if (err.status >= 500) {\n log.error(err, err.message)\n }\n if (err.headers) {\n for (const [k, v] of Object.entries(err.headers)) {\n res.setHeader(k, v)\n }\n }\n const exposeDetails = !isProduction && err.details !== undefined\n return res.status(err.status).json({\n message: err.message,\n ...(exposeDetails ? { errors: err.details } : {}),\n })\n }\n\n // Unexpected errors — always log\n const status = err.status || err.statusCode || 500\n log.error(err, `${req.method} ${req.originalUrl} — ${err.message || 'Unhandled error'}`)\n const message = status === 500 ? 'Internal Server Error' : err.message || 'Error'\n res.status(status).json({ message })\n }\n}\n"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"error-handler.mjs","names":[],"sources":["../../../src/http/middleware/error-handler.ts"],"sourcesContent":["import type { Request, Response, NextFunction } from 'express'\nimport { HttpException, ProblemException, normalizeProblem, createLogger } from '../../core'\n\nconst log = createLogger('ErrorHandler')\n\n/** Catch-all for unmatched routes */\nexport function notFoundHandler() {\n return (_req: Request, res: Response, _next: NextFunction) => {\n res.status(404).json({ message: 'Not Found' })\n }\n}\n\n/**\n * Global error handler.\n *\n * Default behavior strips error `details` from the response in production\n * (NODE_ENV === 'production') so internal context (DB errors, validation\n * issues, custom payloads) does not leak to clients. Apps that want to\n * expose details in production — for client-facing field-level validation,\n * for example — should pass their own `onError` to `bootstrap()` and decide\n * the policy explicitly.\n *\n * {@link ProblemException} is dispatched first and emits an\n * `application/problem+json` response per RFC 9457. Plain\n * {@link HttpException} keeps the existing `{ message, errors? }` shape\n * for backward compatibility.\n */\nexport function errorHandler() {\n const isProduction = process.env.NODE_ENV === 'production'\n return (err: any, req: Request, res: Response, _next: NextFunction) => {\n // Don't write after headers are already sent\n if (res.headersSent) {\n log.warn(`Error after headers sent: ${err?.message || 'Unknown'}`)\n return\n }\n\n // RFC 9457 Problem Details — checked before HttpException because\n // ProblemException extends HttpException; instanceof on the base\n // would otherwise swallow it.\n if (err instanceof ProblemException) {\n if (err.problem.status >= 500) {\n log.error(err, err.message)\n }\n if (err.headers) {\n for (const [k, v] of Object.entries(err.headers)) {\n res.setHeader(k, v)\n }\n }\n const body = normalizeProblem(err.problem)\n res.setHeader('Content-Type', 'application/problem+json')\n return res.status(body.status).json(body)\n }\n\n // Zod validation errors\n if (err?.name === 'ZodError') {\n const firstIssue = err.issues?.[0]\n return res.status(422).json({\n message: firstIssue?.message || 'Validation failed',\n ...(isProduction ? {} : { errors: err.issues }),\n })\n }\n\n // HttpException (expected application errors)\n if (err instanceof HttpException) {\n if (err.status >= 500) {\n log.error(err, err.message)\n }\n if (err.headers) {\n for (const [k, v] of Object.entries(err.headers)) {\n res.setHeader(k, v)\n }\n }\n const exposeDetails = !isProduction && err.details !== undefined\n return res.status(err.status).json({\n message: err.message,\n ...(exposeDetails ? { errors: err.details } : {}),\n })\n }\n\n // Unexpected errors — always log\n const status = err.status || err.statusCode || 500\n log.error(err, `${req.method} ${req.originalUrl} — ${err.message || 'Unhandled error'}`)\n const message = status === 500 ? 'Internal Server Error' : err.message || 'Error'\n res.status(status).json({ message })\n }\n}\n"],"mappings":";;;;;;;;;;mKAGA,MAAM,IAAM,aAAa,cAAc,EAGvC,SAAgB,iBAAkB,CAChC,OAAQ,KAAe,IAAe,QAAwB,CAC5D,IAAI,OAAO,GAAG,EAAE,KAAK,CAAE,QAAS,WAAY,CAAC,CAC/C,CACF,CAiBA,SAAgB,cAAe,CAC7B,IAAM,aAAe,QAAQ,IAAI,WAAa,aAC9C,OAAQ,IAAU,IAAc,IAAe,QAAwB,CAErE,GAAI,IAAI,YAAa,CACnB,IAAI,KAAK,6BAA6B,KAAK,SAAW,WAAW,EACjE,MACF,CAKA,GAAI,eAAe,iBAAkB,CAInC,GAHI,IAAI,QAAQ,QAAU,KACxB,IAAI,MAAM,IAAK,IAAI,OAAO,EAExB,IAAI,QACN,IAAK,GAAM,CAAC,EAAG,KAAM,OAAO,QAAQ,IAAI,OAAO,EAC7C,IAAI,UAAU,EAAG,CAAC,EAGtB,IAAM,KAAO,iBAAiB,IAAI,OAAO,EAEzC,OADA,IAAI,UAAU,eAAgB,0BAA0B,EACjD,IAAI,OAAO,KAAK,MAAM,EAAE,KAAK,IAAI,CAC1C,CAGA,GAAI,KAAK,OAAS,WAAY,CAC5B,IAAM,WAAa,IAAI,SAAS,GAChC,OAAO,IAAI,OAAO,GAAG,EAAE,KAAK,CAC1B,QAAS,YAAY,SAAW,oBAChC,GAAI,aAAe,CAAC,EAAI,CAAE,OAAQ,IAAI,MAAO,CAC/C,CAAC,CACH,CAGA,GAAI,eAAe,cAAe,CAIhC,GAHI,IAAI,QAAU,KAChB,IAAI,MAAM,IAAK,IAAI,OAAO,EAExB,IAAI,QACN,IAAK,GAAM,CAAC,EAAG,KAAM,OAAO,QAAQ,IAAI,OAAO,EAC7C,IAAI,UAAU,EAAG,CAAC,EAGtB,IAAM,cAAgB,CAAC,cAAgB,IAAI,UAAY,IAAA,GACvD,OAAO,IAAI,OAAO,IAAI,MAAM,EAAE,KAAK,CACjC,QAAS,IAAI,QACb,GAAI,cAAgB,CAAE,OAAQ,IAAI,OAAQ,EAAI,CAAC,CACjD,CAAC,CACH,CAGA,IAAM,OAAS,IAAI,QAAU,IAAI,YAAc,IAC/C,IAAI,MAAM,IAAK,GAAG,IAAI,OAAO,GAAG,IAAI,YAAY,KAAK,IAAI,SAAW,mBAAmB,EACvF,IAAM,QAAU,SAAW,IAAM,wBAA0B,IAAI,SAAW,QAC1E,IAAI,OAAO,MAAM,EAAE,KAAK,CAAE,OAAQ,CAAC,CACrC,CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs v5.
|
|
2
|
+
* @forinda/kickjs v5.13.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{createLogger}from"../../core/logger.mjs";import"../../core-
|
|
11
|
+
import{createLogger}from"../../core/logger.mjs";import"../../core-CGEbLIPv.mjs";function requestLogger(options={}){let log=createLogger(options.name??`HTTP`),level=options.level??`info`,skip=options.skip??[];return(req,res,next)=>{if(skip.some(prefix=>req.path.startsWith(prefix)))return next();let start=Date.now();res.on(`finish`,()=>{let duration=Date.now()-start,requestId=req.requestId||req.headers[`x-request-id`]||`-`,status=res.statusCode;log[level](`${req.method} ${req.originalUrl} ${status} ${duration}ms ${requestId}`)}),next()}}export{requestLogger};
|
|
12
12
|
//# sourceMappingURL=request-logger.mjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs v5.
|
|
2
|
+
* @forinda/kickjs v5.13.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{
|
|
11
|
+
import{v as __require}from"../../container-Bq8VjG_Y.mjs";import{Logger}from"../../core/logger.mjs";import"../../core-CGEbLIPv.mjs";import{existsSync,readFileSync}from"node:fs";import{join,resolve}from"node:path";const log=Logger.for(`SpaAdapter`);var SpaAdapter=class{options;name=`SpaAdapter`;clientDir;apiPrefixes;excludePaths;cacheControl;indexCacheControl;indexHtml=null;constructor(options={}){this.options=options,this.clientDir=resolve(options.clientDir??`dist/client`),this.excludePaths=options.exclude??[],this.cacheControl=options.cacheControl??`public, max-age=31536000, immutable`,this.indexCacheControl=options.indexCacheControl??`no-cache`;let prefix=options.apiPrefix??`/api`;this.apiPrefixes=Array.isArray(prefix)?prefix:[prefix]}beforeMount({app}){if(!existsSync(this.clientDir)){log.warn(`SPA client directory not found: ${this.clientDir}`),log.warn(`Build your frontend first, or set clientDir to the correct path.`);return}let indexPath=join(this.clientDir,`index.html`);if(existsSync(indexPath))this.indexHtml=readFileSync(indexPath,`utf-8`);else{log.warn(`index.html not found in ${this.clientDir}`);return}try{let express=__require(`express`),staticOpts={};this.cacheControl&&(staticOpts.setHeaders=(res,filePath)=>{filePath.endsWith(`.html`)?res.setHeader(`Cache-Control`,this.indexCacheControl):res.setHeader(`Cache-Control`,this.cacheControl)}),app.use(express.static(this.clientDir,staticOpts))}catch{log.error(`express.static not available — SPA static file serving disabled`);return}log.debug(`Serving SPA from ${this.clientDir}`)}beforeStart({app}){this.indexHtml&&app.use((req,res,next)=>{for(let prefix of this.apiPrefixes)if(req.path.startsWith(prefix))return next();for(let path of this.excludePaths)if(req.path.startsWith(path))return next();if(req.path.includes(`.`)||req.method!==`GET`)return next();res.setHeader(`Content-Type`,`text/html`),res.setHeader(`Cache-Control`,this.indexCacheControl),res.send(this.indexHtml)})}};export{SpaAdapter};
|
|
12
12
|
//# sourceMappingURL=spa.mjs.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
|
|
2
|
-
import { a as upload, i as resolveMimeTypes, n as buildUploadMiddleware, r as cleanupFiles, t as UploadOptions } from "../../upload-
|
|
2
|
+
import { a as upload, i as resolveMimeTypes, n as buildUploadMiddleware, r as cleanupFiles, t as UploadOptions } from "../../upload-7RRWSKkI.mjs";
|
|
3
3
|
export { UploadOptions, buildUploadMiddleware, cleanupFiles, resolveMimeTypes, upload };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs v5.
|
|
2
|
+
* @forinda/kickjs v5.13.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import"../../core-
|
|
11
|
+
import"../../core-CGEbLIPv.mjs";import{HttpException,HttpStatus}from"../../core/errors.mjs";function toValidationException(error,message,useFirstIssueMessage){let issues=error.issues||[],details=issues.map(i=>({field:i.path?.join(`.`)??``,message:i.message})),finalMessage=useFirstIssueMessage?issues[0]?.message??message:message;return new HttpException(HttpStatus.UNPROCESSABLE_ENTITY,finalMessage,details)}function assignReqProperty(req,key,value){Object.defineProperty(req,key,{value,writable:!0,configurable:!0,enumerable:!0})}function validate(schema){return(req,_res,next)=>{try{if(schema.body){let result=schema.body.safeParse(req.body);if(!result.success)return next(toValidationException(result.error,`Validation failed`,!0));req.body=result.data}if(schema.query){let result=schema.query.safeParse(req.query);if(!result.success)return next(toValidationException(result.error,`Invalid query parameters`,!1));assignReqProperty(req,`query`,result.data)}if(schema.params){let result=schema.params.safeParse(req.params);if(!result.success)return next(toValidationException(result.error,`Invalid path parameters`,!1));assignReqProperty(req,`params`,result.data)}next()}catch(err){next(err)}}}export{validate};
|
|
12
12
|
//# sourceMappingURL=validate.mjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs v5.
|
|
2
|
+
* @forinda/kickjs v5.13.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{Logger}from"../../core/logger.mjs";import{n as defineAdapter}from"../../core-
|
|
11
|
+
import{Logger}from"../../core/logger.mjs";import{n as defineAdapter}from"../../core-CGEbLIPv.mjs";import{resolve}from"node:path";const log=Logger.for(`ViewEngine`),ViewAdapter=defineAdapter({name:`ViewAdapter`,build:options=>({beforeMount({app}){let{engine,ext,viewsDir=`src/views`}=options;engine.__express?app.engine(ext,engine.__express):typeof engine.renderFile==`function`?app.engine(ext,(path,opts,callback)=>{engine.renderFile(path,opts,callback)}):(typeof engine==`function`||log.warn(`Engine for .${ext} does not have __express or renderFile. Trying as-is.`),app.engine(ext,engine)),app.set(`view engine`,ext),app.set(`views`,resolve(viewsDir)),log.debug(`View engine: ${ext} (${resolve(viewsDir)})`)}})});export{ViewAdapter};
|
|
12
12
|
//# sourceMappingURL=views.mjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs v5.
|
|
2
|
+
* @forinda/kickjs v5.13.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,4 +8,4 @@
|
|
|
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-NrahUI9e.mjs";export{FILTER_OPERATORS,buildQueryParams,parseFilters,parsePagination,parseQuery,parseSearchQuery,parseSort};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
|
|
2
|
-
import { n as _setExternalContributorSources, r as buildRoutes, t as BuildRoutesOptions } from "../router-builder-
|
|
2
|
+
import { n as _setExternalContributorSources, r as buildRoutes, t as BuildRoutesOptions } from "../router-builder-CSAOc9MR.mjs";
|
|
3
3
|
export { BuildRoutesOptions, _setExternalContributorSources, buildRoutes };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs v5.
|
|
2
|
+
* @forinda/kickjs v5.13.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{t as Container}from"../container-
|
|
11
|
+
import{t as Container}from"../container-Bq8VjG_Y.mjs";import{METADATA}from"../core/interfaces.mjs";import{a as getMethodMeta,o as getMethodMetaOrUndefined,t as getClassMeta}from"../metadata-pbYET01G.mjs";import{c as runContributors,l as buildPipeline}from"../core-CGEbLIPv.mjs";import{t as RequestContext}from"../context-CnyTYykn.mjs";import{validate}from"./middleware/validate.mjs";import{buildUploadMiddleware}from"./middleware/upload.mjs";import{Router}from"express";let _externalContributorSources=[];function _setExternalContributorSources(sources){_externalContributorSources=sources}function buildRoutes(controllerClass,options={}){let router=Router(),container=Container.getInstance(),externalSources=options.externalSources??_externalContributorSources,routes=getClassMeta(METADATA.ROUTES,controllerClass,[]),classMiddlewares=getClassMeta(METADATA.CLASS_MIDDLEWARES,controllerClass,[]),classContributors=getClassMeta(METADATA.CLASS_CONTRIBUTORS,controllerClass,[]);for(let route of routes){let method=route.method.toLowerCase(),fullPath=route.path||`/`,methodMiddlewares=getMethodMeta(METADATA.METHOD_MIDDLEWARES,controllerClass,route.handlerName,[]),handlers=[];route.validation&&handlers.push(validate(route.validation));let fileUploadConfig=getMethodMetaOrUndefined(METADATA.FILE_UPLOAD,controllerClass,route.handlerName);fileUploadConfig&&handlers.push(buildUploadMiddleware(fileUploadConfig));for(let mw of[...classMiddlewares,...methodMiddlewares])handlers.push((req,res,next)=>{let ctx=new RequestContext(req,res,next);Promise.resolve(mw(ctx,next)).catch(next)});let methodContributors=getMethodMeta(METADATA.METHOD_CONTRIBUTORS,controllerClass,route.handlerName,[]);if(classContributors.length>0||methodContributors.length>0||externalSources.length>0){let pipeline=buildPipeline([...methodContributors.map((registration,i)=>({source:`method`,registration,label:`${controllerClass.name}.${String(route.handlerName)}#${i}(${registration.key})`})),...classContributors.map((registration,i)=>({source:`class`,registration,label:`${controllerClass.name}.@class#${i}(${registration.key})`})),...externalSources],{route:`${route.method.toUpperCase()} ${fullPath}`});handlers.push(async(req,res,next)=>{let ctx=new RequestContext(req,res,next);try{await runContributors({pipeline,ctx,container}),next()}catch(err){next(err)}})}handlers.push(async(req,res,next)=>{let ctx=new RequestContext(req,res,next);try{await container.resolve(controllerClass)[route.handlerName](ctx)}catch(err){next(err)}}),router[method](fullPath,...handlers)}return router}export{_setExternalContributorSources,buildRoutes};
|
|
12
12
|
//# sourceMappingURL=router-builder.mjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { p as EnvKey } from "./decorators-
|
|
2
|
+
import { p as EnvKey } from "./decorators-KbaPUBXd.mjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
|
|
5
5
|
//#region src/config/env.d.ts
|
|
@@ -10,8 +10,8 @@ import { z } from "zod";
|
|
|
10
10
|
declare const baseEnvSchema: z.ZodObject<{
|
|
11
11
|
PORT: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
12
12
|
NODE_ENV: z.ZodDefault<z.ZodEnum<{
|
|
13
|
-
production: "production";
|
|
14
13
|
development: "development";
|
|
14
|
+
production: "production";
|
|
15
15
|
test: "test";
|
|
16
16
|
}>>;
|
|
17
17
|
LOG_LEVEL: z.ZodDefault<z.ZodString>;
|
|
@@ -238,8 +238,8 @@ interface TypedConfigService<TEnv extends Record<string, any>> {
|
|
|
238
238
|
* ```
|
|
239
239
|
*/
|
|
240
240
|
declare function createConfigService<T extends z.ZodObject<any>>(schema: T): {
|
|
241
|
-
new (): TypedConfigService<z.
|
|
241
|
+
new (): TypedConfigService<z.TypeOf<T>>;
|
|
242
242
|
};
|
|
243
243
|
//#endregion
|
|
244
244
|
export { baseEnvSchema as a, loadEnv as c, Env as i, reloadEnv as l, TypedConfigService as n, defineEnv as o, createConfigService as r, getEnv as s, ConfigService as t, resetEnvCache as u };
|
|
245
|
-
//# sourceMappingURL=index-
|
|
245
|
+
//# sourceMappingURL=index-BM32LMqZ.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-BM32LMqZ.d.mts","names":[],"sources":["../src/config/env.ts","../src/config/config-service.ts"],"mappings":";;;;;;;AAsCA;;cAAa,aAAA,EAAa,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyC1B;;;iBAAgB,SAAA,WAAoB,CAAA,CAAE,WAAA,CAAA,CACpC,MAAA,GAAS,IAAA,SAAa,aAAA,KAAkB,CAAA,CAAE,SAAA,CAAU,CAAA,IACnD,CAAA,CAAE,SAAA,QAAiB,aAAA,CAAc,KAAA,GAAQ,CAAA;;;;;;;;;;;;;;;;;;;;;;;;iBA+B5B,OAAA,WAAkB,CAAA,CAAE,SAAA,MAAA,CAAgB,MAAA,EAAQ,CAAA,GAAI,CAAA,CAAE,KAAA,CAAM,CAAA;AAAA,iBACxD,OAAA,CAAA,IAAY,MAAA,oBAA0B,GAAA,GAAM,OAAA;;;;;;;;;;;;;;;;;;AADa;AACzE;;;iBAqCgB,MAAA,WAAiB,MAAA,CAAA,CAAQ,GAAA,EAAK,CAAA,GAAI,OAAA,CAAQ,CAAA;AAAA,iBAC1C,MAAA,WAAiB,CAAA,CAAE,SAAA,gCAAyC,CAAA,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