clear-router 2.8.4 → 2.8.5

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 (58) hide show
  1. package/dist/ClearRequest.d.cts +1 -1
  2. package/dist/ClearRequest.d.mts +1 -1
  3. package/dist/Controller.d.cts +1 -1
  4. package/dist/Controller.d.mts +1 -1
  5. package/dist/ResourceRoutes.cjs +1 -1
  6. package/dist/ResourceRoutes.d.cts +1 -1
  7. package/dist/ResourceRoutes.d.mts +1 -1
  8. package/dist/ResourceRoutes.mjs +1 -1
  9. package/dist/Route.d.cts +1 -1
  10. package/dist/Route.d.mts +1 -1
  11. package/dist/RouteGroup.d.cts +1 -1
  12. package/dist/RouteGroup.d.mts +1 -1
  13. package/dist/core/CoreRouter.cjs +2 -2
  14. package/dist/core/CoreRouter.d.cts +1 -1
  15. package/dist/core/CoreRouter.d.mts +1 -1
  16. package/dist/core/CoreRouter.mjs +2 -2
  17. package/dist/core/Request.d.cts +2 -2
  18. package/dist/core/Request.d.mts +2 -2
  19. package/dist/core/helpers.d.cts +1 -1
  20. package/dist/core/helpers.d.mts +1 -1
  21. package/dist/core/index.cjs +9 -0
  22. package/dist/core/index.mjs +2 -2
  23. package/dist/core/plugins.d.cts +1 -1
  24. package/dist/core/plugins.d.mts +1 -1
  25. package/dist/decorators/setup.d.mts +1 -0
  26. package/dist/express/router.d.cts +15 -15
  27. package/dist/express/router.d.mts +15 -15
  28. package/dist/fastify/router.d.cts +15 -15
  29. package/dist/fastify/router.d.mts +15 -15
  30. package/dist/h3/router.d.cts +15 -15
  31. package/dist/h3/router.d.mts +15 -15
  32. package/dist/hono/router.d.cts +15 -15
  33. package/dist/hono/router.d.mts +15 -15
  34. package/dist/index.d.cts +2 -2
  35. package/dist/index.d.mts +2 -2
  36. package/dist/koa/router.d.cts +17 -17
  37. package/dist/koa/router.d.mts +17 -17
  38. package/dist/types/basic.cjs +0 -0
  39. package/dist/types/basic.d.cts +4 -3
  40. package/dist/types/basic.d.mts +4 -3
  41. package/dist/types/express.cjs +0 -0
  42. package/dist/types/express.d.cts +3 -3
  43. package/dist/types/express.d.mts +3 -3
  44. package/dist/types/fastify.cjs +0 -0
  45. package/dist/types/fastify.d.cts +3 -3
  46. package/dist/types/fastify.d.mts +3 -3
  47. package/dist/types/h3.cjs +0 -0
  48. package/dist/types/h3.d.cts +8 -6
  49. package/dist/types/h3.d.mts +8 -6
  50. package/dist/types/hono.cjs +0 -0
  51. package/dist/types/hono.d.cts +4 -3
  52. package/dist/types/hono.d.mts +4 -3
  53. package/dist/types/koa.cjs +0 -0
  54. package/dist/types/koa.d.cts +4 -3
  55. package/dist/types/koa.d.mts +4 -3
  56. package/package.json +25 -7
  57. package/dist/Route-tq-rge1g.d.mts +0 -136
  58. package/dist/types/index.d.mts +0 -1
@@ -1,6 +1,6 @@
1
+ import { ApiResourceMiddleware, HttpMethod, ResourceAction, RouteGroupSource } from "../types/basic.mjs";
1
2
  import { FastifyApp, Handler, HttpContext, Middleware } from "../types/fastify.mjs";
2
3
  import { Route } from "../Route.mjs";
3
- import { ApiResourceMiddleware, HttpMethod, ResourceAction, RouteGroupSource } from "../types/basic.mjs";
4
4
  import { ResourceRoutes } from "../ResourceRoutes.mjs";
5
5
  import { RouteGroup } from "../RouteGroup.mjs";
6
6
  import { CoreRouter } from "../core/CoreRouter.mjs";
