clear-router 2.5.12 → 2.5.13

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 (42) hide show
  1. package/dist/{bindings-CDGLuAq4.cjs → bindings-CLsZjOEy.cjs} +8 -1
  2. package/dist/{bindings-B6x2HfzP.mjs → bindings-XLDXFpHZ.mjs} +8 -1
  3. package/dist/core/index.cjs +2 -2
  4. package/dist/core/index.d.cts +1 -1
  5. package/dist/core/index.d.mts +1 -1
  6. package/dist/core/index.mjs +2 -2
  7. package/dist/decorators/index.cjs +1 -1
  8. package/dist/decorators/index.mjs +1 -1
  9. package/dist/decorators/setup.cjs +2 -2
  10. package/dist/decorators/setup.mjs +2 -2
  11. package/dist/express/index.cjs +3 -3
  12. package/dist/express/index.d.cts +1 -1
  13. package/dist/express/index.d.mts +1 -1
  14. package/dist/express/index.mjs +3 -3
  15. package/dist/fastify/index.cjs +3 -3
  16. package/dist/fastify/index.d.cts +1 -1
  17. package/dist/fastify/index.d.mts +1 -1
  18. package/dist/fastify/index.mjs +3 -3
  19. package/dist/h3/index.cjs +3 -3
  20. package/dist/h3/index.d.cts +1 -1
  21. package/dist/h3/index.d.mts +1 -1
  22. package/dist/h3/index.mjs +3 -3
  23. package/dist/hono/index.cjs +3 -3
  24. package/dist/hono/index.d.cts +1 -1
  25. package/dist/hono/index.d.mts +1 -1
  26. package/dist/hono/index.mjs +3 -3
  27. package/dist/index.cjs +13 -2
  28. package/dist/index.d.cts +25 -23
  29. package/dist/index.d.mts +25 -23
  30. package/dist/index.mjs +13 -2
  31. package/dist/koa/index.cjs +3 -3
  32. package/dist/koa/index.d.cts +1 -1
  33. package/dist/koa/index.d.mts +1 -1
  34. package/dist/koa/index.mjs +3 -3
  35. package/dist/{responses-DuZeRyGE.mjs → responses-BvETUeDL.mjs} +1 -1
  36. package/dist/{responses-CBP3RYjJ.cjs → responses-Bvnk0uvc.cjs} +1 -1
  37. package/dist/{router-BkJMl4xv.mjs → router-CPmZcbU0.mjs} +6 -2
  38. package/dist/{router-DPJfzvy5.cjs → router-D9H9-T27.cjs} +6 -2
  39. package/dist/{router-35iBbCaF.d.cts → router-DTI0BowV.d.cts} +25 -23
  40. package/dist/{router-91xVPlV0.d.mts → router-DiKqUyvk.d.mts} +25 -23
  41. package/dist/types/core/Response.d.mts +3 -1
  42. package/package.json +1 -1
