clear-router 2.4.0 → 2.5.1

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.
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_router = require('../router-C-c43ybe.cjs');
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
- * Resolve method override from query, headers, or body
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
- * Define a group of routes with a common prefix and optional middlewares
141
+ * Defines a group of routes with a common prefix.
142
142
  *
143
143
  * @param prefix
144
144
  * @param callback
@@ -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-A-9JuZPi.cjs";
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
- * Resolve method override from query, headers, or body
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
- * Define a group of routes with a common prefix and optional middlewares
107
+ * Defines a group of routes with a common prefix.
108
108
  *
109
109
  * @param prefix
110
110
  * @param callback
@@ -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-CVeqd7Ro.mjs";
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
- * Resolve method override from query, headers, or body
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
- * Define a group of routes with a common prefix and optional middlewares
107
+ * Defines a group of routes with a common prefix.
108
108
  *
109
109
  * @param prefix
110
110
  * @param callback
@@ -1,4 +1,4 @@
1
- import { t as CoreRouter } from "../router-CHaZi7NS.mjs";
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
- * Resolve method override from query, headers, or body
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
- * Define a group of routes with a common prefix and optional middlewares
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
@@ -155,6 +155,11 @@ var CoreRouter = class {
155
155
  ctx.reply.code(204).send();
156
156
  return;
157
157
  }
158
+ if (ctx?.set && "status" in ctx) {
159
+ ctx.set("Allow", allow);
160
+ ctx.status = 204;
161
+ ctx.body = null;
162
+ }
158
163
  };
159
164
  }