@@ -24,7 +24,7 @@ declare class Router extends CoreRouter {
24
24
  * @param handler Route handler function
25
25
  * @param middlewares Optional middlewares for the route
26
26
  */
27
- static add(methods: HttpMethod | HttpMethod[], path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
27
+ static add<T = any>(methods: HttpMethod | HttpMethod[], path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
28
28
  /**
29
29
  * Define a resourceful API controller with standard CRUD routes
30
30
  *
@@ -44,7 +44,7 @@ declare class Router extends CoreRouter {
44
44
  * @param handler
45
45
  * @param middlewares
46
46
  */
47
- static get(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
47
+ static get<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
48
48
  /**
49
49
  * Define a POST route
50
50
  *
@@ -52,7 +52,7 @@ declare class Router extends CoreRouter {
52
52
  * @param handler
53
53
  * @param middlewares
54
54
  */
55
- static post(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
55
+ static post<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
56
56
  /**
57
57
  * Define a PUT route
58
58
  *
@@ -60,7 +60,7 @@ declare class Router extends CoreRouter {
60
60
  * @param handler
61
61
  * @param middlewares
62
62
  */
63
- static put(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
63
+ static put<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
64
64
  /**
65
65
  * Define a DELETE route
66
66
  *
@@ -68,7 +68,7 @@ declare class Router extends CoreRouter {
68
68
  * @param handler
69
69
  * @param middlewares
70
70
  */
71
- static delete(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
71
+ static delete<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
72
72
  /**
73
73
  * Define a PATCH route
74
74
  *
@@ -76,7 +76,7 @@ declare class Router extends CoreRouter {
76
76
  * @param handler
77
77
  * @param middlewares
78
78
  */
79
- static patch(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
79
+ static patch<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
80
80
  /**
81
81
  * Define an OPTIONS route
82
82
  *
@@ -84,7 +84,7 @@ declare class Router extends CoreRouter {
84
84
  * @param handler
85
85
  * @param middlewares
86
86
  */
87
- static options(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
87
+ static options<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
88
88
  /**
89
89
  * Define a HEAD route
90
90
  *
@@ -92,7 +92,7 @@ declare class Router extends CoreRouter {
92
92
  * @param handler
93
93
  * @param middlewares
94
94
  */
95
- static head(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
95
+ static head<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
96
96
  /**
97
97
  * Define a group of routes with a common prefix and optional middlewares
98
98
  *
@@ -100,7 +100,7 @@ declare class Router extends CoreRouter {
100
100
  * @param callback
101
101
  * @param middlewares
102
102
  */
103
- static group(prefix: string, source: RouteGroupSource, middlewares?: Middleware[]): RouteGroup<HttpContext, Middleware, Handler>;
103
+ static group<T = any>(prefix: string, source: RouteGroupSource, middlewares?: Middleware[]): RouteGroup<HttpContext, Middleware, Handler<T>>;
104
104
  /**
105
105
  * Apply middlewares to a group of routes defined within the callback
106
106
  *
@@ -108,17 +108,17 @@ declare class Router extends CoreRouter {
108
108
  * @param callback
109
109
  */
110
110
  static middleware(middlewares: Middleware[], callback: () => void): void;
111
- static allRoutes(): Array<Route<HttpContext, Middleware, Handler>>;
111
+ static allRoutes<T = any>(): Array<Route<HttpContext, Middleware, Handler<T>>>;
112
112
  /**
113
113
  * @param type - 'path' to get routes organized by path
114
114
  */
115
- static allRoutes(type: 'path'): Record<string, Route<HttpContext, Middleware, Handler>>;
115
+ static allRoutes<T = any>(type: 'path'): Record<string, Route<HttpContext, Middleware, Handler<T>>>;
116
116
  /**
117
117
  * @param type - 'method' to get routes organized by method
118
118
  */
119
- static allRoutes(type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<HttpContext, Middleware, Handler>> };
120
- static allRoutes(type: 'name'): Record<string, Route<HttpContext, Middleware, Handler>>;
121
- static route(name: string): Route<HttpContext, Middleware, Handler> | undefined;
119
+ static allRoutes<T = any>(type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<HttpContext, Middleware, Handler<T>>> };
120
+ static allRoutes<T = any>(type: 'name'): Record<string, Route<HttpContext, Middleware, Handler<T>>>;
121
+ static route<T = any>(name: string): Route<HttpContext, Middleware, Handler<T>> | undefined;
122
122
  /**
123
123
  * Apply the defined routes to a Fastify application instance
124
124
  *
@@ -1,6 +1,6 @@
1
+ import { ApiResourceMiddleware, HttpMethod, ResourceAction, RouteGroupSource } from "../types/basic.cjs";
1
2
  import { H3App, Handler, HttpContext, Middleware as Middleware$1 } from "../types/h3.cjs";
2
3
  import { Route } from "../Route.cjs";
3
- import { ApiResourceMiddleware, HttpMethod, ResourceAction, RouteGroupSource } from "../types/basic.cjs";
4
4
  import { ResourceRoutes } from "../ResourceRoutes.cjs";
5
5
  import { RouteGroup } from "../RouteGroup.cjs";
6
6
  import { CoreRouter } from "../core/CoreRouter.cjs";
@@ -26,7 +26,7 @@ declare class Router extends CoreRouter {
26
26
  * @param handler
27
27
  * @param middlewares
28
28
  */
29
- static add(methods: HttpMethod | HttpMethod[], path: string, handler: Handler, middlewares?: Middleware$1[] | Middleware$1): Route<HttpContext, Middleware$1, Handler>;
29
+ static add<T = any>(methods: HttpMethod | HttpMethod[], path: string, handler: Handler, middlewares?: Middleware$1[] | Middleware$1): Route<HttpContext, Middleware$1, Handler<T>>;
30
30
  /**
31
31
  * Define a resourceful API controller with standard CRUD routes
32
32
  *
@@ -46,7 +46,7 @@ declare class Router extends CoreRouter {
46
46
  * @param handler
47
47
  * @param middlewares
48
48
  */
49
- static get(path: string, handler: Handler, middlewares?: Middleware$1[] | Middleware$1): Route<HttpContext, Middleware$1, Handler>;
49
+ static get<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware$1[] | Middleware$1): Route<HttpContext, Middleware$1, Handler<T>>;
50
50
  /**
51
51
  * Adds a new POST route to the router with the specified path, handler, and optional middlewares.
52
52
  *
@@ -54,7 +54,7 @@ declare class Router extends CoreRouter {
54
54
  * @param handler
55
55
  * @param middlewares
56
56
  */
57
- static post(path: string, handler: Handler, middlewares?: Middleware$1[] | Middleware$1): Route<HttpContext, Middleware$1, Handler>;
57
+ static post<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware$1[] | Middleware$1): Route<HttpContext, Middleware$1, Handler<T>>;
58
58
  /**
59
59
  * Adds a new PUT route to the router with the specified path, handler, and optional middlewares.
60
60
  *
@@ -62,7 +62,7 @@ declare class Router extends CoreRouter {
62
62
  * @param handler
63
63
  * @param middlewares
64
64
  */
65
- static put(path: string, handler: Handler, middlewares?: Middleware$1[] | Middleware$1): Route<HttpContext, Middleware$1, Handler>;
65
+ static put<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware$1[] | Middleware$1): Route<HttpContext, Middleware$1, Handler<T>>;
66
66
  /**
67
67
  * Adds a new DELETE route to the router with the specified path, handler, and optional middlewares.
68
68
  *
@@ -70,7 +70,7 @@ declare class Router extends CoreRouter {
70
70
  * @param handler
71
71
  * @param middlewares
72
72
  */
73
- static delete(path: string, handler: Handler, middlewares?: Middleware$1[] | Middleware$1): Route<HttpContext, Middleware$1, Handler>;
73
+ static delete<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware$1[] | Middleware$1): Route<HttpContext, Middleware$1, Handler<T>>;
74
74
  /**
75
75
  * Adds a new PATCH route to the router with the specified path, handler, and optional middlewares.
76
76
  *
@@ -78,7 +78,7 @@ declare class Router extends CoreRouter {
78
78
  * @param handler
79
79
  * @param middlewares
80
80
  */
81
- static patch(path: string, handler: Handler, middlewares?: Middleware$1[] | Middleware$1): Route<HttpContext, Middleware$1, Handler>;
81
+ static patch<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware$1[] | Middleware$1): Route<HttpContext, Middleware$1, Handler<T>>;
82
82
  /**
83
83
  * Adds a new OPTIONS route to the router with the specified path, handler, and optional middlewares.
84
84
  *
@@ -86,7 +86,7 @@ declare class Router extends CoreRouter {
86
86
  * @param handler
87
87
  * @param middlewares
88
88
  */
89
- static options(path: string, handler: Handler, middlewares?: Middleware$1[] | Middleware$1): Route<HttpContext, Middleware$1, Handler>;
89
+ static options<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware$1[] | Middleware$1): Route<HttpContext, Middleware$1, Handler<T>>;
90
90
  /**
91
91
  * Adds a new HEAD route to the router.
92
92
  *
@@ -94,7 +94,7 @@ declare class Router extends CoreRouter {
94
94
  * @param handler
95
95
  * @param middlewares
96
96
  */
97
- static head(path: string, handler: Handler, middlewares?: Middleware$1[] | Middleware$1): Route<HttpContext, Middleware$1, Handler>;
97
+ static head<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware$1[] | Middleware$1): Route<HttpContext, Middleware$1, Handler<T>>;
98
98
  /**
99
99
  * Defines a group of routes with a common prefix.
100
100
  *
@@ -102,7 +102,7 @@ declare class Router extends CoreRouter {
102
102
  * @param callback
103
103
  * @param middlewares
104
104
  */
105
- static group(prefix: string, source: RouteGroupSource, middlewares?: Middleware$1[]): RouteGroup<HttpContext, Middleware$1, Handler>;
105
+ static group<T = any>(prefix: string, source: RouteGroupSource, middlewares?: Middleware$1[]): RouteGroup<HttpContext, Middleware$1, Handler<T>>;
106
106
  /**
107
107
  * Adds global middlewares to the router, which will be applied to all routes.
108
108
  *
@@ -116,11 +116,11 @@ declare class Router extends CoreRouter {
116
116
  *
117
117
  * @param type
118
118
  */
119
- static allRoutes(): Array<Route<HttpContext, Middleware$1, Handler>>;
120
- static allRoutes(type: 'path'): Record<string, Route<HttpContext, Middleware$1, Handler>>;
121
- static allRoutes(type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<HttpContext, Middleware$1, Handler>> };
122
- static allRoutes(type: 'name'): Record<string, Route<HttpContext, Middleware$1, Handler>>;
123
- static route(name: string): Route<HttpContext, Middleware$1, Handler> | undefined;
119
+ static allRoutes<T = any>(): Array<Route<HttpContext, Middleware$1, Handler<T>>>;
120
+ static allRoutes<T = any>(type: 'path'): Record<string, Route<HttpContext, Middleware$1, Handler<T>>>;
121
+ static allRoutes<T = any>(type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<HttpContext, Middleware$1, Handler<T>>> };
122
+ static allRoutes<T = any>(type: 'name'): Record<string, Route<HttpContext, Middleware$1, Handler<T>>>;
123
+ static route<T = any>(name: string): Route<HttpContext, Middleware$1, Handler<T>> | undefined;
124
124
  /**
125
125
  * Applies the registered routes to the given H3 application instance, setting up the
126
126
  * necessary handlers and middlewares for each route.
@@ -1,6 +1,6 @@
1
+ import { ApiResourceMiddleware, HttpMethod, ResourceAction, RouteGroupSource } from "../types/basic.mjs";
1
2
  import { H3App, Handler, HttpContext, Middleware as Middleware$1 } from "../types/h3.mjs";
2
3
  import { Route } from "../Route.mjs";
3
- import { ApiResourceMiddleware, HttpMethod, ResourceAction, RouteGroupSource } from "../types/basic.mjs";
4
4
  import { ResourceRoutes } from "../ResourceRoutes.mjs";
5
5
  import { RouteGroup } from "../RouteGroup.mjs";
6
6
  import { CoreRouter } from "../core/CoreRouter.mjs";
@@ -26,7 +26,7 @@ declare class Router extends CoreRouter {
26
26
  * @param handler
27
27
  * @param middlewares
28
28
  */
29
- static add(methods: HttpMethod | HttpMethod[], path: string, handler: Handler, middlewares?: Middleware$1[] | Middleware$1): Route<HttpContext, Middleware$1, Handler>;
29
+ static add<T = any>(methods: HttpMethod | HttpMethod[], path: string, handler: Handler, middlewares?: Middleware$1[] | Middleware$1): Route<HttpContext, Middleware$1, Handler<T>>;
30
30
  /**
31
31
  * Define a resourceful API controller with standard CRUD routes
32
32
  *
@@ -46,7 +46,7 @@ declare class Router extends CoreRouter {
46
46
  * @param handler
47
47
  * @param middlewares
48
48
  */
49
- static get(path: string, handler: Handler, middlewares?: Middleware$1[] | Middleware$1): Route<HttpContext, Middleware$1, Handler>;
49
+ static get<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware$1[] | Middleware$1): Route<HttpContext, Middleware$1, Handler<T>>;
50
50
  /**
51
51
  * Adds a new POST route to the router with the specified path, handler, and optional middlewares.
52
52
  *
@@ -54,7 +54,7 @@ declare class Router extends CoreRouter {
54
54
  * @param handler
55
55
  * @param middlewares
56
56
  */
57
- static post(path: string, handler: Handler, middlewares?: Middleware$1[] | Middleware$1): Route<HttpContext, Middleware$1, Handler>;
57
+ static post<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware$1[] | Middleware$1): Route<HttpContext, Middleware$1, Handler<T>>;
58
58
  /**
59
59
  * Adds a new PUT route to the router with the specified path, handler, and optional middlewares.
60
60
  *
@@ -62,7 +62,7 @@ declare class Router extends CoreRouter {
62
62
  * @param handler
63
63
  * @param middlewares
64
64
  */
65
- static put(path: string, handler: Handler, middlewares?: Middleware$1[] | Middleware$1): Route<HttpContext, Middleware$1, Handler>;
65
+ static put<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware$1[] | Middleware$1): Route<HttpContext, Middleware$1, Handler<T>>;
66
66
  /**
67
67
  * Adds a new DELETE route to the router with the specified path, handler, and optional middlewares.
68
68
  *
@@ -70,7 +70,7 @@ declare class Router extends CoreRouter {
70
70
  * @param handler
71
71
  * @param middlewares
72
72
  */
