clear-router 2.7.6 → 2.7.7

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.
Files changed (107) hide show
  1. package/dist/ClearRequest.cjs +23 -0
  2. package/dist/ClearRequest.d.cts +28 -0
  3. package/dist/ClearRequest.d.mts +28 -0
  4. package/dist/ClearRequest.mjs +22 -0
  5. package/dist/Contracts.d.cts +12 -0
  6. package/dist/Contracts.d.mts +12 -0
  7. package/dist/Controller.cjs +12 -0
  8. package/dist/Controller.d.cts +14 -0
  9. package/dist/Controller.d.mts +14 -0
  10. package/dist/Controller.mjs +11 -0
  11. package/dist/{Request-DKXwa_W0.d.mts → Request-BhTJDR_5.d.mts} +5 -5
  12. package/dist/Route.cjs +58 -0
  13. package/dist/Route.d.cts +35 -0
  14. package/dist/Route.d.mts +35 -0
  15. package/dist/Route.mjs +57 -0
  16. package/dist/core/Request.cjs +35 -0
  17. package/dist/core/Request.d.cts +25 -0
  18. package/dist/core/Request.d.mts +25 -0
  19. package/dist/core/Request.mjs +35 -0
  20. package/dist/core/Response.cjs +59 -0
  21. package/dist/core/Response.d.cts +24 -0
  22. package/dist/core/Response.d.mts +24 -0
  23. package/dist/core/Response.mjs +58 -0
  24. package/dist/{bindings-CLsZjOEy.cjs → core/bindings.cjs} +10 -160
  25. package/dist/{bindings-CNL7bpz5.d.mts → core/bindings.d.cts} +1 -1
  26. package/dist/{bindings-CxvtC8XS.d.cts → core/bindings.d.mts} +1 -1
  27. package/dist/{bindings-XLDXFpHZ.mjs → core/bindings.mjs} +3 -110
  28. package/dist/core/index.cjs +4 -20
  29. package/dist/core/index.d.cts +4 -1
  30. package/dist/core/index.d.mts +4 -1
  31. package/dist/core/index.mjs +4 -14
  32. package/dist/core/plugins.cjs +14 -0
  33. package/dist/core/plugins.d.cts +109 -0
  34. package/dist/core/plugins.d.mts +109 -0
  35. package/dist/core/plugins.mjs +13 -0
  36. package/dist/{responses-Bvnk0uvc.cjs → core/responses.cjs} +5 -20
  37. package/dist/{responses-BvETUeDL.mjs → core/responses.mjs} +2 -2
  38. package/dist/{router-C6W-k6sS.cjs → core/router.cjs} +11 -69
  39. package/dist/core/router.d.cts +274 -0
  40. package/dist/core/router.d.mts +274 -0
  41. package/dist/{router-Dc9w86Wn.mjs → core/router.mjs} +5 -58
  42. package/dist/decorators/index.cjs +1 -1
  43. package/dist/decorators/index.d.cts +1 -1
  44. package/dist/decorators/index.d.mts +1 -1
  45. package/dist/decorators/index.mjs +1 -1
  46. package/dist/decorators/setup.cjs +2 -2
  47. package/dist/decorators/setup.d.cts +1 -1
  48. package/dist/decorators/setup.d.mts +1 -1
  49. package/dist/decorators/setup.mjs +2 -2
  50. package/dist/express/index.cjs +2 -265
  51. package/dist/express/index.d.cts +1 -127
  52. package/dist/express/index.d.mts +1 -127
  53. package/dist/express/index.mjs +1 -264
  54. package/dist/express/router.cjs +265 -0
  55. package/dist/express/router.d.cts +131 -0
  56. package/dist/express/router.d.mts +131 -0
  57. package/dist/express/router.mjs +265 -0
  58. package/dist/fastify/index.cjs +2 -254
  59. package/dist/fastify/index.d.cts +1 -125
  60. package/dist/fastify/index.d.mts +1 -125
  61. package/dist/fastify/index.mjs +1 -253
  62. package/dist/fastify/router.cjs +254 -0
  63. package/dist/fastify/router.d.cts +129 -0
  64. package/dist/fastify/router.d.mts +129 -0
  65. package/dist/fastify/router.mjs +254 -0
  66. package/dist/h3/index.cjs +2 -260
  67. package/dist/h3/index.d.cts +1 -128
  68. package/dist/h3/index.d.mts +1 -128
  69. package/dist/h3/index.mjs +1 -259
  70. package/dist/h3/router.cjs +260 -0
  71. package/dist/h3/router.d.cts +132 -0
  72. package/dist/h3/router.d.mts +132 -0
  73. package/dist/h3/router.mjs +260 -0
  74. package/dist/hono/index.cjs +2 -251
  75. package/dist/hono/index.d.cts +1 -130
  76. package/dist/hono/index.d.mts +1 -130
  77. package/dist/hono/index.mjs +1 -250
  78. package/dist/hono/router.cjs +251 -0
  79. package/dist/hono/router.d.cts +134 -0
  80. package/dist/hono/router.d.mts +134 -0
  81. package/dist/hono/router.mjs +251 -0
  82. package/dist/index.cjs +16 -1097
  83. package/dist/index.d.cts +9 -563
  84. package/dist/index.d.mts +9 -563
  85. package/dist/index.mjs +8 -1089
  86. package/dist/koa/index.cjs +2 -261
  87. package/dist/koa/index.d.cts +1 -131
  88. package/dist/koa/index.d.mts +1 -131
  89. package/dist/koa/index.mjs +1 -260
  90. package/dist/koa/router.cjs +261 -0
  91. package/dist/koa/router.d.cts +135 -0
  92. package/dist/koa/router.d.mts +135 -0
  93. package/dist/koa/router.mjs +261 -0
  94. package/dist/types/basic.d.cts +43 -0
  95. package/dist/types/express.d.cts +44 -0
  96. package/dist/types/express.d.mts +4 -2
  97. package/dist/types/fastify.d.cts +23 -0
  98. package/dist/types/fastify.d.mts +4 -2
  99. package/dist/types/h3.d.cts +41 -0
  100. package/dist/types/h3.d.mts +4 -4
  101. package/dist/types/hono.d.cts +21 -0
  102. package/dist/types/hono.d.mts +4 -3
  103. package/dist/types/koa.d.cts +25 -0
  104. package/dist/types/koa.d.mts +4 -3
  105. package/package.json +1 -1
  106. package/dist/router-BEgAxp5A.d.cts +0 -649
  107. package/dist/router-DKKYx23P.d.mts +0 -649
