clear-router 2.5.11 → 2.5.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{bindings-CDGLuAq4.cjs → bindings-CLsZjOEy.cjs} +8 -1
- package/dist/{bindings-B6x2HfzP.mjs → bindings-XLDXFpHZ.mjs} +8 -1
- package/dist/core/index.cjs +2 -2
- package/dist/core/index.d.cts +2 -2
- package/dist/core/index.d.mts +2 -2
- package/dist/core/index.mjs +2 -2
- package/dist/decorators/index.cjs +1 -1
- package/dist/decorators/index.mjs +1 -1
- package/dist/decorators/setup.cjs +2 -2
- package/dist/decorators/setup.mjs +2 -2
- package/dist/express/index.cjs +3 -3
- package/dist/express/index.d.cts +1 -1
- package/dist/express/index.d.mts +1 -1
- package/dist/express/index.mjs +3 -3
- package/dist/fastify/index.cjs +3 -3
- package/dist/fastify/index.d.cts +1 -1
- package/dist/fastify/index.d.mts +1 -1
- package/dist/fastify/index.mjs +3 -3
- package/dist/h3/index.cjs +3 -3
- package/dist/h3/index.d.cts +1 -1
- package/dist/h3/index.d.mts +1 -1
- package/dist/h3/index.mjs +3 -3
- package/dist/hono/index.cjs +3 -3
- package/dist/hono/index.d.cts +1 -1
- package/dist/hono/index.d.mts +1 -1
- package/dist/hono/index.mjs +3 -3
- package/dist/index.cjs +46 -6
- package/dist/index.d.cts +40 -24
- package/dist/index.d.mts +40 -24
- package/dist/index.mjs +46 -6
- package/dist/koa/index.cjs +3 -3
- package/dist/koa/index.d.cts +1 -1
- package/dist/koa/index.d.mts +1 -1
- package/dist/koa/index.mjs +3 -3
- package/dist/{responses-DuZeRyGE.mjs → responses-BvETUeDL.mjs} +1 -1
- package/dist/{responses-CBP3RYjJ.cjs → responses-Bvnk0uvc.cjs} +1 -1
- package/dist/{router-CArh9OHb.mjs → router-CPmZcbU0.mjs} +39 -6
- package/dist/{router-DtqXUlJq.cjs → router-D9H9-T27.cjs} +39 -6
- package/dist/{router-DCGZNRNj.d.cts → router-DTI0BowV.d.cts} +40 -24
- package/dist/{router-BkYtqjYr.d.mts → router-DiKqUyvk.d.mts} +40 -24
- package/dist/types/core/Response.d.mts +3 -1
- package/package.json +1 -1
|
@@ -9,8 +9,10 @@ declare class Response$2 {
|
|
|
9
9
|
headers: Headers;
|
|
10
10
|
sent: boolean;
|
|
11
11
|
statusCode: number;
|
|
12
|
-
|
|
12
|
+
statusText: string;
|
|
13
|
+
constructor(init?: Partial<Response$2 | globalThis.Response>);
|
|
13
14
|
status(code: number): this;
|
|
15
|
+
setStatusText(text: string): this;
|
|
14
16
|
code(code: number): this;
|
|
15
17
|
setHeader(name: string, value: string): this;
|
|
16
18
|
header(name: string, value: string): this;
|
|
@@ -195,14 +197,25 @@ interface ClearRouterPluginRequestContext {
|
|
|
195
197
|
ctx: any;
|
|
196
198
|
request: Request$1;
|
|
197
199
|
response: Response$2;
|
|
200
|
+
getBindings: () => Record<string, BindValue>;
|
|
198
201
|
[key: string]: any;
|
|
199
202
|
}
|
|
203
|
+
interface ClearRouterPluginArgumentsContext extends ClearRouterPluginRequestContext {
|
|
204
|
+
target?: object;
|
|
205
|
+
method?: PropertyKey;
|
|
206
|
+
handler?: object;
|
|
207
|
+
metadata?: object;
|
|
208
|
+
tokens: BindToken[];
|
|
209
|
+
designTokens: BindToken[];
|
|
210
|
+
}
|
|
200
211
|
type PluginBindFactory<T = any> = (ctx: ClearRouterPluginRequestContext) => T | Promise<T>;
|
|
201
212
|
type PluginBindValue<T = any> = BindValue<T> | PluginBindFactory<T>;
|
|
202
213
|
type PluginBind = <T>(token: BindToken<T>, value: PluginBindValue<T>) => void;
|
|
214
|
+
type PluginArgumentsResolver = (ctx: ClearRouterPluginArgumentsContext) => any[] | undefined | Promise<any[] | undefined>;
|
|
203
215
|
interface ClearRouterPluginContext<Options = any> {
|
|
204
216
|
container: typeof Container;
|
|
205
217
|
bind: PluginBind;
|
|
218
|
+
resolveArguments: (resolver: PluginArgumentsResolver) => void;
|
|
206
219
|
bindings: Record<string, BindValue>;
|
|
207
220
|
configure: (options: RouterConfig) => void;
|
|
208
221
|
configureDefaults: (options: RouterConfig) => void;
|
|
@@ -243,13 +256,15 @@ declare abstract class CoreRouter {
|
|
|
243
256
|
private static readonly defaultConfigKey;
|
|
244
257
|
private static readonly pluginStoreKey;
|
|
245
258
|
private static readonly pluginPendingKey;
|
|
259
|
+
private static readonly pluginArgumentResolversKey;
|
|
246
260
|
protected static createBaseConfig(): RouterConfig;
|
|
247
261
|
protected static mergeConfig(target: RouterConfig, source?: RouterConfig): RouterConfig;
|
|
248
262
|
protected static getDefaultConfig(): RouterConfig;
|
|
249
|
-
protected static resolveStateNamespace(
|
|
263
|
+
protected static resolveStateNamespace(): string;
|
|
250
264
|
protected static getStateStore(): Record<string, any>;
|
|
251
265
|
protected static getPluginStore(): Set<string>;
|
|
252
266
|
protected static getPluginPendingStore(): Set<Promise<void>>;
|
|
267
|
+
protected static getPluginArgumentResolvers(): Set<PluginArgumentsResolver>;
|
|
253
268
|
protected static createDefaultState(): {
|
|
254
269
|
config: RouterConfig;
|
|
255
270
|
groupContext: AsyncLocalStorage<{
|
|
@@ -263,10 +278,10 @@ declare abstract class CoreRouter {
|
|
|
263
278
|
groupMiddlewares: any[];
|
|
264
279
|
globalMiddlewares: any[];
|
|
265
280
|
};
|
|
266
|
-
protected static bindStateAccessors(
|
|
281
|
+
protected static bindStateAccessors(): void;
|
|
267
282
|
protected static createDefaultOptionsHandler(): any;
|
|
268
283
|
static config: RouterConfig;
|
|
269
|
-
static configureDefaults(
|
|
284
|
+
static configureDefaults(options?: RouterConfig): void;
|
|
270
285
|
/**
|
|
271
286
|
* Use a registered plugin
|
|
272
287
|
*
|
|
@@ -275,8 +290,8 @@ declare abstract class CoreRouter {
|
|
|
275
290
|
* @param options
|
|
276
291
|
* @returns
|
|
277
292
|
*/
|
|
278
|
-
static use<Options = any>(
|
|
279
|
-
protected static pluginsReady(
|
|
293
|
+
static use<Options = any>(plugin: ClearRouterPluginInput<Options>, options?: Options): Promise<void>;
|
|
294
|
+
protected static pluginsReady(): Promise<void>;
|
|
280
295
|
protected static groupContext: AsyncLocalStorage<{
|
|
281
296
|
prefix: string;
|
|
282
297
|
groupMiddlewares: any[];
|
|
@@ -291,7 +306,8 @@ declare abstract class CoreRouter {
|
|
|
291
306
|
protected static getCurrentPluginRequestContext(): ClearRouterPluginRequestContext | undefined;
|
|
292
307
|
protected static createPluginRequestContext(ctx: any): ClearRouterPluginRequestContext;
|
|
293
308
|
protected static createPluginBind(): PluginBind;
|
|
294
|
-
protected static
|
|
309
|
+
protected static resolvePluginArguments(this: any, ctx: any, routeContext: Omit<ClearRouterPluginArgumentsContext, keyof ClearRouterPluginRequestContext>): Promise<any[] | undefined>;
|
|
310
|
+
protected static ensureState(): void;
|
|
295
311
|
/**
|
|
296
312
|
* Normalizes a path by ensuring it starts with a single slash and does not have trailing
|
|
297
313
|
* slashes, while preserving dynamic segments and parameters.
|
|
@@ -308,7 +324,7 @@ declare abstract class CoreRouter {
|
|
|
308
324
|
* @returns
|
|
309
325
|
*/
|
|
310
326
|
static configure(this: any, options?: RouterConfig): void;
|
|
311
|
-
protected static resolveMethodOverride(
|
|
327
|
+
protected static resolveMethodOverride(method: string, headers: Headers | Record<string, any>, body: unknown): HttpMethod | null;
|
|
312
328
|
/**
|
|
313
329
|
* Adds a new route to the router.
|
|
314
330
|
*
|
|
@@ -318,7 +334,7 @@ declare abstract class CoreRouter {
|
|
|
318
334
|
* @param handler
|
|
319
335
|
* @param middlewares
|
|
320
336
|
*/
|
|
321
|
-
static add(
|
|
337
|
+
static add(methods: HttpMethod | HttpMethod[], path: string, handler: any, middlewares?: any[] | any): void;
|
|
322
338
|
/**
|
|
323
339
|
* Define a resourceful API controller with standard CRUD routes.
|
|
324
340
|
*
|
|
@@ -327,7 +343,7 @@ declare abstract class CoreRouter {
|
|
|
327
343
|
* @param controller
|
|
328
344
|
* @param options
|
|
329
345
|
*/
|
|
330
|
-
static apiResource(
|
|
346
|
+
static apiResource(basePath: string, controller: any, options?: {
|
|
331
347
|
only?: ControllerAction[];
|
|
332
348
|
except?: ControllerAction[];
|
|
333
349
|
middlewares?: ApiResourceMiddleware<any>;
|
|
@@ -340,7 +356,7 @@ declare abstract class CoreRouter {
|
|
|
340
356
|
* @param handler The handler function for the GET route.
|
|
341
357
|
* @param middlewares Optional middlewares to apply to the GET route.
|
|
342
358
|
*/
|
|
343
|
-
static get(
|
|
359
|
+
static get(path: string, handler: any, middlewares?: any[] | any): void;
|
|
344
360
|
/**
|
|
345
361
|
* Adds a new POST route to the router.
|
|
346
362
|
*
|
|
@@ -349,7 +365,7 @@ declare abstract class CoreRouter {
|
|
|
349
365
|
* @param handler
|
|
350
366
|
* @param middlewares
|
|
351
367
|
*/
|
|
352
|
-
static post(
|
|
368
|
+
static post(path: string, handler: any, middlewares?: any[] | any): void;
|
|
353
369
|
/**
|
|
354
370
|
* Adds a new PUT route to the router.
|
|
355
371
|
*
|
|
@@ -358,7 +374,7 @@ declare abstract class CoreRouter {
|
|
|
358
374
|
* @param handler
|
|
359
375
|
* @param middlewares
|
|
360
376
|
*/
|
|
361
|
-
static put(
|
|
377
|
+
static put(path: string, handler: any, middlewares?: any[] | any): void;
|
|
362
378
|
/**
|
|
363
379
|
* Adds a new DELETE route to the router.
|
|
364
380
|
*
|
|
@@ -367,7 +383,7 @@ declare abstract class CoreRouter {
|
|
|
367
383
|
* @param handler
|
|
368
384
|
* @param middlewares
|
|
369
385
|
*/
|
|
370
|
-
static delete(
|
|
386
|
+
static delete(path: string, handler: any, middlewares?: any[] | any): void;
|
|
371
387
|
/**
|
|
372
388
|
* Adds a new PATCH route to the router.
|
|
373
389
|
*
|
|
@@ -376,7 +392,7 @@ declare abstract class CoreRouter {
|
|
|
376
392
|
* @param handler
|
|
377
393
|
* @param middlewares
|
|
378
394
|
*/
|
|
379
|
-
static patch(
|
|
395
|
+
static patch(path: string, handler: any, middlewares?: any[] | any): void;
|
|
380
396
|
/**
|
|
381
397
|
* Adds a new OPTIONS route to the router.
|
|
382
398
|
*
|
|
@@ -385,7 +401,7 @@ declare abstract class CoreRouter {
|
|
|
385
401
|
* @param handler
|
|
386
402
|
* @param middlewares
|
|
387
403
|
*/
|
|
388
|
-
static options(
|
|
404
|
+
static options(path: string, handler: any, middlewares?: any[] | any): void;
|
|
389
405
|
/**
|
|
390
406
|
* Adds a new HEAD route to the router.
|
|
391
407
|
*
|
|
@@ -394,7 +410,7 @@ declare abstract class CoreRouter {
|
|
|
394
410
|
* @param handler
|
|
395
411
|
* @param middlewares
|
|
396
412
|
*/
|
|
397
|
-
static head(
|
|
413
|
+
static head(path: string, handler: any, middlewares?: any[] | any): void;
|
|
398
414
|
/**
|
|
399
415
|
* Defines a group of routes with a common prefix.
|
|
400
416
|
*
|
|
@@ -403,7 +419,7 @@ declare abstract class CoreRouter {
|
|
|
403
419
|
* @param callback
|
|
404
420
|
* @param middlewares
|
|
405
421
|
*/
|
|
406
|
-
static group(
|
|
422
|
+
static group(prefix: string, callback: () => void | Promise<void>, middlewares?: any[]): Promise<void>;
|
|
407
423
|
/**
|
|
408
424
|
* Adds global middlewares to the router, which will be applied to all routes.
|
|
409
425
|
*
|
|
@@ -411,24 +427,24 @@ declare abstract class CoreRouter {
|
|
|
411
427
|
* @param middlewares
|
|
412
428
|
* @param callback
|
|
413
429
|
*/
|
|
414
|
-
static middleware(
|
|
430
|
+
static middleware(middlewares: any[], callback: () => void): void;
|
|
415
431
|
/**
|
|
416
432
|
* Retrieves all registered routes in the router, optionally organized by path or method
|
|
417
433
|
* for easier access and management.
|
|
418
434
|
*
|
|
419
435
|
* @param this
|
|
420
436
|
*/
|
|
421
|
-
static allRoutes(
|
|
437
|
+
static allRoutes(): Array<Route<any, any, any>>;
|
|
422
438
|
/**
|
|
423
439
|
* @param this
|
|
424
440
|
* @param type - 'path' to get routes organized by path
|
|
425
441
|
*/
|
|
426
|
-
static allRoutes(
|
|
442
|
+
static allRoutes(type: 'path'): Record<string, Route<any, any, any>>;
|
|
427
443
|
/**
|
|
428
444
|
* @param this
|
|
429
445
|
* @param type - 'method' to get routes organized by method
|
|
430
446
|
*/
|
|
431
|
-
static allRoutes(
|
|
447
|
+
static allRoutes(type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<any, any, any>> };
|
|
432
448
|
protected static resolveHandler(route: Route<any, any, any>): {
|
|
433
449
|
handlerFunction: ((ctx: any, req: Request$1) => any | Promise<any>) | null;
|
|
434
450
|
instance: Controller<any> | null;
|
|
@@ -437,7 +453,7 @@ declare abstract class CoreRouter {
|
|
|
437
453
|
bindingHandler?: object;
|
|
438
454
|
bindingMetadata?: object;
|
|
439
455
|
};
|
|
440
|
-
protected static callHandler(
|
|
456
|
+
protected static callHandler(handlerFunction: (ctx: any, req: Request$1) => any | Promise<any>, ctx: any, bindingTarget?: object, bindingMethod?: PropertyKey, bindingHandler?: object, bindingMetadata?: object): Promise<any>;
|
|
441
457
|
protected static bindRequestToInstance(ctx: any, instance: Controller<any> | Route<any, any, any> | null, route: Route<any, any, any>, payload: {
|
|
442
458
|
body: Record<string, any>;
|
|
443
459
|
query: Record<string, any>;
|
|
@@ -446,4 +462,4 @@ declare abstract class CoreRouter {
|
|
|
446
462
|
}): void;
|
|
447
463
|
}
|
|
448
464
|
//#endregion
|
|
449
|
-
export {
|
|
465
|
+
export { ControllerAction as C, Response$2 as E, ApiResourceMiddleware as S, HttpMethod as T, HttpContext as _, ClearRouterPluginInput as a, HttpContext$1 as b, PluginBind as c, PluginSetupResult as d, definePlugin as f, Handler as g, H3App as h, ClearRouterPluginContext as i, 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, ControllerHandler as w, Middleware$1 as x, Handler$1 as y };
|
|
@@ -9,8 +9,10 @@ declare class Response$2 {
|
|
|
9
9
|
headers: Headers;
|
|
10
10
|
sent: boolean;
|
|
11
11
|
statusCode: number;
|
|
12
|
-
|
|
12
|
+
statusText: string;
|
|
13
|
+
constructor(init?: Partial<Response$2 | globalThis.Response>);
|
|
13
14
|
status(code: number): this;
|
|
15
|
+
setStatusText(text: string): this;
|
|
14
16
|
code(code: number): this;
|
|
15
17
|
setHeader(name: string, value: string): this;
|
|
16
18
|
header(name: string, value: string): this;
|
|
@@ -195,14 +197,25 @@ interface ClearRouterPluginRequestContext {
|
|
|
195
197
|
ctx: any;
|
|
196
198
|
request: Request$1;
|
|
197
199
|
response: Response$2;
|
|
200
|
+
getBindings: () => Record<string, BindValue>;
|
|
198
201
|
[key: string]: any;
|
|
199
202
|
}
|
|
203
|
+
interface ClearRouterPluginArgumentsContext extends ClearRouterPluginRequestContext {
|
|
204
|
+
target?: object;
|
|
205
|
+
method?: PropertyKey;
|
|
206
|
+
handler?: object;
|
|
207
|
+
metadata?: object;
|
|
208
|
+
tokens: BindToken[];
|
|
209
|
+
designTokens: BindToken[];
|
|
210
|
+
}
|
|
200
211
|
type PluginBindFactory<T = any> = (ctx: ClearRouterPluginRequestContext) => T | Promise<T>;
|
|
201
212
|
type PluginBindValue<T = any> = BindValue<T> | PluginBindFactory<T>;
|
|
202
213
|
type PluginBind = <T>(token: BindToken<T>, value: PluginBindValue<T>) => void;
|
|
214
|
+
type PluginArgumentsResolver = (ctx: ClearRouterPluginArgumentsContext) => any[] | undefined | Promise<any[] | undefined>;
|
|
203
215
|
interface ClearRouterPluginContext<Options = any> {
|
|
204
216
|
container: typeof Container;
|
|
205
217
|
bind: PluginBind;
|
|
218
|
+
resolveArguments: (resolver: PluginArgumentsResolver) => void;
|
|
206
219
|
bindings: Record<string, BindValue>;
|
|
207
220
|
configure: (options: RouterConfig) => void;
|
|
208
221
|
configureDefaults: (options: RouterConfig) => void;
|
|
@@ -243,13 +256,15 @@ declare abstract class CoreRouter {
|
|
|
243
256
|
private static readonly defaultConfigKey;
|
|
244
257
|
private static readonly pluginStoreKey;
|
|
245
258
|
private static readonly pluginPendingKey;
|
|
259
|
+
private static readonly pluginArgumentResolversKey;
|
|
246
260
|
protected static createBaseConfig(): RouterConfig;
|
|
247
261
|
protected static mergeConfig(target: RouterConfig, source?: RouterConfig): RouterConfig;
|
|
248
262
|
protected static getDefaultConfig(): RouterConfig;
|
|
249
|
-
protected static resolveStateNamespace(
|
|
263
|
+
protected static resolveStateNamespace(): string;
|
|
250
264
|
protected static getStateStore(): Record<string, any>;
|
|
251
265
|
protected static getPluginStore(): Set<string>;
|
|
252
266
|
protected static getPluginPendingStore(): Set<Promise<void>>;
|
|
267
|
+
protected static getPluginArgumentResolvers(): Set<PluginArgumentsResolver>;
|
|
253
268
|
protected static createDefaultState(): {
|
|
254
269
|
config: RouterConfig;
|
|
255
270
|
groupContext: AsyncLocalStorage<{
|
|
@@ -263,10 +278,10 @@ declare abstract class CoreRouter {
|
|
|
263
278
|
groupMiddlewares: any[];
|
|
264
279
|
globalMiddlewares: any[];
|
|
265
280
|
};
|
|
266
|
-
protected static bindStateAccessors(
|
|
281
|
+
protected static bindStateAccessors(): void;
|
|
267
282
|
protected static createDefaultOptionsHandler(): any;
|
|
268
283
|
static config: RouterConfig;
|
|
269
|
-
static configureDefaults(
|
|
284
|
+
static configureDefaults(options?: RouterConfig): void;
|
|
270
285
|
/**
|
|
271
286
|
* Use a registered plugin
|
|
272
287
|
*
|
|
@@ -275,8 +290,8 @@ declare abstract class CoreRouter {
|
|
|
275
290
|
* @param options
|
|
276
291
|
* @returns
|
|
277
292
|
*/
|
|
278
|
-
static use<Options = any>(
|
|
279
|
-
protected static pluginsReady(
|
|
293
|
+
static use<Options = any>(plugin: ClearRouterPluginInput<Options>, options?: Options): Promise<void>;
|
|
294
|
+
protected static pluginsReady(): Promise<void>;
|
|
280
295
|
protected static groupContext: AsyncLocalStorage<{
|
|
281
296
|
prefix: string;
|
|
282
297
|
groupMiddlewares: any[];
|
|
@@ -291,7 +306,8 @@ declare abstract class CoreRouter {
|
|
|
291
306
|
protected static getCurrentPluginRequestContext(): ClearRouterPluginRequestContext | undefined;
|
|
292
307
|
protected static createPluginRequestContext(ctx: any): ClearRouterPluginRequestContext;
|
|
293
308
|
protected static createPluginBind(): PluginBind;
|
|
294
|
-
protected static
|
|
309
|
+
protected static resolvePluginArguments(this: any, ctx: any, routeContext: Omit<ClearRouterPluginArgumentsContext, keyof ClearRouterPluginRequestContext>): Promise<any[] | undefined>;
|
|
310
|
+
protected static ensureState(): void;
|
|
295
311
|
/**
|
|
296
312
|
* Normalizes a path by ensuring it starts with a single slash and does not have trailing
|
|
297
313
|
* slashes, while preserving dynamic segments and parameters.
|
|
@@ -308,7 +324,7 @@ declare abstract class CoreRouter {
|
|
|
308
324
|
* @returns
|
|
309
325
|
*/
|
|
310
326
|
static configure(this: any, options?: RouterConfig): void;
|
|
311
|
-
protected static resolveMethodOverride(
|
|
327
|
+
protected static resolveMethodOverride(method: string, headers: Headers | Record<string, any>, body: unknown): HttpMethod | null;
|
|
312
328
|
/**
|
|
313
329
|
* Adds a new route to the router.
|
|
314
330
|
*
|
|
@@ -318,7 +334,7 @@ declare abstract class CoreRouter {
|
|
|
318
334
|
* @param handler
|
|
319
335
|
* @param middlewares
|
|
320
336
|
*/
|
|
321
|
-
static add(
|
|
337
|
+
static add(methods: HttpMethod | HttpMethod[], path: string, handler: any, middlewares?: any[] | any): void;
|
|
322
338
|
/**
|
|
323
339
|
* Define a resourceful API controller with standard CRUD routes.
|
|
324
340
|
*
|
|
@@ -327,7 +343,7 @@ declare abstract class CoreRouter {
|
|
|
327
343
|
* @param controller
|
|
328
344
|
* @param options
|
|
329
345
|
*/
|
|
330
|
-
static apiResource(
|
|
346
|
+
static apiResource(basePath: string, controller: any, options?: {
|
|
331
347
|
only?: ControllerAction[];
|
|
332
348
|
except?: ControllerAction[];
|
|
333
349
|
middlewares?: ApiResourceMiddleware<any>;
|
|
@@ -340,7 +356,7 @@ declare abstract class CoreRouter {
|
|
|
340
356
|
* @param handler The handler function for the GET route.
|
|
341
357
|
* @param middlewares Optional middlewares to apply to the GET route.
|
|
342
358
|
*/
|
|
343
|
-
static get(
|
|
359
|
+
static get(path: string, handler: any, middlewares?: any[] | any): void;
|
|
344
360
|
/**
|
|
345
361
|
* Adds a new POST route to the router.
|
|
346
362
|
*
|
|
@@ -349,7 +365,7 @@ declare abstract class CoreRouter {
|
|
|
349
365
|
* @param handler
|
|
350
366
|
* @param middlewares
|
|
351
367
|
*/
|
|
352
|
-
static post(
|
|
368
|
+
static post(path: string, handler: any, middlewares?: any[] | any): void;
|
|
353
369
|
/**
|
|
354
370
|
* Adds a new PUT route to the router.
|
|
355
371
|
*
|
|
@@ -358,7 +374,7 @@ declare abstract class CoreRouter {
|
|
|
358
374
|
* @param handler
|
|
359
375
|
* @param middlewares
|
|
360
376
|
*/
|
|
361
|
-
static put(
|
|
377
|
+
static put(path: string, handler: any, middlewares?: any[] | any): void;
|
|
362
378
|
/**
|
|
363
379
|
* Adds a new DELETE route to the router.
|
|
364
380
|
*
|
|
@@ -367,7 +383,7 @@ declare abstract class CoreRouter {
|
|
|
367
383
|
* @param handler
|
|
368
384
|
* @param middlewares
|
|
369
385
|
*/
|
|
370
|
-
static delete(
|
|
386
|
+
static delete(path: string, handler: any, middlewares?: any[] | any): void;
|
|
371
387
|
/**
|
|
372
388
|
* Adds a new PATCH route to the router.
|
|
373
389
|
*
|
|
@@ -376,7 +392,7 @@ declare abstract class CoreRouter {
|
|
|
376
392
|
* @param handler
|
|
377
393
|
* @param middlewares
|
|
378
394
|
*/
|
|
379
|
-
static patch(
|
|
395
|
+
static patch(path: string, handler: any, middlewares?: any[] | any): void;
|
|
380
396
|
/**
|
|
381
397
|
* Adds a new OPTIONS route to the router.
|
|
382
398
|
*
|
|
@@ -385,7 +401,7 @@ declare abstract class CoreRouter {
|
|
|
385
401
|
* @param handler
|
|
386
402
|
* @param middlewares
|
|
387
403
|
*/
|
|
388
|
-
static options(
|
|
404
|
+
static options(path: string, handler: any, middlewares?: any[] | any): void;
|
|
389
405
|
/**
|
|
390
406
|
* Adds a new HEAD route to the router.
|
|
391
407
|
*
|
|
@@ -394,7 +410,7 @@ declare abstract class CoreRouter {
|
|
|
394
410
|
* @param handler
|
|
395
411
|
* @param middlewares
|
|
396
412
|
*/
|
|
397
|
-
static head(
|
|
413
|
+
static head(path: string, handler: any, middlewares?: any[] | any): void;
|
|
398
414
|
/**
|
|
399
415
|
* Defines a group of routes with a common prefix.
|
|
400
416
|
*
|
|
@@ -403,7 +419,7 @@ declare abstract class CoreRouter {
|
|
|
403
419
|
* @param callback
|
|
404
420
|
* @param middlewares
|
|
405
421
|
*/
|
|
406
|
-
static group(
|
|
422
|
+
static group(prefix: string, callback: () => void | Promise<void>, middlewares?: any[]): Promise<void>;
|
|
407
423
|
/**
|
|
408
424
|
* Adds global middlewares to the router, which will be applied to all routes.
|
|
409
425
|
*
|
|
@@ -411,24 +427,24 @@ declare abstract class CoreRouter {
|
|
|
411
427
|
* @param middlewares
|
|
412
428
|
* @param callback
|
|
413
429
|
*/
|
|
414
|
-
static middleware(
|
|
430
|
+
static middleware(middlewares: any[], callback: () => void): void;
|
|
415
431
|
/**
|
|
416
432
|
* Retrieves all registered routes in the router, optionally organized by path or method
|
|
417
433
|
* for easier access and management.
|
|
418
434
|
*
|
|
419
435
|
* @param this
|
|
420
436
|
*/
|
|
421
|
-
static allRoutes(
|
|
437
|
+
static allRoutes(): Array<Route<any, any, any>>;
|
|
422
438
|
/**
|
|
423
439
|
* @param this
|
|
424
440
|
* @param type - 'path' to get routes organized by path
|
|
425
441
|
*/
|
|
426
|
-
static allRoutes(
|
|
442
|
+
static allRoutes(type: 'path'): Record<string, Route<any, any, any>>;
|
|
427
443
|
/**
|
|
428
444
|
* @param this
|
|
429
445
|
* @param type - 'method' to get routes organized by method
|
|
430
446
|
*/
|
|
431
|
-
static allRoutes(
|
|
447
|
+
static allRoutes(type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<any, any, any>> };
|
|
432
448
|
protected static resolveHandler(route: Route<any, any, any>): {
|
|
433
449
|
handlerFunction: ((ctx: any, req: Request$1) => any | Promise<any>) | null;
|
|
434
450
|
instance: Controller<any> | null;
|
|
@@ -437,7 +453,7 @@ declare abstract class CoreRouter {
|
|
|
437
453
|
bindingHandler?: object;
|
|
438
454
|
bindingMetadata?: object;
|
|
439
455
|
};
|
|
440
|
-
protected static callHandler(
|
|
456
|
+
protected static callHandler(handlerFunction: (ctx: any, req: Request$1) => any | Promise<any>, ctx: any, bindingTarget?: object, bindingMethod?: PropertyKey, bindingHandler?: object, bindingMetadata?: object): Promise<any>;
|
|
441
457
|
protected static bindRequestToInstance(ctx: any, instance: Controller<any> | Route<any, any, any> | null, route: Route<any, any, any>, payload: {
|
|
442
458
|
body: Record<string, any>;
|
|
443
459
|
query: Record<string, any>;
|
|
@@ -446,4 +462,4 @@ declare abstract class CoreRouter {
|
|
|
446
462
|
}): void;
|
|
447
463
|
}
|
|
448
464
|
//#endregion
|
|
449
|
-
export {
|
|
465
|
+
export { ControllerAction as C, Response$2 as E, ApiResourceMiddleware as S, HttpMethod as T, HttpContext as _, ClearRouterPluginInput as a, HttpContext$1 as b, PluginBind as c, PluginSetupResult as d, definePlugin as f, Handler as g, H3App as h, ClearRouterPluginContext as i, 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, ControllerHandler as w, Middleware$1 as x, Handler$1 as y };
|
|
@@ -4,8 +4,10 @@ declare class Response {
|
|
|
4
4
|
headers: Headers;
|
|
5
5
|
sent: boolean;
|
|
6
6
|
statusCode: number;
|
|
7
|
-
|
|
7
|
+
statusText: string;
|
|
8
|
+
constructor(init?: Partial<Response | globalThis.Response>);
|
|
8
9
|
status(code: number): this;
|
|
10
|
+
setStatusText(text: string): this;
|
|
9
11
|
code(code: number): this;
|
|
10
12
|
setHeader(name: string, value: string): this;
|
|
11
13
|
header(name: string, value: string): this;
|
package/package.json
CHANGED