clear-router 2.7.5 → 2.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/dist/ClearRequest.cjs +23 -0
  2. package/dist/ClearRequest.d.cts +28 -0
  3. package/dist/ClearRequest.d.mts +28 -0
  4. package/dist/ClearRequest.mjs +22 -0
  5. package/dist/Contracts.d.cts +12 -0
  6. package/dist/Contracts.d.mts +12 -0
  7. package/dist/Controller.cjs +12 -0
  8. package/dist/Controller.d.cts +14 -0
  9. package/dist/Controller.d.mts +14 -0
  10. package/dist/Controller.mjs +11 -0
  11. package/dist/{Request-DKXwa_W0.d.mts → Request-BhTJDR_5.d.mts} +5 -5
  12. package/dist/Route.cjs +58 -0
  13. package/dist/Route.d.cts +35 -0
  14. package/dist/Route.d.mts +35 -0
  15. package/dist/Route.mjs +57 -0
  16. package/dist/core/Request.cjs +35 -0
  17. package/dist/core/Request.d.cts +25 -0
  18. package/dist/core/Request.d.mts +25 -0
  19. package/dist/core/Request.mjs +35 -0
  20. package/dist/core/Response.cjs +59 -0
  21. package/dist/core/Response.d.cts +24 -0
  22. package/dist/core/Response.d.mts +24 -0
  23. package/dist/core/Response.mjs +58 -0
  24. package/dist/{bindings-CLsZjOEy.cjs → core/bindings.cjs} +10 -160
  25. package/dist/{bindings-CNL7bpz5.d.mts → core/bindings.d.cts} +1 -1
  26. package/dist/{bindings-CxvtC8XS.d.cts → core/bindings.d.mts} +1 -1
  27. package/dist/{bindings-XLDXFpHZ.mjs → core/bindings.mjs} +3 -110
  28. package/dist/core/index.cjs +4 -20
  29. package/dist/core/index.d.cts +4 -1
  30. package/dist/core/index.d.mts +4 -1
  31. package/dist/core/index.mjs +4 -14
  32. package/dist/core/plugins.cjs +14 -0
  33. package/dist/core/plugins.d.cts +109 -0
  34. package/dist/core/plugins.d.mts +109 -0
  35. package/dist/core/plugins.mjs +13 -0
  36. package/dist/{responses-Bvnk0uvc.cjs → core/responses.cjs} +5 -20
  37. package/dist/{responses-BvETUeDL.mjs → core/responses.mjs} +2 -2
  38. package/dist/{router-C6W-k6sS.cjs → core/router.cjs} +11 -69
  39. package/dist/core/router.d.cts +274 -0
  40. package/dist/core/router.d.mts +274 -0
  41. package/dist/{router-Dc9w86Wn.mjs → core/router.mjs} +5 -58
  42. package/dist/decorators/index.cjs +1 -1
  43. package/dist/decorators/index.d.cts +1 -1
  44. package/dist/decorators/index.d.mts +1 -1
  45. package/dist/decorators/index.mjs +1 -1
  46. package/dist/decorators/setup.cjs +2 -2
  47. package/dist/decorators/setup.d.cts +1 -1
  48. package/dist/decorators/setup.d.mts +1 -1
  49. package/dist/decorators/setup.mjs +2 -2
  50. package/dist/express/index.cjs +2 -265
  51. package/dist/express/index.d.cts +1 -127
  52. package/dist/express/index.d.mts +1 -127
  53. package/dist/express/index.mjs +1 -264
  54. package/dist/express/router.cjs +265 -0
  55. package/dist/express/router.d.cts +131 -0
  56. package/dist/express/router.d.mts +131 -0
  57. package/dist/express/router.mjs +265 -0
  58. package/dist/fastify/index.cjs +2 -254
  59. package/dist/fastify/index.d.cts +1 -125
  60. package/dist/fastify/index.d.mts +1 -125
  61. package/dist/fastify/index.mjs +1 -253
  62. package/dist/fastify/router.cjs +254 -0
  63. package/dist/fastify/router.d.cts +129 -0
  64. package/dist/fastify/router.d.mts +129 -0
  65. package/dist/fastify/router.mjs +254 -0
  66. package/dist/h3/index.cjs +2 -260
  67. package/dist/h3/index.d.cts +1 -128
  68. package/dist/h3/index.d.mts +1 -128
  69. package/dist/h3/index.mjs +1 -259
  70. package/dist/h3/router.cjs +260 -0
  71. package/dist/h3/router.d.cts +132 -0
  72. package/dist/h3/router.d.mts +132 -0
  73. package/dist/h3/router.mjs +260 -0
  74. package/dist/hono/index.cjs +2 -251
  75. package/dist/hono/index.d.cts +1 -130
  76. package/dist/hono/index.d.mts +1 -130
  77. package/dist/hono/index.mjs +1 -250
  78. package/dist/hono/router.cjs +251 -0
  79. package/dist/hono/router.d.cts +134 -0
  80. package/dist/hono/router.d.mts +134 -0
  81. package/dist/hono/router.mjs +251 -0
  82. package/dist/index.cjs +16 -1097
  83. package/dist/index.d.cts +9 -563
  84. package/dist/index.d.mts +9 -563
  85. package/dist/index.mjs +8 -1089
  86. package/dist/koa/index.cjs +2 -261
  87. package/dist/koa/index.d.cts +1 -131
  88. package/dist/koa/index.d.mts +1 -131
  89. package/dist/koa/index.mjs +1 -260
  90. package/dist/koa/router.cjs +261 -0
  91. package/dist/koa/router.d.cts +135 -0
  92. package/dist/koa/router.d.mts +135 -0
  93. package/dist/koa/router.mjs +261 -0
  94. package/dist/types/basic.d.cts +43 -0
  95. package/dist/types/express.d.cts +44 -0
  96. package/dist/types/express.d.mts +4 -2
  97. package/dist/types/fastify.d.cts +23 -0
  98. package/dist/types/fastify.d.mts +4 -2
  99. package/dist/types/h3.d.cts +41 -0
  100. package/dist/types/h3.d.mts +5 -6
  101. package/dist/types/hono.d.cts +21 -0
  102. package/dist/types/hono.d.mts +5 -5
  103. package/dist/types/koa.d.cts +25 -0
  104. package/dist/types/koa.d.mts +5 -5
  105. package/package.json +1 -1
  106. package/dist/router-CYBshGMl.d.mts +0 -652
  107. package/dist/router-tpnSi_Y7.d.cts +0 -652
