clear-router 2.7.6 → 2.7.7

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