73
- static delete(path: string, handler: Handler, middlewares?: Middleware$1[] | Middleware$1): Route<HttpContext, Middleware$1, Handler>;
73
+ static delete<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware$1[] | Middleware$1): Route<HttpContext, Middleware$1, Handler<T>>;
74
74
  /**
75
75
  * Adds a new PATCH route to the router with the specified path, handler, and optional middlewares.
76
76
  *
@@ -78,7 +78,7 @@ declare class Router extends CoreRouter {
78
78
  * @param handler
79
79
  * @param middlewares
80
80
  */
81
- static patch(path: string, handler: Handler, middlewares?: Middleware$1[] | Middleware$1): Route<HttpContext, Middleware$1, Handler>;
81
+ static patch<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware$1[] | Middleware$1): Route<HttpContext, Middleware$1, Handler<T>>;
82
82
  /**
83
83
  * Adds a new OPTIONS route to the router with the specified path, handler, and optional middlewares.
84
84
  *
@@ -86,7 +86,7 @@ declare class Router extends CoreRouter {
86
86
  * @param handler
87
87
  * @param middlewares
88
88
  */
89
- static options(path: string, handler: Handler, middlewares?: Middleware$1[] | Middleware$1): Route<HttpContext, Middleware$1, Handler>;
89
+ static options<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware$1[] | Middleware$1): Route<HttpContext, Middleware$1, Handler<T>>;
90
90
  /**
91
91
  * Adds a new HEAD route to the router.
92
92
  *
@@ -94,7 +94,7 @@ declare class Router extends CoreRouter {
94
94
  * @param handler
95
95
  * @param middlewares
96
96
  */