@@ -0,0 +1,251 @@
1
+ const require_router = require('../core/router.cjs');
2
+ const require_responses = require('../core/responses.cjs');
3
+
4
+ //#region src/hono/router.ts
5
+ /**
6
+ * @class clear-router Hono Router
7
+ * @description Laravel-style routing system for Hono using shared clear-router core
8
+ * @author 3m1n3nc3
9
+ * @repository https://github.com/arkstack-tmp/clear-router
10
+ */
11
+ var Router = class Router extends require_router.CoreRouter {
12
+ static routerStateNamespace = "clear-router:hono";
13
+ static bodyCache = /* @__PURE__ */ new WeakMap();
14
+ static toResponse(ctx, value, method, path) {
15
+ const meta = require_responses.resolveResponseMeta(value, {
16
+ headers: ctx.req.header(),
17
+ method,
18
+ path
19
+ });
20
+ if (!meta) return void 0;
21
+ if (meta.isNativeResponse) return meta.body;
22
+ const headers = meta.headers ? {} : meta.contentType ? { "Content-Type": meta.contentType } : void 0;
23
+ meta.headers?.forEach((headerValue, key) => {
24
+ if (headers) headers[key] = headerValue;
25
+ });
26
+ if (meta.isEmpty) return ctx.body(null, meta.status, headers);
27
+ if (meta.contentType?.startsWith("application/json")) return ctx.body(JSON.stringify(meta.body), meta.status, headers);
28
+ return ctx.body(meta.body, meta.status, headers);
29
+ }
30
+ static getParams(ctx) {
31
+ try {
32
+ const raw = ctx.req.param?.();
33
+ return raw && typeof raw === "object" ? raw : {};
34
+ } catch {
35
+ return {};
36
+ }
37
+ }
38
+ static async readBodyCached(ctx) {
39
+ if (this.bodyCache.has(ctx)) {
40
+ const cached = this.bodyCache.get(ctx) || {};
41
+ ctx.req.getBody = () => cached;
42
+ return cached;
43
+ }
44
+ let body = {};
45
+ const contentType = (ctx.req.header("content-type") || "").toLowerCase();
46
+ if (contentType.includes("application/json")) body = await ctx.req.json().catch(() => ({}));
47
+ else if (contentType.includes("multipart/form-data") || contentType.includes("application/x-www-form-urlencoded")) body = await ctx.req.parseBody().then((v) => v).catch(() => ({}));
48
+ ctx.req.getBody = () => body;
49
+ this.bodyCache.set(ctx, body);
50
+ return body;
51
+ }
52
+ /**
53
+ * Adds a new route to the router.
54
+ *
55
+ * @param methods
56
+ * @param path
57
+ * @param handler
58
+ * @param middlewares
59
+ */
60
+ static add(methods, path, handler, middlewares) {
61
+ return super.add(methods, path, handler, middlewares);
62
+ }
63
+ /**
64
+ * Define a resourceful API controller with standard CRUD routes
65
+ *
66
+ * @param basePath
67
+ * @param controller
68
+ * @param options
69
+ */
70
+ static apiResource(basePath, controller, options) {
71
+ super.apiResource(basePath, controller, options);
72
+ }
73
+ /**
74
+ * Define a GET route
75
+ *
76
+ * @param path
77
+ * @param handler
78
+ * @param middlewares
79
+ */
80
+ static get(path, handler, middlewares) {
81
+ return super.get(path, handler, middlewares);
82
+ }
83
+ /**
84
+ * Define a POST route
85
+ *
86
+ * @param path
87
+ * @param handler
88
+ * @param middlewares
89
+ */
90
+ static post(path, handler, middlewares) {
91
+ return super.post(path, handler, middlewares);
92
+ }
93
+ /**
94
+ * Define a PUT route
95
+ *
96
+ * @param path
97
+ * @param handler
98
+ * @param middlewares
99
+ */
100
+ static put(path, handler, middlewares) {
101
+ return super.put(path, handler, middlewares);
102
+ }
103
+ /**
104
+ * Define a DELETE route
105
+ *
106
+ * @param path
107
+ * @param handler
108
+ * @param middlewares
109
+ */
110
+ static delete(path, handler, middlewares) {
111
+ return super.delete(path, handler, middlewares);
112
+ }
113
+ /**
114
+ * Define a PATCH route
115
+ *
116
+ * @param path
117
+ * @param handler
118
+ * @param middlewares
119
+ */
120
+ static patch(path, handler, middlewares) {
121
+ return super.patch(path, handler, middlewares);
122
+ }
123
+ /**
124
+ * Define an OPTIONS route
125
+ *
126
+ * @param path
127
+ * @param handler
128
+ * @param middlewares
129
+ */
130
+ static options(path, handler, middlewares) {
131
+ return super.options(path, handler, middlewares);
132
+ }
133
+ /**
134
+ * Define a HEAD route
135
+ *
136
+ * @param path
137
+ * @param handler
138
+ * @param middlewares
139
+ */
140
+ static head(path, handler, middlewares) {
141
+ return super.head(path, handler, middlewares);
142
+ }
143
+ /**
144
+ * Defines a group of routes with a common prefix.
145
+ *
146
+ * @param prefix
147
+ * @param callback
148
+ * @param middlewares
149
+ */
150
+ static async group(prefix, callback, middlewares) {
151
+ await super.group(prefix, callback, middlewares);
152
+ }
153
+ /**
154
+ * Apply middlewares to a group of routes defined within the callback
155
+ *
156
+ * @param middlewares - Middleware or array of middlewares to apply
157
+ * @param callback - Function that defines the routes to which the middlewares will be applied
158
+ */
159
+ static middleware(middlewares, callback) {
160
+ super.middleware(middlewares, callback);
161
+ }
162
+ static allRoutes(type) {
163
+ return super.allRoutes(type);
164
+ }
165
+ static route(name) {
166
+ return super.route(name);
167
+ }
168
+ /**
169
+ * Apply the defined routes to a Hono application instance
170
+ *
171
+ * @param app The Hono application instance
172
+ * @returns The Hono application instance with the applied routes
173
+ */
174
+ static apply(app) {
175
+ for (const route of Array.from(this.routes)) {
176
+ let handlerFunction = null;
177
+ let instance = null;
178
+ let bindingTarget;
179
+ let bindingMethod;
180
+ let bindingHandler;
181
+ let bindingMetadata;
182
+ try {
183
+ const resolved = this.resolveHandler(route);
184
+ handlerFunction = resolved.handlerFunction;
185
+ instance = resolved.instance;
186
+ bindingTarget = resolved.bindingTarget;
187
+ bindingMethod = resolved.bindingMethod;
188
+ bindingHandler = resolved.bindingHandler;
189
+ bindingMetadata = resolved.bindingMetadata;
190
+ } catch (error) {
191
+ console.error(`[ROUTES] Error setting up route ${route.path}:`, error.message);
192
+ throw error;
193
+ }
194
+ if (!handlerFunction) continue;
195
+ for (const method of route.methods) {
196
+ const allowedMethods = [
197
+ "get",
198
+ "post",
199
+ "put",
200
+ "delete",
201
+ "patch",
202
+ "options",
203
+ "head"
204
+ ];
205
+ if (method === "options" && route.methods.length > 1) continue;
206
+ if (!allowedMethods.includes(method)) throw new Error(`Invalid HTTP method: ${method} for route: ${route.path}`);
207
+ for (const registrationPath of route.registrationPaths) app[method](registrationPath, ...route.middlewares || [], async (context) => {
208
+ const ctx = context;
209
+ const reqBody = await Router.readBodyCached(ctx);
210
+ const override = Router.resolveMethodOverride(ctx.req.method, ctx.req.header(), reqBody);
211
+ if (method === "post" && override && override !== "post") return;
212
+ const inst = instance ?? route;
213
+ Router.bindRequestToInstance(ctx, inst, route, {
214
+ body: reqBody,
215
+ query: ctx.req.query(),
216
+ params: Router.getParams(ctx),
217
+ method
218
+ });
219
+ const result = await Router.callHandler(handlerFunction, ctx, bindingTarget, bindingMethod, bindingHandler, bindingMetadata);
220
+ const resolved = await Promise.resolve(result);
221
+ const outgoing = typeof resolved === "undefined" && ctx.clearResponse?.sent ? ctx.clearResponse : resolved;
222
+ return Router.toResponse(ctx, outgoing, method, route.path);
223
+ });
224
+ if ([
225
+ "put",
226
+ "patch",
227
+ "delete"
228
+ ].includes(method)) for (const registrationPath of route.registrationPaths) app.post(registrationPath, ...route.middlewares || [], async (context) => {
229
+ const ctx = context;
230
+ const reqBody = await Router.readBodyCached(ctx);
231
+ if (Router.resolveMethodOverride(ctx.req.method, ctx.req.header(), reqBody) !== method) return;
232
+ const inst = instance ?? route;
233
+ Router.bindRequestToInstance(ctx, inst, route, {
234
+ body: reqBody,
235
+ query: ctx.req.query(),
236
+ params: Router.getParams(ctx),
237
+ method
238
+ });
239
+ const result = await Router.callHandler(handlerFunction, ctx, bindingTarget, bindingMethod, bindingHandler, bindingMetadata);
240
+ const resolved = await Promise.resolve(result);
241
+ const outgoing = typeof resolved === "undefined" && ctx.clearResponse?.sent ? ctx.clearResponse : resolved;
242
+ return Router.toResponse(ctx, outgoing, method, route.path);
243
+ });
244
+ }
245
+ }
246
+ return app;
247
+ }
248
+ };
249
+
250
+ //#endregion
251
+ exports.default = Router;
@@ -0,0 +1,134 @@
1
+ import { ApiResourceMiddleware, ControllerAction, HttpMethod } from "../types/basic.cjs";
2
+ import { Handler, HonoApp, HttpContext, Middleware } from "../types/hono.cjs";
3
+ import { Route } from "../Route.cjs";
4
+ import { CoreRouter } from "../core/router.cjs";
5
+
6
+ //#region src/hono/router.d.ts
7
+ /**
8
+ * @class clear-router Hono Router
9
+ * @description Laravel-style routing system for Hono using shared clear-router core
10
+ * @author 3m1n3nc3
11
+ * @repository https://github.com/arkstack-tmp/clear-router
12
+ */
13
+ declare class Router extends CoreRouter {
14
+ protected static routerStateNamespace: string;
15
+ private static readonly bodyCache;
16
+ private static toResponse;
17
+ private static getParams;
18
+ private static readBodyCached;
19
+ /**
20
+ * Adds a new route to the router.
21
+ *
22
+ * @param methods
23
+ * @param path
24
+ * @param handler
25
+ * @param middlewares
26
+ */
27
+ static add(methods: HttpMethod | HttpMethod[], path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
28
+ /**
29
+ * Define a resourceful API controller with standard CRUD routes
30
+ *
31
+ * @param basePath
32
+ * @param controller
33
+ * @param options
34
+ */
35
+ static apiResource(basePath: string, controller: any, options?: {
36
+ only?: ControllerAction[];
37
+ except?: ControllerAction[];
38
+ middlewares?: ApiResourceMiddleware<Middleware>;
39
+ }): void;
40
+ /**
41
+ * Define a GET route
42
+ *
43
+ * @param path
44
+ * @param handler
45
+ * @param middlewares
46
+ */
47
+ static get(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
48
+ /**
49
+ * Define a POST route
50
+ *
51
+ * @param path
52
+ * @param handler
53
+ * @param middlewares
54
+ */
55
+ static post(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
56
+ /**
57
+ * Define a PUT route
58
+ *
59
+ * @param path
60
+ * @param handler
61
+ * @param middlewares
62
+ */
63
+ static put(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
64
+ /**
65
+ * Define a DELETE route
66
+ *
67
+ * @param path
68
+ * @param handler
69
+ * @param middlewares
70
+ */
71
+ static delete(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
72
+ /**
73
+ * Define a PATCH route
74
+ *
75
+ * @param path
76
+ * @param handler
77
+ * @param middlewares
78
+ */
79
+ static patch(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
80
+ /**
81
+ * Define an OPTIONS route
82
+ *
83
+ * @param path
84
+ * @param handler
85
+ * @param middlewares
86
+ */
87
+ static options(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
88
+ /**
89
+ * Define a HEAD route
90
+ *
91
+ * @param path
92
+ * @param handler
93
+ * @param middlewares
94
+ */
95
+ static head(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
96
+ /**
97
+ * Defines a group of routes with a common prefix.
98
+ *
99
+ * @param prefix
100
+ * @param callback
101
+ * @param middlewares
102
+ */
103
+ static group(prefix: string, callback: () => void | Promise<void>, middlewares?: Middleware[]): Promise<void>;
104
+ /**
105
+ * Apply middlewares to a group of routes defined within the callback
106
+ *
107
+ * @param middlewares - Middleware or array of middlewares to apply
108
+ * @param callback - Function that defines the routes to which the middlewares will be applied
109
+ */
110
+ static middleware(middlewares: Middleware[], callback: () => void): void;
111
+ /**
112
+ * Get all defined routes, optionally organized by path or method
113
+ */
114
+ static allRoutes(): Array<Route<HttpContext, Middleware, Handler>>;
115
+ /**
116
+ * @param type - 'path' to get routes organized by path
117
+ */
118
+ static allRoutes(type: 'path'): Record<string, Route<HttpContext, Middleware, Handler>>;
119
+ /**
120
+ * @param type - 'method' to get routes organized by method
121
+ */
122
+ static allRoutes(type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<HttpContext, Middleware, Handler>> };
123
+ static allRoutes(type: 'name'): Record<string, Route<HttpContext, Middleware, Handler>>;
124
+ static route(name: string): Route<HttpContext, Middleware, Handler> | undefined;
125
+ /**
126
+ * Apply the defined routes to a Hono application instance
127
+ *
128
+ * @param app The Hono application instance
129
+ * @returns The Hono application instance with the applied routes
130
+ */
131
+ static apply(app: HonoApp): HonoApp;
132
+ }
133
+ //#endregion
134
+ export { Router };
@@ -0,0 +1,134 @@
1
+ import { ApiResourceMiddleware, ControllerAction, HttpMethod } from "../types/basic.mjs";
2
+ import { Handler, HonoApp, HttpContext, Middleware } from "../types/hono.mjs";
3
+ import { Route } from "../Route.mjs";
4
+ import { CoreRouter } from "../core/router.mjs";
5
+
6
+ //#region src/hono/router.d.ts
7
+ /**
8
+ * @class clear-router Hono Router
9
+ * @description Laravel-style routing system for Hono using shared clear-router core
10
+ * @author 3m1n3nc3
11
+ * @repository https://github.com/arkstack-tmp/clear-router
12
+ */
13
+ declare class Router extends CoreRouter {
14
+ protected static routerStateNamespace: string;
15
+ private static readonly bodyCache;
16
+ private static toResponse;
17
+ private static getParams;
18
+ private static readBodyCached;
19
+ /**
20
+ * Adds a new route to the router.
21
+ *
22
+ * @param methods
23
+ * @param path
24
+ * @param handler
25
+ * @param middlewares
26
+ */
27
+ static add(methods: HttpMethod | HttpMethod[], path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
28
+ /**
29
+ * Define a resourceful API controller with standard CRUD routes
30
+ *
31
+ * @param basePath
32
+ * @param controller
33
+ * @param options
34
+ */
35
+ static apiResource(basePath: string, controller: any, options?: {
36
+ only?: ControllerAction[];
37
+ except?: ControllerAction[];
38
+ middlewares?: ApiResourceMiddleware<Middleware>;
39
+ }): void;
40
+ /**
41
+ * Define a GET route
42
+ *
43
+ * @param path
44
+ * @param handler
45
+ * @param middlewares
46
+ */
47
+ static get(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
48
+ /**
49
+ * Define a POST route
50
+ *
51
+ * @param path
52
+ * @param handler
53
+ * @param middlewares
54
+ */
55
+ static post(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
56
+ /**
57
+ * Define a PUT route
58
+ *
59
+ * @param path
60
+ * @param handler
61
+ * @param middlewares
62
+ */
63
+ static put(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
64
+ /**
65
+ * Define a DELETE route
66
+ *
67
+ * @param path
68
+ * @param handler
69
+ * @param middlewares
70
+ */
71
+ static delete(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
72
+ /**
73
+ * Define a PATCH route
74
+ *
75
+ * @param path
76
+ * @param handler
77
+ * @param middlewares
78
+ */
79
+ static patch(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
80
+ /**
81
+ * Define an OPTIONS route
82
+ *
83
+ * @param path
84
+ * @param handler
85
+ * @param middlewares
86
+ */
87
+ static options(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
88
+ /**
89
+ * Define a HEAD route
90
+ *
91
+ * @param path
92
+ * @param handler
93
+ * @param middlewares
94
+ */
95
+ static head(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
96
+ /**
97
+ * Defines a group of routes with a common prefix.
98
+ *
99
+ * @param prefix
100
+ * @param callback
101
+ * @param middlewares
102
+ */
103
+ static group(prefix: string, callback: () => void | Promise<void>, middlewares?: Middleware[]): Promise<void>;
104
+ /**
105
+ * Apply middlewares to a group of routes defined within the callback
106
+ *
107
+ * @param middlewares - Middleware or array of middlewares to apply
108
+ * @param callback - Function that defines the routes to which the middlewares will be applied
109
+ */
110
+ static middleware(middlewares: Middleware[], callback: () => void): void;
111
+ /**
112
+ * Get all defined routes, optionally organized by path or method
113
+ */
114
+ static allRoutes(): Array<Route<HttpContext, Middleware, Handler>>;
115
+ /**
116
+ * @param type - 'path' to get routes organized by path
117
+ */
118
+ static allRoutes(type: 'path'): Record<string, Route<HttpContext, Middleware, Handler>>;
119
+ /**
120
+ * @param type - 'method' to get routes organized by method
121
+ */
122
+ static allRoutes(type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<HttpContext, Middleware, Handler>> };
123
+ static allRoutes(type: 'name'): Record<string, Route<HttpContext, Middleware, Handler>>;
124
+ static route(name: string): Route<HttpContext, Middleware, Handler> | undefined;
125
+ /**
126
+ * Apply the defined routes to a Hono application instance
127
+ *
128
+ * @param app The Hono application instance
129
+ * @returns The Hono application instance with the applied routes
130
+ */
131
+ static apply(app: HonoApp): HonoApp;
132
+ }
133
+ //#endregion
134
+ export { Router };