stratal 0.0.18 → 0.0.19
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 +8 -8
- package/dist/{base-email.provider-Cuw4OAB0.mjs → base-email.provider-mjynzewK.mjs} +1 -1
- package/dist/{base-email.provider-Cuw4OAB0.mjs.map → base-email.provider-mjynzewK.mjs.map} +1 -1
- package/dist/bin/cloudflare-workers-loader.mjs.map +1 -1
- package/dist/bin/quarry.mjs +21 -36
- package/dist/bin/quarry.mjs.map +1 -1
- package/dist/cache/index.d.mts +3 -2
- package/dist/cache/index.d.mts.map +1 -1
- package/dist/cache/index.mjs +3 -3
- package/dist/{colors-BTAnQRGU.mjs → colors-DJaRDXoS.mjs} +1 -1
- package/dist/{colors-BTAnQRGU.mjs.map → colors-DJaRDXoS.mjs.map} +1 -1
- package/dist/{command-DjGqCYHv.mjs → command-BgSlsS4M.mjs} +2 -2
- package/dist/{command-DjGqCYHv.mjs.map → command-BgSlsS4M.mjs.map} +1 -1
- package/dist/{command-B1YuV-UZ.d.mts → command-DsQq56Lp.d.mts} +2 -2
- package/dist/{command-B1YuV-UZ.d.mts.map → command-DsQq56Lp.d.mts.map} +1 -1
- package/dist/config/index.d.mts +81 -37
- package/dist/config/index.d.mts.map +1 -1
- package/dist/config/index.mjs +126 -45
- package/dist/config/index.mjs.map +1 -1
- package/dist/{consumer-registry-BkuHXR_u.d.mts → consumer-registry-Doom7BEh.d.mts} +1 -1
- package/dist/{consumer-registry-BkuHXR_u.d.mts.map → consumer-registry-Doom7BEh.d.mts.map} +1 -1
- package/dist/controller.decorator-LZY9aHYG.mjs +66 -0
- package/dist/controller.decorator-LZY9aHYG.mjs.map +1 -0
- package/dist/cron/index.d.mts +4 -3
- package/dist/cron/index.d.mts.map +1 -1
- package/dist/cron/index.mjs +1 -1
- package/dist/{cron-manager-1KnZvojs.mjs → cron-manager-C30t9UZM.mjs} +29 -19
- package/dist/cron-manager-C30t9UZM.mjs.map +1 -0
- package/dist/{cron-manager-BnEZquBL.d.mts → cron-manager-RuPtFVLy.d.mts} +27 -13
- package/dist/cron-manager-RuPtFVLy.d.mts.map +1 -0
- package/dist/di/index.d.mts +1 -1
- package/dist/di/index.mjs +2 -2
- package/dist/email/index.d.mts +3 -3
- package/dist/email/index.mjs +87 -10
- package/dist/email/index.mjs.map +1 -1
- package/dist/{en-3QnZwP-u.mjs → en-rHmW6vD9.mjs} +5 -31
- package/dist/en-rHmW6vD9.mjs.map +1 -0
- package/dist/env-CamWD-U1.d.mts +25 -0
- package/dist/env-CamWD-U1.d.mts.map +1 -0
- package/dist/errors/index.d.mts +1 -1
- package/dist/errors/index.mjs +1 -1
- package/dist/{errors--RBIvDXr.mjs → errors-B4pYgYON.mjs} +161 -7
- package/dist/errors-B4pYgYON.mjs.map +1 -0
- package/dist/{errors-B7hCnXgB.mjs → errors-BUyUfr2Z.mjs} +14 -7
- package/dist/errors-BUyUfr2Z.mjs.map +1 -0
- package/dist/events/index.d.mts +2 -2
- package/dist/events/index.mjs +1 -1
- package/dist/{events-UTJliZhl.mjs → events-COKixqnG.mjs} +2 -2
- package/dist/{events-UTJliZhl.mjs.map → events-COKixqnG.mjs.map} +1 -1
- package/dist/{gateway-context-BdBFoQd8.mjs → gateway-context-cqZ8wMoi.mjs} +4 -65
- package/dist/gateway-context-cqZ8wMoi.mjs.map +1 -0
- package/dist/guards/index.d.mts +14 -5
- package/dist/guards/index.d.mts.map +1 -1
- package/dist/guards/index.mjs +1 -1
- package/dist/{guards-MtDgcHnF.mjs → guards-DMbsAxSX.mjs} +1 -1
- package/dist/guards-DMbsAxSX.mjs.map +1 -0
- package/dist/http-method.decorator-BT3ufnz8.mjs +96 -0
- package/dist/http-method.decorator-BT3ufnz8.mjs.map +1 -0
- package/dist/i18n/index.d.mts +3 -3
- package/dist/i18n/index.mjs +2 -2
- package/dist/i18n/messages/en/index.d.mts +1 -1
- package/dist/i18n/messages/en/index.mjs +1 -1
- package/dist/i18n/utils/index.mjs +1 -1
- package/dist/i18n/validation/index.d.mts +1 -1
- package/dist/i18n/validation/index.mjs +1 -1
- package/dist/{i18n.module-BpLLLCTg.mjs → i18n.module-CI_prYFD.mjs} +74 -196
- package/dist/i18n.module-CI_prYFD.mjs.map +1 -0
- package/dist/{index-Dfpd_ypO.d.mts → index-B437eK7p.d.mts} +26 -12
- package/dist/index-B437eK7p.d.mts.map +1 -0
- package/dist/{index-BR23zDMy.d.mts → index-CWRS7Ri3.d.mts} +1 -1
- package/dist/{index-BR23zDMy.d.mts.map → index-CWRS7Ri3.d.mts.map} +1 -1
- package/dist/{index-BDh9J2KD.d.mts → index-DFhEeFfC.d.mts} +4 -30
- package/dist/{index-BDh9J2KD.d.mts.map → index-DFhEeFfC.d.mts.map} +1 -1
- package/dist/{index-BrmS34sa.d.mts → index-DPFqRs8L.d.mts} +70 -39
- package/dist/index-DPFqRs8L.d.mts.map +1 -0
- package/dist/{index-DPxmo6AY.d.mts → index-Dnqm9ZB6.d.mts} +5 -4
- package/dist/index-Dnqm9ZB6.d.mts.map +1 -0
- package/dist/index-SHx31sBJ.d.mts +101 -0
- package/dist/index-SHx31sBJ.d.mts.map +1 -0
- package/dist/index.d.mts +3 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{is-command-PvULqiTa.mjs → is-command-C6a7WTPw.mjs} +2 -2
- package/dist/{is-command-PvULqiTa.mjs.map → is-command-C6a7WTPw.mjs.map} +1 -1
- package/dist/{is-seeder-BN9Ej1r7.mjs → is-seeder-CebjZCDn.mjs} +1 -1
- package/dist/{is-seeder-BN9Ej1r7.mjs.map → is-seeder-CebjZCDn.mjs.map} +1 -1
- package/dist/logger/index.d.mts +1 -1
- package/dist/logger/index.mjs +1 -1
- package/dist/{logger-c0ftIK4G.mjs → logger-V6Ms3QnQ.mjs} +38 -20
- package/dist/{logger-c0ftIK4G.mjs.map → logger-V6Ms3QnQ.mjs.map} +1 -1
- package/dist/macroable/index.d.mts +2 -0
- package/dist/macroable/index.mjs +2 -0
- package/dist/macroable-BmufBshB.mjs +122 -0
- package/dist/macroable-BmufBshB.mjs.map +1 -0
- package/dist/module/index.d.mts +2 -2
- package/dist/module/index.mjs +1 -1
- package/dist/{module-C3YZ-kZN.mjs → module-qGE_1duv.mjs} +31 -18
- package/dist/module-qGE_1duv.mjs.map +1 -0
- package/dist/openapi/index.d.mts +3 -3
- package/dist/openapi/index.mjs +2 -2
- package/dist/{openapi-tools.service-B77QXD56.mjs → openapi-tools.service-CYWGuhue.mjs} +4 -1
- package/dist/{openapi-tools.service-B77QXD56.mjs.map → openapi-tools.service-CYWGuhue.mjs.map} +1 -1
- package/dist/{openapi.service-6yj0BUY4.d.mts → openapi.service-Bv_NioM9.d.mts} +3 -3
- package/dist/{openapi.service-6yj0BUY4.d.mts.map → openapi.service-Bv_NioM9.d.mts.map} +1 -1
- package/dist/quarry/index.d.mts +7 -7
- package/dist/quarry/index.d.mts.map +1 -1
- package/dist/quarry/index.mjs +4 -4
- package/dist/{quarry-registry-CQCIlYTO.mjs → quarry-registry-DFfRRkA7.mjs} +17 -15
- package/dist/quarry-registry-DFfRRkA7.mjs.map +1 -0
- package/dist/queue/index.d.mts +2 -2
- package/dist/queue/index.mjs +2 -2
- package/dist/{queue.module-DIjD6nr-.mjs → queue.module-P-G-nCYz.mjs} +4 -4
- package/dist/{queue.module-DIjD6nr-.mjs.map → queue.module-P-G-nCYz.mjs.map} +1 -1
- package/dist/r2-storage.provider-LdzK9tfG.mjs +244 -0
- package/dist/r2-storage.provider-LdzK9tfG.mjs.map +1 -0
- package/dist/{resend.provider-Bvw36rQy.mjs → resend.provider-bwILp0WI.mjs} +2 -2
- package/dist/{resend.provider-Bvw36rQy.mjs.map → resend.provider-bwILp0WI.mjs.map} +1 -1
- package/dist/router/index.d.mts +2 -2
- package/dist/router/index.mjs +7 -5
- package/dist/seeder/index.d.mts +3 -3
- package/dist/seeder/index.mjs +2 -2
- package/dist/{seeder-D7VXULXB.mjs → seeder-BcqIFa2X.mjs} +5 -5
- package/dist/{seeder-D7VXULXB.mjs.map → seeder-BcqIFa2X.mjs.map} +1 -1
- package/dist/{setup-BRIN-iYT.mjs → setup-CtekcwuO.mjs} +1 -1
- package/dist/{setup-BRIN-iYT.mjs.map → setup-CtekcwuO.mjs.map} +1 -1
- package/dist/signed-url-COX7cCWR.mjs +74 -0
- package/dist/signed-url-COX7cCWR.mjs.map +1 -0
- package/dist/{smtp.provider-CAwpvzvD.mjs → smtp.provider-B07yuARi.mjs} +2 -2
- package/dist/{smtp.provider-CAwpvzvD.mjs.map → smtp.provider-B07yuARi.mjs.map} +1 -1
- package/dist/storage/index.d.mts +39 -17
- package/dist/storage/index.d.mts.map +1 -1
- package/dist/storage/index.mjs +3 -3
- package/dist/storage/providers/index.d.mts +30 -70
- package/dist/storage/providers/index.d.mts.map +1 -1
- package/dist/storage/providers/index.mjs +2 -2
- package/dist/{storage-CJ-QOwNv.mjs → storage-P6X4h9So.mjs} +101 -27
- package/dist/storage-P6X4h9So.mjs.map +1 -0
- package/dist/{storage-provider.interface-YRtyYBxV.d.mts → storage-provider.interface-CC1nniHk.d.mts} +20 -21
- package/dist/storage-provider.interface-CC1nniHk.d.mts.map +1 -0
- package/dist/{stratal-B7G4i9-N.mjs → stratal-BCiwCFN9.mjs} +57 -26
- package/dist/stratal-BCiwCFN9.mjs.map +1 -0
- package/dist/{types-CN0zONAZ.d.mts → types-DIWemRad.d.mts} +1 -1
- package/dist/types-DIWemRad.d.mts.map +1 -0
- package/dist/{usage-generator-Cl1HPlUp.mjs → usage-generator-MBcRo0Q2.mjs} +2 -2
- package/dist/{usage-generator-Cl1HPlUp.mjs.map → usage-generator-MBcRo0Q2.mjs.map} +1 -1
- package/dist/{validation-B4bePOa_.mjs → validation-Dbg3ehdP.mjs} +1 -1
- package/dist/{validation-B4bePOa_.mjs.map → validation-Dbg3ehdP.mjs.map} +1 -1
- package/dist/websocket/index.d.mts +3 -3
- package/dist/websocket/index.mjs +1 -1
- package/dist/workers/index.d.mts +2 -1
- package/dist/workers/index.d.mts.map +1 -1
- package/dist/workers/index.mjs +2 -2
- package/package.json +27 -39
- package/dist/cron-manager-1KnZvojs.mjs.map +0 -1
- package/dist/cron-manager-BnEZquBL.d.mts.map +0 -1
- package/dist/en-3QnZwP-u.mjs.map +0 -1
- package/dist/errors--RBIvDXr.mjs.map +0 -1
- package/dist/errors-B7hCnXgB.mjs.map +0 -1
- package/dist/gateway-context-BdBFoQd8.mjs.map +0 -1
- package/dist/guards-MtDgcHnF.mjs.map +0 -1
- package/dist/i18n.module-BpLLLCTg.mjs.map +0 -1
- package/dist/index-BrmS34sa.d.mts.map +0 -1
- package/dist/index-DPxmo6AY.d.mts.map +0 -1
- package/dist/index-Dfpd_ypO.d.mts.map +0 -1
- package/dist/module-C3YZ-kZN.mjs.map +0 -1
- package/dist/quarry-registry-CQCIlYTO.mjs.map +0 -1
- package/dist/s3-storage.provider-BAhHDMI3.mjs +0 -343
- package/dist/s3-storage.provider-BAhHDMI3.mjs.map +0 -1
- package/dist/storage-CJ-QOwNv.mjs.map +0 -1
- package/dist/storage-provider.interface-YRtyYBxV.d.mts.map +0 -1
- package/dist/stratal-B7G4i9-N.mjs.map +0 -1
- package/dist/types-CN0zONAZ.d.mts.map +0 -1
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { f as ROUTE_METADATA_KEYS } from "./errors-B4pYgYON.mjs";
|
|
2
|
+
import { i as z } from "./validation-Dbg3ehdP.mjs";
|
|
3
|
+
//#region src/router/decorators/http-method.decorator.ts
|
|
4
|
+
/**
|
|
5
|
+
* Creates an HTTP method decorator factory for the given HTTP method.
|
|
6
|
+
*
|
|
7
|
+
* The returned decorator stores {@link ExplicitRouteMetadata} on the method and
|
|
8
|
+
* tracks the method name under {@link ROUTE_METADATA_KEYS.DECORATED_METHODS}
|
|
9
|
+
* on the controller prototype so they can be discovered at registration time.
|
|
10
|
+
*/
|
|
11
|
+
function createHttpMethodDecorator(method) {
|
|
12
|
+
return function(path, config) {
|
|
13
|
+
return function(target, propertyKey, descriptor) {
|
|
14
|
+
const metadata = {
|
|
15
|
+
type: "explicit",
|
|
16
|
+
method,
|
|
17
|
+
path,
|
|
18
|
+
config: config ?? { response: z.any() }
|
|
19
|
+
};
|
|
20
|
+
Reflect.defineMetadata(ROUTE_METADATA_KEYS.ROUTE_CONFIG, metadata, target, propertyKey);
|
|
21
|
+
const existing = Reflect.getOwnMetadata(ROUTE_METADATA_KEYS.DECORATED_METHODS, target) ?? [];
|
|
22
|
+
existing.push(propertyKey);
|
|
23
|
+
Reflect.defineMetadata(ROUTE_METADATA_KEYS.DECORATED_METHODS, existing, target);
|
|
24
|
+
return descriptor;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Registers a GET route on the controller method.
|
|
30
|
+
*
|
|
31
|
+
* @param path - Route path relative to the controller base path
|
|
32
|
+
* @param config - Optional route configuration (response schema, body, params, etc.)
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* @Controller('/api/v1/users')
|
|
37
|
+
* class UsersController {
|
|
38
|
+
* @Get('/', { response: z.array(userSchema), summary: 'List users' })
|
|
39
|
+
* async list(ctx: RouterContext) { ... }
|
|
40
|
+
*
|
|
41
|
+
* @Get('/:id', { params: z.object({ id: z.string().uuid() }), response: userSchema })
|
|
42
|
+
* async getUser(ctx: RouterContext) { ... }
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
const Get = createHttpMethodDecorator("get");
|
|
47
|
+
/**
|
|
48
|
+
* Registers a POST route on the controller method.
|
|
49
|
+
*
|
|
50
|
+
* @param path - Route path relative to the controller base path
|
|
51
|
+
* @param config - Optional route configuration (response schema, body, params, etc.)
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* @Controller('/api/v1/users')
|
|
56
|
+
* class UsersController {
|
|
57
|
+
* @Post('/', { body: createUserSchema, response: userSchema, statusCode: 201 })
|
|
58
|
+
* async createUser(ctx: RouterContext) { ... }
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
const Post = createHttpMethodDecorator("post");
|
|
63
|
+
/**
|
|
64
|
+
* Registers a PUT route on the controller method.
|
|
65
|
+
*
|
|
66
|
+
* @param path - Route path relative to the controller base path
|
|
67
|
+
* @param config - Optional route configuration
|
|
68
|
+
*/
|
|
69
|
+
const Put = createHttpMethodDecorator("put");
|
|
70
|
+
/**
|
|
71
|
+
* Registers a PATCH route on the controller method.
|
|
72
|
+
*
|
|
73
|
+
* @param path - Route path relative to the controller base path
|
|
74
|
+
* @param config - Optional route configuration
|
|
75
|
+
*/
|
|
76
|
+
const Patch = createHttpMethodDecorator("patch");
|
|
77
|
+
/**
|
|
78
|
+
* Registers a DELETE route on the controller method.
|
|
79
|
+
*
|
|
80
|
+
* @param path - Route path relative to the controller base path
|
|
81
|
+
* @param config - Optional route configuration
|
|
82
|
+
*/
|
|
83
|
+
const Delete = createHttpMethodDecorator("delete");
|
|
84
|
+
/**
|
|
85
|
+
* Registers an ALL (any HTTP method) route on the controller method.
|
|
86
|
+
* Routes using @All are registered without OpenAPI validation
|
|
87
|
+
* since OpenAPI does not support a catch-all HTTP method.
|
|
88
|
+
*
|
|
89
|
+
* @param path - Route path relative to the controller base path
|
|
90
|
+
* @param config - Optional route configuration
|
|
91
|
+
*/
|
|
92
|
+
const All = createHttpMethodDecorator("all");
|
|
93
|
+
//#endregion
|
|
94
|
+
export { Post as a, Patch as i, Delete as n, Put as o, Get as r, All as t };
|
|
95
|
+
|
|
96
|
+
//# sourceMappingURL=http-method.decorator-BT3ufnz8.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-method.decorator-BT3ufnz8.mjs","names":[],"sources":["../src/router/decorators/http-method.decorator.ts"],"sourcesContent":["import { z } from '../../i18n/validation'\nimport { ROUTE_METADATA_KEYS } from '../constants'\nimport type { ExplicitRouteMetadata, HttpMethod, RouteConfig } from '../types'\n\n/**\n * Creates an HTTP method decorator factory for the given HTTP method.\n *\n * The returned decorator stores {@link ExplicitRouteMetadata} on the method and\n * tracks the method name under {@link ROUTE_METADATA_KEYS.DECORATED_METHODS}\n * on the controller prototype so they can be discovered at registration time.\n */\nfunction createHttpMethodDecorator(method: HttpMethod) {\n return function (path: string, config?: RouteConfig) {\n return function (\n target: object,\n propertyKey: string,\n descriptor: PropertyDescriptor\n ) {\n const metadata: ExplicitRouteMetadata = {\n type: 'explicit',\n method,\n path,\n config: config ?? { response: z.any() },\n }\n\n Reflect.defineMetadata(\n ROUTE_METADATA_KEYS.ROUTE_CONFIG,\n metadata,\n target,\n propertyKey\n )\n\n // Track this method as decorated on the prototype\n const existing: string[] =\n (Reflect.getOwnMetadata(ROUTE_METADATA_KEYS.DECORATED_METHODS, target) as string[] | undefined) ?? []\n existing.push(propertyKey)\n Reflect.defineMetadata(ROUTE_METADATA_KEYS.DECORATED_METHODS, existing, target)\n\n return descriptor\n }\n }\n}\n\n/**\n * Registers a GET route on the controller method.\n *\n * @param path - Route path relative to the controller base path\n * @param config - Optional route configuration (response schema, body, params, etc.)\n *\n * @example\n * ```typescript\n * @Controller('/api/v1/users')\n * class UsersController {\n * @Get('/', { response: z.array(userSchema), summary: 'List users' })\n * async list(ctx: RouterContext) { ... }\n *\n * @Get('/:id', { params: z.object({ id: z.string().uuid() }), response: userSchema })\n * async getUser(ctx: RouterContext) { ... }\n * }\n * ```\n */\nexport const Get = createHttpMethodDecorator('get')\n\n/**\n * Registers a POST route on the controller method.\n *\n * @param path - Route path relative to the controller base path\n * @param config - Optional route configuration (response schema, body, params, etc.)\n *\n * @example\n * ```typescript\n * @Controller('/api/v1/users')\n * class UsersController {\n * @Post('/', { body: createUserSchema, response: userSchema, statusCode: 201 })\n * async createUser(ctx: RouterContext) { ... }\n * }\n * ```\n */\nexport const Post = createHttpMethodDecorator('post')\n\n/**\n * Registers a PUT route on the controller method.\n *\n * @param path - Route path relative to the controller base path\n * @param config - Optional route configuration\n */\nexport const Put = createHttpMethodDecorator('put')\n\n/**\n * Registers a PATCH route on the controller method.\n *\n * @param path - Route path relative to the controller base path\n * @param config - Optional route configuration\n */\nexport const Patch = createHttpMethodDecorator('patch')\n\n/**\n * Registers a DELETE route on the controller method.\n *\n * @param path - Route path relative to the controller base path\n * @param config - Optional route configuration\n */\nexport const Delete = createHttpMethodDecorator('delete')\n\n/**\n * Registers an ALL (any HTTP method) route on the controller method.\n * Routes using @All are registered without OpenAPI validation\n * since OpenAPI does not support a catch-all HTTP method.\n *\n * @param path - Route path relative to the controller base path\n * @param config - Optional route configuration\n */\nexport const All = createHttpMethodDecorator('all')\n"],"mappings":";;;;;;;;;;AAWA,SAAS,0BAA0B,QAAoB;AACrD,QAAO,SAAU,MAAc,QAAsB;AACnD,SAAO,SACL,QACA,aACA,YACA;GACA,MAAM,WAAkC;IACtC,MAAM;IACN;IACA;IACA,QAAQ,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE;IACxC;AAED,WAAQ,eACN,oBAAoB,cACpB,UACA,QACA,YACD;GAGD,MAAM,WACH,QAAQ,eAAe,oBAAoB,mBAAmB,OAAO,IAA6B,EAAE;AACvG,YAAS,KAAK,YAAY;AAC1B,WAAQ,eAAe,oBAAoB,mBAAmB,UAAU,OAAO;AAE/E,UAAO;;;;;;;;;;;;;;;;;;;;;;AAuBb,MAAa,MAAM,0BAA0B,MAAM;;;;;;;;;;;;;;;;AAiBnD,MAAa,OAAO,0BAA0B,OAAO;;;;;;;AAQrD,MAAa,MAAM,0BAA0B,MAAM;;;;;;;AAQnD,MAAa,QAAQ,0BAA0B,QAAQ;;;;;;;AAQvD,MAAa,SAAS,0BAA0B,SAAS;;;;;;;;;AAUzD,MAAa,MAAM,0BAA0B,MAAM"}
|
package/dist/i18n/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as LocaleNotSupportedError, C as DetectionStrategy, D as buildDetectorOptions, E as ResolvedI18nOptions, O as resolveI18nOptions, S as I18nModule, T as LanguageDetectionOptions, _ as Messages, b as messages, g as MessageRegistry, h as MessageLoaderService, k as TranslationMissingError, m as I18nContextMiddleware, v as getLocales, w as I18nModuleOptions, x as I18N_TOKENS, y as getMessages } from "../index-
|
|
2
|
-
import {
|
|
3
|
-
export { AppMessageKeys, AppMessages, DeepKeys, DetectionStrategy, I18N_TOKENS, I18nContextMiddleware, I18nModule, I18nModuleOptions, II18nService, LanguageDetectionOptions, LocaleNotSupportedError, MessageKeyPrefix, MessageKeys, MessageLoaderService, MessageParams, MessageRegistry, Messages, Prefixes, ResolvedI18nOptions, SystemMessageKeys, TranslationMissingError, buildDetectorOptions, getLocales, getMessages, messages, resolveI18nOptions };
|
|
1
|
+
import { A as LocaleNotSupportedError, C as DetectionStrategy, D as buildDetectorOptions, E as ResolvedI18nOptions, O as resolveI18nOptions, S as I18nModule, T as LanguageDetectionOptions, _ as Messages, b as messages, g as MessageRegistry, h as MessageLoaderService, k as TranslationMissingError, m as I18nContextMiddleware, v as getLocales, w as I18nModuleOptions, x as I18N_TOKENS, y as getMessages } from "../index-DPFqRs8L.mjs";
|
|
2
|
+
import { C as SystemMessageKeys, S as Prefixes, _ as DeepKeys, b as MessageKeys, g as AppMessages, h as AppMessageNamespaces, m as AppMessageKeys, v as II18nService, x as MessageParams, y as MessageKeyPrefix } from "../index-B437eK7p.mjs";
|
|
3
|
+
export { AppMessageKeys, AppMessageNamespaces, AppMessages, DeepKeys, DetectionStrategy, I18N_TOKENS, I18nContextMiddleware, I18nModule, I18nModuleOptions, II18nService, LanguageDetectionOptions, LocaleNotSupportedError, MessageKeyPrefix, MessageKeys, MessageLoaderService, MessageParams, MessageRegistry, Messages, Prefixes, ResolvedI18nOptions, SystemMessageKeys, TranslationMissingError, buildDetectorOptions, getLocales, getMessages, messages, resolveI18nOptions };
|
package/dist/i18n/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { w as I18N_TOKENS } from "../errors
|
|
2
|
-
import { B as
|
|
1
|
+
import { w as I18N_TOKENS } from "../errors-B4pYgYON.mjs";
|
|
2
|
+
import { B as LocaleNotSupportedError, F as getMessages, H as I18nContextMiddleware, I as messages, L as buildDetectorOptions, M as MessageRegistry, N as MessageLoaderService, P as getLocales, R as resolveI18nOptions, t as I18nModule, z as TranslationMissingError } from "../i18n.module-CI_prYFD.mjs";
|
|
3
3
|
export { I18N_TOKENS, I18nContextMiddleware, I18nModule, LocaleNotSupportedError, MessageLoaderService, MessageRegistry, TranslationMissingError, buildDetectorOptions, getLocales, getMessages, messages, resolveI18nOptions };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as errors, i as emails, n as zodI18n, o as common, r as validation } from "../../../index-
|
|
1
|
+
import { a as errors, i as emails, n as zodI18n, o as common, r as validation } from "../../../index-DFhEeFfC.mjs";
|
|
2
2
|
export { common, emails, errors, validation, zodI18n };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as errors, i as emails, n as zodI18n, o as common, r as validation } from "../../../en-
|
|
1
|
+
import { a as errors, i as emails, n as zodI18n, o as common, r as validation } from "../../../en-rHmW6vD9.mjs";
|
|
2
2
|
export { common, emails, errors, validation, zodI18n };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as setupI18nCompiler } from "../../setup-
|
|
1
|
+
import { t as setupI18nCompiler } from "../../setup-CtekcwuO.mjs";
|
|
2
2
|
export { setupI18nCompiler };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as runWithErrorMapContext, d as LocaleProvider, f as ZodCustomIssue, i as ZodError, l as ErrorMapContext, n as OpenAPIObject, o as z, p as withI18n, r as PathItemObject, s as backendErrorMap, t as OpenAPIHono, u as I18nErrorMetadata } from "../../index-
|
|
1
|
+
import { c as runWithErrorMapContext, d as LocaleProvider, f as ZodCustomIssue, i as ZodError, l as ErrorMapContext, n as OpenAPIObject, o as z, p as withI18n, r as PathItemObject, s as backendErrorMap, t as OpenAPIHono, u as I18nErrorMetadata } from "../../index-B437eK7p.mjs";
|
|
2
2
|
export * from "@hono/zod-openapi";
|
|
3
3
|
export * from "zod";
|
|
4
4
|
export { ErrorMapContext, I18nErrorMetadata, LocaleProvider, OpenAPIHono, OpenAPIObject, PathItemObject, ZodCustomIssue, ZodError, backendErrorMap, runWithErrorMapContext, withI18n, z };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as withI18n, i as z, n as ZodError, o as backendErrorMap, s as runWithErrorMapContext, t as OpenAPIHono } from "../../validation-
|
|
1
|
+
import { a as withI18n, i as z, n as ZodError, o as backendErrorMap, s as runWithErrorMapContext, t as OpenAPIHono } from "../../validation-Dbg3ehdP.mjs";
|
|
2
2
|
export * from "@hono/zod-openapi";
|
|
3
3
|
export { OpenAPIHono, ZodError, backendErrorMap, runWithErrorMapContext, withI18n, z };
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { A as Scope, D as runWithContainer, E as getContainer, H as ApplicationError, V as ROUTER_TOKENS, a as createHttpExceptionContext, c as DEFAULT_CONTENT_TYPE, d as ROUTER_CONTEXT_KEYS, f as ROUTE_METADATA_KEYS, k as ERROR_CODES, l as HTTP_METHODS, m as VERSION_NEUTRAL, p as SECURITY_SCHEMES, s as RouterContext, u as METHOD_STATUS_CODES, w as I18N_TOKENS } from "./errors
|
|
2
|
-
import { a as __decorate, d as CONTAINER_TOKEN, f as DI_TOKENS, g as getMethodInjections, o as __decorateParam, p as Transient, s as __decorateMetadata, u as LOGGER_TOKENS } from "./logger-
|
|
3
|
-
import {
|
|
4
|
-
import { i as z, o as backendErrorMap, r as validation_exports, s as runWithErrorMapContext, t as OpenAPIHono } from "./validation-
|
|
5
|
-
import { n as OPENAPI_TOKENS } from "./openapi-tools.service-
|
|
6
|
-
import { t as en_exports } from "./en-
|
|
7
|
-
import { i as getMethodGuards, r as getControllerGuards, t as GuardExecutionService } from "./guards-
|
|
8
|
-
import {
|
|
9
|
-
import { t as
|
|
1
|
+
import { A as Scope, D as runWithContainer, E as getContainer, H as ApplicationError, V as ROUTER_TOKENS, a as createHttpExceptionContext, c as DEFAULT_CONTENT_TYPE, d as ROUTER_CONTEXT_KEYS, f as ROUTE_METADATA_KEYS, k as ERROR_CODES, l as HTTP_METHODS, m as VERSION_NEUTRAL, p as SECURITY_SCHEMES, s as RouterContext, u as METHOD_STATUS_CODES, w as I18N_TOKENS } from "./errors-B4pYgYON.mjs";
|
|
2
|
+
import { a as __decorate, d as CONTAINER_TOKEN, f as DI_TOKENS, g as getMethodInjections, o as __decorateParam, p as Transient, s as __decorateMetadata, u as LOGGER_TOKENS } from "./logger-V6Ms3QnQ.mjs";
|
|
3
|
+
import { C as Module, b as ControllerRegistrationError, c as InvalidSignatureError, d as MissingRouteParamError, f as ResponseValidationError, g as RouteNotFoundError, h as SchemaValidationError, l as MiddlewareNextCalledMultipleTimesError, o as DomainMismatchError, p as RouteNameNotFoundError, s as DuplicateRouteNameError, u as MissingEnvironmentVariableError, v as OpenAPIRouteRegistrationError, x as ControllerMethodNotFoundError, y as HonoAppAlreadyConfiguredError } from "./module-qGE_1duv.mjs";
|
|
4
|
+
import { i as z, o as backendErrorMap, r as validation_exports, s as runWithErrorMapContext, t as OpenAPIHono } from "./validation-Dbg3ehdP.mjs";
|
|
5
|
+
import { n as OPENAPI_TOKENS } from "./openapi-tools.service-CYWGuhue.mjs";
|
|
6
|
+
import { t as en_exports } from "./en-rHmW6vD9.mjs";
|
|
7
|
+
import { i as getMethodGuards, r as getControllerGuards, t as GuardExecutionService } from "./guards-DMbsAxSX.mjs";
|
|
8
|
+
import { n as getControllerOptions, r as getControllerRoute } from "./controller.decorator-LZY9aHYG.mjs";
|
|
9
|
+
import { c as getWsOnMessageMethod, d as isGateway, o as getWsOnCloseMethod, s as getWsOnErrorMethod, t as GatewayContext } from "./gateway-context-cqZ8wMoi.mjs";
|
|
10
|
+
import "./http-method.decorator-BT3ufnz8.mjs";
|
|
11
|
+
import { n as verifySignedUrl, t as signUrl } from "./signed-url-COX7cCWR.mjs";
|
|
12
|
+
import { t as setupI18nCompiler } from "./setup-CtekcwuO.mjs";
|
|
10
13
|
import { inject } from "tsyringe";
|
|
11
14
|
import { createCoreContext, translate } from "@intlify/core-base";
|
|
12
15
|
import { swaggerUI } from "@hono/swagger-ui";
|
|
@@ -705,105 +708,28 @@ function createMiddlewareChain(classes) {
|
|
|
705
708
|
let current = next;
|
|
706
709
|
for (let i = classes.length - 1; i >= 0; i--) {
|
|
707
710
|
const prevNext = current;
|
|
708
|
-
const
|
|
709
|
-
current = () =>
|
|
711
|
+
const middlewareClass = classes[i];
|
|
712
|
+
current = () => {
|
|
713
|
+
const middleware = requestContainer.resolve(middlewareClass);
|
|
714
|
+
let called = false;
|
|
715
|
+
const guardedNext = () => {
|
|
716
|
+
if (called) {
|
|
717
|
+
const err = new MiddlewareNextCalledMultipleTimesError(middlewareClass.name ?? "anonymous");
|
|
718
|
+
console.error("[STRATAL DEBUG] next() called multiple times for " + middlewareClass.name);
|
|
719
|
+
console.error("[STRATAL DEBUG] Stack trace:", (/* @__PURE__ */ new Error()).stack);
|
|
720
|
+
return Promise.reject(err);
|
|
721
|
+
}
|
|
722
|
+
called = true;
|
|
723
|
+
return prevNext();
|
|
724
|
+
};
|
|
725
|
+
return middleware.handle(ctx, guardedNext);
|
|
726
|
+
};
|
|
710
727
|
}
|
|
711
728
|
const result = await current();
|
|
712
729
|
if (result instanceof Response) return result;
|
|
713
730
|
};
|
|
714
731
|
}
|
|
715
732
|
//#endregion
|
|
716
|
-
//#region src/router/decorators/http-method.decorator.ts
|
|
717
|
-
/**
|
|
718
|
-
* Creates an HTTP method decorator factory for the given HTTP method.
|
|
719
|
-
*
|
|
720
|
-
* The returned decorator stores {@link ExplicitRouteMetadata} on the method and
|
|
721
|
-
* tracks the method name under {@link ROUTE_METADATA_KEYS.DECORATED_METHODS}
|
|
722
|
-
* on the controller prototype so they can be discovered at registration time.
|
|
723
|
-
*/
|
|
724
|
-
function createHttpMethodDecorator(method) {
|
|
725
|
-
return function(path, config) {
|
|
726
|
-
return function(target, propertyKey, descriptor) {
|
|
727
|
-
const metadata = {
|
|
728
|
-
type: "explicit",
|
|
729
|
-
method,
|
|
730
|
-
path,
|
|
731
|
-
config: config ?? { response: z.any() }
|
|
732
|
-
};
|
|
733
|
-
Reflect.defineMetadata(ROUTE_METADATA_KEYS.ROUTE_CONFIG, metadata, target, propertyKey);
|
|
734
|
-
const existing = Reflect.getOwnMetadata(ROUTE_METADATA_KEYS.DECORATED_METHODS, target) ?? [];
|
|
735
|
-
existing.push(propertyKey);
|
|
736
|
-
Reflect.defineMetadata(ROUTE_METADATA_KEYS.DECORATED_METHODS, existing, target);
|
|
737
|
-
return descriptor;
|
|
738
|
-
};
|
|
739
|
-
};
|
|
740
|
-
}
|
|
741
|
-
/**
|
|
742
|
-
* Registers a GET route on the controller method.
|
|
743
|
-
*
|
|
744
|
-
* @param path - Route path relative to the controller base path
|
|
745
|
-
* @param config - Optional route configuration (response schema, body, params, etc.)
|
|
746
|
-
*
|
|
747
|
-
* @example
|
|
748
|
-
* ```typescript
|
|
749
|
-
* @Controller('/api/v1/users')
|
|
750
|
-
* class UsersController {
|
|
751
|
-
* @Get('/', { response: z.array(userSchema), summary: 'List users' })
|
|
752
|
-
* async list(ctx: RouterContext) { ... }
|
|
753
|
-
*
|
|
754
|
-
* @Get('/:id', { params: z.object({ id: z.string().uuid() }), response: userSchema })
|
|
755
|
-
* async getUser(ctx: RouterContext) { ... }
|
|
756
|
-
* }
|
|
757
|
-
* ```
|
|
758
|
-
*/
|
|
759
|
-
const Get = createHttpMethodDecorator("get");
|
|
760
|
-
/**
|
|
761
|
-
* Registers a POST route on the controller method.
|
|
762
|
-
*
|
|
763
|
-
* @param path - Route path relative to the controller base path
|
|
764
|
-
* @param config - Optional route configuration (response schema, body, params, etc.)
|
|
765
|
-
*
|
|
766
|
-
* @example
|
|
767
|
-
* ```typescript
|
|
768
|
-
* @Controller('/api/v1/users')
|
|
769
|
-
* class UsersController {
|
|
770
|
-
* @Post('/', { body: createUserSchema, response: userSchema, statusCode: 201 })
|
|
771
|
-
* async createUser(ctx: RouterContext) { ... }
|
|
772
|
-
* }
|
|
773
|
-
* ```
|
|
774
|
-
*/
|
|
775
|
-
const Post = createHttpMethodDecorator("post");
|
|
776
|
-
/**
|
|
777
|
-
* Registers a PUT route on the controller method.
|
|
778
|
-
*
|
|
779
|
-
* @param path - Route path relative to the controller base path
|
|
780
|
-
* @param config - Optional route configuration
|
|
781
|
-
*/
|
|
782
|
-
const Put = createHttpMethodDecorator("put");
|
|
783
|
-
/**
|
|
784
|
-
* Registers a PATCH route on the controller method.
|
|
785
|
-
*
|
|
786
|
-
* @param path - Route path relative to the controller base path
|
|
787
|
-
* @param config - Optional route configuration
|
|
788
|
-
*/
|
|
789
|
-
const Patch = createHttpMethodDecorator("patch");
|
|
790
|
-
/**
|
|
791
|
-
* Registers a DELETE route on the controller method.
|
|
792
|
-
*
|
|
793
|
-
* @param path - Route path relative to the controller base path
|
|
794
|
-
* @param config - Optional route configuration
|
|
795
|
-
*/
|
|
796
|
-
const Delete = createHttpMethodDecorator("delete");
|
|
797
|
-
/**
|
|
798
|
-
* Registers an ALL (any HTTP method) route on the controller method.
|
|
799
|
-
* Routes using @All are registered without OpenAPI validation
|
|
800
|
-
* since OpenAPI does not support a catch-all HTTP method.
|
|
801
|
-
*
|
|
802
|
-
* @param path - Route path relative to the controller base path
|
|
803
|
-
* @param config - Optional route configuration
|
|
804
|
-
*/
|
|
805
|
-
const All = createHttpMethodDecorator("all");
|
|
806
|
-
//#endregion
|
|
807
733
|
//#region src/router/decorators/route.decorator.ts
|
|
808
734
|
/**
|
|
809
735
|
* Decorator to add OpenAPI metadata to a controller method using convention-based routing.
|
|
@@ -1227,7 +1153,7 @@ let RouteRegistrationService = class RouteRegistrationService {
|
|
|
1227
1153
|
middleware: routerConfig.middleware.map((m) => m.name)
|
|
1228
1154
|
});
|
|
1229
1155
|
for (const route of expandedRoutes) actions.set(route, () => {
|
|
1230
|
-
if (routerConfig.middleware.length > 0) this.app.use(
|
|
1156
|
+
if (routerConfig.middleware.length > 0) this.app.use(route.path, createMiddlewareChain(routerConfig.middleware));
|
|
1231
1157
|
if (effectiveDomain) {
|
|
1232
1158
|
const domainHandler = createDomainMiddleware(effectiveDomain);
|
|
1233
1159
|
this.app.use(route.path, domainHandler);
|
|
@@ -1252,7 +1178,7 @@ let RouteRegistrationService = class RouteRegistrationService {
|
|
|
1252
1178
|
middleware: routerConfig.middleware.map((m) => m.name)
|
|
1253
1179
|
});
|
|
1254
1180
|
for (const route of expandedRoutes) actions.set(route, () => {
|
|
1255
|
-
if (routerConfig.middleware.length > 0) this.app.use(
|
|
1181
|
+
if (routerConfig.middleware.length > 0) this.app.use(route.path, createMiddlewareChain(routerConfig.middleware));
|
|
1256
1182
|
this.registerWildcardRoute(ControllerClass, route.path);
|
|
1257
1183
|
});
|
|
1258
1184
|
return;
|
|
@@ -1273,10 +1199,11 @@ let RouteRegistrationService = class RouteRegistrationService {
|
|
|
1273
1199
|
else if (meta.type === "explicit") hasExplicit = true;
|
|
1274
1200
|
}
|
|
1275
1201
|
if (hasConvention && hasExplicit) throw new ControllerRegistrationError(ControllerClass.name, "Cannot mix @Route() with HTTP method decorators (@Get, @Post, etc.) in the same controller. Use one pattern or the other.");
|
|
1276
|
-
let scopedMiddlewareApplied = false;
|
|
1277
1202
|
const routerHidden = routerConfig.hideFromDocs;
|
|
1278
1203
|
const controllerHidden = controllerOpts?.hideFromDocs ?? false;
|
|
1279
|
-
const
|
|
1204
|
+
const routerName = routerConfig.name;
|
|
1205
|
+
const controllerName = controllerOpts?.name;
|
|
1206
|
+
const effectiveNamePrefix = routerName && controllerName ? `${routerName}${controllerName}` : routerName ?? controllerName;
|
|
1280
1207
|
const middlewareNames = routerConfig.middleware.map((m) => m.name);
|
|
1281
1208
|
for (const { method: methodName, meta } of methodMetadata) {
|
|
1282
1209
|
const resolved = this.resolveMethodAndPath(meta, methodName, basePath, className);
|
|
@@ -1306,11 +1233,6 @@ let RouteRegistrationService = class RouteRegistrationService {
|
|
|
1306
1233
|
const responseSchema = httpMethod !== "all" ? this.extractResponseSchema(routeConfig) : null;
|
|
1307
1234
|
const handler = this.createControllerHandler(ControllerClass, methodName, responseSchema);
|
|
1308
1235
|
for (const route of expandedRoutes) actions.set(route, () => {
|
|
1309
|
-
if (!scopedMiddlewareApplied && routerConfig.middleware.length > 0) {
|
|
1310
|
-
const primaryRoute = expandedRoutes.find((r) => !r.isLocaleVariant) ?? expandedRoutes[0];
|
|
1311
|
-
this.app.use(`${primaryRoute.path}/*`, createMiddlewareChain(routerConfig.middleware));
|
|
1312
|
-
scopedMiddlewareApplied = true;
|
|
1313
|
-
}
|
|
1314
1236
|
if (effectiveDomain) {
|
|
1315
1237
|
const domainHandler = createDomainMiddleware(effectiveDomain);
|
|
1316
1238
|
this.app.use(route.path, domainHandler);
|
|
@@ -1329,12 +1251,13 @@ let RouteRegistrationService = class RouteRegistrationService {
|
|
|
1329
1251
|
path: route.path,
|
|
1330
1252
|
methodName
|
|
1331
1253
|
});
|
|
1332
|
-
if (
|
|
1333
|
-
|
|
1254
|
+
if (routerConfig.middleware.length > 0) this.app.use(route.path, createMiddlewareChain(routerConfig.middleware));
|
|
1255
|
+
if (allGuards.length > 0) this.app.use(route.path, this.createGuardMiddleware(allGuards));
|
|
1256
|
+
this.app.all(route.path, handler);
|
|
1334
1257
|
return;
|
|
1335
1258
|
}
|
|
1336
1259
|
const metadata = this.mergeMetadata(controllerOpts, routeConfig, ControllerClass, methodName);
|
|
1337
|
-
const openApiRoute = this.buildOpenAPIRoute(httpMethod, route.path, routeConfig, metadata,
|
|
1260
|
+
const openApiRoute = this.buildOpenAPIRoute(httpMethod, route.path, routeConfig, metadata, meta.type === "convention" ? methodName : void 0, statusCodeOverride, route.isLocaleVariant ?? false);
|
|
1338
1261
|
this.logger.info(`Registering route`, {
|
|
1339
1262
|
controller: className,
|
|
1340
1263
|
method: httpMethod.toUpperCase(),
|
|
@@ -1343,7 +1266,8 @@ let RouteRegistrationService = class RouteRegistrationService {
|
|
|
1343
1266
|
tags: metadata.tags,
|
|
1344
1267
|
hidden: route.hidden
|
|
1345
1268
|
});
|
|
1346
|
-
this.
|
|
1269
|
+
const wrappedHandler = this.wrapHandlerWithChain(handler, routerConfig.middleware, allGuards);
|
|
1270
|
+
this.app.openapi(openApiRoute, wrappedHandler);
|
|
1347
1271
|
if (!route.hidden) {
|
|
1348
1272
|
const { hide: _, ...specRoute } = openApiRoute;
|
|
1349
1273
|
this.app.openAPIRegistry.registerPath({
|
|
@@ -1416,6 +1340,31 @@ let RouteRegistrationService = class RouteRegistrationService {
|
|
|
1416
1340
|
};
|
|
1417
1341
|
}
|
|
1418
1342
|
/**
|
|
1343
|
+
* Wrap a controller handler with a `scopedMiddleware → guards → handler`
|
|
1344
|
+
* chain that runs *inside* the Hono route handler — after request
|
|
1345
|
+
* validators have populated `c.req.valid(...)`. This is the only place
|
|
1346
|
+
* we can run user middleware after `@hono/zod-openapi`'s validators in
|
|
1347
|
+
* the same pipeline.
|
|
1348
|
+
*
|
|
1349
|
+
* Returns a Hono handler with the same signature as the original so
|
|
1350
|
+
* `app.openapi(route, wrapped)` works transparently.
|
|
1351
|
+
*/
|
|
1352
|
+
wrapHandlerWithChain(handler, scopedMiddleware, guards) {
|
|
1353
|
+
if (scopedMiddleware.length === 0 && guards.length === 0) return handler;
|
|
1354
|
+
const scopedChain = scopedMiddleware.length > 0 ? createMiddlewareChain(scopedMiddleware) : null;
|
|
1355
|
+
const guardChain = guards.length > 0 ? this.createGuardMiddleware(guards) : null;
|
|
1356
|
+
return async (c) => {
|
|
1357
|
+
let captured;
|
|
1358
|
+
const runHandler = async () => {
|
|
1359
|
+
captured = await handler(c);
|
|
1360
|
+
};
|
|
1361
|
+
const runGuards = guardChain ? () => guardChain(c, runHandler) : runHandler;
|
|
1362
|
+
const result = await (scopedChain ? () => scopedChain(c, runGuards) : runGuards)();
|
|
1363
|
+
if (result instanceof Response) return result;
|
|
1364
|
+
return captured;
|
|
1365
|
+
};
|
|
1366
|
+
}
|
|
1367
|
+
/**
|
|
1419
1368
|
* Register wildcard route for non-RESTful controllers
|
|
1420
1369
|
*/
|
|
1421
1370
|
registerWildcardRoute(ControllerClass, route) {
|
|
@@ -1453,9 +1402,9 @@ let RouteRegistrationService = class RouteRegistrationService {
|
|
|
1453
1402
|
* Join a base path and a route path, normalizing slashes
|
|
1454
1403
|
*/
|
|
1455
1404
|
joinPaths(basePath, routePath) {
|
|
1456
|
-
if (
|
|
1457
|
-
if (
|
|
1458
|
-
if (
|
|
1405
|
+
if (basePath.endsWith("/")) basePath = basePath.slice(0, -1);
|
|
1406
|
+
if (routePath === "/" || routePath === "") return basePath || "/";
|
|
1407
|
+
if (!routePath.startsWith("/")) routePath = "/" + routePath;
|
|
1459
1408
|
return basePath + routePath;
|
|
1460
1409
|
}
|
|
1461
1410
|
/**
|
|
@@ -1492,12 +1441,13 @@ let RouteRegistrationService = class RouteRegistrationService {
|
|
|
1492
1441
|
}
|
|
1493
1442
|
/**
|
|
1494
1443
|
* Build OpenAPI route configuration from metadata
|
|
1495
|
-
* Creates a route definition compatible with @hono/zod-openapi
|
|
1496
|
-
* Includes guard execution for proper access control
|
|
1444
|
+
* Creates a route definition compatible with @hono/zod-openapi.
|
|
1497
1445
|
*
|
|
1498
|
-
*
|
|
1446
|
+
* Scoped middleware and guards are NOT attached to `route.middleware`
|
|
1447
|
+
* here — they're composed into a wrapped handler in `collectRoutes` so
|
|
1448
|
+
* they run after Hono's request validators. See `wrapHandlerWithChain`.
|
|
1499
1449
|
*/
|
|
1500
|
-
buildOpenAPIRoute(method, path, routeConfig, metadata,
|
|
1450
|
+
buildOpenAPIRoute(method, path, routeConfig, metadata, methodName, statusCodeOverride, hasLocaleParam = false) {
|
|
1501
1451
|
try {
|
|
1502
1452
|
const route = {
|
|
1503
1453
|
method,
|
|
@@ -1506,7 +1456,6 @@ let RouteRegistrationService = class RouteRegistrationService {
|
|
|
1506
1456
|
responses: {},
|
|
1507
1457
|
hide: true
|
|
1508
1458
|
};
|
|
1509
|
-
if (guards.length > 0) route.middleware = [this.createGuardMiddleware(guards)];
|
|
1510
1459
|
if (routeConfig.body) {
|
|
1511
1460
|
const bodySchema = this.isRouteBodyObject(routeConfig.body) ? routeConfig.body.schema : routeConfig.body;
|
|
1512
1461
|
const bodyContentType = this.isRouteBodyObject(routeConfig.body) ? routeConfig.body.contentType ?? "application/json" : DEFAULT_CONTENT_TYPE;
|
|
@@ -1972,77 +1921,6 @@ RouteRegistry = __decorate([
|
|
|
1972
1921
|
__decorateMetadata("design:paramtypes", [Object, Object])
|
|
1973
1922
|
], RouteRegistry);
|
|
1974
1923
|
//#endregion
|
|
1975
|
-
//#region src/router/signed-url.ts
|
|
1976
|
-
/**
|
|
1977
|
-
* Import a signing key for HMAC-SHA256.
|
|
1978
|
-
*/
|
|
1979
|
-
async function importKey(secret) {
|
|
1980
|
-
const encoder = new TextEncoder();
|
|
1981
|
-
return crypto.subtle.importKey("raw", encoder.encode(secret), {
|
|
1982
|
-
name: "HMAC",
|
|
1983
|
-
hash: "SHA-256"
|
|
1984
|
-
}, false, ["sign", "verify"]);
|
|
1985
|
-
}
|
|
1986
|
-
/**
|
|
1987
|
-
* Encode an ArrayBuffer as base64url (URL-safe base64).
|
|
1988
|
-
*/
|
|
1989
|
-
function toBase64Url(buffer) {
|
|
1990
|
-
const bytes = new Uint8Array(buffer);
|
|
1991
|
-
let binary = "";
|
|
1992
|
-
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
1993
|
-
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
1994
|
-
}
|
|
1995
|
-
/**
|
|
1996
|
-
* Sign a URL with HMAC-SHA256.
|
|
1997
|
-
*
|
|
1998
|
-
* Appends `signature` and optionally `expires` query parameters.
|
|
1999
|
-
* The signature covers the pathname + search (excluding the signature params themselves).
|
|
2000
|
-
*
|
|
2001
|
-
* @param url - Full URL or path to sign
|
|
2002
|
-
* @param secret - HMAC secret key (e.g., from env.APP_SECRET)
|
|
2003
|
-
* @param options - Optional expiration
|
|
2004
|
-
* @returns URL string with `signature` (and `expires`) query params appended
|
|
2005
|
-
*/
|
|
2006
|
-
async function signUrl(url, secret, options) {
|
|
2007
|
-
const parsedUrl = new URL(url, "https://placeholder.local");
|
|
2008
|
-
const key = await importKey(secret);
|
|
2009
|
-
if (options?.expiresIn) {
|
|
2010
|
-
const expires = Math.floor(Date.now() / 1e3) + options.expiresIn;
|
|
2011
|
-
parsedUrl.searchParams.set("expires", String(expires));
|
|
2012
|
-
}
|
|
2013
|
-
const dataToSign = `${parsedUrl.pathname}?${parsedUrl.searchParams.toString()}`;
|
|
2014
|
-
const encoder = new TextEncoder();
|
|
2015
|
-
const signature = toBase64Url(await crypto.subtle.sign("HMAC", key, encoder.encode(dataToSign)));
|
|
2016
|
-
parsedUrl.searchParams.set("signature", signature);
|
|
2017
|
-
return url.startsWith("http") ? parsedUrl.toString() : `${parsedUrl.pathname}?${parsedUrl.searchParams.toString()}`;
|
|
2018
|
-
}
|
|
2019
|
-
/**
|
|
2020
|
-
* Verify a signed URL using `crypto.subtle.verify()` (timing-attack-safe).
|
|
2021
|
-
*
|
|
2022
|
-
* @param url - Full URL or path with signature query param
|
|
2023
|
-
* @param secret - HMAC secret key (same key used for signing)
|
|
2024
|
-
* @returns true if signature is valid and not expired
|
|
2025
|
-
*/
|
|
2026
|
-
async function verifySignedUrl(url, secret) {
|
|
2027
|
-
const parsedUrl = new URL(url, "https://placeholder.local");
|
|
2028
|
-
const signature = parsedUrl.searchParams.get("signature");
|
|
2029
|
-
if (!signature) return false;
|
|
2030
|
-
const expires = parsedUrl.searchParams.get("expires");
|
|
2031
|
-
if (expires) {
|
|
2032
|
-
const expiryTime = parseInt(expires, 10);
|
|
2033
|
-
if (isNaN(expiryTime) || Math.floor(Date.now() / 1e3) > expiryTime) return false;
|
|
2034
|
-
}
|
|
2035
|
-
parsedUrl.searchParams.delete("signature");
|
|
2036
|
-
const dataToVerify = `${parsedUrl.pathname}?${parsedUrl.searchParams.toString()}`;
|
|
2037
|
-
const base64 = signature.replace(/-/g, "+").replace(/_/g, "/");
|
|
2038
|
-
const binaryStr = atob(base64);
|
|
2039
|
-
const signatureBytes = new Uint8Array(binaryStr.length);
|
|
2040
|
-
for (let i = 0; i < binaryStr.length; i++) signatureBytes[i] = binaryStr.charCodeAt(i);
|
|
2041
|
-
const key = await importKey(secret);
|
|
2042
|
-
const encoder = new TextEncoder();
|
|
2043
|
-
return crypto.subtle.verify("HMAC", key, signatureBytes, encoder.encode(dataToVerify));
|
|
2044
|
-
}
|
|
2045
|
-
//#endregion
|
|
2046
1924
|
//#region src/router/uri.ts
|
|
2047
1925
|
/**
|
|
2048
1926
|
* Build a URL from a registered route, filling path/domain params and appending extras as query string.
|
|
@@ -2457,6 +2335,6 @@ I18nModule = _I18nModule = __decorate([Module({ providers: [
|
|
|
2457
2335
|
}
|
|
2458
2336
|
] })], I18nModule);
|
|
2459
2337
|
//#endregion
|
|
2460
|
-
export {
|
|
2338
|
+
export { OpenAPIModule as A, LocaleNotSupportedError as B, validationErrorResponseSchema as C, createMiddlewareChain as D, getRouteMetadata as E, getMessages as F, I18nContextMiddleware as H, messages as I, buildDetectorOptions as L, MessageRegistry as M, MessageLoaderService as N, createDomainMiddleware as O, getLocales as P, resolveI18nOptions as R, uuidParamSchema as S, getRouteDecoratedMethods as T, OpenAPIConfigService as V, commonErrorSchemas as _, buildRouteUrl as a, paginationQuerySchema as b, LocalePathService as c, extractDomainParamNames as d, extractParamNames as f, toOpenAPIPath as g, sortRoutesBySpecificity as h, Uri as i, OpenAPIService as j, parseDomainPattern as k, HonoApp as l, getPathSpecificityScore as m, VerifySignatureMiddleware as n, RouteRegistry as o, generateConventionRouteName as p, route as r, VersioningService as s, I18nModule as t, RouteRegistrationService as u, errorResponseSchema as v, Route as w, successMessageSchema as x, paginatedResponseSchema as y, TranslationMissingError as z };
|
|
2461
2339
|
|
|
2462
|
-
//# sourceMappingURL=i18n.module-
|
|
2340
|
+
//# sourceMappingURL=i18n.module-CI_prYFD.mjs.map
|