97
- static head(path: string, handler: Handler, middlewares?: Middleware$1[] | Middleware$1): Route<HttpContext, Middleware$1, Handler>;
97
+ static head<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware$1[] | Middleware$1): Route<HttpContext, Middleware$1, Handler<T>>;
98
98
  /**
99
99
  * Defines a group of routes with a common prefix.
100
100
  *
@@ -102,7 +102,7 @@ declare class Router extends CoreRouter {
102
102
  * @param callback
103
103
  * @param middlewares
104
104
  */
105
- static group(prefix: string, source: RouteGroupSource, middlewares?: Middleware$1[]): RouteGroup<HttpContext, Middleware$1, Handler>;
105
+ static group<T = any>(prefix: string, source: RouteGroupSource, middlewares?: Middleware$1[]): RouteGroup<HttpContext, Middleware$1, Handler<T>>;
106
106
  /**
107
107
  * Adds global middlewares to the router, which will be applied to all routes.
108
108
  *
@@ -116,11 +116,11 @@ declare class Router extends CoreRouter {
116
116
  *
117
117
  * @param type
118
118
  */
119
- static allRoutes(): Array<Route<HttpContext, Middleware$1, Handler>>;
120
- static allRoutes(type: 'path'): Record<string, Route<HttpContext, Middleware$1, Handler>>;
121
- static allRoutes(type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<HttpContext, Middleware$1, Handler>> };
122
- static allRoutes(type: 'name'): Record<string, Route<HttpContext, Middleware$1, Handler>>;
123
- static route(name: string): Route<HttpContext, Middleware$1, Handler> | undefined;
119
+ static allRoutes<T = any>(): Array<Route<HttpContext, Middleware$1, Handler<T>>>;
120
+ static allRoutes<T = any>(type: 'path'): Record<string, Route<HttpContext, Middleware$1, Handler<T>>>;
121
+ static allRoutes<T = any>(type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<HttpContext, Middleware$1, Handler<T>>> };
122
+ static allRoutes<T = any>(type: 'name'): Record<string, Route<HttpContext, Middleware$1, Handler<T>>>;
123
+ static route<T = any>(name: string): Route<HttpContext, Middleware$1, Handler<T>> | undefined;
124
124
  /**
125
125
  * Applies the registered routes to the given H3 application instance, setting up the
126
126
  * necessary handlers and middlewares for each route.
@@ -1,6 +1,6 @@
1
+ import { ApiResourceMiddleware, HttpMethod, ResourceAction, RouteGroupSource } from "../types/basic.cjs";
1
2
  import { Handler, HonoApp, HttpContext, Middleware } from "../types/hono.cjs";
2
3
  import { Route } from "../Route.cjs";
3
- import { ApiResourceMiddleware, HttpMethod, ResourceAction, RouteGroupSource } from "../types/basic.cjs";
4
4
  import { ResourceRoutes } from "../ResourceRoutes.cjs";
5
5
  import { RouteGroup } from "../RouteGroup.cjs";
6
6
  import { CoreRouter } from "../core/CoreRouter.cjs";
@@ -26,7 +26,7 @@ declare class Router extends CoreRouter {
26
26
  * @param handler
27
27
  * @param middlewares
28
28
  */