160
165
  static config = { methodOverride: {
@@ -250,7 +255,7 @@ var CoreRouter = class {
250
255
  return null;
251
256
  }
252
257
  /**
253
- * Adds a new route to the router with the specified methods, path, handler, and middlewares.
258
+ * Adds a new route to the router.
254
259
  *
255
260
  * @param this
256
261
  * @param methods
@@ -280,8 +285,7 @@ var CoreRouter = class {
280
285
  }
281
286
  }
282
287
  /**
283
- * Adds a new API resource route to the router for the specified base path and controller, with
284
- * options to include/exclude specific actions and apply middlewares.
288
+ * Define a resourceful API controller with standard CRUD routes.
285
289
  *
286
290
  * @param this
287
291
  * @param basePath
@@ -324,7 +328,7 @@ var CoreRouter = class {
324
328
  }
325
329
  }
326
330
  /**
327
- * Adds a new GET route to the router with the specified path, handler, and optional middlewares.
331
+ * Adds a new GET route to the router.
328
332
  *
329
333
  * @param this The router instance.
330
334
  * @param path The path for the GET route.
@@ -335,7 +339,7 @@ var CoreRouter = class {
335
339
  this.add("get", path, handler, middlewares);
336
340
  }
337
341
  /**
338
- * Adds a new POST route to the router with the specified path, handler, and optional middlewares.
342
+ * Adds a new POST route to the router.
339
343
  *
340
344
  * @param this
341
345
  * @param path
@@ -346,7 +350,7 @@ var CoreRouter = class {
346
350
  this.add("post", path, handler, middlewares);
347
351
  }
348
352
  /**
349
- * Adds a new PUT route to the router with the specified path, handler, and optional middlewares.
353
+ * Adds a new PUT route to the router.
350
354
  *
351
355
  * @param this
352
356
  * @param path
@@ -357,7 +361,7 @@ var CoreRouter = class {
357
361
  this.add("put", path, handler, middlewares);
358
362
  }
359
363
  /**
360
- * Adds a new DELETE route to the router with the specified path, handler, and optional middlewares.
364
+ * Adds a new DELETE route to the router.
361
365
  *
362
366
  * @param this
363
367
  * @param path
@@ -368,7 +372,7 @@ var CoreRouter = class {
368
372
  this.add("delete", path, handler, middlewares);
369
373
  }
370
374
  /**
371
- * Adds a new PATCH route to the router with the specified path, handler, and optional middlewares.
375
+ * Adds a new PATCH route to the router.
372
376
  *
373
377
  * @param this
374
378
  * @param path
@@ -379,7 +383,7 @@ var CoreRouter = class {
379
383
  this.add("patch", path, handler, middlewares);
380
384
  }
381
385
  /**
382
- * Adds a new OPTIONS route to the router with the specified path, handler, and optional middlewares.
386
+ * Adds a new OPTIONS route to the router.
383
387
  *
384
388
  * @param this
385
389
  * @param path
@@ -390,7 +394,7 @@ var CoreRouter = class {
390
394
  this.add("options", path, handler, middlewares);
391
395
  }
392
396
  /**
393
- * Adds a new HEAD route to the router with the specified path, handler, and optional middlewares.
397
+ * Adds a new HEAD route to the router.
394
398
  *
395
399
  * @param this
396
400
  * @param path
@@ -401,8 +405,7 @@ var CoreRouter = class {
401
405
  this.add("head", path, handler, middlewares);
402
406
  }
403
407
  /**
404
- * Defines a group of routes with a common prefix and optional middlewares, allowing for better
405
- * organization and reuse of route configurations.
408
+ * Defines a group of routes with a common prefix.
406
409
  *
407
410
  * @param this
408
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 with the specified methods, path, handler, and middlewares.
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
- * Adds a new API resource route to the router for the specified base path and controller, with
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 with the specified path, handler, and optional middlewares.
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 with the specified path, handler, and optional middlewares.
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 with the specified path, handler, and optional middlewares.
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 with the specified path, handler, and optional middlewares.
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 with the specified path, handler, and optional middlewares.
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 with the specified path, handler, and optional middlewares.
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 with the specified path, handler, and optional middlewares.
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 and optional middlewares, allowing for better
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 with the specified methods, path, handler, and middlewares.
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
- * Adds a new API resource route to the router for the specified base path and controller, with
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 with the specified path, handler, and optional middlewares.
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 with the specified path, handler, and optional middlewares.
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 with the specified path, handler, and optional middlewares.
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 with the specified path, handler, and optional middlewares.
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 with the specified path, handler, and optional middlewares.
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 with the specified path, handler, and optional middlewares.
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 with the specified path, handler, and optional middlewares.
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 and optional middlewares, allowing for better
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
@@ -154,6 +154,11 @@ var CoreRouter = class {
154
154
  ctx.reply.code(204).send();
155
155
  return;
156
156
  }
157
+ if (ctx?.set && "status" in ctx) {
158
+ ctx.set("Allow", allow);
159
+ ctx.status = 204;
160
+ ctx.body = null;
161
+ }
157
162
  };
158
163
  }
159
164
  static config = { methodOverride: {
@@ -249,7 +254,7 @@ var CoreRouter = class {
249
254
  return null;
250
255
  }
251
256
  /**
252
- * Adds a new route to the router with the specified methods, path, handler, and middlewares.
257
+ * Adds a new route to the router.
253
258
  *
254
259
  * @param this
255
260
  * @param methods
@@ -279,8 +284,7 @@ var CoreRouter = class {
279
284
  }
280
285
  }
281
286
  /**
282
- * Adds a new API resource route to the router for the specified base path and controller, with
283
- * options to include/exclude specific actions and apply middlewares.
287
+ * Define a resourceful API controller with standard CRUD routes.
284
288
  *
285
289
  * @param this
286
290
  * @param basePath
@@ -323,7 +327,7 @@ var CoreRouter = class {
323
327
  }
324
328
  }
325
329
  /**
326
- * Adds a new GET route to the router with the specified path, handler, and optional middlewares.
330
+ * Adds a new GET route to the router.
327
331
  *
328
332
  * @param this The router instance.
329
333
  * @param path The path for the GET route.
@@ -334,7 +338,7 @@ var CoreRouter = class {
334
338
  this.add("get", path, handler, middlewares);
335
339
  }
336
340
  /**
337
- * Adds a new POST route to the router with the specified path, handler, and optional middlewares.
341
+ * Adds a new POST route to the router.
338
342
  *
339
343
  * @param this
340
344
  * @param path
@@ -345,7 +349,7 @@ var CoreRouter = class {
345
349
  this.add("post", path, handler, middlewares);
346
350
  }
347
351
  /**
348
- * Adds a new PUT route to the router with the specified path, handler, and optional middlewares.
352
+ * Adds a new PUT route to the router.
349
353
  *
350
354
  * @param this
351
355
  * @param path
@@ -356,7 +360,7 @@ var CoreRouter = class {
356
360
  this.add("put", path, handler, middlewares);
357
361
  }
358
362
  /**
359
- * Adds a new DELETE route to the router with the specified path, handler, and optional middlewares.
363
+ * Adds a new DELETE route to the router.
360
364
  *
361
365
  * @param this
362
366
  * @param path
@@ -367,7 +371,7 @@ var CoreRouter = class {
367
371
  this.add("delete", path, handler, middlewares);
368
372
  }
369
373
  /**
370
- * Adds a new PATCH route to the router with the specified path, handler, and optional middlewares.
374
+ * Adds a new PATCH route to the router.
371
375
  *
372
376
  * @param this
373
377
  * @param path
@@ -378,7 +382,7 @@ var CoreRouter = class {
378
382
  this.add("patch", path, handler, middlewares);
379
383
  }
380
384
  /**
381
- * Adds a new OPTIONS route to the router with the specified path, handler, and optional middlewares.
385
+ * Adds a new OPTIONS route to the router.
382
386
  *
383
387
  * @param this
384
388
  * @param path
@@ -389,7 +393,7 @@ var CoreRouter = class {
389
393
  this.add("options", path, handler, middlewares);
390
394
  }
391
395
  /**
392
- * Adds a new HEAD route to the router with the specified path, handler, and optional middlewares.
396
+ * Adds a new HEAD route to the router.
393
397
  *
394
398
  * @param this
395
399
  * @param path
@@ -400,8 +404,7 @@ var CoreRouter = class {
400
404
  this.add("head", path, handler, middlewares);
401
405
  }
402
406
  /**
403
- * Defines a group of routes with a common prefix and optional middlewares, allowing for better
404
- * organization and reuse of route configurations.
407
+ * Defines a group of routes with a common prefix.
405
408
  *
406
409
  * @param this
407
410
  * @param prefix