clear-router 2.8.4 → 2.8.6

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 (43) hide show
  1. package/dist/ResourceRoutes.cjs +1 -1
  2. package/dist/ResourceRoutes.mjs +1 -1
  3. package/dist/RouteGroup.d.cts +4 -4
  4. package/dist/RouteGroup.d.mts +4 -4
  5. package/dist/core/CoreRouter.cjs +2 -2
  6. package/dist/core/CoreRouter.d.cts +1 -1
  7. package/dist/core/CoreRouter.d.mts +1 -1
  8. package/dist/core/CoreRouter.mjs +2 -2
  9. package/dist/core/index.cjs +9 -0
  10. package/dist/core/index.mjs +2 -2
  11. package/dist/express/router.d.cts +14 -14
  12. package/dist/express/router.d.mts +14 -14
  13. package/dist/fastify/router.d.cts +14 -14
  14. package/dist/fastify/router.d.mts +14 -14
  15. package/dist/h3/router.d.cts +14 -14
  16. package/dist/h3/router.d.mts +14 -14
  17. package/dist/hono/router.d.cts +14 -14
  18. package/dist/hono/router.d.mts +14 -14
  19. package/dist/index.d.cts +3 -3
  20. package/dist/index.d.mts +3 -3
  21. package/dist/koa/router.d.cts +16 -16
  22. package/dist/koa/router.d.mts +16 -16
  23. package/dist/types/basic.cjs +0 -0
  24. package/dist/types/basic.d.cts +8 -5
  25. package/dist/types/basic.d.mts +9 -6
  26. package/dist/types/express.cjs +0 -0
  27. package/dist/types/express.d.cts +2 -2
  28. package/dist/types/express.d.mts +2 -2
  29. package/dist/types/fastify.cjs +0 -0
  30. package/dist/types/fastify.d.cts +2 -2
  31. package/dist/types/fastify.d.mts +2 -2
  32. package/dist/types/h3.cjs +0 -0
  33. package/dist/types/h3.d.cts +7 -5
  34. package/dist/types/h3.d.mts +7 -5
  35. package/dist/types/hono.cjs +0 -0
  36. package/dist/types/hono.d.cts +3 -2
  37. package/dist/types/hono.d.mts +3 -2
  38. package/dist/types/koa.cjs +0 -0
  39. package/dist/types/koa.d.cts +3 -2
  40. package/dist/types/koa.d.mts +3 -2
  41. package/package.json +25 -7
  42. package/dist/Route-tq-rge1g.d.mts +0 -136
  43. package/dist/types/index.d.mts +0 -1
@@ -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, S extends RouteGroupSource = RouteGroupSource>(prefix: string, source: S, middlewares?: Middleware$1[]): RouteGroup<HttpContext, Middleware$1, Handler<T>, S>;
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.
@@ -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, S extends RouteGroupSource = RouteGroupSource>(prefix: string, source: S, middlewares?: Middleware$1[]): RouteGroup<HttpContext, Middleware$1, Handler<T>, S>;
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.
@@ -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, S extends RouteGroupSource = RouteGroupSource>(prefix: string, source: S, middlewares?: Middleware[]): RouteGroup<HttpContext, Middleware, Handler<T>, S>;
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
  *
@@ -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, S extends RouteGroupSource = RouteGroupSource>(prefix: string, source: S, middlewares?: Middleware[]): RouteGroup<HttpContext, Middleware, Handler<T>, S>;
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
- import { Route } from "./Route.cjs";
5
3
  import { ClearRequest } from "./ClearRequest.cjs";
4
+ import { Route } from "./Route.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
- import { Route } from "./Route.mjs";
5
3
  import { ClearRequest } from "./ClearRequest.mjs";
4
+ import { Route } from "./Route.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 };
@@ -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
  *
@@ -34,11 +34,11 @@ declare class Router extends CoreRouter {
34
34
  * @param controller
35
35
  * @param options
36
36
  */
37
- static apiResource(basePath: string, controller: any, options?: {
37
+ static apiResource<T = any>(basePath: string, controller: any, options?: {
38
38
  only?: ResourceAction[];
39
39
  except?: ResourceAction[];
40
40
  middlewares?: ApiResourceMiddleware<Middleware>;
41
- }): ResourceRoutes<HttpContext, Middleware, Handler>;
41
+ }): ResourceRoutes<HttpContext, Middleware, Handler<T>>;
42
42
  /**
43
43
  * Define a GET route
44
44
  *
@@ -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
  * Adds a new HEAD route to the router.
92
92
  *
@@ -95,7 +95,7 @@ declare class Router extends CoreRouter {
95
95
  * @param handler
96
96
  * @param middlewares
97
97
  */
98
- static head(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
98
+ static head<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
99
99
  /**
100
100
  * Defines a group of routes with a common prefix.
101
101
  *
@@ -103,7 +103,7 @@ declare class Router extends CoreRouter {
103
103
  * @param callback
104
104
  * @param middlewares
105
105
  */
106
- static group(prefix: string, source: RouteGroupSource, middlewares?: Middleware[]): RouteGroup<HttpContext, Middleware, Handler>;
106
+ static group<T = any, S extends RouteGroupSource = RouteGroupSource>(prefix: string, source: S, middlewares?: Middleware[]): RouteGroup<HttpContext, Middleware, Handler<T>, S>;
107
107
  /**
108
108
  * Apply middlewares to a group of routes defined within the callback
109
109
  *
@@ -114,17 +114,17 @@ declare class Router extends CoreRouter {
114
114
  /**
115
115
  * Get all defined routes, optionally organized by path or method
116
116
  */
117
- static allRoutes(): Array<Route<HttpContext, Middleware, Handler>>;
117
+ static allRoutes<T = any>(): Array<Route<HttpContext, Middleware, Handler<T>>>;
118
118
  /**
119
119
  * @param type - 'path' to get routes organized by path
120
120
  */
121
- static allRoutes(type: 'path'): Record<string, Route<HttpContext, Middleware, Handler>>;
121
+ static allRoutes<T = any>(type: 'path'): Record<string, Route<HttpContext, Middleware, Handler<T>>>;
122
122
  /**
123
123
  * @param type - 'method' to get routes organized by method
124
124
  */
125
- static allRoutes(type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<HttpContext, Middleware, Handler>> };
126
- static allRoutes(type: 'name'): Record<string, Route<HttpContext, Middleware, Handler>>;
127
- static route(name: string): Route<HttpContext, Middleware, Handler> | undefined;
125
+ static allRoutes<T = any>(type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<HttpContext, Middleware, Handler<T>>> };
126
+ static allRoutes<T = any>(type: 'name'): Record<string, Route<HttpContext, Middleware, Handler<T>>>;
127
+ static route<T = any>(name: string): Route<HttpContext, Middleware, Handler<T>> | undefined;
128
128
  /**
129
129
  * Apply the defined routes to a @koa/router instance
130
130
  *