@@ -58,14 +58,21 @@ var Response = class {
58
58
  headers = new Headers();
59
59
  sent = false;
60
60
  statusCode = 200;
61
+ statusText = "OK";
61
62
  constructor(init) {
62
- Object.assign(this, init);
63
+ const { status: _, ...rest } = init ?? {};
64
+ Object.assign(this, rest);
63
65
  if (init?.headers && !(init.headers instanceof Headers)) this.headers = new Headers(init.headers);
66
+ if (init?.status && typeof init.status === "number") this.statusCode = init?.status;
64
67
  }
65
68
  status(code) {
66
69
  this.statusCode = code;
67
70
  return this;
68
71
  }
72
+ setStatusText(text) {
73
+ this.statusText = text;
74
+ return this;
75
+ }
69
76
  code(code) {
70
77
  return this.status(code);
71
78
  }
@@ -57,14 +57,21 @@ var Response = class {
57
57
  headers = new Headers();
58
58
  sent = false;
59
59
  statusCode = 200;
60
+ statusText = "OK";
60
61
  constructor(init) {
61
- Object.assign(this, init);
62
+ const { status: _, ...rest } = init ?? {};
63
+ Object.assign(this, rest);
62
64
  if (init?.headers && !(init.headers instanceof Headers)) this.headers = new Headers(init.headers);
65
+ if (init?.status && typeof init.status === "number") this.statusCode = init?.status;
63
66
  }
64
67
  status(code) {
65
68
  this.statusCode = code;
66
69
  return this;
67
70
  }
71
+ setStatusText(text) {
72
+ this.statusText = text;
73
+ return this;
74
+ }
68
75
  code(code) {
69
76
  return this.status(code);
70
77
  }
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_bindings = require('../bindings-CDGLuAq4.cjs');
3
- const require_router = require('../router-DPJfzvy5.cjs');
2
+ const require_bindings = require('../bindings-CLsZjOEy.cjs');
3
+ const require_router = require('../router-D9H9-T27.cjs');
4
4
 
5
5
  //#region src/core/plugins.ts
6
6
  function definePlugin(plugin) {
@@ -1,2 +1,2 @@
1
- import { E as Response, a as ClearRouterPluginInput, c as PluginBind, d as PluginSetupResult, f as definePlugin, i as ClearRouterPluginContext, l as PluginBindFactory, n as ClearRouterPlugin, o as ClearRouterPluginRequestContext, p as Request, r as ClearRouterPluginArgumentsContext, s as PluginArgumentsResolver, t as CoreRouter, u as PluginBindValue } from "../router-35iBbCaF.cjs";
1
+ import { E as Response, a as ClearRouterPluginInput, c as PluginBind, d as PluginSetupResult, f as definePlugin, i as ClearRouterPluginContext, l as PluginBindFactory, n as ClearRouterPlugin, o as ClearRouterPluginRequestContext, p as Request, r as ClearRouterPluginArgumentsContext, s as PluginArgumentsResolver, t as CoreRouter, u as PluginBindValue } from "../router-DTI0BowV.cjs";
2
2
  export { ClearRouterPlugin, ClearRouterPluginArgumentsContext, ClearRouterPluginContext, ClearRouterPluginInput, ClearRouterPluginRequestContext, CoreRouter, PluginArgumentsResolver, PluginBind, PluginBindFactory, PluginBindValue, PluginSetupResult, Request, Response, definePlugin };
@@ -1,2 +1,2 @@
1
- import { E as Response, a as ClearRouterPluginInput, c as PluginBind, d as PluginSetupResult, f as definePlugin, i as ClearRouterPluginContext, l as PluginBindFactory, n as ClearRouterPlugin, o as ClearRouterPluginRequestContext, p as Request, r as ClearRouterPluginArgumentsContext, s as PluginArgumentsResolver, t as CoreRouter, u as PluginBindValue } from "../router-91xVPlV0.mjs";
1
+ import { E as Response, a as ClearRouterPluginInput, c as PluginBind, d as PluginSetupResult, f as definePlugin, i as ClearRouterPluginContext, l as PluginBindFactory, n as ClearRouterPlugin, o as ClearRouterPluginRequestContext, p as Request, r as ClearRouterPluginArgumentsContext, s as PluginArgumentsResolver, t as CoreRouter, u as PluginBindValue } from "../router-DiKqUyvk.mjs";
2
2
  export { ClearRouterPlugin, ClearRouterPluginArgumentsContext, ClearRouterPluginContext, ClearRouterPluginInput, ClearRouterPluginRequestContext, CoreRouter, PluginArgumentsResolver, PluginBind, PluginBindFactory, PluginBindValue, PluginSetupResult, Request, Response, definePlugin };
@@ -1,5 +1,5 @@
1
- import { c as Request, s as Response } from "../bindings-B6x2HfzP.mjs";
2
- import { t as CoreRouter } from "../router-BkJMl4xv.mjs";
1
+ import { c as Request, s as Response } from "../bindings-XLDXFpHZ.mjs";
2
+ import { t as CoreRouter } from "../router-CPmZcbU0.mjs";
3
3
 
4
4
  //#region src/core/plugins.ts
5
5
  function definePlugin(plugin) {
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_bindings = require('../bindings-CDGLuAq4.cjs');
2
+ const require_bindings = require('../bindings-CLsZjOEy.cjs');
3
3
 
4
4
  exports.Bind = require_bindings.Bind;
5
5
  exports.Container = require_bindings.Container;
@@ -1,3 +1,3 @@
1
- import { n as Container, t as Bind } from "../bindings-B6x2HfzP.mjs";
1
+ import { n as Container, t as Bind } from "../bindings-XLDXFpHZ.mjs";
2
2
 
3
3
  export { Bind, Container };
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_bindings = require('../bindings-CDGLuAq4.cjs');
3
- const require_router = require('../router-DPJfzvy5.cjs');
2
+ const require_bindings = require('../bindings-CLsZjOEy.cjs');
3
+ const require_router = require('../router-D9H9-T27.cjs');
4
4
  require('./index.cjs');
5
5
  require("reflect-metadata");
6
6
 
@@ -1,5 +1,5 @@
1
- import { n as Container, t as Bind } from "../bindings-B6x2HfzP.mjs";
2
- import { t as CoreRouter } from "../router-BkJMl4xv.mjs";
1
+ import { n as Container, t as Bind } from "../bindings-XLDXFpHZ.mjs";
2
+ import { t as CoreRouter } from "../router-CPmZcbU0.mjs";
3
3
  import "./index.mjs";
4
4
  import "reflect-metadata";
5
5
 
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- require('../bindings-CDGLuAq4.cjs');
3
- const require_router = require('../router-DPJfzvy5.cjs');
4
- const require_responses = require('../responses-CBP3RYjJ.cjs');
2
+ require('../bindings-CLsZjOEy.cjs');
3
+ const require_router = require('../router-D9H9-T27.cjs');
4
+ const require_responses = require('../responses-Bvnk0uvc.cjs');
5
5
 
6
6
  //#region src/express/router.ts
7
7
  /**
@@ -1,4 +1,4 @@
1
- import { C as ControllerAction, S as ApiResourceMiddleware, T as HttpMethod, b as HttpContext, m as Route, t as CoreRouter, x as Middleware, y as Handler } from "../router-35iBbCaF.cjs";
1
+ import { C as ControllerAction, S as ApiResourceMiddleware, T as HttpMethod, b as HttpContext, m as Route, t as CoreRouter, x as Middleware, y as Handler } from "../router-DTI0BowV.cjs";
2
2
  import { Router as Router$1 } from "express";
3
3
 
4
4
  //#region src/express/router.d.ts
@@ -1,4 +1,4 @@
1
- import { C as ControllerAction, S as ApiResourceMiddleware, T as HttpMethod, b as HttpContext, m as Route, t as CoreRouter, x as Middleware, y as Handler } from "../router-91xVPlV0.mjs";
1
+ import { C as ControllerAction, S as ApiResourceMiddleware, T as HttpMethod, b as HttpContext, m as Route, t as CoreRouter, x as Middleware, y as Handler } from "../router-DiKqUyvk.mjs";
2
2
  import { Router as Router$1 } from "express";
3
3
 
4
4
  //#region src/express/router.d.ts
@@ -1,6 +1,6 @@
1
- import "../bindings-B6x2HfzP.mjs";
2
- import { t as CoreRouter } from "../router-BkJMl4xv.mjs";
3
- import { n as resolveResponseMeta, r as responseWasSent, t as isFetchResponse } from "../responses-DuZeRyGE.mjs";
1
+ import "../bindings-XLDXFpHZ.mjs";
2
+ import { t as CoreRouter } from "../router-CPmZcbU0.mjs";
3
+ import { n as resolveResponseMeta, r as responseWasSent, t as isFetchResponse } from "../responses-BvETUeDL.mjs";
4
4
 
5
5
  //#region src/express/router.ts
6
6
  /**
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- require('../bindings-CDGLuAq4.cjs');
3
- const require_router = require('../router-DPJfzvy5.cjs');
4
- const require_responses = require('../responses-CBP3RYjJ.cjs');
2
+ require('../bindings-CLsZjOEy.cjs');
3
+ const require_router = require('../router-D9H9-T27.cjs');
4
+ const require_responses = require('../responses-Bvnk0uvc.cjs');
5
5
 
6
6
  //#region src/fastify/router.ts
7
7
  /**
@@ -1,4 +1,4 @@
1
- import { C as ControllerAction, E as Response, S as ApiResourceMiddleware, T as HttpMethod, m as Route, p as Request, t as CoreRouter, w as ControllerHandler } from "../router-35iBbCaF.cjs";
1
+ import { C as ControllerAction, E as Response, S as ApiResourceMiddleware, T as HttpMethod, m as Route, p as Request, t as CoreRouter, w as ControllerHandler } from "../router-DTI0BowV.cjs";
2
2
  import { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
3
3
 
4
4
  //#region types/fastify.d.ts
@@ -1,4 +1,4 @@
1
- import { C as ControllerAction, E as Response, S as ApiResourceMiddleware, T as HttpMethod, m as Route, p as Request, t as CoreRouter, w as ControllerHandler } from "../router-91xVPlV0.mjs";
1
+ import { C as ControllerAction, E as Response, S as ApiResourceMiddleware, T as HttpMethod, m as Route, p as Request, t as CoreRouter, w as ControllerHandler } from "../router-DiKqUyvk.mjs";
2
2
  import { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
3
3
 
4
4
  //#region types/fastify.d.ts
@@ -1,6 +1,6 @@
1
- import "../bindings-B6x2HfzP.mjs";
2
- import { t as CoreRouter } from "../router-BkJMl4xv.mjs";
3
- import { n as resolveResponseMeta, r as responseWasSent, t as isFetchResponse } from "../responses-DuZeRyGE.mjs";
1
+ import "../bindings-XLDXFpHZ.mjs";
2
+ import { t as CoreRouter } from "../router-CPmZcbU0.mjs";
3
+ import { n as resolveResponseMeta, r as responseWasSent, t as isFetchResponse } from "../responses-BvETUeDL.mjs";
4
4
 
5
5
  //#region src/fastify/router.ts
6
6
  /**
package/dist/h3/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- require('../bindings-CDGLuAq4.cjs');
3
- const require_router = require('../router-DPJfzvy5.cjs');
4
- const require_responses = require('../responses-CBP3RYjJ.cjs');
2
+ require('../bindings-CLsZjOEy.cjs');
3
+ const require_router = require('../router-D9H9-T27.cjs');
4
+ const require_responses = require('../responses-Bvnk0uvc.cjs');
5
5
  let h3 = require("h3");
6
6
 
7
7
  //#region src/h3/router.ts
@@ -1,4 +1,4 @@
1
- import { C as ControllerAction, S as ApiResourceMiddleware, T as HttpMethod, _ as HttpContext, g as Handler, h as H3App, m as Route, t as CoreRouter, v as Middleware } from "../router-35iBbCaF.cjs";
1
+ import { C as ControllerAction, S as ApiResourceMiddleware, T as HttpMethod, _ as HttpContext, g as Handler, h as H3App, m as Route, t as CoreRouter, v as Middleware } from "../router-DTI0BowV.cjs";
2
2
  import { H3 } from "h3";
3
3
 
4
4
  //#region src/h3/router.d.ts
@@ -1,4 +1,4 @@
1
- import { C as ControllerAction, S as ApiResourceMiddleware, T as HttpMethod, _ as HttpContext, g as Handler, h as H3App, m as Route, t as CoreRouter, v as Middleware } from "../router-91xVPlV0.mjs";
1
+ import { C as ControllerAction, S as ApiResourceMiddleware, T as HttpMethod, _ as HttpContext, g as Handler, h as H3App, m as Route, t as CoreRouter, v as Middleware } from "../router-DiKqUyvk.mjs";
2
2
  import { H3 } from "h3";
3
3
 
4
4
  //#region src/h3/router.d.ts
package/dist/h3/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import "../bindings-B6x2HfzP.mjs";
2
- import { t as CoreRouter } from "../router-BkJMl4xv.mjs";
3
- import { n as resolveResponseMeta } from "../responses-DuZeRyGE.mjs";
1
+ import "../bindings-XLDXFpHZ.mjs";
2
+ import { t as CoreRouter } from "../router-CPmZcbU0.mjs";
3
+ import { n as resolveResponseMeta } from "../responses-BvETUeDL.mjs";
4
4
  import { HTTPResponse, getQuery, getRouterParams, readBody } from "h3";
5
5
 
6
6
  //#region src/h3/router.ts
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- require('../bindings-CDGLuAq4.cjs');
3
- const require_router = require('../router-DPJfzvy5.cjs');
4
- const require_responses = require('../responses-CBP3RYjJ.cjs');
2
+ require('../bindings-CLsZjOEy.cjs');
3
+ const require_router = require('../router-D9H9-T27.cjs');
4
+ const require_responses = require('../responses-Bvnk0uvc.cjs');
5
5
 
6
6
  //#region src/hono/router.ts
7
7
  /**
@@ -1,4 +1,4 @@
1
- import { C as ControllerAction, E as Response, S as ApiResourceMiddleware, T as HttpMethod, m as Route, p as Request, t as CoreRouter, w as ControllerHandler } from "../router-35iBbCaF.cjs";
1
+ import { C as ControllerAction, E as Response, S as ApiResourceMiddleware, T as HttpMethod, m as Route, p as Request, t as CoreRouter, w as ControllerHandler } from "../router-DTI0BowV.cjs";
2
2
  import { Context, HonoRequest, MiddlewareHandler } from "hono";
3
3
 
4
4
  //#region types/hono.d.ts
@@ -1,4 +1,4 @@
1
- import { C as ControllerAction, E as Response, S as ApiResourceMiddleware, T as HttpMethod, m as Route, p as Request, t as CoreRouter, w as ControllerHandler } from "../router-91xVPlV0.mjs";
1
+ import { C as ControllerAction, E as Response, S as ApiResourceMiddleware, T as HttpMethod, m as Route, p as Request, t as CoreRouter, w as ControllerHandler } from "../router-DiKqUyvk.mjs";
2
2
  import { Context, HonoRequest, MiddlewareHandler } from "hono";
3
3
 
4
4
  //#region types/hono.d.ts
@@ -1,6 +1,6 @@
1
- import "../bindings-B6x2HfzP.mjs";
2
- import { t as CoreRouter } from "../router-BkJMl4xv.mjs";
3
- import { n as resolveResponseMeta } from "../responses-DuZeRyGE.mjs";
1
+ import "../bindings-XLDXFpHZ.mjs";
2
+ import { t as CoreRouter } from "../router-CPmZcbU0.mjs";
3
+ import { n as resolveResponseMeta } from "../responses-BvETUeDL.mjs";
4
4
 
5
5
  //#region src/hono/router.ts
6
6
  /**
package/dist/index.cjs CHANGED
@@ -98,14 +98,21 @@ var Response = class {
98
98
  headers = new Headers();
99
99
  sent = false;
100
100
  statusCode = 200;
101
+ statusText = "OK";
101
102
  constructor(init) {
102
- Object.assign(this, init);
103
+ const { status: _, ...rest } = init ?? {};
104
+ Object.assign(this, rest);
103
105
  if (init?.headers && !(init.headers instanceof Headers)) this.headers = new Headers(init.headers);
106
+ if (init?.status && typeof init.status === "number") this.statusCode = init?.status;
104
107
  }
105
108
  status(code) {
106
109
  this.statusCode = code;
107
110
  return this;
108
111
  }
112
+ setStatusText(text) {
113
+ this.statusText = text;
114
+ return this;
115
+ }
109
116
  code(code) {
110
117
  return this.status(code);
111
118
  }
@@ -884,7 +891,11 @@ var CoreRouter = class {
884
891
  clearRequest.query = payload.query;
885
892
  clearRequest.params = payload.params;
886
893
  ctx.clearRequest = clearRequest;
887
- if (!(ctx.clearResponse instanceof Response)) ctx.clearResponse = new Response();
894
+ Container.bind(Request, ctx.clearRequest);
895
+ if (!(ctx.clearResponse instanceof Response)) {
896
+ ctx.clearResponse = new Response(ctx.response ?? ctx.reply ?? ctx.res);
897
+ Container.bind(Response, ctx.clearResponse);
898
+ }
888
899
  if (!instance) return;
889
900
  instance.ctx = ctx;
890
901
  instance.body = payload.body;
package/dist/index.d.cts CHANGED
@@ -41,8 +41,10 @@ declare class Response$1 {
41
41
  headers: Headers;
42
42
  sent: boolean;
43
43
  statusCode: number;
44
- constructor(init?: Partial<Response$1>);
44
+ statusText: string;
45
+ constructor(init?: Partial<Response$1 | globalThis.Response>);
45
46
  status(code: number): this;
47
+ setStatusText(text: string): this;
46
48
  code(code: number): this;
47
49
  setHeader(name: string, value: string): this;
48
50
  header(name: string, value: string): this;
@@ -206,7 +208,7 @@ declare abstract class CoreRouter {
206
208
  protected static createBaseConfig(): RouterConfig;
207
209
  protected static mergeConfig(target: RouterConfig, source?: RouterConfig): RouterConfig;
208
210
  protected static getDefaultConfig(): RouterConfig;
209
- protected static resolveStateNamespace(this: any): string;
211
+ protected static resolveStateNamespace(): string;
210
212
  protected static getStateStore(): Record<string, any>;
211
213
  protected static getPluginStore(): Set<string>;
212
214
  protected static getPluginPendingStore(): Set<Promise<void>>;
@@ -224,10 +226,10 @@ declare abstract class CoreRouter {
224
226
  groupMiddlewares: any[];
225
227
  globalMiddlewares: any[];
226
228
  };
227
- protected static bindStateAccessors(this: any): void;
229
+ protected static bindStateAccessors(): void;
228
230
  protected static createDefaultOptionsHandler(): any;
229
231
  static config: RouterConfig;
230
- static configureDefaults(this: any, options?: RouterConfig): void;
232
+ static configureDefaults(options?: RouterConfig): void;
231
233
  /**
232
234
  * Use a registered plugin
233
235
  *
@@ -236,8 +238,8 @@ declare abstract class CoreRouter {
236
238
  * @param options
237
239
  * @returns
238
240
  */
239
- static use<Options = any>(this: any, plugin: ClearRouterPluginInput<Options>, options?: Options): Promise<void>;
240
- protected static pluginsReady(this: any): Promise<void>;
241
+ static use<Options = any>(plugin: ClearRouterPluginInput<Options>, options?: Options): Promise<void>;
242
+ protected static pluginsReady(): Promise<void>;
241
243
  protected static groupContext: AsyncLocalStorage<{
242
244
  prefix: string;
243
245
  groupMiddlewares: any[];
@@ -253,7 +255,7 @@ declare abstract class CoreRouter {
253
255
  protected static createPluginRequestContext(ctx: any): ClearRouterPluginRequestContext;
254
256
  protected static createPluginBind(): PluginBind;
255
257
  protected static resolvePluginArguments(this: any, ctx: any, routeContext: Omit<ClearRouterPluginArgumentsContext, keyof ClearRouterPluginRequestContext>): Promise<any[] | undefined>;
256
- protected static ensureState(this: any): void;
258
+ protected static ensureState(): void;
257
259
  /**
258
260
  * Normalizes a path by ensuring it starts with a single slash and does not have trailing
259
261
  * slashes, while preserving dynamic segments and parameters.
@@ -270,7 +272,7 @@ declare abstract class CoreRouter {
270
272
  * @returns
271
273
  */
272
274
  static configure(this: any, options?: RouterConfig): void;
273
- protected static resolveMethodOverride(this: any, method: string, headers: Headers | Record<string, any>, body: unknown): HttpMethod | null;
275
+ protected static resolveMethodOverride(method: string, headers: Headers | Record<string, any>, body: unknown): HttpMethod | null;
274
276
  /**
275
277
  * Adds a new route to the router.
276
278
  *
@@ -280,7 +282,7 @@ declare abstract class CoreRouter {
280
282
  * @param handler
281
283
  * @param middlewares
282
284
  */
283
- static add(this: any, methods: HttpMethod | HttpMethod[], path: string, handler: any, middlewares?: any[] | any): void;
285
+ static add(methods: HttpMethod | HttpMethod[], path: string, handler: any, middlewares?: any[] | any): void;
284
286
  /**
285
287
  * Define a resourceful API controller with standard CRUD routes.
286
288
  *
@@ -289,7 +291,7 @@ declare abstract class CoreRouter {
289
291
  * @param controller
290
292
  * @param options
291
293
  */
292
- static apiResource(this: any, basePath: string, controller: any, options?: {
294
+ static apiResource(basePath: string, controller: any, options?: {
293
295
  only?: ControllerAction[];
294
296
  except?: ControllerAction[];
295
297
  middlewares?: ApiResourceMiddleware<any>;
@@ -302,7 +304,7 @@ declare abstract class CoreRouter {
302
304
  * @param handler The handler function for the GET route.
303
305
  * @param middlewares Optional middlewares to apply to the GET route.
304
306
  */
305
- static get(this: any, path: string, handler: any, middlewares?: any[] | any): void;
307
+ static get(path: string, handler: any, middlewares?: any[] | any): void;
306
308
  /**
307
309
  * Adds a new POST route to the router.
308
310
  *
@@ -311,7 +313,7 @@ declare abstract class CoreRouter {
311
313
  * @param handler
312
314
  * @param middlewares
313
315
  */
314
- static post(this: any, path: string, handler: any, middlewares?: any[] | any): void;
316
+ static post(path: string, handler: any, middlewares?: any[] | any): void;
315
317
  /**
316
318
  * Adds a new PUT route to the router.
317
319
  *
@@ -320,7 +322,7 @@ declare abstract class CoreRouter {
320
322
  * @param handler
321
323
  * @param middlewares
322
324
  */
323
- static put(this: any, path: string, handler: any, middlewares?: any[] | any): void;
325
+ static put(path: string, handler: any, middlewares?: any[] | any): void;
324
326
  /**
325
327
  * Adds a new DELETE route to the router.
326
328
  *
@@ -329,7 +331,7 @@ declare abstract class CoreRouter {
329
331
  * @param handler
330
332
  * @param middlewares
331
333
  */
332
- static delete(this: any, path: string, handler: any, middlewares?: any[] | any): void;
334
+ static delete(path: string, handler: any, middlewares?: any[] | any): void;
333
335
  /**
334
336
  * Adds a new PATCH route to the router.
335
337
  *
@@ -338,7 +340,7 @@ declare abstract class CoreRouter {
338
340
  * @param handler
339
341
  * @param middlewares
340
342
  */
341
- static patch(this: any, path: string, handler: any, middlewares?: any[] | any): void;
343
+ static patch(path: string, handler: any, middlewares?: any[] | any): void;
342
344
  /**
343
345
  * Adds a new OPTIONS route to the router.
344
346
  *
@@ -347,7 +349,7 @@ declare abstract class CoreRouter {
347
349
  * @param handler
348
350
  * @param middlewares
349
351
  */
350
- static options(this: any, path: string, handler: any, middlewares?: any[] | any): void;
352
+ static options(path: string, handler: any, middlewares?: any[] | any): void;
351
353
  /**
352
354
  * Adds a new HEAD route to the router.
353
355
  *
@@ -356,7 +358,7 @@ declare abstract class CoreRouter {
356
358
  * @param handler
357
359
  * @param middlewares
358
360
  */
359
- static head(this: any, path: string, handler: any, middlewares?: any[] | any): void;
361
+ static head(path: string, handler: any, middlewares?: any[] | any): void;
360
362
  /**
361
363
  * Defines a group of routes with a common prefix.
362
364
  *
@@ -365,7 +367,7 @@ declare abstract class CoreRouter {
365
367
  * @param callback
366
368
  * @param middlewares
367
369
  */
368
- static group(this: any, prefix: string, callback: () => void | Promise<void>, middlewares?: any[]): Promise<void>;
370
+ static group(prefix: string, callback: () => void | Promise<void>, middlewares?: any[]): Promise<void>;
369
371
  /**
370
372
  * Adds global middlewares to the router, which will be applied to all routes.
371
373
  *
@@ -373,24 +375,24 @@ declare abstract class CoreRouter {
373
375
  * @param middlewares
374
376
  * @param callback
375
377
  */
376
- static middleware(this: any, middlewares: any[], callback: () => void): void;
378
+ static middleware(middlewares: any[], callback: () => void): void;
377
379
  /**
378
380
  * Retrieves all registered routes in the router, optionally organized by path or method
379
381
  * for easier access and management.
380
382
  *
381
383
  * @param this
382
384
  */
383
- static allRoutes(this: any): Array<Route<any, any, any>>;
385
+ static allRoutes(): Array<Route<any, any, any>>;
384
386
  /**
385
387
  * @param this
386
388
  * @param type - 'path' to get routes organized by path
387
389
  */
388
- static allRoutes(this: any, type: 'path'): Record<string, Route<any, any, any>>;
390
+ static allRoutes(type: 'path'): Record<string, Route<any, any, any>>;
389
391
  /**
390
392
  * @param this
391
393
  * @param type - 'method' to get routes organized by method
392
394
  */
393
- static allRoutes(this: any, type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<any, any, any>> };
395
+ static allRoutes(type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<any, any, any>> };
394
396
  protected static resolveHandler(route: Route<any, any, any>): {
395
397
  handlerFunction: ((ctx: any, req: Request) => any | Promise<any>) | null;
396
398
  instance: Controller<any> | null;
@@ -399,7 +401,7 @@ declare abstract class CoreRouter {
399
401
  bindingHandler?: object;
400
402
  bindingMetadata?: object;
401
403
  };
402
- protected static callHandler(this: any, handlerFunction: (ctx: any, req: Request) => any | Promise<any>, ctx: any, bindingTarget?: object, bindingMethod?: PropertyKey, bindingHandler?: object, bindingMetadata?: object): Promise<any>;
404
+ protected static callHandler(handlerFunction: (ctx: any, req: Request) => any | Promise<any>, ctx: any, bindingTarget?: object, bindingMethod?: PropertyKey, bindingHandler?: object, bindingMetadata?: object): Promise<any>;
403
405
  protected static bindRequestToInstance(ctx: any, instance: Controller<any> | Route<any, any, any> | null, route: Route<any, any, any>, payload: {
404
406
  body: Record<string, any>;
405
407
  query: Record<string, any>;
package/dist/index.d.mts CHANGED
@@ -41,8 +41,10 @@ declare class Response$1 {
41
41
  headers: Headers;
42
42
  sent: boolean;
43
43
  statusCode: number;
44
- constructor(init?: Partial<Response$1>);
44
+ statusText: string;
45
+ constructor(init?: Partial<Response$1 | globalThis.Response>);
45
46
  status(code: number): this;
47
+ setStatusText(text: string): this;
46
48
  code(code: number): this;
47
49
  setHeader(name: string, value: string): this;
48
50
  header(name: string, value: string): this;
@@ -206,7 +208,7 @@ declare abstract class CoreRouter {
206
208
  protected static createBaseConfig(): RouterConfig;
207
209
  protected static mergeConfig(target: RouterConfig, source?: RouterConfig): RouterConfig;
208
210
  protected static getDefaultConfig(): RouterConfig;
209
- protected static resolveStateNamespace(this: any): string;
211
+ protected static resolveStateNamespace(): string;
210
212
  protected static getStateStore(): Record<string, any>;
211
213
  protected static getPluginStore(): Set<string>;
212
214
  protected static getPluginPendingStore(): Set<Promise<void>>;
@@ -224,10 +226,10 @@ declare abstract class CoreRouter {
224
226
  groupMiddlewares: any[];
225
227
  globalMiddlewares: any[];
226
228
  };
227
- protected static bindStateAccessors(this: any): void;
229
+ protected static bindStateAccessors(): void;
228
230
  protected static createDefaultOptionsHandler(): any;
229
231
  static config: RouterConfig;
230
- static configureDefaults(this: any, options?: RouterConfig): void;
232
+ static configureDefaults(options?: RouterConfig): void;
231
233
  /**
232
234
  * Use a registered plugin
233
235
  *
@@ -236,8 +238,8 @@ declare abstract class CoreRouter {
236
238
  * @param options
237
239
  * @returns
238
240
  */
239
- static use<Options = any>(this: any, plugin: ClearRouterPluginInput<Options>, options?: Options): Promise<void>;
240
- protected static pluginsReady(this: any): Promise<void>;
241
+ static use<Options = any>(plugin: ClearRouterPluginInput<Options>, options?: Options): Promise<void>;
242
+ protected static pluginsReady(): Promise<void>;
241
243
  protected static groupContext: AsyncLocalStorage<{
242
244
  prefix: string;
243
245
  groupMiddlewares: any[];
@@ -253,7 +255,7 @@ declare abstract class CoreRouter {
253
255
  protected static createPluginRequestContext(ctx: any): ClearRouterPluginRequestContext;
254
256
  protected static createPluginBind(): PluginBind;
255
257
  protected static resolvePluginArguments(this: any, ctx: any, routeContext: Omit<ClearRouterPluginArgumentsContext, keyof ClearRouterPluginRequestContext>): Promise<any[] | undefined>;
256
- protected static ensureState(this: any): void;
258
+ protected static ensureState(): void;
257
259
  /**
258
260
  * Normalizes a path by ensuring it starts with a single slash and does not have trailing
259
261
  * slashes, while preserving dynamic segments and parameters.
@@ -270,7 +272,7 @@ declare abstract class CoreRouter {
270
272
  * @returns
271
273
  */
272
274
  static configure(this: any, options?: RouterConfig): void;
273
- protected static resolveMethodOverride(this: any, method: string, headers: Headers | Record<string, any>, body: unknown): HttpMethod | null;
275
+ protected static resolveMethodOverride(method: string, headers: Headers | Record<string, any>, body: unknown): HttpMethod | null;
274
276
  /**
275
277
  * Adds a new route to the router.
276
278
  *
@@ -280,7 +282,7 @@ declare abstract class CoreRouter {
280
282
  * @param handler
281
283
  * @param middlewares
282
284
  */
283
- static add(this: any, methods: HttpMethod | HttpMethod[], path: string, handler: any, middlewares?: any[] | any): void;
285
+ static add(methods: HttpMethod | HttpMethod[], path: string, handler: any, middlewares?: any[] | any): void;
284
286
  /**
285
287
  * Define a resourceful API controller with standard CRUD routes.
286
288
  *
@@ -289,7 +291,7 @@ declare abstract class CoreRouter {
289
291
  * @param controller
290
292
  * @param options
291
293
  */
292
- static apiResource(this: any, basePath: string, controller: any, options?: {
294
+ static apiResource(basePath: string, controller: any, options?: {
293
295
  only?: ControllerAction[];
294
296
  except?: ControllerAction[];
295
297
  middlewares?: ApiResourceMiddleware<any>;
@@ -302,7 +304,7 @@ declare abstract class CoreRouter {
302
304
  * @param handler The handler function for the GET route.
303
305
  * @param middlewares Optional middlewares to apply to the GET route.
304
306
  */
305
- static get(this: any, path: string, handler: any, middlewares?: any[] | any): void;
307
+ static get(path: string, handler: any, middlewares?: any[] | any): void;
306
308
  /**
307
309
  * Adds a new POST route to the router.
308
310
  *
@@ -311,7 +313,7 @@ declare abstract class CoreRouter {
311
313
  * @param handler
312
314
  * @param middlewares
313
315
  */
314
- static post(this: any, path: string, handler: any, middlewares?: any[] | any): void;
316
+ static post(path: string, handler: any, middlewares?: any[] | any): void;
315
317
  /**
316
318
  * Adds a new PUT route to the router.
317
319
  *
@@ -320,7 +322,7 @@ declare abstract class CoreRouter {
320
322
  * @param handler
321
323
  * @param middlewares
322
324
  */
323
- static put(this: any, path: string, handler: any, middlewares?: any[] | any): void;
325
+ static put(path: string, handler: any, middlewares?: any[] | any): void;
324
326
  /**
325
327
  * Adds a new DELETE route to the router.
326
328
  *
@@ -329,7 +331,7 @@ declare abstract class CoreRouter {
329
331
  * @param handler
330
332
  * @param middlewares
331
333
  */
332
- static delete(this: any, path: string, handler: any, middlewares?: any[] | any): void;
334
+ static delete(path: string, handler: any, middlewares?: any[] | any): void;
333
335
  /**
334
336
  * Adds a new PATCH route to the router.
335
337
  *
@@ -338,7 +340,7 @@ declare abstract class CoreRouter {
338
340
  * @param handler
339
341
  * @param middlewares
340
342
  */
341
- static patch(this: any, path: string, handler: any, middlewares?: any[] | any): void;
343
+ static patch(path: string, handler: any, middlewares?: any[] | any): void;
342
344
  /**
343
345
  * Adds a new OPTIONS route to the router.
344
346
  *
@@ -347,7 +349,7 @@ declare abstract class CoreRouter {
347
349
  * @param handler
348
350
  * @param middlewares
349
351
  */
350
- static options(this: any, path: string, handler: any, middlewares?: any[] | any): void;
352
+ static options(path: string, handler: any, middlewares?: any[] | any): void;
351
353
  /**
352
354
  * Adds a new HEAD route to the router.
353
355
  *
@@ -356,7 +358,7 @@ declare abstract class CoreRouter {
356
358
  * @param handler
357
359
  * @param middlewares
358
360
  */
359
- static head(this: any, path: string, handler: any, middlewares?: any[] | any): void;
361
+ static head(path: string, handler: any, middlewares?: any[] | any): void;
360
362
  /**
361
363
  * Defines a group of routes with a common prefix.
362
364
  *
@@ -365,7 +367,7 @@ declare abstract class CoreRouter {
365
367
  * @param callback
366
368
  * @param middlewares
367
369
  */
368
- static group(this: any, prefix: string, callback: () => void | Promise<void>, middlewares?: any[]): Promise<void>;
370
+ static group(prefix: string, callback: () => void | Promise<void>, middlewares?: any[]): Promise<void>;
369
371
  /**
370
372
  * Adds global middlewares to the router, which will be applied to all routes.
371
373
  *
@@ -373,24 +375,24 @@ declare abstract class CoreRouter {
373
375
  * @param middlewares
374
376
  * @param callback
375
377
  */
376
- static middleware(this: any, middlewares: any[], callback: () => void): void;
378
+ static middleware(middlewares: any[], callback: () => void): void;
377
379
  /**
378
380
  * Retrieves all registered routes in the router, optionally organized by path or method
379
381
  * for easier access and management.
380
382
  *
381
383
  * @param this
382
384
  */
383
- static allRoutes(this: any): Array<Route<any, any, any>>;
385
+ static allRoutes(): Array<Route<any, any, any>>;
384
386
  /**
385
387
  * @param this
386
388
  * @param type - 'path' to get routes organized by path
387
389
  */
388
- static allRoutes(this: any, type: 'path'): Record<string, Route<any, any, any>>;
390
+ static allRoutes(type: 'path'): Record<string, Route<any, any, any>>;
389
391
  /**
390
392
  * @param this
391
393
  * @param type - 'method' to get routes organized by method
392
394
  */
393
- static allRoutes(this: any, type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<any, any, any>> };
395
+ static allRoutes(type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<any, any, any>> };
394
396
  protected static resolveHandler(route: Route<any, any, any>): {
395
397
  handlerFunction: ((ctx: any, req: Request) => any | Promise<any>) | null;
396
398
  instance: Controller<any> | null;
@@ -399,7 +401,7 @@ declare abstract class CoreRouter {
399
401
  bindingHandler?: object;
400
402
  bindingMetadata?: object;
401
403
  };
402
- protected static callHandler(this: any, handlerFunction: (ctx: any, req: Request) => any | Promise<any>, ctx: any, bindingTarget?: object, bindingMethod?: PropertyKey, bindingHandler?: object, bindingMetadata?: object): Promise<any>;
404
+ protected static callHandler(handlerFunction: (ctx: any, req: Request) => any | Promise<any>, ctx: any, bindingTarget?: object, bindingMethod?: PropertyKey, bindingHandler?: object, bindingMetadata?: object): Promise<any>;
403
405
  protected static bindRequestToInstance(ctx: any, instance: Controller<any> | Route<any, any, any> | null, route: Route<any, any, any>, payload: {
404
406
  body: Record<string, any>;
405
407
  query: Record<string, any>;
package/dist/index.mjs CHANGED
@@ -97,14 +97,21 @@ var Response = class {
97
97
  headers = new Headers();
98
98
  sent = false;
99
99
  statusCode = 200;
100
+ statusText = "OK";
100
101
  constructor(init) {
101
- Object.assign(this, init);
102
+ const { status: _, ...rest } = init ?? {};
103
+ Object.assign(this, rest);
102
104
  if (init?.headers && !(init.headers instanceof Headers)) this.headers = new Headers(init.headers);
105
+ if (init?.status && typeof init.status === "number") this.statusCode = init?.status;
103
106
  }
104
107
  status(code) {
105
108
  this.statusCode = code;
106
109
  return this;
107
110
  }
111
+ setStatusText(text) {
112
+ this.statusText = text;
113
+ return this;
114
+ }
108
115
  code(code) {
109
116
  return this.status(code);
110
117
  }
@@ -883,7 +890,11 @@ var CoreRouter = class {
883
890
  clearRequest.query = payload.query;
884
891
  clearRequest.params = payload.params;
885
892
  ctx.clearRequest = clearRequest;
886
- if (!(ctx.clearResponse instanceof Response)) ctx.clearResponse = new Response();
893
+ Container.bind(Request, ctx.clearRequest);
894
+ if (!(ctx.clearResponse instanceof Response)) {
895
+ ctx.clearResponse = new Response(ctx.response ?? ctx.reply ?? ctx.res);
896
+ Container.bind(Response, ctx.clearResponse);
897
+ }
887
898
  if (!instance) return;
888
899
  instance.ctx = ctx;
889
900
  instance.body = payload.body;
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- require('../bindings-CDGLuAq4.cjs');
3
- const require_router = require('../router-DPJfzvy5.cjs');
4
- const require_responses = require('../responses-CBP3RYjJ.cjs');
2
+ require('../bindings-CLsZjOEy.cjs');
3
+ const require_router = require('../router-D9H9-T27.cjs');
4
+ const require_responses = require('../responses-Bvnk0uvc.cjs');
5
5
 
6
6
  //#region src/koa/router.ts
7
7
  /**
@@ -1,4 +1,4 @@
1
- import { C as ControllerAction, E as Response, S as ApiResourceMiddleware, T as HttpMethod, m as Route, p as Request, t as CoreRouter, w as ControllerHandler } from "../router-35iBbCaF.cjs";
1
+ import { C as ControllerAction, E as Response, S as ApiResourceMiddleware, T as HttpMethod, m as Route, p as Request, t as CoreRouter, w as ControllerHandler } from "../router-DTI0BowV.cjs";
2
2
  import Koa from "koa";
3
3
  import Router$1 from "@koa/router";
4
4
 
@@ -1,4 +1,4 @@
1
- import { C as ControllerAction, E as Response, S as ApiResourceMiddleware, T as HttpMethod, m as Route, p as Request, t as CoreRouter, w as ControllerHandler } from "../router-91xVPlV0.mjs";
1
+ import { C as ControllerAction, E as Response, S as ApiResourceMiddleware, T as HttpMethod, m as Route, p as Request, t as CoreRouter, w as ControllerHandler } from "../router-DiKqUyvk.mjs";
2
2
  import Koa from "koa";
3
3
  import Router$1 from "@koa/router";
4
4
 
@@ -1,6 +1,6 @@
1
- import "../bindings-B6x2HfzP.mjs";
2
- import { t as CoreRouter } from "../router-BkJMl4xv.mjs";
3
- import { n as resolveResponseMeta, t as isFetchResponse } from "../responses-DuZeRyGE.mjs";
1
+ import "../bindings-XLDXFpHZ.mjs";
2
+ import { t as CoreRouter } from "../router-CPmZcbU0.mjs";
3
+ import { n as resolveResponseMeta, t as isFetchResponse } from "../responses-BvETUeDL.mjs";
4
4
 
5
5
  //#region src/koa/router.ts
6
6
  /**
@@ -1,4 +1,4 @@
1
- import { s as Response } from "./bindings-B6x2HfzP.mjs";
1
+ import { s as Response } from "./bindings-XLDXFpHZ.mjs";
2
2
 
3
3
  //#region src/core/responses.ts
4
4
  function isFetchResponse(value) {
@@ -1,4 +1,4 @@
1
- const require_bindings = require('./bindings-CDGLuAq4.cjs');
1
+ const require_bindings = require('./bindings-CLsZjOEy.cjs');
2
2
 
3
3
  //#region src/core/responses.ts
4
4
  function isFetchResponse(value) {
@@ -1,4 +1,4 @@
1
- import { a as getStandardMetadata, c as Request, i as getDesignParamTypes, n as Container, o as isClass, r as getBindingMetadataFromTargets, s as Response } from "./bindings-B6x2HfzP.mjs";
1
+ import { a as getStandardMetadata, c as Request, i as getDesignParamTypes, n as Container, o as isClass, r as getBindingMetadataFromTargets, s as Response } from "./bindings-XLDXFpHZ.mjs";
2
2
  import { AsyncLocalStorage } from "node:async_hooks";
3
3
 
4
4
  //#region src/Route.ts
@@ -664,7 +664,11 @@ var CoreRouter = class {
664
664
  clearRequest.query = payload.query;
665
665
  clearRequest.params = payload.params;
666
666
  ctx.clearRequest = clearRequest;
667
- if (!(ctx.clearResponse instanceof Response)) ctx.clearResponse = new Response();
667
+ Container.bind(Request, ctx.clearRequest);
668
+ if (!(ctx.clearResponse instanceof Response)) {
669
+ ctx.clearResponse = new Response(ctx.response ?? ctx.reply ?? ctx.res);
670
+ Container.bind(Response, ctx.clearResponse);
671
+ }
668
672
  if (!instance) return;
669
673
  instance.ctx = ctx;
670
674
  instance.body = payload.body;
@@ -1,4 +1,4 @@
1
- const require_bindings = require('./bindings-CDGLuAq4.cjs');
1
+ const require_bindings = require('./bindings-CLsZjOEy.cjs');
2
2
  let node_async_hooks = require("node:async_hooks");
3
3
 
4
4
  //#region src/Route.ts
@@ -664,7 +664,11 @@ var CoreRouter = class {
664
664
  clearRequest.query = payload.query;
665
665
  clearRequest.params = payload.params;
666
666
  ctx.clearRequest = clearRequest;
667
- if (!(ctx.clearResponse instanceof require_bindings.Response)) ctx.clearResponse = new require_bindings.Response();
667
+ require_bindings.Container.bind(require_bindings.Request, ctx.clearRequest);
668
+ if (!(ctx.clearResponse instanceof require_bindings.Response)) {
669
+ ctx.clearResponse = new require_bindings.Response(ctx.response ?? ctx.reply ?? ctx.res);
670
+ require_bindings.Container.bind(require_bindings.Response, ctx.clearResponse);
671
+ }
668
672
  if (!instance) return;
669
673
  instance.ctx = ctx;
670
674
  instance.body = payload.body;
@@ -9,8 +9,10 @@ declare class Response$2 {
9
9
  headers: Headers;
10
10
  sent: boolean;
11
11
  statusCode: number;
12
- constructor(init?: Partial<Response$2>);
12
+ statusText: string;
13
+ constructor(init?: Partial<Response$2 | globalThis.Response>);
13
14
  status(code: number): this;
15
+ setStatusText(text: string): this;
14
16
  code(code: number): this;
15
17
  setHeader(name: string, value: string): this;
16
18
  header(name: string, value: string): this;
@@ -258,7 +260,7 @@ declare abstract class CoreRouter {
258
260
  protected static createBaseConfig(): RouterConfig;
259
261
  protected static mergeConfig(target: RouterConfig, source?: RouterConfig): RouterConfig;
260
262
  protected static getDefaultConfig(): RouterConfig;
261
- protected static resolveStateNamespace(this: any): string;
263
+ protected static resolveStateNamespace(): string;
262
264
  protected static getStateStore(): Record<string, any>;
263
265
  protected static getPluginStore(): Set<string>;
264
266
  protected static getPluginPendingStore(): Set<Promise<void>>;
@@ -276,10 +278,10 @@ declare abstract class CoreRouter {
276
278
  groupMiddlewares: any[];
277
279
  globalMiddlewares: any[];
278
280
  };
279
- protected static bindStateAccessors(this: any): void;
281
+ protected static bindStateAccessors(): void;
280
282
  protected static createDefaultOptionsHandler(): any;
281
283
  static config: RouterConfig;
282
- static configureDefaults(this: any, options?: RouterConfig): void;
284
+ static configureDefaults(options?: RouterConfig): void;
283
285
  /**
284
286
  * Use a registered plugin
285
287
  *
@@ -288,8 +290,8 @@ declare abstract class CoreRouter {
288
290
  * @param options
289
291
  * @returns
290
292
  */
291
- static use<Options = any>(this: any, plugin: ClearRouterPluginInput<Options>, options?: Options): Promise<void>;
292
- protected static pluginsReady(this: any): Promise<void>;
293
+ static use<Options = any>(plugin: ClearRouterPluginInput<Options>, options?: Options): Promise<void>;
294
+ protected static pluginsReady(): Promise<void>;
293
295
  protected static groupContext: AsyncLocalStorage<{
294
296
  prefix: string;
295
297
  groupMiddlewares: any[];
@@ -305,7 +307,7 @@ declare abstract class CoreRouter {
305
307
  protected static createPluginRequestContext(ctx: any): ClearRouterPluginRequestContext;
306
308
  protected static createPluginBind(): PluginBind;
307
309
  protected static resolvePluginArguments(this: any, ctx: any, routeContext: Omit<ClearRouterPluginArgumentsContext, keyof ClearRouterPluginRequestContext>): Promise<any[] | undefined>;
308
- protected static ensureState(this: any): void;
310
+ protected static ensureState(): void;
309
311
  /**
310
312
  * Normalizes a path by ensuring it starts with a single slash and does not have trailing
311
313
  * slashes, while preserving dynamic segments and parameters.
@@ -322,7 +324,7 @@ declare abstract class CoreRouter {
322
324
  * @returns
323
325
  */
324
326
  static configure(this: any, options?: RouterConfig): void;
325
- protected static resolveMethodOverride(this: any, method: string, headers: Headers | Record<string, any>, body: unknown): HttpMethod | null;
327
+ protected static resolveMethodOverride(method: string, headers: Headers | Record<string, any>, body: unknown): HttpMethod | null;
326
328
  /**
327
329
  * Adds a new route to the router.
328
330
  *
@@ -332,7 +334,7 @@ declare abstract class CoreRouter {
332
334
  * @param handler
333
335
  * @param middlewares
334
336
  */
335
- static add(this: any, methods: HttpMethod | HttpMethod[], path: string, handler: any, middlewares?: any[] | any): void;
337
+ static add(methods: HttpMethod | HttpMethod[], path: string, handler: any, middlewares?: any[] | any): void;
336
338
  /**
337
339
  * Define a resourceful API controller with standard CRUD routes.
338
340
  *
@@ -341,7 +343,7 @@ declare abstract class CoreRouter {
341
343
  * @param controller
342
344
  * @param options
343
345
  */
344
- static apiResource(this: any, basePath: string, controller: any, options?: {
346
+ static apiResource(basePath: string, controller: any, options?: {
345
347
  only?: ControllerAction[];
346
348
  except?: ControllerAction[];
347
349
  middlewares?: ApiResourceMiddleware<any>;
@@ -354,7 +356,7 @@ declare abstract class CoreRouter {
354
356
  * @param handler The handler function for the GET route.
355
357
  * @param middlewares Optional middlewares to apply to the GET route.
356
358
  */
357
- static get(this: any, path: string, handler: any, middlewares?: any[] | any): void;
359
+ static get(path: string, handler: any, middlewares?: any[] | any): void;
358
360
  /**
359
361
  * Adds a new POST route to the router.
360
362
  *
@@ -363,7 +365,7 @@ declare abstract class CoreRouter {
363
365
  * @param handler
364
366
  * @param middlewares
365
367
  */
366
- static post(this: any, path: string, handler: any, middlewares?: any[] | any): void;
368
+ static post(path: string, handler: any, middlewares?: any[] | any): void;
367
369
  /**
368
370
  * Adds a new PUT route to the router.
369
371
  *
@@ -372,7 +374,7 @@ declare abstract class CoreRouter {
372
374
  * @param handler
373
375
  * @param middlewares
374
376
  */
375
- static put(this: any, path: string, handler: any, middlewares?: any[] | any): void;
377
+ static put(path: string, handler: any, middlewares?: any[] | any): void;
376
378
  /**
377
379
  * Adds a new DELETE route to the router.
378
380
  *
@@ -381,7 +383,7 @@ declare abstract class CoreRouter {
381
383
  * @param handler
382
384
  * @param middlewares
383
385
  */
384
- static delete(this: any, path: string, handler: any, middlewares?: any[] | any): void;
386
+ static delete(path: string, handler: any, middlewares?: any[] | any): void;
385
387
  /**
386
388
  * Adds a new PATCH route to the router.
387
389
  *
@@ -390,7 +392,7 @@ declare abstract class CoreRouter {
390
392
  * @param handler
391
393
  * @param middlewares
392
394
  */
393
- static patch(this: any, path: string, handler: any, middlewares?: any[] | any): void;
395
+ static patch(path: string, handler: any, middlewares?: any[] | any): void;
394
396
  /**
395
397
  * Adds a new OPTIONS route to the router.
396
398
  *
@@ -399,7 +401,7 @@ declare abstract class CoreRouter {
399
401
  * @param handler
400
402
  * @param middlewares
401
403
  */
402
- static options(this: any, path: string, handler: any, middlewares?: any[] | any): void;
404
+ static options(path: string, handler: any, middlewares?: any[] | any): void;
403
405
  /**
404
406
  * Adds a new HEAD route to the router.
405
407
  *
@@ -408,7 +410,7 @@ declare abstract class CoreRouter {
408
410
  * @param handler
409
411
  * @param middlewares
410
412
  */
411
- static head(this: any, path: string, handler: any, middlewares?: any[] | any): void;
413
+ static head(path: string, handler: any, middlewares?: any[] | any): void;
412
414
  /**
413
415
  * Defines a group of routes with a common prefix.
414
416
  *
@@ -417,7 +419,7 @@ declare abstract class CoreRouter {
417
419
  * @param callback
418
420
  * @param middlewares
419
421
  */
420
- static group(this: any, prefix: string, callback: () => void | Promise<void>, middlewares?: any[]): Promise<void>;
422
+ static group(prefix: string, callback: () => void | Promise<void>, middlewares?: any[]): Promise<void>;
421
423
  /**
422
424
  * Adds global middlewares to the router, which will be applied to all routes.
423
425
  *
@@ -425,24 +427,24 @@ declare abstract class CoreRouter {
425
427
  * @param middlewares
426
428
  * @param callback
427
429
  */
428
- static middleware(this: any, middlewares: any[], callback: () => void): void;
430
+ static middleware(middlewares: any[], callback: () => void): void;
429
431
  /**
430
432
  * Retrieves all registered routes in the router, optionally organized by path or method
431
433
  * for easier access and management.
432
434
  *
433
435
  * @param this
434
436
  */
435
- static allRoutes(this: any): Array<Route<any, any, any>>;
437
+ static allRoutes(): Array<Route<any, any, any>>;
436
438
  /**
437
439
  * @param this
438
440
  * @param type - 'path' to get routes organized by path
439
441
  */
440
- static allRoutes(this: any, type: 'path'): Record<string, Route<any, any, any>>;
442
+ static allRoutes(type: 'path'): Record<string, Route<any, any, any>>;
441
443
  /**
442
444
  * @param this
443
445
  * @param type - 'method' to get routes organized by method
444
446
  */
445
- static allRoutes(this: any, type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<any, any, any>> };
447
+ static allRoutes(type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<any, any, any>> };
446
448
  protected static resolveHandler(route: Route<any, any, any>): {
447
449
  handlerFunction: ((ctx: any, req: Request$1) => any | Promise<any>) | null;
448
450
  instance: Controller<any> | null;
@@ -451,7 +453,7 @@ declare abstract class CoreRouter {
451
453
  bindingHandler?: object;
452
454
  bindingMetadata?: object;
453
455
  };
454
- protected static callHandler(this: any, handlerFunction: (ctx: any, req: Request$1) => any | Promise<any>, ctx: any, bindingTarget?: object, bindingMethod?: PropertyKey, bindingHandler?: object, bindingMetadata?: object): Promise<any>;
456
+ protected static callHandler(handlerFunction: (ctx: any, req: Request$1) => any | Promise<any>, ctx: any, bindingTarget?: object, bindingMethod?: PropertyKey, bindingHandler?: object, bindingMetadata?: object): Promise<any>;
455
457
  protected static bindRequestToInstance(ctx: any, instance: Controller<any> | Route<any, any, any> | null, route: Route<any, any, any>, payload: {
456
458
  body: Record<string, any>;
457
459
  query: Record<string, any>;
@@ -9,8 +9,10 @@ declare class Response$2 {
9
9
  headers: Headers;
10
10
  sent: boolean;
11
11
  statusCode: number;
12
- constructor(init?: Partial<Response$2>);
12
+ statusText: string;
13
+ constructor(init?: Partial<Response$2 | globalThis.Response>);
13
14
  status(code: number): this;
15
+ setStatusText(text: string): this;
14
16
  code(code: number): this;
15
17
  setHeader(name: string, value: string): this;
16
18
  header(name: string, value: string): this;
@@ -258,7 +260,7 @@ declare abstract class CoreRouter {
258
260
  protected static createBaseConfig(): RouterConfig;
259
261
  protected static mergeConfig(target: RouterConfig, source?: RouterConfig): RouterConfig;
260
262
  protected static getDefaultConfig(): RouterConfig;
261
- protected static resolveStateNamespace(this: any): string;
263
+ protected static resolveStateNamespace(): string;
262
264
  protected static getStateStore(): Record<string, any>;
263
265
  protected static getPluginStore(): Set<string>;
264
266
  protected static getPluginPendingStore(): Set<Promise<void>>;
@@ -276,10 +278,10 @@ declare abstract class CoreRouter {
276
278
  groupMiddlewares: any[];
277
279
  globalMiddlewares: any[];
278
280
  };
279
- protected static bindStateAccessors(this: any): void;
281
+ protected static bindStateAccessors(): void;
280
282
  protected static createDefaultOptionsHandler(): any;
281
283
  static config: RouterConfig;
282
- static configureDefaults(this: any, options?: RouterConfig): void;
284
+ static configureDefaults(options?: RouterConfig): void;
283
285
  /**
284
286
  * Use a registered plugin
285
287
  *
@@ -288,8 +290,8 @@ declare abstract class CoreRouter {
288
290
  * @param options
289
291
  * @returns
290
292
  */
291
- static use<Options = any>(this: any, plugin: ClearRouterPluginInput<Options>, options?: Options): Promise<void>;
292
- protected static pluginsReady(this: any): Promise<void>;
293
+ static use<Options = any>(plugin: ClearRouterPluginInput<Options>, options?: Options): Promise<void>;
294
+ protected static pluginsReady(): Promise<void>;
293
295
  protected static groupContext: AsyncLocalStorage<{
294
296
  prefix: string;
295
297
  groupMiddlewares: any[];
@@ -305,7 +307,7 @@ declare abstract class CoreRouter {
305
307
  protected static createPluginRequestContext(ctx: any): ClearRouterPluginRequestContext;
306
308
  protected static createPluginBind(): PluginBind;
307
309
  protected static resolvePluginArguments(this: any, ctx: any, routeContext: Omit<ClearRouterPluginArgumentsContext, keyof ClearRouterPluginRequestContext>): Promise<any[] | undefined>;
308
- protected static ensureState(this: any): void;
310
+ protected static ensureState(): void;
309
311
  /**
310
312
  * Normalizes a path by ensuring it starts with a single slash and does not have trailing
311
313
  * slashes, while preserving dynamic segments and parameters.
@@ -322,7 +324,7 @@ declare abstract class CoreRouter {
322
324
  * @returns
323
325
  */
324
326
  static configure(this: any, options?: RouterConfig): void;
325
- protected static resolveMethodOverride(this: any, method: string, headers: Headers | Record<string, any>, body: unknown): HttpMethod | null;
327
+ protected static resolveMethodOverride(method: string, headers: Headers | Record<string, any>, body: unknown): HttpMethod | null;
326
328
  /**
327
329
  * Adds a new route to the router.
328
330
  *
@@ -332,7 +334,7 @@ declare abstract class CoreRouter {
332
334
  * @param handler
333
335
  * @param middlewares
334
336
  */
335
- static add(this: any, methods: HttpMethod | HttpMethod[], path: string, handler: any, middlewares?: any[] | any): void;
337
+ static add(methods: HttpMethod | HttpMethod[], path: string, handler: any, middlewares?: any[] | any): void;
336
338
  /**
337
339
  * Define a resourceful API controller with standard CRUD routes.
338
340
  *
@@ -341,7 +343,7 @@ declare abstract class CoreRouter {
341
343
  * @param controller
342
344
  * @param options
343
345
  */
344
- static apiResource(this: any, basePath: string, controller: any, options?: {
346
+ static apiResource(basePath: string, controller: any, options?: {
345
347
  only?: ControllerAction[];
346
348
  except?: ControllerAction[];
347
349
  middlewares?: ApiResourceMiddleware<any>;
@@ -354,7 +356,7 @@ declare abstract class CoreRouter {
354
356
  * @param handler The handler function for the GET route.
355
357
  * @param middlewares Optional middlewares to apply to the GET route.
356
358
  */
357
- static get(this: any, path: string, handler: any, middlewares?: any[] | any): void;
359
+ static get(path: string, handler: any, middlewares?: any[] | any): void;
358
360
  /**
359
361
  * Adds a new POST route to the router.
360
362
  *
@@ -363,7 +365,7 @@ declare abstract class CoreRouter {
363
365
  * @param handler
364
366
  * @param middlewares
365
367
  */
366
- static post(this: any, path: string, handler: any, middlewares?: any[] | any): void;
368
+ static post(path: string, handler: any, middlewares?: any[] | any): void;
367
369
  /**
368
370
  * Adds a new PUT route to the router.
369
371
  *
@@ -372,7 +374,7 @@ declare abstract class CoreRouter {
372
374
  * @param handler
373
375
  * @param middlewares
374
376
  */
375
- static put(this: any, path: string, handler: any, middlewares?: any[] | any): void;
377
+ static put(path: string, handler: any, middlewares?: any[] | any): void;
376
378
  /**
377
379
  * Adds a new DELETE route to the router.
378
380
  *
@@ -381,7 +383,7 @@ declare abstract class CoreRouter {
381
383
  * @param handler
382
384
  * @param middlewares
383
385
  */
384
- static delete(this: any, path: string, handler: any, middlewares?: any[] | any): void;
386
+ static delete(path: string, handler: any, middlewares?: any[] | any): void;
385
387
  /**
386
388
  * Adds a new PATCH route to the router.
387
389
  *
@@ -390,7 +392,7 @@ declare abstract class CoreRouter {
390
392
  * @param handler
391
393
  * @param middlewares
392
394
  */
393
- static patch(this: any, path: string, handler: any, middlewares?: any[] | any): void;
395
+ static patch(path: string, handler: any, middlewares?: any[] | any): void;
394
396
  /**
395
397
  * Adds a new OPTIONS route to the router.
396
398
  *
@@ -399,7 +401,7 @@ declare abstract class CoreRouter {
399
401
  * @param handler
400
402
  * @param middlewares
401
403
  */
402
- static options(this: any, path: string, handler: any, middlewares?: any[] | any): void;
404
+ static options(path: string, handler: any, middlewares?: any[] | any): void;
403
405
  /**
404
406
  * Adds a new HEAD route to the router.
405
407
  *
@@ -408,7 +410,7 @@ declare abstract class CoreRouter {
408
410
  * @param handler
409
411
  * @param middlewares
410
412
  */
411
- static head(this: any, path: string, handler: any, middlewares?: any[] | any): void;
413
+ static head(path: string, handler: any, middlewares?: any[] | any): void;
412
414
  /**
413
415
  * Defines a group of routes with a common prefix.
414
416
  *
@@ -417,7 +419,7 @@ declare abstract class CoreRouter {
417
419
  * @param callback
418
420
  * @param middlewares
419
421
  */
420
- static group(this: any, prefix: string, callback: () => void | Promise<void>, middlewares?: any[]): Promise<void>;
422
+ static group(prefix: string, callback: () => void | Promise<void>, middlewares?: any[]): Promise<void>;
421
423
  /**
422
424
  * Adds global middlewares to the router, which will be applied to all routes.
423
425
  *
@@ -425,24 +427,24 @@ declare abstract class CoreRouter {
425
427
  * @param middlewares
426
428
  * @param callback
427
429
  */
428
- static middleware(this: any, middlewares: any[], callback: () => void): void;
430
+ static middleware(middlewares: any[], callback: () => void): void;
429
431
  /**
430
432
  * Retrieves all registered routes in the router, optionally organized by path or method
431
433
  * for easier access and management.
432
434
  *
433
435
  * @param this
434
436
  */
435
- static allRoutes(this: any): Array<Route<any, any, any>>;
437
+ static allRoutes(): Array<Route<any, any, any>>;
436
438
  /**
437
439
  * @param this
438
440
  * @param type - 'path' to get routes organized by path
439
441
  */
440
- static allRoutes(this: any, type: 'path'): Record<string, Route<any, any, any>>;
442
+ static allRoutes(type: 'path'): Record<string, Route<any, any, any>>;
441
443
  /**
442
444
  * @param this
443
445
  * @param type - 'method' to get routes organized by method
444
446
  */
445
- static allRoutes(this: any, type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<any, any, any>> };
447
+ static allRoutes(type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<any, any, any>> };
446
448
  protected static resolveHandler(route: Route<any, any, any>): {
447
449
  handlerFunction: ((ctx: any, req: Request$1) => any | Promise<any>) | null;
448
450
  instance: Controller<any> | null;
@@ -451,7 +453,7 @@ declare abstract class CoreRouter {
451
453
  bindingHandler?: object;
452
454
  bindingMetadata?: object;
453
455
  };
454
- protected static callHandler(this: any, handlerFunction: (ctx: any, req: Request$1) => any | Promise<any>, ctx: any, bindingTarget?: object, bindingMethod?: PropertyKey, bindingHandler?: object, bindingMetadata?: object): Promise<any>;
456
+ protected static callHandler(handlerFunction: (ctx: any, req: Request$1) => any | Promise<any>, ctx: any, bindingTarget?: object, bindingMethod?: PropertyKey, bindingHandler?: object, bindingMetadata?: object): Promise<any>;
455
457
  protected static bindRequestToInstance(ctx: any, instance: Controller<any> | Route<any, any, any> | null, route: Route<any, any, any>, payload: {
456
458
  body: Record<string, any>;
457
459
  query: Record<string, any>;
@@ -4,8 +4,10 @@ declare class Response {
4
4
  headers: Headers;
5
5
  sent: boolean;
6
6
  statusCode: number;
7
- constructor(init?: Partial<Response>);
7
+ statusText: string;
8
+ constructor(init?: Partial<Response | globalThis.Response>);
8
9
  status(code: number): this;
10
+ setStatusText(text: string): this;
9
11
  code(code: number): this;
10
12
  setHeader(name: string, value: string): this;
11
13
  header(name: string, value: string): this;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clear-router",
3
- "version": "2.5.12",
3
+ "version": "2.5.13",
4
4
  "description": "Laravel-style routing for Node.js with support for Express, H3, Fastify, Hono, and Koa, including CommonJS, ESM, and TypeScript support.",
5
5
  "keywords": [
6
6
  "h3",