clear-router 2.5.0 → 2.5.2
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.
- package/README.md +10 -5
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.d.cts +1 -1
- package/dist/core/index.d.mts +1 -1
- package/dist/core/index.mjs +1 -1
- package/dist/express/index.cjs +11 -13
- package/dist/express/index.d.cts +11 -13
- package/dist/express/index.d.mts +11 -13
- package/dist/express/index.mjs +11 -13
- package/dist/fastify/index.cjs +1 -1
- package/dist/fastify/index.d.cts +1 -1
- package/dist/fastify/index.d.mts +1 -1
- package/dist/fastify/index.mjs +1 -1
- package/dist/h3/index.cjs +5 -7
- package/dist/h3/index.d.cts +5 -7
- package/dist/h3/index.d.mts +5 -7
- package/dist/h3/index.mjs +5 -7
- package/dist/hono/index.cjs +3 -3
- package/dist/hono/index.d.cts +3 -3
- package/dist/hono/index.d.mts +3 -3
- package/dist/hono/index.mjs +3 -3
- package/dist/index.cjs +10 -12
- package/dist/index.d.cts +10 -12
- package/dist/index.d.mts +10 -12
- package/dist/index.mjs +10 -12
- package/dist/koa/index.cjs +79 -4
- package/dist/koa/index.d.cts +88 -4
- package/dist/koa/index.d.mts +88 -4
- package/dist/koa/index.mjs +79 -4
- package/dist/{router-Dxc8FQOl.mjs → router-BReOXz-F.mjs} +10 -12
- package/dist/{router-Cxi21bzi.cjs → router-CHg0pZUO.cjs} +10 -12
- package/dist/{router-A-9JuZPi.d.cts → router-CS_2XQ7I.d.cts} +10 -12
- package/dist/{router-CVeqd7Ro.d.mts → router-_w2VzMQF.d.mts} +10 -12
- package/package.json +2 -2
package/dist/hono/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_router = require('../router-
|
|
2
|
+
const require_router = require('../router-CHg0pZUO.cjs');
|
|
3
3
|
const require_responses = require('../responses-r-O3jS-S.cjs');
|
|
4
4
|
|
|
5
5
|
//#region src/hono/router.ts
|
|
@@ -47,7 +47,7 @@ var Router = class Router extends require_router.CoreRouter {
|
|
|
47
47
|
return body;
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
|
-
*
|
|
50
|
+
* Adds a new route to the router.
|
|
51
51
|
*
|
|
52
52
|
* @param methods
|
|
53
53
|
* @param path
|
|
@@ -138,7 +138,7 @@ var Router = class Router extends require_router.CoreRouter {
|
|
|
138
138
|
super.head(path, handler, middlewares);
|
|
139
139
|
}
|
|
140
140
|
/**
|
|
141
|
-
*
|
|
141
|
+
* Defines a group of routes with a common prefix.
|
|
142
142
|
*
|
|
143
143
|
* @param prefix
|
|
144
144
|
* @param callback
|
package/dist/hono/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as ApiResourceMiddleware, f as ControllerAction, m as HttpMethod, n as ClearRequest, p as ControllerHandler, r as Route, t as CoreRouter } from "../router-
|
|
1
|
+
import { d as ApiResourceMiddleware, f as ControllerAction, m as HttpMethod, n as ClearRequest, p as ControllerHandler, r as Route, t as CoreRouter } from "../router-CS_2XQ7I.cjs";
|
|
2
2
|
import { Context, HonoRequest, MiddlewareHandler } from "hono";
|
|
3
3
|
|
|
4
4
|
//#region types/hono.d.ts
|
|
@@ -27,7 +27,7 @@ declare class Router extends CoreRouter {
|
|
|
27
27
|
private static getParams;
|
|
28
28
|
private static readBodyCached;
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* Adds a new route to the router.
|
|
31
31
|
*
|
|
32
32
|
* @param methods
|
|
33
33
|
* @param path
|
|
@@ -104,7 +104,7 @@ declare class Router extends CoreRouter {
|
|
|
104
104
|
*/
|
|
105
105
|
static head(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): void;
|
|
106
106
|
/**
|
|
107
|
-
*
|
|
107
|
+
* Defines a group of routes with a common prefix.
|
|
108
108
|
*
|
|
109
109
|
* @param prefix
|
|
110
110
|
* @param callback
|
package/dist/hono/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as ApiResourceMiddleware, f as ControllerAction, m as HttpMethod, n as ClearRequest, p as ControllerHandler, r as Route, t as CoreRouter } from "../router-
|
|
1
|
+
import { d as ApiResourceMiddleware, f as ControllerAction, m as HttpMethod, n as ClearRequest, p as ControllerHandler, r as Route, t as CoreRouter } from "../router-_w2VzMQF.mjs";
|
|
2
2
|
import { Context, HonoRequest, MiddlewareHandler } from "hono";
|
|
3
3
|
|
|
4
4
|
//#region types/hono.d.ts
|
|
@@ -27,7 +27,7 @@ declare class Router extends CoreRouter {
|
|
|
27
27
|
private static getParams;
|
|
28
28
|
private static readBodyCached;
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* Adds a new route to the router.
|
|
31
31
|
*
|
|
32
32
|
* @param methods
|
|
33
33
|
* @param path
|
|
@@ -104,7 +104,7 @@ declare class Router extends CoreRouter {
|
|
|
104
104
|
*/
|
|
105
105
|
static head(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): void;
|
|
106
106
|
/**
|
|
107
|
-
*
|
|
107
|
+
* Defines a group of routes with a common prefix.
|
|
108
108
|
*
|
|
109
109
|
* @param prefix
|
|
110
110
|
* @param callback
|
package/dist/hono/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as CoreRouter } from "../router-
|
|
1
|
+
import { t as CoreRouter } from "../router-BReOXz-F.mjs";
|
|
2
2
|
import { n as resolveResponseMeta } from "../responses-HOePPAl8.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/hono/router.ts
|
|
@@ -46,7 +46,7 @@ var Router = class Router extends CoreRouter {
|
|
|
46
46
|
return body;
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
49
|
+
* Adds a new route to the router.
|
|
50
50
|
*
|
|
51
51
|
* @param methods
|
|
52
52
|
* @param path
|
|
@@ -137,7 +137,7 @@ var Router = class Router extends CoreRouter {
|
|
|
137
137
|
super.head(path, handler, middlewares);
|
|
138
138
|
}
|
|
139
139
|
/**
|
|
140
|
-
*
|
|
140
|
+
* Defines a group of routes with a common prefix.
|
|
141
141
|
*
|
|
142
142
|
* @param prefix
|
|
143
143
|
* @param callback
|
package/dist/index.cjs
CHANGED
|
@@ -255,7 +255,7 @@ var CoreRouter = class {
|
|
|
255
255
|
return null;
|
|
256
256
|
}
|
|
257
257
|
/**
|
|
258
|
-
* Adds a new route to the router
|
|
258
|
+
* Adds a new route to the router.
|
|
259
259
|
*
|
|
260
260
|
* @param this
|
|
261
261
|
* @param methods
|
|
@@ -285,8 +285,7 @@ var CoreRouter = class {
|
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
287
|
/**
|
|
288
|
-
*
|
|
289
|
-
* options to include/exclude specific actions and apply middlewares.
|
|
288
|
+
* Define a resourceful API controller with standard CRUD routes.
|
|
290
289
|
*
|
|
291
290
|
* @param this
|
|
292
291
|
* @param basePath
|
|
@@ -329,7 +328,7 @@ var CoreRouter = class {
|
|
|
329
328
|
}
|
|
330
329
|
}
|
|
331
330
|
/**
|
|
332
|
-
* Adds a new GET route to the router
|
|
331
|
+
* Adds a new GET route to the router.
|
|
333
332
|
*
|
|
334
333
|
* @param this The router instance.
|
|
335
334
|
* @param path The path for the GET route.
|
|
@@ -340,7 +339,7 @@ var CoreRouter = class {
|
|
|
340
339
|
this.add("get", path, handler, middlewares);
|
|
341
340
|
}
|
|
342
341
|
/**
|
|
343
|
-
* Adds a new POST route to the router
|
|
342
|
+
* Adds a new POST route to the router.
|
|
344
343
|
*
|
|
345
344
|
* @param this
|
|
346
345
|
* @param path
|
|
@@ -351,7 +350,7 @@ var CoreRouter = class {
|
|
|
351
350
|
this.add("post", path, handler, middlewares);
|
|
352
351
|
}
|
|
353
352
|
/**
|
|
354
|
-
* Adds a new PUT route to the router
|
|
353
|
+
* Adds a new PUT route to the router.
|
|
355
354
|
*
|
|
356
355
|
* @param this
|
|
357
356
|
* @param path
|
|
@@ -362,7 +361,7 @@ var CoreRouter = class {
|
|
|
362
361
|
this.add("put", path, handler, middlewares);
|
|
363
362
|
}
|
|
364
363
|
/**
|
|
365
|
-
* Adds a new DELETE route to the router
|
|
364
|
+
* Adds a new DELETE route to the router.
|
|
366
365
|
*
|
|
367
366
|
* @param this
|
|
368
367
|
* @param path
|
|
@@ -373,7 +372,7 @@ var CoreRouter = class {
|
|
|
373
372
|
this.add("delete", path, handler, middlewares);
|
|
374
373
|
}
|
|
375
374
|
/**
|
|
376
|
-
* Adds a new PATCH route to the router
|
|
375
|
+
* Adds a new PATCH route to the router.
|
|
377
376
|
*
|
|
378
377
|
* @param this
|
|
379
378
|
* @param path
|
|
@@ -384,7 +383,7 @@ var CoreRouter = class {
|
|
|
384
383
|
this.add("patch", path, handler, middlewares);
|
|
385
384
|
}
|
|
386
385
|
/**
|
|
387
|
-
* Adds a new OPTIONS route to the router
|
|
386
|
+
* Adds a new OPTIONS route to the router.
|
|
388
387
|
*
|
|
389
388
|
* @param this
|
|
390
389
|
* @param path
|
|
@@ -395,7 +394,7 @@ var CoreRouter = class {
|
|
|
395
394
|
this.add("options", path, handler, middlewares);
|
|
396
395
|
}
|
|
397
396
|
/**
|
|
398
|
-
* Adds a new HEAD route to the router
|
|
397
|
+
* Adds a new HEAD route to the router.
|
|
399
398
|
*
|
|
400
399
|
* @param this
|
|
401
400
|
* @param path
|
|
@@ -406,8 +405,7 @@ var CoreRouter = class {
|
|
|
406
405
|
this.add("head", path, handler, middlewares);
|
|
407
406
|
}
|
|
408
407
|
/**
|
|
409
|
-
* Defines a group of routes with a common prefix
|
|
410
|
-
* organization and reuse of route configurations.
|
|
408
|
+
* Defines a group of routes with a common prefix.
|
|
411
409
|
*
|
|
412
410
|
* @param this
|
|
413
411
|
* @param prefix
|
package/dist/index.d.cts
CHANGED
|
@@ -145,7 +145,7 @@ declare abstract class CoreRouter {
|
|
|
145
145
|
static configure(this: any, options?: RouterConfig): void;
|
|
146
146
|
protected static resolveMethodOverride(this: any, method: string, headers: Headers | Record<string, any>, body: unknown): HttpMethod | null;
|
|
147
147
|
/**
|
|
148
|
-
* Adds a new route to the router
|
|
148
|
+
* Adds a new route to the router.
|
|
149
149
|
*
|
|
150
150
|
* @param this
|
|
151
151
|
* @param methods
|
|
@@ -155,8 +155,7 @@ declare abstract class CoreRouter {
|
|
|
155
155
|
*/
|
|
156
156
|
static add(this: any, methods: HttpMethod | HttpMethod[], path: string, handler: any, middlewares?: any[] | any): void;
|
|
157
157
|
/**
|
|
158
|
-
*
|
|
159
|
-
* options to include/exclude specific actions and apply middlewares.
|
|
158
|
+
* Define a resourceful API controller with standard CRUD routes.
|
|
160
159
|
*
|
|
161
160
|
* @param this
|
|
162
161
|
* @param basePath
|
|
@@ -169,7 +168,7 @@ declare abstract class CoreRouter {
|
|
|
169
168
|
middlewares?: ApiResourceMiddleware<any>;
|
|
170
169
|
}): void;
|
|
171
170
|
/**
|
|
172
|
-
* Adds a new GET route to the router
|
|
171
|
+
* Adds a new GET route to the router.
|
|
173
172
|
*
|
|
174
173
|
* @param this The router instance.
|
|
175
174
|
* @param path The path for the GET route.
|
|
@@ -178,7 +177,7 @@ declare abstract class CoreRouter {
|
|
|
178
177
|
*/
|
|
179
178
|
static get(this: any, path: string, handler: any, middlewares?: any[] | any): void;
|
|
180
179
|
/**
|
|
181
|
-
* Adds a new POST route to the router
|
|
180
|
+
* Adds a new POST route to the router.
|
|
182
181
|
*
|
|
183
182
|
* @param this
|
|
184
183
|
* @param path
|
|
@@ -187,7 +186,7 @@ declare abstract class CoreRouter {
|
|
|
187
186
|
*/
|
|
188
187
|
static post(this: any, path: string, handler: any, middlewares?: any[] | any): void;
|
|
189
188
|
/**
|
|
190
|
-
* Adds a new PUT route to the router
|
|
189
|
+
* Adds a new PUT route to the router.
|
|
191
190
|
*
|
|
192
191
|
* @param this
|
|
193
192
|
* @param path
|
|
@@ -196,7 +195,7 @@ declare abstract class CoreRouter {
|
|
|
196
195
|
*/
|
|
197
196
|
static put(this: any, path: string, handler: any, middlewares?: any[] | any): void;
|
|
198
197
|
/**
|
|
199
|
-
* Adds a new DELETE route to the router
|
|
198
|
+
* Adds a new DELETE route to the router.
|
|
200
199
|
*
|
|
201
200
|
* @param this
|
|
202
201
|
* @param path
|
|
@@ -205,7 +204,7 @@ declare abstract class CoreRouter {
|
|
|
205
204
|
*/
|
|
206
205
|
static delete(this: any, path: string, handler: any, middlewares?: any[] | any): void;
|
|
207
206
|
/**
|
|
208
|
-
* Adds a new PATCH route to the router
|
|
207
|
+
* Adds a new PATCH route to the router.
|
|
209
208
|
*
|
|
210
209
|
* @param this
|
|
211
210
|
* @param path
|
|
@@ -214,7 +213,7 @@ declare abstract class CoreRouter {
|
|
|
214
213
|
*/
|
|
215
214
|
static patch(this: any, path: string, handler: any, middlewares?: any[] | any): void;
|
|
216
215
|
/**
|
|
217
|
-
* Adds a new OPTIONS route to the router
|
|
216
|
+
* Adds a new OPTIONS route to the router.
|
|
218
217
|
*
|
|
219
218
|
* @param this
|
|
220
219
|
* @param path
|
|
@@ -223,7 +222,7 @@ declare abstract class CoreRouter {
|
|
|
223
222
|
*/
|
|
224
223
|
static options(this: any, path: string, handler: any, middlewares?: any[] | any): void;
|
|
225
224
|
/**
|
|
226
|
-
* Adds a new HEAD route to the router
|
|
225
|
+
* Adds a new HEAD route to the router.
|
|
227
226
|
*
|
|
228
227
|
* @param this
|
|
229
228
|
* @param path
|
|
@@ -232,8 +231,7 @@ declare abstract class CoreRouter {
|
|
|
232
231
|
*/
|
|
233
232
|
static head(this: any, path: string, handler: any, middlewares?: any[] | any): void;
|
|
234
233
|
/**
|
|
235
|
-
* Defines a group of routes with a common prefix
|
|
236
|
-
* organization and reuse of route configurations.
|
|
234
|
+
* Defines a group of routes with a common prefix.
|
|
237
235
|
*
|
|
238
236
|
* @param this
|
|
239
237
|
* @param prefix
|
package/dist/index.d.mts
CHANGED
|
@@ -145,7 +145,7 @@ declare abstract class CoreRouter {
|
|
|
145
145
|
static configure(this: any, options?: RouterConfig): void;
|
|
146
146
|
protected static resolveMethodOverride(this: any, method: string, headers: Headers | Record<string, any>, body: unknown): HttpMethod | null;
|
|
147
147
|
/**
|
|
148
|
-
* Adds a new route to the router
|
|
148
|
+
* Adds a new route to the router.
|
|
149
149
|
*
|
|
150
150
|
* @param this
|
|
151
151
|
* @param methods
|
|
@@ -155,8 +155,7 @@ declare abstract class CoreRouter {
|
|
|
155
155
|
*/
|
|
156
156
|
static add(this: any, methods: HttpMethod | HttpMethod[], path: string, handler: any, middlewares?: any[] | any): void;
|
|
157
157
|
/**
|
|
158
|
-
*
|
|
159
|
-
* options to include/exclude specific actions and apply middlewares.
|
|
158
|
+
* Define a resourceful API controller with standard CRUD routes.
|
|
160
159
|
*
|
|
161
160
|
* @param this
|
|
162
161
|
* @param basePath
|
|
@@ -169,7 +168,7 @@ declare abstract class CoreRouter {
|
|
|
169
168
|
middlewares?: ApiResourceMiddleware<any>;
|
|
170
169
|
}): void;
|
|
171
170
|
/**
|
|
172
|
-
* Adds a new GET route to the router
|
|
171
|
+
* Adds a new GET route to the router.
|
|
173
172
|
*
|
|
174
173
|
* @param this The router instance.
|
|
175
174
|
* @param path The path for the GET route.
|
|
@@ -178,7 +177,7 @@ declare abstract class CoreRouter {
|
|
|
178
177
|
*/
|
|
179
178
|
static get(this: any, path: string, handler: any, middlewares?: any[] | any): void;
|
|
180
179
|
/**
|
|
181
|
-
* Adds a new POST route to the router
|
|
180
|
+
* Adds a new POST route to the router.
|
|
182
181
|
*
|
|
183
182
|
* @param this
|
|
184
183
|
* @param path
|
|
@@ -187,7 +186,7 @@ declare abstract class CoreRouter {
|
|
|
187
186
|
*/
|
|
188
187
|
static post(this: any, path: string, handler: any, middlewares?: any[] | any): void;
|
|
189
188
|
/**
|
|
190
|
-
* Adds a new PUT route to the router
|
|
189
|
+
* Adds a new PUT route to the router.
|
|
191
190
|
*
|
|
192
191
|
* @param this
|
|
193
192
|
* @param path
|
|
@@ -196,7 +195,7 @@ declare abstract class CoreRouter {
|
|
|
196
195
|
*/
|
|
197
196
|
static put(this: any, path: string, handler: any, middlewares?: any[] | any): void;
|
|
198
197
|
/**
|
|
199
|
-
* Adds a new DELETE route to the router
|
|
198
|
+
* Adds a new DELETE route to the router.
|
|
200
199
|
*
|
|
201
200
|
* @param this
|
|
202
201
|
* @param path
|
|
@@ -205,7 +204,7 @@ declare abstract class CoreRouter {
|
|
|
205
204
|
*/
|
|
206
205
|
static delete(this: any, path: string, handler: any, middlewares?: any[] | any): void;
|
|
207
206
|
/**
|
|
208
|
-
* Adds a new PATCH route to the router
|
|
207
|
+
* Adds a new PATCH route to the router.
|
|
209
208
|
*
|
|
210
209
|
* @param this
|
|
211
210
|
* @param path
|
|
@@ -214,7 +213,7 @@ declare abstract class CoreRouter {
|
|
|
214
213
|
*/
|
|
215
214
|
static patch(this: any, path: string, handler: any, middlewares?: any[] | any): void;
|
|
216
215
|
/**
|
|
217
|
-
* Adds a new OPTIONS route to the router
|
|
216
|
+
* Adds a new OPTIONS route to the router.
|
|
218
217
|
*
|
|
219
218
|
* @param this
|
|
220
219
|
* @param path
|
|
@@ -223,7 +222,7 @@ declare abstract class CoreRouter {
|
|
|
223
222
|
*/
|
|
224
223
|
static options(this: any, path: string, handler: any, middlewares?: any[] | any): void;
|
|
225
224
|
/**
|
|
226
|
-
* Adds a new HEAD route to the router
|
|
225
|
+
* Adds a new HEAD route to the router.
|
|
227
226
|
*
|
|
228
227
|
* @param this
|
|
229
228
|
* @param path
|
|
@@ -232,8 +231,7 @@ declare abstract class CoreRouter {
|
|
|
232
231
|
*/
|
|
233
232
|
static head(this: any, path: string, handler: any, middlewares?: any[] | any): void;
|
|
234
233
|
/**
|
|
235
|
-
* Defines a group of routes with a common prefix
|
|
236
|
-
* organization and reuse of route configurations.
|
|
234
|
+
* Defines a group of routes with a common prefix.
|
|
237
235
|
*
|
|
238
236
|
* @param this
|
|
239
237
|
* @param prefix
|
package/dist/index.mjs
CHANGED
|
@@ -254,7 +254,7 @@ var CoreRouter = class {
|
|
|
254
254
|
return null;
|
|
255
255
|
}
|
|
256
256
|
/**
|
|
257
|
-
* Adds a new route to the router
|
|
257
|
+
* Adds a new route to the router.
|
|
258
258
|
*
|
|
259
259
|
* @param this
|
|
260
260
|
* @param methods
|
|
@@ -284,8 +284,7 @@ var CoreRouter = class {
|
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
286
|
/**
|
|
287
|
-
*
|
|
288
|
-
* options to include/exclude specific actions and apply middlewares.
|
|
287
|
+
* Define a resourceful API controller with standard CRUD routes.
|
|
289
288
|
*
|
|
290
289
|
* @param this
|
|
291
290
|
* @param basePath
|
|
@@ -328,7 +327,7 @@ var CoreRouter = class {
|
|
|
328
327
|
}
|
|
329
328
|
}
|
|
330
329
|
/**
|
|
331
|
-
* Adds a new GET route to the router
|
|
330
|
+
* Adds a new GET route to the router.
|
|
332
331
|
*
|
|
333
332
|
* @param this The router instance.
|
|
334
333
|
* @param path The path for the GET route.
|
|
@@ -339,7 +338,7 @@ var CoreRouter = class {
|
|
|
339
338
|
this.add("get", path, handler, middlewares);
|
|
340
339
|
}
|
|
341
340
|
/**
|
|
342
|
-
* Adds a new POST route to the router
|
|
341
|
+
* Adds a new POST route to the router.
|
|
343
342
|
*
|
|
344
343
|
* @param this
|
|
345
344
|
* @param path
|
|
@@ -350,7 +349,7 @@ var CoreRouter = class {
|
|
|
350
349
|
this.add("post", path, handler, middlewares);
|
|
351
350
|
}
|
|
352
351
|
/**
|
|
353
|
-
* Adds a new PUT route to the router
|
|
352
|
+
* Adds a new PUT route to the router.
|
|
354
353
|
*
|
|
355
354
|
* @param this
|
|
356
355
|
* @param path
|
|
@@ -361,7 +360,7 @@ var CoreRouter = class {
|
|
|
361
360
|
this.add("put", path, handler, middlewares);
|
|
362
361
|
}
|
|
363
362
|
/**
|
|
364
|
-
* Adds a new DELETE route to the router
|
|
363
|
+
* Adds a new DELETE route to the router.
|
|
365
364
|
*
|
|
366
365
|
* @param this
|
|
367
366
|
* @param path
|
|
@@ -372,7 +371,7 @@ var CoreRouter = class {
|
|
|
372
371
|
this.add("delete", path, handler, middlewares);
|
|
373
372
|
}
|
|
374
373
|
/**
|
|
375
|
-
* Adds a new PATCH route to the router
|
|
374
|
+
* Adds a new PATCH route to the router.
|
|
376
375
|
*
|
|
377
376
|
* @param this
|
|
378
377
|
* @param path
|
|
@@ -383,7 +382,7 @@ var CoreRouter = class {
|
|
|
383
382
|
this.add("patch", path, handler, middlewares);
|
|
384
383
|
}
|
|
385
384
|
/**
|
|
386
|
-
* Adds a new OPTIONS route to the router
|
|
385
|
+
* Adds a new OPTIONS route to the router.
|
|
387
386
|
*
|
|
388
387
|
* @param this
|
|
389
388
|
* @param path
|
|
@@ -394,7 +393,7 @@ var CoreRouter = class {
|
|
|
394
393
|
this.add("options", path, handler, middlewares);
|
|
395
394
|
}
|
|
396
395
|
/**
|
|
397
|
-
* Adds a new HEAD route to the router
|
|
396
|
+
* Adds a new HEAD route to the router.
|
|
398
397
|
*
|
|
399
398
|
* @param this
|
|
400
399
|
* @param path
|
|
@@ -405,8 +404,7 @@ var CoreRouter = class {
|
|
|
405
404
|
this.add("head", path, handler, middlewares);
|
|
406
405
|
}
|
|
407
406
|
/**
|
|
408
|
-
* Defines a group of routes with a common prefix
|
|
409
|
-
* organization and reuse of route configurations.
|
|
407
|
+
* Defines a group of routes with a common prefix.
|
|
410
408
|
*
|
|
411
409
|
* @param this
|
|
412
410
|
* @param prefix
|
package/dist/koa/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_router = require('../router-
|
|
2
|
+
const require_router = require('../router-CHg0pZUO.cjs');
|
|
3
3
|
const require_responses = require('../responses-r-O3jS-S.cjs');
|
|
4
4
|
|
|
5
5
|
//#region src/koa/router.ts
|
|
@@ -57,41 +57,113 @@ var Router = class Router extends require_router.CoreRouter {
|
|
|
57
57
|
return ctx.body;
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
|
-
* Adds a new route to the router
|
|
60
|
+
* Adds a new route to the router.
|
|
61
|
+
*
|
|
62
|
+
* @param methods
|
|
63
|
+
* @param path
|
|
64
|
+
* @param handler
|
|
65
|
+
* @param middlewares
|
|
61
66
|
*/
|
|
62
67
|
static add(methods, path, handler, middlewares) {
|
|
63
68
|
super.add(methods, path, handler, middlewares);
|
|
64
69
|
}
|
|
65
70
|
/**
|
|
66
|
-
*
|
|
71
|
+
* Define a resourceful API controller with standard CRUD routes
|
|
72
|
+
*
|
|
73
|
+
* @param basePath
|
|
74
|
+
* @param controller
|
|
75
|
+
* @param options
|
|
67
76
|
*/
|
|
68
77
|
static apiResource(basePath, controller, options) {
|
|
69
78
|
super.apiResource(basePath, controller, options);
|
|
70
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Define a GET route
|
|
82
|
+
*
|
|
83
|
+
* @param path
|
|
84
|
+
* @param handler
|
|
85
|
+
* @param middlewares
|
|
86
|
+
*/
|
|
71
87
|
static get(path, handler, middlewares) {
|
|
72
88
|
super.get(path, handler, middlewares);
|
|
73
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Define a POST route
|
|
92
|
+
*
|
|
93
|
+
* @param path
|
|
94
|
+
* @param handler
|
|
95
|
+
* @param middlewares
|
|
96
|
+
*/
|
|
74
97
|
static post(path, handler, middlewares) {
|
|
75
98
|
super.post(path, handler, middlewares);
|
|
76
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Define a PUT route
|
|
102
|
+
*
|
|
103
|
+
* @param path
|
|
104
|
+
* @param handler
|
|
105
|
+
* @param middlewares
|
|
106
|
+
*/
|
|
77
107
|
static put(path, handler, middlewares) {
|
|
78
108
|
super.put(path, handler, middlewares);
|
|
79
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Define a DELETE route
|
|
112
|
+
*
|
|
113
|
+
* @param path
|
|
114
|
+
* @param handler
|
|
115
|
+
* @param middlewares
|
|
116
|
+
*/
|
|
80
117
|
static delete(path, handler, middlewares) {
|
|
81
118
|
super.delete(path, handler, middlewares);
|
|
82
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* Define a PATCH route
|
|
122
|
+
*
|
|
123
|
+
* @param path
|
|
124
|
+
* @param handler
|
|
125
|
+
* @param middlewares
|
|
126
|
+
*/
|
|
83
127
|
static patch(path, handler, middlewares) {
|
|
84
128
|
super.patch(path, handler, middlewares);
|
|
85
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* Define an OPTIONS route
|
|
132
|
+
*
|
|
133
|
+
* @param path
|
|
134
|
+
* @param handler
|
|
135
|
+
* @param middlewares
|
|
136
|
+
*/
|
|
86
137
|
static options(path, handler, middlewares) {
|
|
87
138
|
super.options(path, handler, middlewares);
|
|
88
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* Adds a new HEAD route to the router.
|
|
142
|
+
*
|
|
143
|
+
* @param this
|
|
144
|
+
* @param path
|
|
145
|
+
* @param handler
|
|
146
|
+
* @param middlewares
|
|
147
|
+
*/
|
|
89
148
|
static head(path, handler, middlewares) {
|
|
90
149
|
super.head(path, handler, middlewares);
|
|
91
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* Defines a group of routes with a common prefix.
|
|
153
|
+
*
|
|
154
|
+
* @param prefix
|
|
155
|
+
* @param callback
|
|
156
|
+
* @param middlewares
|
|
157
|
+
*/
|
|
92
158
|
static async group(prefix, callback, middlewares) {
|
|
93
159
|
await super.group(prefix, callback, middlewares);
|
|
94
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* Apply middlewares to a group of routes defined within the callback
|
|
163
|
+
*
|
|
164
|
+
* @param middlewares - Middleware or array of middlewares to apply
|
|
165
|
+
* @param callback - Function that defines the routes to which the middlewares will be applied
|
|
166
|
+
*/
|
|
95
167
|
static middleware(middlewares, callback) {
|
|
96
168
|
super.middleware(middlewares, callback);
|
|
97
169
|
}
|
|
@@ -99,7 +171,10 @@ var Router = class Router extends require_router.CoreRouter {
|
|
|
99
171
|
return super.allRoutes(type);
|
|
100
172
|
}
|
|
101
173
|
/**
|
|
102
|
-
*
|
|
174
|
+
* Apply the defined routes to a @koa/router instance
|
|
175
|
+
*
|
|
176
|
+
* @param router @koa/router instance
|
|
177
|
+
* @returns The @koa/router instance with the applied routes
|
|
103
178
|
*/
|
|
104
179
|
static apply(router) {
|
|
105
180
|
for (const route of this.routes) {
|