clear-router 2.7.6 → 2.8.0

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