@@ -1,649 +0,0 @@
1
- import { a as BindValue, i as BindToken, o as Container } from "./bindings-CNL7bpz5.mjs";
2
- import { AsyncLocalStorage } from "node:async_hooks";
3
- import { EventHandlerRequest, H3, H3Event, Middleware as Middleware$2, TypedServerRequest } from "h3";
4
- import { NextFunction, Request, Response as Response$1 } from "express";
5
- import { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
6
- import { Context, HonoRequest, MiddlewareHandler } from "hono";
7
- import Koa from "koa";
8
- import Router$1 from "@koa/router";
9
-
10
- //#region src/types/basic.d.ts
11
- /**
12
- * Controller method reference
13
- */
14
- type ControllerHandler = [any, string];
15
- /**
16
- * HTTP methods supported by the router
17
- */
18
- type HttpMethod = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' | 'head';
19
- /**
20
- * Common controller action names
21
- */
22
- type ControllerAction = 'index' | 'show' | 'create' | 'update' | 'destroy';
23
- /**
24
- * Generic Object type for request data
25
- */
26
- type RequestData = Record<string, any>;
27
- type ApiResourceMiddleware<M = any> = M | M[] | { [K in ControllerAction]?: M | M[] };
28
- interface RouterConfig {
29
- /**
30
- * When enabled, API param name will be infered from the route path.
31
- * So instead of getting /api/users/:id, we will now get /api/users/:user
32
- */
33
- inferParamName?: boolean;
34
- /**
35
- * Configuration for method override functionality, allowing clients to use a
36
- * specific header or body parameter to override the HTTP method.
37
- */
38
- methodOverride?: {
39
- /** Whether method override is enabled */enabled?: boolean; /** Keys in the request body to check for method override */
40
- bodyKeys?: string[] | string; /** Keys in the request headers to check for method override */
41
- headerKeys?: string[] | string;
42
- };
43
- /**
44
- * Optional method binding / container resolution support. Disabled by default.
45
- */
46
- container?: {
47
- /** Whether decorated handler parameter binding is enabled */enabled?: boolean; /** Whether unknown constructor tokens should be instantiated automatically */
48
- autoDiscover?: boolean;
49
- };
50
- }
51
- //#endregion
52
- //#region src/Contracts.d.ts
53
- /**
54
- * HTTP context passed to route handlers
55
- */
56
- interface ClearHttpContext {}
57
- //#endregion
58
- //#region src/core/Response.d.ts
59
- declare class Response$2 {
60
- [key: string]: any;
61
- body: any;
62
- headers: Headers;
63
- sent: boolean;
64
- statusCode: number;
65
- statusText: string;
66
- constructor(init?: Partial<Response$2 | globalThis.Response>);
67
- status(code: number): this;
68
- setStatusText(text: string): this;
69
- code(code: number): this;
70
- setHeader(name: string, value: string): this;
71
- header(name: string, value: string): this;
72
- set(name: string, value: string): this;
73
- type(contentType: string): this;
74
- send(body?: any): this;
75
- json(body: any): this;
76
- html(body: string): this;
77
- text(body: string): this;
78
- noContent(): this;
79
- }
80
- //#endregion
81
- //#region src/types/express.d.ts
82
- interface RequestWithGetBody$3 extends Request {
83
- getBody: () => Record<string, any>;
84
- }
85
- /**
86
- * HTTP context passed to route handlers
87
- */
88
- interface HttpContext$4 extends ClearHttpContext {
89
- req: RequestWithGetBody$3;
90
- res: Response$1;
91
- next: NextFunction;
92
- clearRequest: Request$1;
93
- clearResponse: Response$2;
94
- }
95
- /**
96
- * Route handler function type
97
- */
98
- type RouteHandler$4 = (
99
- /**
100
- * Express context object containing req, res, and next
101
- */
102
-
103
- ctx: HttpContext$4,
104
- /**
105
- * ClearRequest instance
106
- */
107
-
108
- req: Request$1) => any | Promise<any>;
109
- /**
110
- * Handler can be either a function or controller reference
111
- */
112
- type Handler$4 = RouteHandler$4 | ControllerHandler;
113
- /**
114
- * Middleware function type
115
- */
116
- type Middleware$4 = (req: Request, res: Response$1, next: NextFunction) => any | Promise<any>;
117
- //#endregion
118
- //#region src/types/fastify.d.ts
119
- interface RequestWithGetBody$2 extends FastifyRequest {
120
- getBody: () => Record<string, any>;
121
- }
122
- interface HttpContext$3 extends ClearHttpContext {
123
- req: RequestWithGetBody$2;
124
- reply: FastifyReply;
125
- clearRequest: Request$1;
126
- clearResponse: Response$2;
127
- }
128
- type RouteHandler$3 = (ctx: HttpContext$3, req: Request$1) => any | Promise<any>;
129
- type Handler$3 = RouteHandler$3 | ControllerHandler;
130
- type NextFunction$1 = (err?: Error) => void;
131
- type Middleware$3 = (req: RequestWithGetBody$2, reply: FastifyReply, next: NextFunction$1) => any | Promise<any>;
132
- type FastifyApp = FastifyInstance;
133
- //#endregion
134
- //#region src/types/h3.d.ts
135
- type H3App = Omit<H3, 'fetch'> & {
136
- fetch: (request: TypedServerRequest<EventHandlerRequest>) => Promise<Response>;
137
- };
138
- interface HttpRequest extends TypedServerRequest<EventHandlerRequest> {
139
- getBody: () => Record<string, any>;
140
- }
141
- /**
142
- * HTTP context passed to route handlers
143
- */
144
- interface HttpContext$2 extends Omit<H3Event, 'req'>, ClearHttpContext {
145
- req: HttpRequest;
146
- clearRequest: Request$1;
147
- clearResponse: Response$2;
148
- }
149
- /**
150
- * Route handler function type
151
- */
152
- type RouteHandler$2 = (
153
- /**
154
- * H3 event context
155
- */
156
-
157
- ctx: HttpContext$2,
158
- /**
159
- * ClearRequest instance
160
- */
161
-
162
- req: Request$1) => any | Promise<any>;
163
- /**
164
- * Handler can be either a function or controller reference
165
- */
166
- type Handler$2 = RouteHandler$2 | ControllerHandler;
167
- //#endregion
168
- //#region src/types/hono.d.ts
169
- type RequestWithGetBody$1 = HonoRequest & {
170
- getBody: () => Record<string, any>;
171
- };
172
- interface HttpContext$1 extends Context, ClearHttpContext {
173
- req: RequestWithGetBody$1;
174
- clearRequest: Request$1;
175
- clearResponse: Response$2;
176
- }
177
- type RouteHandler$1 = (ctx: HttpContext$1, req: Request$1) => any | Promise<any>;
178
- type Handler$1 = RouteHandler$1 | ControllerHandler;
179
- type Middleware$1 = MiddlewareHandler;
180
- type HonoApp = { [K in 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' | 'head']: (path: string, ...handlers: Middleware$1[]) => any };
181
- //#endregion
182
- //#region src/types/koa.d.ts
183
- interface RequestWithGetBody extends Koa.Request {
184
- getBody: () => Record<string, any>;
185
- body?: any;
186
- }
187
- interface HttpContext extends Koa.Context, ClearHttpContext {
188
- request: RequestWithGetBody;
189
- clearRequest: Request$1;
190
- clearResponse: Response$2;
191
- params: Record<string, any>;
192
- query: Record<string, any>;
193
- }
194
- type RouteHandler = (ctx: HttpContext, req: Request$1) => any | Promise<any>;
195
- type Handler = RouteHandler | ControllerHandler;
196
- type Middleware = Koa.Middleware<any, any>;
197
- type KoaRouterApp = Router$1<any, any>;
198
- //#endregion
199
- //#region src/Route.d.ts
200
- interface RouteParameter {
201
- name: string;
202
- field?: string;
203
- optional: boolean;
204
- }
205
- declare class Route<X = any, M = Middleware$2 | Middleware$4, H = any> {
206
- ctx: X;
207
- body: RequestData;
208
- query: RequestData;
209
- params: RequestData;
210
- clearRequest: ClearRequest;
211
- methods: HttpMethod[];
212
- path: string;
213
- registrationPaths: string[];
214
- parameters: RouteParameter[];
215
- routeName?: string;
216
- handler: H;
217
- middlewares: M[];
218
- controllerName?: string;
219
- actionName?: string;
220
- handlerType: 'function' | 'controller';
221
- middlewareCount: number;
222
- constructor(methods: HttpMethod[], path: string, handler: H, middlewares?: M[], options?: {
223
- registrationPaths?: string[];
224
- parameters?: RouteParameter[];
225
- onName?: (name: string, route: Route<X, M, H>, previousName?: string) => void;
226
- });
227
- private onName?;
228
- name(name: string): this;
229
- toPath(params?: RequestData): string;
230
- }
231
- //#endregion
232
- //#region src/ClearRequest.d.ts
233
- declare class ClearRequest<X = any, M = Middleware$2 | Middleware$4 | Middleware$3 | Middleware$1 | Middleware> {
234
- [key: string]: any;
235
- /**
236
- * @param body - Parsed request body
237
- */
238
- body: RequestData;
239
- /**
240
- * @param query - Parsed query parameters
241
- */
242
- query: RequestData;
243
- /**
244
- * @param params - Parsed route parameters
245
- */
246
- params: RequestData;
247
- route: Route<X, M>;
248
- constructor(init?: Partial<ClearRequest>);
249
- }
250
- //#endregion
251
- //#region src/core/Request.d.ts
252
- declare class Request$1<X = any, M = any> extends ClearRequest<X, M> {
253
- original?: any;
254
- method: string;
255
- path: string;
256
- url: string;
257
- headers: Headers | Record<string, any>;
258
- constructor(init?: Partial<Request$1<X, M>> & {
259
- body?: RequestData;
260
- query?: RequestData;
261
- params?: RequestData;
262
- route?: Route<X, M>;
263
- });
264
- getBody(): RequestData;
265
- header(name: string): string;
266
- param(name: string): any;
267
- input(name: string): any;
268
- is(method: HttpMethod | string): boolean;
269
- }
270
- //#endregion
271
- //#region src/core/plugins.d.ts
272
- type PluginSetupResult = void | Promise<void>;
273
- interface ClearRouterPluginRequestContext<HttpContext = any> {
274
- ctx: HttpContext;
275
- request: Request$1;
276
- response: Response$2;
277
- getBindings: () => Record<string, BindValue>;
278
- [key: string]: any;
279
- }
280
- interface ClearRouterPluginArgumentsContext<X = any> extends ClearRouterPluginRequestContext<X> {
281
- target?: object;
282
- method?: PropertyKey;
283
- handler?: object;
284
- metadata?: object;
285
- tokens: BindToken[];
286
- designTokens: BindToken[];
287
- }
288
- type PluginBindFactory<T = any, X = any> = (ctx: ClearRouterPluginRequestContext<X>) => T | Promise<T>;
289
- type PluginBindValue<T = any, X = any> = BindValue<T> | PluginBindFactory<T, X>;
290
- type PluginBind<X = any> = <T>(token: BindToken<T>, value: PluginBindValue<T, X>) => void;
291
- type PluginArgumentsResolver<HttpContext = any> = (ctx: ClearRouterPluginArgumentsContext<HttpContext>) => any[] | undefined | Promise<any[] | undefined>;
292
- interface ClearRouterPluginContext<Options = any, HttpContext = any> {
293
- /**
294
- * The service container
295
- */
296
- container: typeof Container;
297
- /**
298
- * Register service container bindings
299
- */
300
- bind: PluginBind<HttpContext>;
301
- /**
302
- * Replace all controller method arguments
303
- * @param resolver
304
- * @returns
305
- */
306
- resolveArguments: (resolver: PluginArgumentsResolver<HttpContext>) => void;
307
- /**
308
- * Use the current http context
309
- */
310
- useHttpContext: (resolver: PluginArgumentsResolver<HttpContext>) => void;
311
- /**
312
- * All registered service container bindings
313
- */
314
- bindings: Record<string, BindValue>;
315
- /**
316
- * Configures the router with the given options, such as method override settings
317
- *
318
- * @param options
319
- * @returns
320
- */
321
- configure: (options: RouterConfig) => void;
322
- /**
323
- * Default configuration used for everytime the router is reset
324
- *
325
- * @param options
326
- */
327
- configureDefaults: (options: RouterConfig) => void;
328
- /**
329
- * The current Request instance
330
- */
331
- readonly request?: Request$1;
332
- /**
333
- * The current Response instance
334
- * @returns
335
- */
336
- readonly response?: Response$2;
337
- /**
338
- * Get the current Request instance
339
- * @returns
340
- */
341
- getRequest: () => Request$1 | undefined;
342
- /**
343
- * Get the current Response instance
344
- * @returns
345
- */
346
- getResponse: () => Response$2 | undefined;
347
- /**
348
- * Plugin configuration options
349
- */
350
- options: Options;
351
- }
352
- interface ClearRouterPlugin<Options = any, HttpContext = any> {
353
- /**
354
- * The name of the plugin
355
- */
356
- name?: string;
357
- /**
358
- * Plugin setup an implemnetation
359
- *
360
- * @param ctx
361
- * @returns
362
- */
363
- setup: (ctx: ClearRouterPluginContext<Options, HttpContext>) => PluginSetupResult;
364
- }
365
- type ClearRouterPluginInput<Options = any, HttpContext = any> = ClearRouterPlugin<Options> | ((ctx: ClearRouterPluginContext<Options, HttpContext>) => PluginSetupResult);
366
- /**
367
- * Creates a new plugin
368
- *
369
- * @param plugin
370
- * @returns
371
- */
372
- declare function definePlugin<Options = any, HttpContext = any>(plugin: ClearRouterPlugin<Options, HttpContext>): ClearRouterPlugin<Options, HttpContext>;
373
- //#endregion
374
- //#region src/Controller.d.ts
375
- declare abstract class Controller<X = any> {
376
- [x: string]: any;
377
- ctx: X;
378
- body: RequestData;
379
- query: RequestData;
380
- params: RequestData;
381
- clearRequest: ClearRequest;
382
- }
383
- //#endregion
384
- //#region src/core/router.d.ts
385
- /**
386
- * @class clear-router CoreRouter
387
- * @description Core routing logic for clear-router, shared between all supported adapters (Express.js, H3, etc.)
388
- * @author 3m1n3nc3
389
- * @repository https://github.com/arkstack-tmp/clear-router
390
- */
391
- declare abstract class CoreRouter {
392
- protected static routerStateNamespace: string;
393
- private static readonly stateStoreKey;
394
- private static readonly stateBoundKey;
395
- private static readonly defaultConfigKey;
396
- private static readonly pluginStoreKey;
397
- private static readonly pluginPendingKey;
398
- private static readonly pluginHttpCtxResolversKey;
399
- private static readonly pluginArgumentResolversKey;
400
- private static requestProvider?;
401
- private static responseProvider?;
402
- static config: RouterConfig;
403
- protected static groupContext: AsyncLocalStorage<{
404
- prefix: string;
405
- groupMiddlewares: any[];
406
- }>;
407
- protected static pluginRequestContext: AsyncLocalStorage<ClearRouterPluginRequestContext<any>>;
408
- static routes: Set<Route<any, any, any>>;
409
- static routesByPathMethod: Map<string, Route<any, any, any>>;
410
- static routesByMethod: Map<"GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "OPTIONS" | "HEAD", Route<any, any, any>[]>;
411
- static routesByName: Map<string, Route<any, any, any>>;
412
- static prefix: string;
413
- static groupMiddlewares: any[];
414
- static globalMiddlewares: any[];
415
- /**
416
- * Resets the router to it's default state
417
- */
418
- static reset(): typeof CoreRouter;
419
- protected static createBaseConfig(): RouterConfig;
420
- protected static mergeConfig(target: RouterConfig, source?: RouterConfig): RouterConfig;
421
- protected static getDefaultConfig(): RouterConfig;
422
- protected static resolveStateNamespace(): string;
423
- protected static getStateStore(): Record<string, any>;
424
- protected static getPluginStore(): Set<string>;
425
- protected static getPluginPendingStore(): Set<Promise<void>>;
426
- protected static getPluginArgumentResolvers(): Set<PluginArgumentsResolver>;
427
- protected static getPluginHttpCtxResolvers(): Set<PluginArgumentsResolver>;
428
- protected static createDefaultState(): {
429
- config: RouterConfig;
430
- groupContext: AsyncLocalStorage<{
431
- prefix: string;
432
- groupMiddlewares: any[];
433
- }>;
434
- routes: Set<never>;
435
- routesByPathMethod: Map<any, any>;
436
- routesByMethod: Map<any, any>;
437
- routesByName: Map<any, any>;
438
- prefix: string;
439
- groupMiddlewares: any[];
440
- globalMiddlewares: any[];
441
- };
442
- protected static bindStateAccessors(): void;
443
- protected static createDefaultOptionsHandler(): any;
444
- /**
445
- * Default configuration used for everytime the router is reset
446
- *
447
- * @param options
448
- */
449
- static configureDefaults(options?: RouterConfig): void;
450
- /**
451
- * Use a registered plugin
452
- *
453
- * @param this
454
- * @param plugin
455
- * @param options
456
- * @returns
457
- */
458
- static use<Options = any>(plugin: ClearRouterPluginInput<Options>, options?: Options): Promise<void>;
459
- protected static pluginsReady(): Promise<void>;
460
- protected static getCurrentPluginRequestContext(): ClearRouterPluginRequestContext | undefined;
461
- protected static createPluginRequestContext(ctx: any): ClearRouterPluginRequestContext;
462
- protected static createPluginBind(): PluginBind;
463
- protected static resolvePluginArguments(ctx: any, routeContext: Omit<ClearRouterPluginArgumentsContext, keyof ClearRouterPluginRequestContext>): Promise<any[] | undefined>;
464
- protected static resolvePluginHttpCtx(ctx: any): Promise<void>;
465
- protected static ensureState(): void;
466
- /**
467
- * Normalizes a path by ensuring it starts with a single slash and does not have trailing
468
- * slashes, while preserving dynamic segments and parameters.
469
- *
470
- * @param path The path to normalize.
471
- * @returns The normalized path.
472
- */
473
- static normalizePath(path: string): string;
474
- protected static parseRouteParameters(path: string): Array<{
475
- name: string;
476
- field?: string;
477
- optional: boolean;
478
- }>;
479
- protected static expandRoutePath(path: string): string[];
480
- protected static routeRegistrationPaths(path: string): string[];
481
- /**
482
- * Configures the router with the given options, such as method override settings.
483
- *
484
- * @param this
485
- * @param options
486
- * @returns
487
- */
488
- static configure(this: any, options?: RouterConfig): void;
489
- protected static resolveMethodOverride(method: string, headers: Headers | Record<string, any>, body: unknown): HttpMethod | null;
490
- /**
491
- * Adds a new route to the router.
492
- *
493
- * @param this
494
- * @param methods
495
- * @param path
496
- * @param handler
497
- * @param middlewares
498
- */
499
- static add(methods: HttpMethod | HttpMethod[], path: string, handler: any, middlewares?: any[] | any): Route<any, any, any>;
500
- /**
501
- * Define a resourceful API controller with standard CRUD routes.
502
- *
503
- * @param this
504
- * @param basePath
505
- * @param controller
506
- * @param options
507
- */
508
- static apiResource(basePath: string, controller: any, options?: {
509
- only?: ControllerAction[];
510
- except?: ControllerAction[];
511
- middlewares?: ApiResourceMiddleware<any>;
512
- }): void;
513
- /**
514
- * Adds a new GET route to the router.
515
- *
516
- * @param this The router instance.
517
- * @param path The path for the GET route.
518
- * @param handler The handler function for the GET route.
519
- * @param middlewares Optional middlewares to apply to the GET route.
520
- */
521
- static get(path: string, handler: any, middlewares?: any[] | any): Route<any, any, any>;
522
- /**
523
- * Adds a new POST route to the router.
524
- *
525
- * @param this
526
- * @param path
527
- * @param handler
528
- * @param middlewares
529
- */
530
- static post(path: string, handler: any, middlewares?: any[] | any): Route<any, any, any>;
531
- /**
532
- * Adds a new PUT route to the router.
533
- *
534
- * @param this
535
- * @param path
536
- * @param handler
537
- * @param middlewares
538
- */
539
- static put(path: string, handler: any, middlewares?: any[] | any): Route<any, any, any>;
540
- /**
541
- * Adds a new DELETE route to the router.
542
- *
543
- * @param this
544
- * @param path
545
- * @param handler
546
- * @param middlewares
547
- */
548
- static delete(path: string, handler: any, middlewares?: any[] | any): Route<any, any, any>;
549
- /**
550
- * Adds a new PATCH route to the router.
551
- *
552
- * @param this
553
- * @param path
554
- * @param handler
555
- * @param middlewares
556
- */
557
- static patch(path: string, handler: any, middlewares?: any[] | any): Route<any, any, any>;
558
- /**
559
- * Adds a new OPTIONS route to the router.
560
- *
561
- * @param this
562
- * @param path
563
- * @param handler
564
- * @param middlewares
565
- */
566
- static options(path: string, handler: any, middlewares?: any[] | any): Route<any, any, any>;
567
- /**
568
- * Adds a new HEAD route to the router.
569
- *
570
- * @param this
571
- * @param path
572
- * @param handler
573
- * @param middlewares
574
- */
575
- static head(path: string, handler: any, middlewares?: any[] | any): Route<any, any, any>;
576
- /**
577
- * Defines a group of routes with a common prefix.
578
- *
579
- * @param this
580
- * @param prefix
581
- * @param callback
582
- * @param middlewares
583
- */
584
- static group(prefix: string, callback: () => void | Promise<void>, middlewares?: any[]): Promise<void>;
585
- /**
586
- * Adds global middlewares to the router, which will be applied to all routes.
587
- *
588
- * @param this
589
- * @param middlewares
590
- * @param callback
591
- */
592
- static middleware(middlewares: any[], callback: () => void): void;
593
- /**
594
- * Retrieves all registered routes in the router, optionally organized by path or method
595
- * for easier access and management.
596
- *
597
- * @param this
598
- */
599
- static allRoutes(): Array<Route<any, any, any>>;
600
- /**
601
- * @param this
602
- * @param type - 'path' to get routes organized by path
603
- */
604
- static allRoutes(type: 'path'): Record<string, Route<any, any, any>>;
605
- /**
606
- * @param this
607
- * @param type - 'method' to get routes organized by method
608
- */
609
- static allRoutes(type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<any, any, any>> };
610
- static allRoutes(type: 'name'): Record<string, Route<any, any, any>>;
611
- static route(name: string): Route<any, any, any> | undefined;
612
- static url(name: string, params?: Record<string, any>): string | undefined;
613
- /**
614
- * Provide a class that will overide the base Request instance
615
- *
616
- * @param provider
617
- */
618
- static setRequestProvider(provider: typeof Request$1): void;
619
- /**
620
- * Provide a class that will overide the base Response instance
621
- *
622
- * @param provider
623
- */
624
- static setResponseProvider(provider: typeof Response$2): void;
625
- private static hasPackageInstalled;
626
- /**
627
- * Provide a class that will overide the base Response instance
628
- *
629
- * @param provider
630
- */
631
- private static initializeInstance;
632
- protected static resolveHandler(route: Route<any, any, any>): {
633
- handlerFunction: ((ctx: any, req: Request$1) => any | Promise<any>) | null;
634
- instance: Controller<any> | null;
635
- bindingTarget?: object;
636
- bindingMethod?: PropertyKey;
637
- bindingHandler?: object;
638
- bindingMetadata?: object;
639
- };
640
- protected static callHandler(handlerFunction: (ctx: any, req: Request$1) => any | Promise<any>, ctx: any, bindingTarget?: object, bindingMethod?: PropertyKey, bindingHandler?: object, bindingMetadata?: object): Promise<any>;
641
- protected static bindRequestToInstance(ctx: any, instance: Controller<any> | Route<any, any, any> | null, route: Route<any, any, any>, payload: {
642
- body: Record<string, any>;
643
- query: Record<string, any>;
644
- params: Record<string, any>;
645
- method?: HttpMethod | string;
646
- }): void;
647
- }
648
- //#endregion
649
- export { Middleware$3 as A, H3App as C, FastifyApp as D, Middleware$2 as E, ApiResourceMiddleware as F, ControllerAction as I, HttpMethod as L, HttpContext$4 as M, Middleware$4 as N, Handler$3 as O, Response$2 as P, Middleware$1 as S, HttpContext$2 as T, KoaRouterApp as _, ClearRouterPluginInput as a, HonoApp as b, PluginBind as c, PluginSetupResult as d, definePlugin as f, HttpContext as g, Handler as h, ClearRouterPluginContext as i, Handler$4 as j, HttpContext$3 as k, PluginBindFactory as l, Route as m, ClearRouterPlugin as n, ClearRouterPluginRequestContext as o, Request$1 as p, ClearRouterPluginArgumentsContext as r, PluginArgumentsResolver as s, CoreRouter as t, PluginBindValue as u, Middleware as v, Handler$2 as w, HttpContext$1 as x, Handler$1 as y };