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