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
package/dist/index.d.mts CHANGED
@@ -1,563 +1,9 @@
1
- import { AsyncLocalStorage } from "node:async_hooks";
2
- import { NextFunction, Request as Request$1, Response as Response$2 } from "express";
3
- import { Middleware as Middleware$4 } from "h3";
4
- import { FastifyReply, FastifyRequest } from "fastify";
5
- import { MiddlewareHandler } from "hono";
6
- import Koa from "koa";
7
-
8
- //#region src/Contracts.d.ts
9
- /**
10
- * HTTP context passed to route handlers
11
- */
12
- interface ClearHttpContext {}
13
- //#endregion
14
- //#region src/types/basic.d.ts
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/core/Response.d.ts
53
- declare class Response$1 {
54
- [key: string]: any;
55
- body: any;
56
- headers: Headers;
57
- sent: boolean;
58
- statusCode: number;
59
- statusText: string;
60
- constructor(init?: Partial<Response$1 | globalThis.Response>);
61
- status(code: number): this;
62
- setStatusText(text: string): this;
63
- code(code: number): this;
64
- setHeader(name: string, value: string): this;
65
- header(name: string, value: string): this;
66
- set(name: string, value: string): this;
67
- type(contentType: string): this;
68
- send(body?: any): this;
69
- json(body: any): this;
70
- html(body: string): this;
71
- text(body: string): this;
72
- noContent(): this;
73
- }
74
- //#endregion
75
- //#region src/Route.d.ts
76
- interface RouteParameter {
77
- name: string;
78
- field?: string;
79
- optional: boolean;
80
- }
81
- declare class Route<X = any, M = Middleware$4 | Middleware$3, H = any> {
82
- ctx: X;
83
- body: RequestData;
84
- query: RequestData;
85
- params: RequestData;
86
- clearRequest: ClearRequest;
87
- methods: HttpMethod[];
88
- path: string;
89
- registrationPaths: string[];
90
- parameters: RouteParameter[];
91
- routeName?: string;
92
- handler: H;
93
- middlewares: M[];
94
- controllerName?: string;
95
- actionName?: string;
96
- handlerType: 'function' | 'controller';
97
- middlewareCount: number;
98
- constructor(methods: HttpMethod[], path: string, handler: H, middlewares?: M[], options?: {
99
- registrationPaths?: string[];
100
- parameters?: RouteParameter[];
101
- onName?: (name: string, route: Route<X, M, H>, previousName?: string) => void;
102
- });
103
- private onName?;
104
- name(name: string): this;
105
- toPath(params?: RequestData): string;
106
- }
107
- //#endregion
108
- //#region src/core/Request.d.ts
109
- declare class Request<X = any, M = any> extends ClearRequest<X, M> {
110
- original?: any;
111
- method: string;
112
- path: string;
113
- url: string;
114
- headers: Headers | Record<string, any>;
115
- constructor(init?: Partial<Request<X, M>> & {
116
- body?: RequestData;
117
- query?: RequestData;
118
- params?: RequestData;
119
- route?: Route<X, M>;
120
- });
121
- getBody(): RequestData;
122
- header(name: string): string;
123
- param(name: string): any;
124
- input(name: string): any;
125
- is(method: HttpMethod | string): boolean;
126
- }
127
- //#endregion
128
- //#region src/types/express.d.ts
129
- /**
130
- * Middleware function type
131
- */
132
- type Middleware$3 = (req: Request$1, res: Response$2, next: NextFunction) => any | Promise<any>;
133
- //#endregion
134
- //#region src/types/fastify.d.ts
135
- interface RequestWithGetBody extends FastifyRequest {
136
- getBody: () => Record<string, any>;
137
- }
138
- type NextFunction$1 = (err?: Error) => void;
139
- type Middleware$2 = (req: RequestWithGetBody, reply: FastifyReply, next: NextFunction$1) => any | Promise<any>;
140
- //#endregion
141
- //#region src/types/hono.d.ts
142
- type Middleware$1 = MiddlewareHandler;
143
- //#endregion
144
- //#region src/types/koa.d.ts
145
- type Middleware = Koa.Middleware<any, any>;
146
- //#endregion
147
- //#region src/ClearRequest.d.ts
148
- declare class ClearRequest<X = any, M = Middleware$4 | Middleware$3 | Middleware$2 | Middleware$1 | Middleware> {
149
- [key: string]: any;
150
- /**
151
- * @param body - Parsed request body
152
- */
153
- body: RequestData;
154
- /**
155
- * @param query - Parsed query parameters
156
- */
157
- query: RequestData;
158
- /**
159
- * @param params - Parsed route parameters
160
- */
161
- params: RequestData;
162
- route: Route<X, M>;
163
- constructor(init?: Partial<ClearRequest>);
164
- }
165
- //#endregion
166
- //#region src/Controller.d.ts
167
- declare abstract class Controller<X = any> {
168
- [x: string]: any;
169
- ctx: X;
170
- body: RequestData;
171
- query: RequestData;
172
- params: RequestData;
173
- clearRequest: ClearRequest;
174
- }
175
- //#endregion
176
- //#region src/core/bindings.d.ts
177
- type BindToken<T = any> = abstract new (...args: any[]) => T;
178
- type BindFactory<T = any> = (ctx: any) => T | Promise<T>;
179
- type BindValue<T = any> = T | BindFactory<T> | BindToken<T>;
180
- declare class Container {
181
- private static readonly registry;
182
- static bind<T>(token: BindToken<T>, value: BindValue<T>): void;
183
- static unbind<T>(token: BindToken<T>): void;
184
- static clear(): void;
185
- static has<T>(token: BindToken<T>): boolean;
186
- static bindings<V = any>(): Record<string, BindValue<V>>;
187
- static resolve<T>(token: BindToken<T>, ctx: any, autoDiscover?: boolean): Promise<T | undefined>;
188
- private static getBinding;
189
- private static findEquivalentToken;
190
- private static getComparableStaticProps;
191
- private static staticPropsMatch;
192
- private static resolveBinding;
193
- }
194
- //#endregion
195
- //#region src/core/plugins.d.ts
196
- type PluginSetupResult = void | Promise<void>;
197
- interface ClearRouterPluginRequestContext<HttpContext = any> {
198
- ctx: HttpContext;
199
- request: Request;
200
- response: Response$1;
201
- getBindings: () => Record<string, BindValue>;
202
- [key: string]: any;
203
- }
204
- interface ClearRouterPluginArgumentsContext<X = any> extends ClearRouterPluginRequestContext<X> {
205
- target?: object;
206
- method?: PropertyKey;
207
- handler?: object;
208
- metadata?: object;
209
- tokens: BindToken[];
210
- designTokens: BindToken[];
211
- }
212
- type PluginBindFactory<T = any, X = any> = (ctx: ClearRouterPluginRequestContext<X>) => T | Promise<T>;
213
- type PluginBindValue<T = any, X = any> = BindValue<T> | PluginBindFactory<T, X>;
214
- type PluginBind<X = any> = <T>(token: BindToken<T>, value: PluginBindValue<T, X>) => void;
215
- type PluginArgumentsResolver<HttpContext = any> = (ctx: ClearRouterPluginArgumentsContext<HttpContext>) => any[] | undefined | Promise<any[] | undefined>;
216
- interface ClearRouterPluginContext<Options = any, HttpContext = any> {
217
- /**
218
- * The service container
219
- */
220
- container: typeof Container;
221
- /**
222
- * Register service container bindings
223
- */
224
- bind: PluginBind<HttpContext>;
225
- /**
226
- * Replace all controller method arguments
227
- * @param resolver
228
- * @returns
229
- */
230
- resolveArguments: (resolver: PluginArgumentsResolver<HttpContext>) => void;
231
- /**
232
- * Use the current http context
233
- */
234
- useHttpContext: (resolver: PluginArgumentsResolver<HttpContext>) => void;
235
- /**
236
- * All registered service container bindings
237
- */
238
- bindings: Record<string, BindValue>;
239
- /**
240
- * Configures the router with the given options, such as method override settings
241
- *
242
- * @param options
243
- * @returns
244
- */
245
- configure: (options: RouterConfig) => void;
246
- /**
247
- * Default configuration used for everytime the router is reset
248
- *
249
- * @param options
250
- */
251
- configureDefaults: (options: RouterConfig) => void;
252
- /**
253
- * The current Request instance
254
- */
255
- readonly request?: Request;
256
- /**
257
- * The current Response instance
258
- * @returns
259
- */
260
- readonly response?: Response$1;
261
- /**
262
- * Get the current Request instance
263
- * @returns
264
- */
265
- getRequest: () => Request | undefined;
266
- /**
267
- * Get the current Response instance
268
- * @returns
269
- */
270
- getResponse: () => Response$1 | undefined;
271
- /**
272
- * Plugin configuration options
273
- */
274
- options: Options;
275
- }
276
- interface ClearRouterPlugin<Options = any, HttpContext = any> {
277
- /**
278
- * The name of the plugin
279
- */
280
- name?: string;
281
- /**
282
- * Plugin setup an implemnetation
283
- *
284
- * @param ctx
285
- * @returns
286
- */
287
- setup: (ctx: ClearRouterPluginContext<Options, HttpContext>) => PluginSetupResult;
288
- }
289
- type ClearRouterPluginInput<Options = any, HttpContext = any> = ClearRouterPlugin<Options> | ((ctx: ClearRouterPluginContext<Options, HttpContext>) => PluginSetupResult);
290
- /**
291
- * Creates a new plugin
292
- *
293
- * @param plugin
294
- * @returns
295
- */
296
- declare function definePlugin<Options = any, HttpContext = any>(plugin: ClearRouterPlugin<Options, HttpContext>): ClearRouterPlugin<Options, HttpContext>;
297
- //#endregion
298
- //#region src/core/router.d.ts
299
- /**
300
- * @class clear-router CoreRouter
301
- * @description Core routing logic for clear-router, shared between all supported adapters (Express.js, H3, etc.)
302
- * @author 3m1n3nc3
303
- * @repository https://github.com/arkstack-tmp/clear-router
304
- */
305
- declare abstract class CoreRouter {
306
- protected static routerStateNamespace: string;
307
- private static readonly stateStoreKey;
308
- private static readonly stateBoundKey;
309
- private static readonly defaultConfigKey;
310
- private static readonly pluginStoreKey;
311
- private static readonly pluginPendingKey;
312
- private static readonly pluginHttpCtxResolversKey;
313
- private static readonly pluginArgumentResolversKey;
314
- private static requestProvider?;
315
- private static responseProvider?;
316
- static config: RouterConfig;
317
- protected static groupContext: AsyncLocalStorage<{
318
- prefix: string;
319
- groupMiddlewares: any[];
320
- }>;
321
- protected static pluginRequestContext: AsyncLocalStorage<ClearRouterPluginRequestContext<any>>;
322
- static routes: Set<Route<any, any, any>>;
323
- static routesByPathMethod: Map<string, Route<any, any, any>>;
324
- static routesByMethod: Map<"GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "OPTIONS" | "HEAD", Route<any, any, any>[]>;
325
- static routesByName: Map<string, Route<any, any, any>>;
326
- static prefix: string;
327
- static groupMiddlewares: any[];
328
- static globalMiddlewares: any[];
329
- /**
330
- * Resets the router to it's default state
331
- */
332
- static reset(): typeof CoreRouter;
333
- protected static createBaseConfig(): RouterConfig;
334
- protected static mergeConfig(target: RouterConfig, source?: RouterConfig): RouterConfig;
335
- protected static getDefaultConfig(): RouterConfig;
336
- protected static resolveStateNamespace(): string;
337
- protected static getStateStore(): Record<string, any>;
338
- protected static getPluginStore(): Set<string>;
339
- protected static getPluginPendingStore(): Set<Promise<void>>;
340
- protected static getPluginArgumentResolvers(): Set<PluginArgumentsResolver>;
341
- protected static getPluginHttpCtxResolvers(): Set<PluginArgumentsResolver>;
342
- protected static createDefaultState(): {
343
- config: RouterConfig;
344
- groupContext: AsyncLocalStorage<{
345
- prefix: string;
346
- groupMiddlewares: any[];
347
- }>;
348
- routes: Set<never>;
349
- routesByPathMethod: Map<any, any>;
350
- routesByMethod: Map<any, any>;
351
- routesByName: Map<any, any>;
352
- prefix: string;
353
- groupMiddlewares: any[];
354
- globalMiddlewares: any[];
355
- };
356
- protected static bindStateAccessors(): void;
357
- protected static createDefaultOptionsHandler(): any;
358
- /**
359
- * Default configuration used for everytime the router is reset
360
- *
361
- * @param options
362
- */
363
- static configureDefaults(options?: RouterConfig): void;
364
- /**
365
- * Use a registered plugin
366
- *
367
- * @param this
368
- * @param plugin
369
- * @param options
370
- * @returns
371
- */
372
- static use<Options = any>(plugin: ClearRouterPluginInput<Options>, options?: Options): Promise<void>;
373
- protected static pluginsReady(): Promise<void>;
374
- protected static getCurrentPluginRequestContext(): ClearRouterPluginRequestContext | undefined;
375
- protected static createPluginRequestContext(ctx: any): ClearRouterPluginRequestContext;
376
- protected static createPluginBind(): PluginBind;
377
- protected static resolvePluginArguments(ctx: any, routeContext: Omit<ClearRouterPluginArgumentsContext, keyof ClearRouterPluginRequestContext>): Promise<any[] | undefined>;
378
- protected static resolvePluginHttpCtx(ctx: any): Promise<void>;
379
- protected static ensureState(): void;
380
- /**
381
- * Normalizes a path by ensuring it starts with a single slash and does not have trailing
382
- * slashes, while preserving dynamic segments and parameters.
383
- *
384
- * @param path The path to normalize.
385
- * @returns The normalized path.
386
- */
387
- static normalizePath(path: string): string;
388
- protected static parseRouteParameters(path: string): Array<{
389
- name: string;
390
- field?: string;
391
- optional: boolean;
392
- }>;
393
- protected static expandRoutePath(path: string): string[];
394
- protected static routeRegistrationPaths(path: string): string[];
395
- /**
396
- * Configures the router with the given options, such as method override settings.
397
- *
398
- * @param this
399
- * @param options
400
- * @returns
401
- */
402
- static configure(this: any, options?: RouterConfig): void;
403
- protected static resolveMethodOverride(method: string, headers: Headers | Record<string, any>, body: unknown): HttpMethod | null;
404
- /**
405
- * Adds a new route to the router.
406
- *
407
- * @param this
408
- * @param methods
409
- * @param path
410
- * @param handler
411
- * @param middlewares
412
- */
413
- static add(methods: HttpMethod | HttpMethod[], path: string, handler: any, middlewares?: any[] | any): Route<any, any, any>;
414
- /**
415
- * Define a resourceful API controller with standard CRUD routes.
416
- *
417
- * @param this
418
- * @param basePath
419
- * @param controller
420
- * @param options
421
- */
422
- static apiResource(basePath: string, controller: any, options?: {
423
- only?: ControllerAction[];
424
- except?: ControllerAction[];
425
- middlewares?: ApiResourceMiddleware<any>;
426
- }): void;
427
- /**
428
- * Adds a new GET route to the router.
429
- *
430
- * @param this The router instance.
431
- * @param path The path for the GET route.
432
- * @param handler The handler function for the GET route.
433
- * @param middlewares Optional middlewares to apply to the GET route.
434
- */
435
- static get(path: string, handler: any, middlewares?: any[] | any): Route<any, any, any>;
436
- /**
437
- * Adds a new POST route to the router.
438
- *
439
- * @param this
440
- * @param path
441
- * @param handler
442
- * @param middlewares
443
- */
444
- static post(path: string, handler: any, middlewares?: any[] | any): Route<any, any, any>;
445
- /**
446
- * Adds a new PUT route to the router.
447
- *
448
- * @param this
449
- * @param path
450
- * @param handler
451
- * @param middlewares
452
- */
453
- static put(path: string, handler: any, middlewares?: any[] | any): Route<any, any, any>;
454
- /**
455
- * Adds a new DELETE route to the router.
456
- *
457
- * @param this
458
- * @param path
459
- * @param handler
460
- * @param middlewares
461
- */
462
- static delete(path: string, handler: any, middlewares?: any[] | any): Route<any, any, any>;
463
- /**
464
- * Adds a new PATCH route to the router.
465
- *
466
- * @param this
467
- * @param path
468
- * @param handler
469
- * @param middlewares
470
- */
471
- static patch(path: string, handler: any, middlewares?: any[] | any): Route<any, any, any>;
472
- /**
473
- * Adds a new OPTIONS route to the router.
474
- *
475
- * @param this
476
- * @param path
477
- * @param handler
478
- * @param middlewares
479
- */
480
- static options(path: string, handler: any, middlewares?: any[] | any): Route<any, any, any>;
481
- /**
482
- * Adds a new HEAD route to the router.
483
- *
484
- * @param this
485
- * @param path
486
- * @param handler
487
- * @param middlewares
488
- */
489
- static head(path: string, handler: any, middlewares?: any[] | any): Route<any, any, any>;
490
- /**
491
- * Defines a group of routes with a common prefix.
492
- *
493
- * @param this
494
- * @param prefix
495
- * @param callback
496
- * @param middlewares
497
- */
498
- static group(prefix: string, callback: () => void | Promise<void>, middlewares?: any[]): Promise<void>;
499
- /**
500
- * Adds global middlewares to the router, which will be applied to all routes.
501
- *
502
- * @param this
503
- * @param middlewares
504
- * @param callback
505
- */
506
- static middleware(middlewares: any[], callback: () => void): void;
507
- /**
508
- * Retrieves all registered routes in the router, optionally organized by path or method
509
- * for easier access and management.
510
- *
511
- * @param this
512
- */
513
- static allRoutes(): Array<Route<any, any, any>>;
514
- /**
515
- * @param this
516
- * @param type - 'path' to get routes organized by path
517
- */
518
- static allRoutes(type: 'path'): Record<string, Route<any, any, any>>;
519
- /**
520
- * @param this
521
- * @param type - 'method' to get routes organized by method
522
- */
523
- static allRoutes(type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<any, any, any>> };
524
- static allRoutes(type: 'name'): Record<string, Route<any, any, any>>;
525
- static route(name: string): Route<any, any, any> | undefined;
526
- static url(name: string, params?: Record<string, any>): string | undefined;
527
- /**
528
- * Provide a class that will overide the base Request instance
529
- *
530
- * @param provider
531
- */
532
- static setRequestProvider(provider: typeof Request): void;
533
- /**
534
- * Provide a class that will overide the base Response instance
535
- *
536
- * @param provider
537
- */
538
- static setResponseProvider(provider: typeof Response$1): void;
539
- private static hasPackageInstalled;
540
- /**
541
- * Provide a class that will overide the base Response instance
542
- *
543
- * @param provider
544
- */
545
- private static initializeInstance;
546
- protected static resolveHandler(route: Route<any, any, any>): {
547
- handlerFunction: ((ctx: any, req: Request) => any | Promise<any>) | null;
548
- instance: Controller<any> | null;
549
- bindingTarget?: object;
550
- bindingMethod?: PropertyKey;
551
- bindingHandler?: object;
552
- bindingMetadata?: object;
553
- };
554
- protected static callHandler(handlerFunction: (ctx: any, req: Request) => any | Promise<any>, ctx: any, bindingTarget?: object, bindingMethod?: PropertyKey, bindingHandler?: object, bindingMetadata?: object): Promise<any>;
555
- protected static bindRequestToInstance(ctx: any, instance: Controller<any> | Route<any, any, any> | null, route: Route<any, any, any>, payload: {
556
- body: Record<string, any>;
557
- query: Record<string, any>;
558
- params: Record<string, any>;
559
- method?: HttpMethod | string;
560
- }): void;
561
- }
562
- //#endregion
563
- export { ClearHttpContext, ClearRequest, ClearRouterPlugin, ClearRouterPluginArgumentsContext, ClearRouterPluginContext, ClearRouterPluginInput, ClearRouterPluginRequestContext, Controller, CoreRouter, PluginArgumentsResolver, PluginBind, PluginBindFactory, PluginBindValue, PluginSetupResult, Request, Response$1 as Response, Route, RouteParameter, definePlugin };
1
+ import { ClearHttpContext, RouteParameter } from "./Contracts.mjs";
2
+ import { Response } from "./core/Response.mjs";
3
+ import { Route } from "./Route.mjs";
4
+ import { Request } from "./core/Request.mjs";
5
+ import { ClearRequest } from "./ClearRequest.mjs";
6
+ import { Controller } from "./Controller.mjs";
7
+ import { ClearRouterPlugin, ClearRouterPluginArgumentsContext, ClearRouterPluginContext, ClearRouterPluginInput, ClearRouterPluginRequestContext, PluginArgumentsResolver, PluginBind, PluginBindFactory, PluginBindValue, PluginSetupResult, definePlugin } from "./core/plugins.mjs";
8
+ import { CoreRouter } from "./core/router.mjs";
9
+ export { ClearHttpContext, ClearRequest, ClearRouterPlugin, ClearRouterPluginArgumentsContext, ClearRouterPluginContext, ClearRouterPluginInput, ClearRouterPluginRequestContext, Controller, CoreRouter, PluginArgumentsResolver, PluginBind, PluginBindFactory, PluginBindValue, PluginSetupResult, Request, Response, Route, RouteParameter, definePlugin };