29
- static add(methods: HttpMethod | HttpMethod[], path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
29
+ static add<T = any>(methods: HttpMethod | HttpMethod[], path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
30
30
  /**
31
31
  * Define a resourceful API controller with standard CRUD routes
32
32
  *
@@ -46,7 +46,7 @@ declare class Router extends CoreRouter {
46
46
  * @param handler
47
47
  * @param middlewares
48
48
  */
49
- static get(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
49
+ static get<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
50
50
  /**
51
51
  * Define a POST route
52
52
  *
@@ -54,7 +54,7 @@ declare class Router extends CoreRouter {
54
54
  * @param handler
55
55
  * @param middlewares
56
56
  */
57
- static post(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
57
+ static post<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
58
58
  /**
59
59
  * Define a PUT route
60
60
  *
@@ -62,7 +62,7 @@ declare class Router extends CoreRouter {
62
62
  * @param handler
63
63
  * @param middlewares
64
64
  */
65
- static put(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
65
+ static put<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
66
66
  /**
67
67
  * Define a DELETE route
68
68
  *
@@ -70,7 +70,7 @@ declare class Router extends CoreRouter {
70
70
  * @param handler
71
71
  * @param middlewares
72
72
  */
73
- static delete(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
73
+ static delete<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
74
74
  /**
75
75
  * Define a PATCH route
76
76
  *
@@ -78,7 +78,7 @@ declare class Router extends CoreRouter {
78
78
  * @param handler
79
79
  * @param middlewares
80
80
  */
81
- static patch(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
81
+ static patch<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
82
82
  /**
83
83
  * Define an OPTIONS route
84
84
  *
@@ -86,7 +86,7 @@ declare class Router extends CoreRouter {
86
86
  * @param handler
87
87
  * @param middlewares
88
88
  */
89
- static options(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
89
+ static options<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
90
90
  /**
91
91
  * Define a HEAD route
92
92
  *
@@ -94,7 +94,7 @@ declare class Router extends CoreRouter {
94
94
  * @param handler
95
95
  * @param middlewares
96
96
  */
97
- static head(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
97
+ static head<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
98
98
  /**
99
99
  * Defines a group of routes with a common prefix.
100
100
  *
@@ -102,7 +102,7 @@ declare class Router extends CoreRouter {
102
102
  * @param callback
103
103
  * @param middlewares
104
104
  */
105
- static group(prefix: string, source: RouteGroupSource, middlewares?: Middleware[]): RouteGroup<HttpContext, Middleware, Handler>;
105
+ static group<T = any>(prefix: string, source: RouteGroupSource, middlewares?: Middleware[]): RouteGroup<HttpContext, Middleware, Handler<T>>;
106
106
  /**
107
107
  * Apply middlewares to a group of routes defined within the callback
108
108
  *
@@ -113,17 +113,17 @@ declare class Router extends CoreRouter {
113
113
  /**
114
114
  * Get all defined routes, optionally organized by path or method
115
115
  */
116
- static allRoutes(): Array<Route<HttpContext, Middleware, Handler>>;
116
+ static allRoutes<T = any>(): Array<Route<HttpContext, Middleware, Handler<T>>>;
117
117
  /**
118
118
  * @param type - 'path' to get routes organized by path
119
119
  */
120
- static allRoutes(type: 'path'): Record<string, Route<HttpContext, Middleware, Handler>>;
120
+ static allRoutes<T = any>(type: 'path'): Record<string, Route<HttpContext, Middleware, Handler<T>>>;
121
121
  /**
122
122
  * @param type - 'method' to get routes organized by method
123
123
  */
124
- static allRoutes(type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<HttpContext, Middleware, Handler>> };
125
- static allRoutes(type: 'name'): Record<string, Route<HttpContext, Middleware, Handler>>;
126
- static route(name: string): Route<HttpContext, Middleware, Handler> | undefined;
124
+ static allRoutes<T = any>(type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<HttpContext, Middleware, Handler<T>>> };
125
+ static allRoutes<T = any>(type: 'name'): Record<string, Route<HttpContext, Middleware, Handler<T>>>;
126
+ static route<T = any>(name: string): Route<HttpContext, Middleware, Handler<T>> | undefined;
127
127
  /**
128
128
  * Apply the defined routes to a Hono application instance
129
129
  *
@@ -1,6 +1,6 @@
1
+ import { ApiResourceMiddleware, HttpMethod, ResourceAction, RouteGroupSource } from "../types/basic.mjs";
1
2
  import { Handler, HonoApp, HttpContext, Middleware } from "../types/hono.mjs";
2
3
  import { Route } from "../Route.mjs";
3
- import { ApiResourceMiddleware, HttpMethod, ResourceAction, RouteGroupSource } from "../types/basic.mjs";
4
4
  import { ResourceRoutes } from "../ResourceRoutes.mjs";
5
5
  import { RouteGroup } from "../RouteGroup.mjs";
6
6
  import { CoreRouter } from "../core/CoreRouter.mjs";
@@ -26,7 +26,7 @@ declare class Router extends CoreRouter {
26
26
  * @param handler
27
27
  * @param middlewares
28
28
  */
29
- static add(methods: HttpMethod | HttpMethod[], path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
29
+ static add<T = any>(methods: HttpMethod | HttpMethod[], path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
30
30
  /**
31
31
  * Define a resourceful API controller with standard CRUD routes
32
32
  *
@@ -46,7 +46,7 @@ declare class Router extends CoreRouter {
46
46
  * @param handler
47
47
  * @param middlewares
48
48
  */
49
- static get(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
49
+ static get<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
50
50
  /**
51
51
  * Define a POST route
52
52
  *
@@ -54,7 +54,7 @@ declare class Router extends CoreRouter {
54
54
  * @param handler
55
55
  * @param middlewares
56
56
  */
57
- static post(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
57
+ static post<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
58
58
  /**
59
59
  * Define a PUT route
60
60
  *
@@ -62,7 +62,7 @@ declare class Router extends CoreRouter {
62
62
  * @param handler
63
63
  * @param middlewares
64
64
  */
65
- static put(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
65
+ static put<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
66
66
  /**
67
67
  * Define a DELETE route
68
68
  *
@@ -70,7 +70,7 @@ declare class Router extends CoreRouter {
70
70
  * @param handler
71
71
  * @param middlewares
72
72
  */
73
- static delete(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
73
+ static delete<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
74
74
  /**
75
75
  * Define a PATCH route
76
76
  *
@@ -78,7 +78,7 @@ declare class Router extends CoreRouter {
78
78
  * @param handler
79
79
  * @param middlewares
80
80
  */
81
- static patch(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
81
+ static patch<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
82
82
  /**
83
83
  * Define an OPTIONS route
84
84
  *
@@ -86,7 +86,7 @@ declare class Router extends CoreRouter {
86
86
  * @param handler
87
87
  * @param middlewares
88
88
  */
89
- static options(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
89
+ static options<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
90
90
  /**
91
91
  * Define a HEAD route
92
92
  *
@@ -94,7 +94,7 @@ declare class Router extends CoreRouter {
94
94
  * @param handler
95
95
  * @param middlewares
96
96
  */
97
- static head(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
97
+ static head<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
98
98
  /**
99
99
  * Defines a group of routes with a common prefix.
100
100
  *
@@ -102,7 +102,7 @@ declare class Router extends CoreRouter {
102
102
  * @param callback
103
103
  * @param middlewares
104
104
  */
105
- static group(prefix: string, source: RouteGroupSource, middlewares?: Middleware[]): RouteGroup<HttpContext, Middleware, Handler>;
105
+ static group<T = any>(prefix: string, source: RouteGroupSource, middlewares?: Middleware[]): RouteGroup<HttpContext, Middleware, Handler<T>>;
106
106
  /**
107
107
  * Apply middlewares to a group of routes defined within the callback
108
108
  *
@@ -113,17 +113,17 @@ declare class Router extends CoreRouter {
113
113
  /**
114
114
  * Get all defined routes, optionally organized by path or method
115
115
  */
116
- static allRoutes(): Array<Route<HttpContext, Middleware, Handler>>;
116
+ static allRoutes<T = any>(): Array<Route<HttpContext, Middleware, Handler<T>>>;
117
117
  /**
118
118
  * @param type - 'path' to get routes organized by path
119
119
  */
120
- static allRoutes(type: 'path'): Record<string, Route<HttpContext, Middleware, Handler>>;
120
+ static allRoutes<T = any>(type: 'path'): Record<string, Route<HttpContext, Middleware, Handler<T>>>;
121
121
  /**
122
122
  * @param type - 'method' to get routes organized by method
123
123
  */
124
- static allRoutes(type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<HttpContext, Middleware, Handler>> };
125
- static allRoutes(type: 'name'): Record<string, Route<HttpContext, Middleware, Handler>>;
126
- static route(name: string): Route<HttpContext, Middleware, Handler> | undefined;
124
+ static allRoutes<T = any>(type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<HttpContext, Middleware, Handler<T>>> };
125
+ static allRoutes<T = any>(type: 'name'): Record<string, Route<HttpContext, Middleware, Handler<T>>>;
126
+ static route<T = any>(name: string): Route<HttpContext, Middleware, Handler<T>> | undefined;
127
127
  /**
128
128
  * Apply the defined routes to a Hono application instance
129
129
  *
package/dist/index.d.cts CHANGED
@@ -1,11 +1,11 @@
1
1
  import { ClearHttpContext, RouteParameter } from "./Contracts.cjs";
2
- import { Request } from "./core/Request.cjs";
3
2
  import { Response } from "./core/Response.cjs";
4
3
  import { Route } from "./Route.cjs";
5
4
  import { ClearRequest } from "./ClearRequest.cjs";
5
+ import { Request } from "./core/Request.cjs";
6
+ import { ClearRouterPlugin, ClearRouterPluginArgumentsContext, ClearRouterPluginContext, ClearRouterPluginInput, ClearRouterPluginRequestContext, PluginArgumentsResolver, PluginBind, PluginBindFactory, PluginBindValue, PluginSetupResult, definePlugin } from "./core/plugins.cjs";
6
7
  import { Controller } from "./Controller.cjs";
7
8
  import { RouteGroup } from "./RouteGroup.cjs";
8
- import { ClearRouterPlugin, ClearRouterPluginArgumentsContext, ClearRouterPluginContext, ClearRouterPluginInput, ClearRouterPluginRequestContext, PluginArgumentsResolver, PluginBind, PluginBindFactory, PluginBindValue, PluginSetupResult, definePlugin } from "./core/plugins.cjs";
9
9
  import { CoreRouter } from "./core/CoreRouter.cjs";
10
10
  import { importFile, wrap } from "./core/helpers.cjs";
11
11
  export { ClearHttpContext, ClearRequest, ClearRouterPlugin, ClearRouterPluginArgumentsContext, ClearRouterPluginContext, ClearRouterPluginInput, ClearRouterPluginRequestContext, Controller, CoreRouter, PluginArgumentsResolver, PluginBind, PluginBindFactory, PluginBindValue, PluginSetupResult, Request, Response, Route, RouteGroup, RouteParameter, definePlugin, importFile, wrap };
package/dist/index.d.mts CHANGED
@@ -1,11 +1,11 @@
1
1
  import { ClearHttpContext, RouteParameter } from "./Contracts.mjs";
2
- import { Request } from "./core/Request.mjs";
3
2
  import { Response } from "./core/Response.mjs";
4
3
  import { Route } from "./Route.mjs";
5
4
  import { ClearRequest } from "./ClearRequest.mjs";
5
+ import { Request } from "./core/Request.mjs";
6
+ import { ClearRouterPlugin, ClearRouterPluginArgumentsContext, ClearRouterPluginContext, ClearRouterPluginInput, ClearRouterPluginRequestContext, PluginArgumentsResolver, PluginBind, PluginBindFactory, PluginBindValue, PluginSetupResult, definePlugin } from "./core/plugins.mjs";
6
7
  import { Controller } from "./Controller.mjs";
7
8
  import { RouteGroup } from "./RouteGroup.mjs";
8
- import { ClearRouterPlugin, ClearRouterPluginArgumentsContext, ClearRouterPluginContext, ClearRouterPluginInput, ClearRouterPluginRequestContext, PluginArgumentsResolver, PluginBind, PluginBindFactory, PluginBindValue, PluginSetupResult, definePlugin } from "./core/plugins.mjs";
9
9
  import { CoreRouter } from "./core/CoreRouter.mjs";
10
10
  import { importFile, wrap } from "./core/helpers.mjs";
11
11
  export { ClearHttpContext, ClearRequest, ClearRouterPlugin, ClearRouterPluginArgumentsContext, ClearRouterPluginContext, ClearRouterPluginInput, ClearRouterPluginRequestContext, Controller, CoreRouter, PluginArgumentsResolver, PluginBind, PluginBindFactory, PluginBindValue, PluginSetupResult, Request, Response, Route, RouteGroup, RouteParameter, definePlugin, importFile, wrap };