clear-router 2.3.1 → 2.3.3
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/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 +2 -1
- package/dist/express/index.d.cts +2 -1
- package/dist/express/index.d.mts +2 -1
- package/dist/express/index.mjs +2 -1
- package/dist/fastify/index.cjs +2 -1
- package/dist/fastify/index.d.cts +2 -1
- package/dist/fastify/index.d.mts +2 -1
- package/dist/fastify/index.mjs +2 -1
- package/dist/h3/index.cjs +3 -2
- package/dist/h3/index.d.cts +2 -1
- package/dist/h3/index.d.mts +2 -1
- package/dist/h3/index.mjs +3 -2
- package/dist/hono/index.cjs +2 -1
- package/dist/hono/index.d.cts +2 -1
- package/dist/hono/index.d.mts +2 -1
- package/dist/hono/index.mjs +2 -1
- package/dist/index.cjs +73 -8
- package/dist/index.d.cts +25 -0
- package/dist/index.d.mts +25 -0
- package/dist/index.mjs +73 -8
- package/dist/{router-Ba2MVNn-.cjs → router-C-c43ybe.cjs} +73 -8
- package/dist/{router-Bug2IE_u.mjs → router-CHaZi7NS.mjs} +73 -8
- package/dist/{router-DLmimm_U.d.cts → router-DdBiXfPU.d.mts} +26 -1
- package/dist/{router-cWYmcfTX.d.mts → router-DhBN2GwJ.d.cts} +26 -1
- package/package.json +1 -1
package/dist/core/index.cjs
CHANGED
package/dist/core/index.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as CoreRouter } from "../router-
|
|
1
|
+
import { t as CoreRouter } from "../router-DhBN2GwJ.cjs";
|
|
2
2
|
export { CoreRouter };
|
package/dist/core/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as CoreRouter } from "../router-
|
|
1
|
+
import { t as CoreRouter } from "../router-DdBiXfPU.mjs";
|
|
2
2
|
export { CoreRouter };
|
package/dist/core/index.mjs
CHANGED
package/dist/express/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-C-c43ybe.cjs');
|
|
3
3
|
|
|
4
4
|
//#region src/express/router.ts
|
|
5
5
|
/**
|
|
@@ -10,6 +10,7 @@ const require_router = require('../router-Ba2MVNn-.cjs');
|
|
|
10
10
|
* @repository https://github.com/toneflix/clear-router
|
|
11
11
|
*/
|
|
12
12
|
var Router = class Router extends require_router.CoreRouter {
|
|
13
|
+
static routerStateNamespace = "clear-router:express";
|
|
13
14
|
static ensureRequestBodyAccessor(req) {
|
|
14
15
|
if (typeof req.getBody !== "function") req.getBody = () => req.body ?? {};
|
|
15
16
|
}
|
package/dist/express/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as Handler, d as ApiResourceMiddleware, f as ControllerAction, l as HttpContext, m as HttpMethod, r as Route, t as CoreRouter, u as Middleware } from "../router-
|
|
1
|
+
import { c as Handler, d as ApiResourceMiddleware, f as ControllerAction, l as HttpContext, m as HttpMethod, r as Route, t as CoreRouter, u as Middleware } from "../router-DhBN2GwJ.cjs";
|
|
2
2
|
import { Router as Router$1 } from "express";
|
|
3
3
|
|
|
4
4
|
//#region src/express/router.d.ts
|
|
@@ -10,6 +10,7 @@ import { Router as Router$1 } from "express";
|
|
|
10
10
|
* @repository https://github.com/toneflix/clear-router
|
|
11
11
|
*/
|
|
12
12
|
declare class Router extends CoreRouter {
|
|
13
|
+
protected static routerStateNamespace: string;
|
|
13
14
|
private static ensureRequestBodyAccessor;
|
|
14
15
|
/**
|
|
15
16
|
* Adds a new route to the router with the specified HTTP methods, path, handler, and optional middlewares.
|
package/dist/express/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as Handler, d as ApiResourceMiddleware, f as ControllerAction, l as HttpContext, m as HttpMethod, r as Route, t as CoreRouter, u as Middleware } from "../router-
|
|
1
|
+
import { c as Handler, d as ApiResourceMiddleware, f as ControllerAction, l as HttpContext, m as HttpMethod, r as Route, t as CoreRouter, u as Middleware } from "../router-DdBiXfPU.mjs";
|
|
2
2
|
import { Router as Router$1 } from "express";
|
|
3
3
|
|
|
4
4
|
//#region src/express/router.d.ts
|
|
@@ -10,6 +10,7 @@ import { Router as Router$1 } from "express";
|
|
|
10
10
|
* @repository https://github.com/toneflix/clear-router
|
|
11
11
|
*/
|
|
12
12
|
declare class Router extends CoreRouter {
|
|
13
|
+
protected static routerStateNamespace: string;
|
|
13
14
|
private static ensureRequestBodyAccessor;
|
|
14
15
|
/**
|
|
15
16
|
* Adds a new route to the router with the specified HTTP methods, path, handler, and optional middlewares.
|
package/dist/express/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as CoreRouter } from "../router-
|
|
1
|
+
import { t as CoreRouter } from "../router-CHaZi7NS.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/express/router.ts
|
|
4
4
|
/**
|
|
@@ -9,6 +9,7 @@ import { t as CoreRouter } from "../router-Bug2IE_u.mjs";
|
|
|
9
9
|
* @repository https://github.com/toneflix/clear-router
|
|
10
10
|
*/
|
|
11
11
|
var Router = class Router extends CoreRouter {
|
|
12
|
+
static routerStateNamespace = "clear-router:express";
|
|
12
13
|
static ensureRequestBodyAccessor(req) {
|
|
13
14
|
if (typeof req.getBody !== "function") req.getBody = () => req.body ?? {};
|
|
14
15
|
}
|
package/dist/fastify/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-C-c43ybe.cjs');
|
|
3
3
|
|
|
4
4
|
//#region src/fastify/router.ts
|
|
5
5
|
/**
|
|
@@ -9,6 +9,7 @@ const require_router = require('../router-Ba2MVNn-.cjs');
|
|
|
9
9
|
* @repository https://github.com/toneflix/clear-router
|
|
10
10
|
*/
|
|
11
11
|
var Router = class Router extends require_router.CoreRouter {
|
|
12
|
+
static routerStateNamespace = "clear-router:fastify";
|
|
12
13
|
static ensureRequestBodyAccessor(req) {
|
|
13
14
|
if (typeof req.getBody !== "function") req.getBody = () => req.body ?? {};
|
|
14
15
|
}
|
package/dist/fastify/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-DhBN2GwJ.cjs";
|
|
2
2
|
import { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
|
|
3
3
|
|
|
4
4
|
//#region types/fastify.d.ts
|
|
@@ -23,6 +23,7 @@ type FastifyApp = FastifyInstance;
|
|
|
23
23
|
* @repository https://github.com/toneflix/clear-router
|
|
24
24
|
*/
|
|
25
25
|
declare class Router extends CoreRouter {
|
|
26
|
+
protected static routerStateNamespace: string;
|
|
26
27
|
private static ensureRequestBodyAccessor;
|
|
27
28
|
/**
|
|
28
29
|
* Add a route to the router
|
package/dist/fastify/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-DdBiXfPU.mjs";
|
|
2
2
|
import { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
|
|
3
3
|
|
|
4
4
|
//#region types/fastify.d.ts
|
|
@@ -23,6 +23,7 @@ type FastifyApp = FastifyInstance;
|
|
|
23
23
|
* @repository https://github.com/toneflix/clear-router
|
|
24
24
|
*/
|
|
25
25
|
declare class Router extends CoreRouter {
|
|
26
|
+
protected static routerStateNamespace: string;
|
|
26
27
|
private static ensureRequestBodyAccessor;
|
|
27
28
|
/**
|
|
28
29
|
* Add a route to the router
|
package/dist/fastify/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as CoreRouter } from "../router-
|
|
1
|
+
import { t as CoreRouter } from "../router-CHaZi7NS.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/fastify/router.ts
|
|
4
4
|
/**
|
|
@@ -8,6 +8,7 @@ import { t as CoreRouter } from "../router-Bug2IE_u.mjs";
|
|
|
8
8
|
* @repository https://github.com/toneflix/clear-router
|
|
9
9
|
*/
|
|
10
10
|
var Router = class Router extends CoreRouter {
|
|
11
|
+
static routerStateNamespace = "clear-router:fastify";
|
|
11
12
|
static ensureRequestBodyAccessor(req) {
|
|
12
13
|
if (typeof req.getBody !== "function") req.getBody = () => req.body ?? {};
|
|
13
14
|
}
|
package/dist/h3/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-C-c43ybe.cjs');
|
|
3
3
|
let h3 = require("h3");
|
|
4
4
|
|
|
5
5
|
//#region src/h3/router.ts
|
|
@@ -10,6 +10,7 @@ let h3 = require("h3");
|
|
|
10
10
|
* @repository https://github.com/toneflix/clear-router
|
|
11
11
|
*/
|
|
12
12
|
var Router = class Router extends require_router.CoreRouter {
|
|
13
|
+
static routerStateNamespace = "clear-router:h3";
|
|
13
14
|
static bodyCache = /* @__PURE__ */ new WeakMap();
|
|
14
15
|
static async readBodyCached(ctx) {
|
|
15
16
|
if (this.bodyCache.has(ctx)) {
|
|
@@ -203,7 +204,7 @@ var Router = class Router extends require_router.CoreRouter {
|
|
|
203
204
|
try {
|
|
204
205
|
const ctx = event;
|
|
205
206
|
const reqBody = await Router.readBodyCached(ctx);
|
|
206
|
-
if (Router.resolveMethodOverride(ctx.req.method, ctx.req.headers, reqBody) !== method) return;
|
|
207
|
+
if (Router.resolveMethodOverride(ctx.req.method, ctx.req.headers, reqBody) !== method) return Symbol.for("h3.notFound");
|
|
207
208
|
const inst = instance ?? route;
|
|
208
209
|
Router.bindRequestToInstance(ctx, inst, route, {
|
|
209
210
|
body: reqBody,
|
package/dist/h3/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as Handler, d as ApiResourceMiddleware, f as ControllerAction, i as H3App, m as HttpMethod, o as HttpContext, r as Route, s as Middleware, t as CoreRouter } from "../router-
|
|
1
|
+
import { a as Handler, d as ApiResourceMiddleware, f as ControllerAction, i as H3App, m as HttpMethod, o as HttpContext, r as Route, s as Middleware, t as CoreRouter } from "../router-DhBN2GwJ.cjs";
|
|
2
2
|
import { H3 } from "h3";
|
|
3
3
|
|
|
4
4
|
//#region src/h3/router.d.ts
|
|
@@ -9,6 +9,7 @@ import { H3 } from "h3";
|
|
|
9
9
|
* @repository https://github.com/toneflix/clear-router
|
|
10
10
|
*/
|
|
11
11
|
declare class Router extends CoreRouter {
|
|
12
|
+
protected static routerStateNamespace: string;
|
|
12
13
|
private static readonly bodyCache;
|
|
13
14
|
private static readBodyCached;
|
|
14
15
|
/**
|
package/dist/h3/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as Handler, d as ApiResourceMiddleware, f as ControllerAction, i as H3App, m as HttpMethod, o as HttpContext, r as Route, s as Middleware, t as CoreRouter } from "../router-
|
|
1
|
+
import { a as Handler, d as ApiResourceMiddleware, f as ControllerAction, i as H3App, m as HttpMethod, o as HttpContext, r as Route, s as Middleware, t as CoreRouter } from "../router-DdBiXfPU.mjs";
|
|
2
2
|
import { H3 } from "h3";
|
|
3
3
|
|
|
4
4
|
//#region src/h3/router.d.ts
|
|
@@ -9,6 +9,7 @@ import { H3 } from "h3";
|
|
|
9
9
|
* @repository https://github.com/toneflix/clear-router
|
|
10
10
|
*/
|
|
11
11
|
declare class Router extends CoreRouter {
|
|
12
|
+
protected static routerStateNamespace: string;
|
|
12
13
|
private static readonly bodyCache;
|
|
13
14
|
private static readBodyCached;
|
|
14
15
|
/**
|
package/dist/h3/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as CoreRouter } from "../router-
|
|
1
|
+
import { t as CoreRouter } from "../router-CHaZi7NS.mjs";
|
|
2
2
|
import { getQuery, getRouterParams, readBody } from "h3";
|
|
3
3
|
|
|
4
4
|
//#region src/h3/router.ts
|
|
@@ -9,6 +9,7 @@ import { getQuery, getRouterParams, readBody } from "h3";
|
|
|
9
9
|
* @repository https://github.com/toneflix/clear-router
|
|
10
10
|
*/
|
|
11
11
|
var Router = class Router extends CoreRouter {
|
|
12
|
+
static routerStateNamespace = "clear-router:h3";
|
|
12
13
|
static bodyCache = /* @__PURE__ */ new WeakMap();
|
|
13
14
|
static async readBodyCached(ctx) {
|
|
14
15
|
if (this.bodyCache.has(ctx)) {
|
|
@@ -202,7 +203,7 @@ var Router = class Router extends CoreRouter {
|
|
|
202
203
|
try {
|
|
203
204
|
const ctx = event;
|
|
204
205
|
const reqBody = await Router.readBodyCached(ctx);
|
|
205
|
-
if (Router.resolveMethodOverride(ctx.req.method, ctx.req.headers, reqBody) !== method) return;
|
|
206
|
+
if (Router.resolveMethodOverride(ctx.req.method, ctx.req.headers, reqBody) !== method) return Symbol.for("h3.notFound");
|
|
206
207
|
const inst = instance ?? route;
|
|
207
208
|
Router.bindRequestToInstance(ctx, inst, route, {
|
|
208
209
|
body: reqBody,
|
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-C-c43ybe.cjs');
|
|
3
3
|
|
|
4
4
|
//#region src/hono/router.ts
|
|
5
5
|
/**
|
|
@@ -9,6 +9,7 @@ const require_router = require('../router-Ba2MVNn-.cjs');
|
|
|
9
9
|
* @repository https://github.com/toneflix/clear-router
|
|
10
10
|
*/
|
|
11
11
|
var Router = class Router extends require_router.CoreRouter {
|
|
12
|
+
static routerStateNamespace = "clear-router:hono";
|
|
12
13
|
static bodyCache = /* @__PURE__ */ new WeakMap();
|
|
13
14
|
static toResponse(ctx, value) {
|
|
14
15
|
if (value instanceof Response) return value;
|
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-DhBN2GwJ.cjs";
|
|
2
2
|
import { Context, HonoRequest, MiddlewareHandler } from "hono";
|
|
3
3
|
|
|
4
4
|
//#region types/hono.d.ts
|
|
@@ -21,6 +21,7 @@ type HonoApp = { [K in 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' |
|
|
|
21
21
|
* @repository https://github.com/toneflix/clear-router
|
|
22
22
|
*/
|
|
23
23
|
declare class Router extends CoreRouter {
|
|
24
|
+
protected static routerStateNamespace: string;
|
|
24
25
|
private static readonly bodyCache;
|
|
25
26
|
private static toResponse;
|
|
26
27
|
private static getParams;
|
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-DdBiXfPU.mjs";
|
|
2
2
|
import { Context, HonoRequest, MiddlewareHandler } from "hono";
|
|
3
3
|
|
|
4
4
|
//#region types/hono.d.ts
|
|
@@ -21,6 +21,7 @@ type HonoApp = { [K in 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' |
|
|
|
21
21
|
* @repository https://github.com/toneflix/clear-router
|
|
22
22
|
*/
|
|
23
23
|
declare class Router extends CoreRouter {
|
|
24
|
+
protected static routerStateNamespace: string;
|
|
24
25
|
private static readonly bodyCache;
|
|
25
26
|
private static toResponse;
|
|
26
27
|
private static getParams;
|
package/dist/hono/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as CoreRouter } from "../router-
|
|
1
|
+
import { t as CoreRouter } from "../router-CHaZi7NS.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/hono/router.ts
|
|
4
4
|
/**
|
|
@@ -8,6 +8,7 @@ import { t as CoreRouter } from "../router-Bug2IE_u.mjs";
|
|
|
8
8
|
* @repository https://github.com/toneflix/clear-router
|
|
9
9
|
*/
|
|
10
10
|
var Router = class Router extends CoreRouter {
|
|
11
|
+
static routerStateNamespace = "clear-router:hono";
|
|
11
12
|
static bodyCache = /* @__PURE__ */ new WeakMap();
|
|
12
13
|
static toResponse(ctx, value) {
|
|
13
14
|
if (value instanceof Response) return value;
|
package/dist/index.cjs
CHANGED
|
@@ -68,6 +68,70 @@ var Route = class {
|
|
|
68
68
|
* @repository https://github.com/toneflix/clear-router
|
|
69
69
|
*/
|
|
70
70
|
var CoreRouter = class {
|
|
71
|
+
static routerStateNamespace = "clear-router:core";
|
|
72
|
+
static stateStoreKey = Symbol.for("clear-router:router-state");
|
|
73
|
+
static stateBoundKey = Symbol.for("clear-router:router-state-bound");
|
|
74
|
+
static resolveStateNamespace() {
|
|
75
|
+
return String(this.routerStateNamespace || this.name || "clear-router:core");
|
|
76
|
+
}
|
|
77
|
+
static getStateStore() {
|
|
78
|
+
const g = globalThis;
|
|
79
|
+
if (!g[this.stateStoreKey]) g[this.stateStoreKey] = Object.create(null);
|
|
80
|
+
return g[this.stateStoreKey];
|
|
81
|
+
}
|
|
82
|
+
static createDefaultState() {
|
|
83
|
+
return {
|
|
84
|
+
config: { methodOverride: {
|
|
85
|
+
enabled: true,
|
|
86
|
+
bodyKeys: ["_method"],
|
|
87
|
+
headerKeys: ["x-http-method"]
|
|
88
|
+
} },
|
|
89
|
+
groupContext: new node_async_hooks.AsyncLocalStorage(),
|
|
90
|
+
routes: [],
|
|
91
|
+
routesByPathMethod: {},
|
|
92
|
+
routesByMethod: {},
|
|
93
|
+
prefix: "",
|
|
94
|
+
groupMiddlewares: [],
|
|
95
|
+
globalMiddlewares: []
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
static bindStateAccessors() {
|
|
99
|
+
if (Object.prototype.hasOwnProperty.call(this, this.stateBoundKey)) return;
|
|
100
|
+
const namespace = this.resolveStateNamespace();
|
|
101
|
+
const store = this.getStateStore();
|
|
102
|
+
if (!store[namespace]) store[namespace] = this.createDefaultState();
|
|
103
|
+
for (const key of [
|
|
104
|
+
"config",
|
|
105
|
+
"groupContext",
|
|
106
|
+
"routes",
|
|
107
|
+
"routesByPathMethod",
|
|
108
|
+
"routesByMethod",
|
|
109
|
+
"prefix",
|
|
110
|
+
"groupMiddlewares",
|
|
111
|
+
"globalMiddlewares"
|
|
112
|
+
]) Object.defineProperty(this, key, {
|
|
113
|
+
get() {
|
|
114
|
+
const ns = this.resolveStateNamespace();
|
|
115
|
+
const registry = this.getStateStore();
|
|
116
|
+
if (!registry[ns]) registry[ns] = this.createDefaultState();
|
|
117
|
+
return registry[ns][key];
|
|
118
|
+
},
|
|
119
|
+
set(value) {
|
|
120
|
+
const ns = this.resolveStateNamespace();
|
|
121
|
+
const registry = this.getStateStore();
|
|
122
|
+
if (!registry[ns]) registry[ns] = this.createDefaultState();
|
|
123
|
+
registry[ns][key] = value;
|
|
124
|
+
},
|
|
125
|
+
configurable: true,
|
|
126
|
+
enumerable: true
|
|
127
|
+
});
|
|
128
|
+
Object.defineProperty(this, this.stateBoundKey, {
|
|
129
|
+
value: true,
|
|
130
|
+
configurable: false,
|
|
131
|
+
enumerable: false,
|
|
132
|
+
writable: false
|
|
133
|
+
});
|
|
134
|
+
}
|
|
71
135
|
static createDefaultOptionsHandler() {
|
|
72
136
|
return (ctx) => {
|
|
73
137
|
const allow = "GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD";
|
|
@@ -106,18 +170,19 @@ var CoreRouter = class {
|
|
|
106
170
|
static groupMiddlewares = [];
|
|
107
171
|
static globalMiddlewares = [];
|
|
108
172
|
static ensureState() {
|
|
109
|
-
|
|
173
|
+
this.bindStateAccessors();
|
|
174
|
+
if (!this.config) this.config = { methodOverride: {
|
|
110
175
|
enabled: true,
|
|
111
176
|
bodyKeys: ["_method"],
|
|
112
177
|
headerKeys: ["x-http-method"]
|
|
113
178
|
} };
|
|
114
|
-
if (!
|
|
115
|
-
if (!
|
|
116
|
-
if (!
|
|
117
|
-
if (!
|
|
118
|
-
if (
|
|
119
|
-
if (!
|
|
120
|
-
if (!
|
|
179
|
+
if (!this.groupContext) this.groupContext = new node_async_hooks.AsyncLocalStorage();
|
|
180
|
+
if (!Array.isArray(this.routes)) this.routes = [];
|
|
181
|
+
if (!this.routesByPathMethod || typeof this.routesByPathMethod !== "object") this.routesByPathMethod = {};
|
|
182
|
+
if (!this.routesByMethod || typeof this.routesByMethod !== "object") this.routesByMethod = {};
|
|
183
|
+
if (typeof this.prefix !== "string") this.prefix = "";
|
|
184
|
+
if (!Array.isArray(this.groupMiddlewares)) this.groupMiddlewares = [];
|
|
185
|
+
if (!Array.isArray(this.globalMiddlewares)) this.globalMiddlewares = [];
|
|
121
186
|
}
|
|
122
187
|
/**
|
|
123
188
|
* Normalizes a path by ensuring it starts with a single slash and does not have trailing
|
package/dist/index.d.cts
CHANGED
|
@@ -89,6 +89,31 @@ declare abstract class Controller<X = any> {
|
|
|
89
89
|
* @repository https://github.com/toneflix/clear-router
|
|
90
90
|
*/
|
|
91
91
|
declare abstract class CoreRouter {
|
|
92
|
+
protected static routerStateNamespace: string;
|
|
93
|
+
private static readonly stateStoreKey;
|
|
94
|
+
private static readonly stateBoundKey;
|
|
95
|
+
protected static resolveStateNamespace(this: any): string;
|
|
96
|
+
protected static getStateStore(): Record<string, any>;
|
|
97
|
+
protected static createDefaultState(): {
|
|
98
|
+
config: {
|
|
99
|
+
methodOverride: {
|
|
100
|
+
enabled: boolean;
|
|
101
|
+
bodyKeys: string[];
|
|
102
|
+
headerKeys: string[];
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
groupContext: AsyncLocalStorage<{
|
|
106
|
+
prefix: string;
|
|
107
|
+
groupMiddlewares: any[];
|
|
108
|
+
}>;
|
|
109
|
+
routes: Array<Route<any, any, any>>;
|
|
110
|
+
routesByPathMethod: Record<string, Route<any, any, any>>;
|
|
111
|
+
routesByMethod: { [method in Uppercase<HttpMethod>]?: Array<Route<any, any, any>> };
|
|
112
|
+
prefix: string;
|
|
113
|
+
groupMiddlewares: any[];
|
|
114
|
+
globalMiddlewares: any[];
|
|
115
|
+
};
|
|
116
|
+
protected static bindStateAccessors(this: any): void;
|
|
92
117
|
protected static createDefaultOptionsHandler(): any;
|
|
93
118
|
static config: RouterConfig;
|
|
94
119
|
protected static groupContext: AsyncLocalStorage<{
|
package/dist/index.d.mts
CHANGED
|
@@ -89,6 +89,31 @@ declare abstract class Controller<X = any> {
|
|
|
89
89
|
* @repository https://github.com/toneflix/clear-router
|
|
90
90
|
*/
|
|
91
91
|
declare abstract class CoreRouter {
|
|
92
|
+
protected static routerStateNamespace: string;
|
|
93
|
+
private static readonly stateStoreKey;
|
|
94
|
+
private static readonly stateBoundKey;
|
|
95
|
+
protected static resolveStateNamespace(this: any): string;
|
|
96
|
+
protected static getStateStore(): Record<string, any>;
|
|
97
|
+
protected static createDefaultState(): {
|
|
98
|
+
config: {
|
|
99
|
+
methodOverride: {
|
|
100
|
+
enabled: boolean;
|
|
101
|
+
bodyKeys: string[];
|
|
102
|
+
headerKeys: string[];
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
groupContext: AsyncLocalStorage<{
|
|
106
|
+
prefix: string;
|
|
107
|
+
groupMiddlewares: any[];
|
|
108
|
+
}>;
|
|
109
|
+
routes: Array<Route<any, any, any>>;
|
|
110
|
+
routesByPathMethod: Record<string, Route<any, any, any>>;
|
|
111
|
+
routesByMethod: { [method in Uppercase<HttpMethod>]?: Array<Route<any, any, any>> };
|
|
112
|
+
prefix: string;
|
|
113
|
+
groupMiddlewares: any[];
|
|
114
|
+
globalMiddlewares: any[];
|
|
115
|
+
};
|
|
116
|
+
protected static bindStateAccessors(this: any): void;
|
|
92
117
|
protected static createDefaultOptionsHandler(): any;
|
|
93
118
|
static config: RouterConfig;
|
|
94
119
|
protected static groupContext: AsyncLocalStorage<{
|
package/dist/index.mjs
CHANGED
|
@@ -67,6 +67,70 @@ var Route = class {
|
|
|
67
67
|
* @repository https://github.com/toneflix/clear-router
|
|
68
68
|
*/
|
|
69
69
|
var CoreRouter = class {
|
|
70
|
+
static routerStateNamespace = "clear-router:core";
|
|
71
|
+
static stateStoreKey = Symbol.for("clear-router:router-state");
|
|
72
|
+
static stateBoundKey = Symbol.for("clear-router:router-state-bound");
|
|
73
|
+
static resolveStateNamespace() {
|
|
74
|
+
return String(this.routerStateNamespace || this.name || "clear-router:core");
|
|
75
|
+
}
|
|
76
|
+
static getStateStore() {
|
|
77
|
+
const g = globalThis;
|
|
78
|
+
if (!g[this.stateStoreKey]) g[this.stateStoreKey] = Object.create(null);
|
|
79
|
+
return g[this.stateStoreKey];
|
|
80
|
+
}
|
|
81
|
+
static createDefaultState() {
|
|
82
|
+
return {
|
|
83
|
+
config: { methodOverride: {
|
|
84
|
+
enabled: true,
|
|
85
|
+
bodyKeys: ["_method"],
|
|
86
|
+
headerKeys: ["x-http-method"]
|
|
87
|
+
} },
|
|
88
|
+
groupContext: new AsyncLocalStorage(),
|
|
89
|
+
routes: [],
|
|
90
|
+
routesByPathMethod: {},
|
|
91
|
+
routesByMethod: {},
|
|
92
|
+
prefix: "",
|
|
93
|
+
groupMiddlewares: [],
|
|
94
|
+
globalMiddlewares: []
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
static bindStateAccessors() {
|
|
98
|
+
if (Object.prototype.hasOwnProperty.call(this, this.stateBoundKey)) return;
|
|
99
|
+
const namespace = this.resolveStateNamespace();
|
|
100
|
+
const store = this.getStateStore();
|
|
101
|
+
if (!store[namespace]) store[namespace] = this.createDefaultState();
|
|
102
|
+
for (const key of [
|
|
103
|
+
"config",
|
|
104
|
+
"groupContext",
|
|
105
|
+
"routes",
|
|
106
|
+
"routesByPathMethod",
|
|
107
|
+
"routesByMethod",
|
|
108
|
+
"prefix",
|
|
109
|
+
"groupMiddlewares",
|
|
110
|
+
"globalMiddlewares"
|
|
111
|
+
]) Object.defineProperty(this, key, {
|
|
112
|
+
get() {
|
|
113
|
+
const ns = this.resolveStateNamespace();
|
|
114
|
+
const registry = this.getStateStore();
|
|
115
|
+
if (!registry[ns]) registry[ns] = this.createDefaultState();
|
|
116
|
+
return registry[ns][key];
|
|
117
|
+
},
|
|
118
|
+
set(value) {
|
|
119
|
+
const ns = this.resolveStateNamespace();
|
|
120
|
+
const registry = this.getStateStore();
|
|
121
|
+
if (!registry[ns]) registry[ns] = this.createDefaultState();
|
|
122
|
+
registry[ns][key] = value;
|
|
123
|
+
},
|
|
124
|
+
configurable: true,
|
|
125
|
+
enumerable: true
|
|
126
|
+
});
|
|
127
|
+
Object.defineProperty(this, this.stateBoundKey, {
|
|
128
|
+
value: true,
|
|
129
|
+
configurable: false,
|
|
130
|
+
enumerable: false,
|
|
131
|
+
writable: false
|
|
132
|
+
});
|
|
133
|
+
}
|
|
70
134
|
static createDefaultOptionsHandler() {
|
|
71
135
|
return (ctx) => {
|
|
72
136
|
const allow = "GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD";
|
|
@@ -105,18 +169,19 @@ var CoreRouter = class {
|
|
|
105
169
|
static groupMiddlewares = [];
|
|
106
170
|
static globalMiddlewares = [];
|
|
107
171
|
static ensureState() {
|
|
108
|
-
|
|
172
|
+
this.bindStateAccessors();
|
|
173
|
+
if (!this.config) this.config = { methodOverride: {
|
|
109
174
|
enabled: true,
|
|
110
175
|
bodyKeys: ["_method"],
|
|
111
176
|
headerKeys: ["x-http-method"]
|
|
112
177
|
} };
|
|
113
|
-
if (!
|
|
114
|
-
if (!
|
|
115
|
-
if (!
|
|
116
|
-
if (!
|
|
117
|
-
if (
|
|
118
|
-
if (!
|
|
119
|
-
if (!
|
|
178
|
+
if (!this.groupContext) this.groupContext = new AsyncLocalStorage();
|
|
179
|
+
if (!Array.isArray(this.routes)) this.routes = [];
|
|
180
|
+
if (!this.routesByPathMethod || typeof this.routesByPathMethod !== "object") this.routesByPathMethod = {};
|
|
181
|
+
if (!this.routesByMethod || typeof this.routesByMethod !== "object") this.routesByMethod = {};
|
|
182
|
+
if (typeof this.prefix !== "string") this.prefix = "";
|
|
183
|
+
if (!Array.isArray(this.groupMiddlewares)) this.groupMiddlewares = [];
|
|
184
|
+
if (!Array.isArray(this.globalMiddlewares)) this.globalMiddlewares = [];
|
|
120
185
|
}
|
|
121
186
|
/**
|
|
122
187
|
* Normalizes a path by ensuring it starts with a single slash and does not have trailing
|
|
@@ -57,6 +57,70 @@ var Route = class {
|
|
|
57
57
|
* @repository https://github.com/toneflix/clear-router
|
|
58
58
|
*/
|
|
59
59
|
var CoreRouter = class {
|
|
60
|
+
static routerStateNamespace = "clear-router:core";
|
|
61
|
+
static stateStoreKey = Symbol.for("clear-router:router-state");
|
|
62
|
+
static stateBoundKey = Symbol.for("clear-router:router-state-bound");
|
|
63
|
+
static resolveStateNamespace() {
|
|
64
|
+
return String(this.routerStateNamespace || this.name || "clear-router:core");
|
|
65
|
+
}
|
|
66
|
+
static getStateStore() {
|
|
67
|
+
const g = globalThis;
|
|
68
|
+
if (!g[this.stateStoreKey]) g[this.stateStoreKey] = Object.create(null);
|
|
69
|
+
return g[this.stateStoreKey];
|
|
70
|
+
}
|
|
71
|
+
static createDefaultState() {
|
|
72
|
+
return {
|
|
73
|
+
config: { methodOverride: {
|
|
74
|
+
enabled: true,
|
|
75
|
+
bodyKeys: ["_method"],
|
|
76
|
+
headerKeys: ["x-http-method"]
|
|
77
|
+
} },
|
|
78
|
+
groupContext: new node_async_hooks.AsyncLocalStorage(),
|
|
79
|
+
routes: [],
|
|
80
|
+
routesByPathMethod: {},
|
|
81
|
+
routesByMethod: {},
|
|
82
|
+
prefix: "",
|
|
83
|
+
groupMiddlewares: [],
|
|
84
|
+
globalMiddlewares: []
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
static bindStateAccessors() {
|
|
88
|
+
if (Object.prototype.hasOwnProperty.call(this, this.stateBoundKey)) return;
|
|
89
|
+
const namespace = this.resolveStateNamespace();
|
|
90
|
+
const store = this.getStateStore();
|
|
91
|
+
if (!store[namespace]) store[namespace] = this.createDefaultState();
|
|
92
|
+
for (const key of [
|
|
93
|
+
"config",
|
|
94
|
+
"groupContext",
|
|
95
|
+
"routes",
|
|
96
|
+
"routesByPathMethod",
|
|
97
|
+
"routesByMethod",
|
|
98
|
+
"prefix",
|
|
99
|
+
"groupMiddlewares",
|
|
100
|
+
"globalMiddlewares"
|
|
101
|
+
]) Object.defineProperty(this, key, {
|
|
102
|
+
get() {
|
|
103
|
+
const ns = this.resolveStateNamespace();
|
|
104
|
+
const registry = this.getStateStore();
|
|
105
|
+
if (!registry[ns]) registry[ns] = this.createDefaultState();
|
|
106
|
+
return registry[ns][key];
|
|
107
|
+
},
|
|
108
|
+
set(value) {
|
|
109
|
+
const ns = this.resolveStateNamespace();
|
|
110
|
+
const registry = this.getStateStore();
|
|
111
|
+
if (!registry[ns]) registry[ns] = this.createDefaultState();
|
|
112
|
+
registry[ns][key] = value;
|
|
113
|
+
},
|
|
114
|
+
configurable: true,
|
|
115
|
+
enumerable: true
|
|
116
|
+
});
|
|
117
|
+
Object.defineProperty(this, this.stateBoundKey, {
|
|
118
|
+
value: true,
|
|
119
|
+
configurable: false,
|
|
120
|
+
enumerable: false,
|
|
121
|
+
writable: false
|
|
122
|
+
});
|
|
123
|
+
}
|
|
60
124
|
static createDefaultOptionsHandler() {
|
|
61
125
|
return (ctx) => {
|
|
62
126
|
const allow = "GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD";
|
|
@@ -95,18 +159,19 @@ var CoreRouter = class {
|
|
|
95
159
|
static groupMiddlewares = [];
|
|
96
160
|
static globalMiddlewares = [];
|
|
97
161
|
static ensureState() {
|
|
98
|
-
|
|
162
|
+
this.bindStateAccessors();
|
|
163
|
+
if (!this.config) this.config = { methodOverride: {
|
|
99
164
|
enabled: true,
|
|
100
165
|
bodyKeys: ["_method"],
|
|
101
166
|
headerKeys: ["x-http-method"]
|
|
102
167
|
} };
|
|
103
|
-
if (!
|
|
104
|
-
if (!
|
|
105
|
-
if (!
|
|
106
|
-
if (!
|
|
107
|
-
if (
|
|
108
|
-
if (!
|
|
109
|
-
if (!
|
|
168
|
+
if (!this.groupContext) this.groupContext = new node_async_hooks.AsyncLocalStorage();
|
|
169
|
+
if (!Array.isArray(this.routes)) this.routes = [];
|
|
170
|
+
if (!this.routesByPathMethod || typeof this.routesByPathMethod !== "object") this.routesByPathMethod = {};
|
|
171
|
+
if (!this.routesByMethod || typeof this.routesByMethod !== "object") this.routesByMethod = {};
|
|
172
|
+
if (typeof this.prefix !== "string") this.prefix = "";
|
|
173
|
+
if (!Array.isArray(this.groupMiddlewares)) this.groupMiddlewares = [];
|
|
174
|
+
if (!Array.isArray(this.globalMiddlewares)) this.globalMiddlewares = [];
|
|
110
175
|
}
|
|
111
176
|
/**
|
|
112
177
|
* Normalizes a path by ensuring it starts with a single slash and does not have trailing
|
|
@@ -57,6 +57,70 @@ var Route = class {
|
|
|
57
57
|
* @repository https://github.com/toneflix/clear-router
|
|
58
58
|
*/
|
|
59
59
|
var CoreRouter = class {
|
|
60
|
+
static routerStateNamespace = "clear-router:core";
|
|
61
|
+
static stateStoreKey = Symbol.for("clear-router:router-state");
|
|
62
|
+
static stateBoundKey = Symbol.for("clear-router:router-state-bound");
|
|
63
|
+
static resolveStateNamespace() {
|
|
64
|
+
return String(this.routerStateNamespace || this.name || "clear-router:core");
|
|
65
|
+
}
|
|
66
|
+
static getStateStore() {
|
|
67
|
+
const g = globalThis;
|
|
68
|
+
if (!g[this.stateStoreKey]) g[this.stateStoreKey] = Object.create(null);
|
|
69
|
+
return g[this.stateStoreKey];
|
|
70
|
+
}
|
|
71
|
+
static createDefaultState() {
|
|
72
|
+
return {
|
|
73
|
+
config: { methodOverride: {
|
|
74
|
+
enabled: true,
|
|
75
|
+
bodyKeys: ["_method"],
|
|
76
|
+
headerKeys: ["x-http-method"]
|
|
77
|
+
} },
|
|
78
|
+
groupContext: new AsyncLocalStorage(),
|
|
79
|
+
routes: [],
|
|
80
|
+
routesByPathMethod: {},
|
|
81
|
+
routesByMethod: {},
|
|
82
|
+
prefix: "",
|
|
83
|
+
groupMiddlewares: [],
|
|
84
|
+
globalMiddlewares: []
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
static bindStateAccessors() {
|
|
88
|
+
if (Object.prototype.hasOwnProperty.call(this, this.stateBoundKey)) return;
|
|
89
|
+
const namespace = this.resolveStateNamespace();
|
|
90
|
+
const store = this.getStateStore();
|
|
91
|
+
if (!store[namespace]) store[namespace] = this.createDefaultState();
|
|
92
|
+
for (const key of [
|
|
93
|
+
"config",
|
|
94
|
+
"groupContext",
|
|
95
|
+
"routes",
|
|
96
|
+
"routesByPathMethod",
|
|
97
|
+
"routesByMethod",
|
|
98
|
+
"prefix",
|
|
99
|
+
"groupMiddlewares",
|
|
100
|
+
"globalMiddlewares"
|
|
101
|
+
]) Object.defineProperty(this, key, {
|
|
102
|
+
get() {
|
|
103
|
+
const ns = this.resolveStateNamespace();
|
|
104
|
+
const registry = this.getStateStore();
|
|
105
|
+
if (!registry[ns]) registry[ns] = this.createDefaultState();
|
|
106
|
+
return registry[ns][key];
|
|
107
|
+
},
|
|
108
|
+
set(value) {
|
|
109
|
+
const ns = this.resolveStateNamespace();
|
|
110
|
+
const registry = this.getStateStore();
|
|
111
|
+
if (!registry[ns]) registry[ns] = this.createDefaultState();
|
|
112
|
+
registry[ns][key] = value;
|
|
113
|
+
},
|
|
114
|
+
configurable: true,
|
|
115
|
+
enumerable: true
|
|
116
|
+
});
|
|
117
|
+
Object.defineProperty(this, this.stateBoundKey, {
|
|
118
|
+
value: true,
|
|
119
|
+
configurable: false,
|
|
120
|
+
enumerable: false,
|
|
121
|
+
writable: false
|
|
122
|
+
});
|
|
123
|
+
}
|
|
60
124
|
static createDefaultOptionsHandler() {
|
|
61
125
|
return (ctx) => {
|
|
62
126
|
const allow = "GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD";
|
|
@@ -95,18 +159,19 @@ var CoreRouter = class {
|
|
|
95
159
|
static groupMiddlewares = [];
|
|
96
160
|
static globalMiddlewares = [];
|
|
97
161
|
static ensureState() {
|
|
98
|
-
|
|
162
|
+
this.bindStateAccessors();
|
|
163
|
+
if (!this.config) this.config = { methodOverride: {
|
|
99
164
|
enabled: true,
|
|
100
165
|
bodyKeys: ["_method"],
|
|
101
166
|
headerKeys: ["x-http-method"]
|
|
102
167
|
} };
|
|
103
|
-
if (!
|
|
104
|
-
if (!
|
|
105
|
-
if (!
|
|
106
|
-
if (!
|
|
107
|
-
if (
|
|
108
|
-
if (!
|
|
109
|
-
if (!
|
|
168
|
+
if (!this.groupContext) this.groupContext = new AsyncLocalStorage();
|
|
169
|
+
if (!Array.isArray(this.routes)) this.routes = [];
|
|
170
|
+
if (!this.routesByPathMethod || typeof this.routesByPathMethod !== "object") this.routesByPathMethod = {};
|
|
171
|
+
if (!this.routesByMethod || typeof this.routesByMethod !== "object") this.routesByMethod = {};
|
|
172
|
+
if (typeof this.prefix !== "string") this.prefix = "";
|
|
173
|
+
if (!Array.isArray(this.groupMiddlewares)) this.groupMiddlewares = [];
|
|
174
|
+
if (!Array.isArray(this.globalMiddlewares)) this.globalMiddlewares = [];
|
|
110
175
|
}
|
|
111
176
|
/**
|
|
112
177
|
* Normalizes a path by ensuring it starts with a single slash and does not have trailing
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
-
import { NextFunction, Request, Response as Response$1 } from "express";
|
|
3
2
|
import { H3, H3Event, Middleware, TypedServerRequest } from "h3";
|
|
3
|
+
import { NextFunction, Request, Response as Response$1 } from "express";
|
|
4
4
|
|
|
5
5
|
//#region types/basic.d.ts
|
|
6
6
|
/**
|
|
@@ -154,6 +154,31 @@ declare abstract class Controller<X = any> {
|
|
|
154
154
|
* @repository https://github.com/toneflix/clear-router
|
|
155
155
|
*/
|
|
156
156
|
declare abstract class CoreRouter {
|
|
157
|
+
protected static routerStateNamespace: string;
|
|
158
|
+
private static readonly stateStoreKey;
|
|
159
|
+
private static readonly stateBoundKey;
|
|
160
|
+
protected static resolveStateNamespace(this: any): string;
|
|
161
|
+
protected static getStateStore(): Record<string, any>;
|
|
162
|
+
protected static createDefaultState(): {
|
|
163
|
+
config: {
|
|
164
|
+
methodOverride: {
|
|
165
|
+
enabled: boolean;
|
|
166
|
+
bodyKeys: string[];
|
|
167
|
+
headerKeys: string[];
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
groupContext: AsyncLocalStorage<{
|
|
171
|
+
prefix: string;
|
|
172
|
+
groupMiddlewares: any[];
|
|
173
|
+
}>;
|
|
174
|
+
routes: Array<Route<any, any, any>>;
|
|
175
|
+
routesByPathMethod: Record<string, Route<any, any, any>>;
|
|
176
|
+
routesByMethod: { [method in Uppercase<HttpMethod>]?: Array<Route<any, any, any>> };
|
|
177
|
+
prefix: string;
|
|
178
|
+
groupMiddlewares: any[];
|
|
179
|
+
globalMiddlewares: any[];
|
|
180
|
+
};
|
|
181
|
+
protected static bindStateAccessors(this: any): void;
|
|
157
182
|
protected static createDefaultOptionsHandler(): any;
|
|
158
183
|
static config: RouterConfig;
|
|
159
184
|
protected static groupContext: AsyncLocalStorage<{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
-
import { H3, H3Event, Middleware, TypedServerRequest } from "h3";
|
|
3
2
|
import { NextFunction, Request, Response as Response$1 } from "express";
|
|
3
|
+
import { H3, H3Event, Middleware, TypedServerRequest } from "h3";
|
|
4
4
|
|
|
5
5
|
//#region types/basic.d.ts
|
|
6
6
|
/**
|
|
@@ -154,6 +154,31 @@ declare abstract class Controller<X = any> {
|
|
|
154
154
|
* @repository https://github.com/toneflix/clear-router
|
|
155
155
|
*/
|
|
156
156
|
declare abstract class CoreRouter {
|
|
157
|
+
protected static routerStateNamespace: string;
|
|
158
|
+
private static readonly stateStoreKey;
|
|
159
|
+
private static readonly stateBoundKey;
|
|
160
|
+
protected static resolveStateNamespace(this: any): string;
|
|
161
|
+
protected static getStateStore(): Record<string, any>;
|
|
162
|
+
protected static createDefaultState(): {
|
|
163
|
+
config: {
|
|
164
|
+
methodOverride: {
|
|
165
|
+
enabled: boolean;
|
|
166
|
+
bodyKeys: string[];
|
|
167
|
+
headerKeys: string[];
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
groupContext: AsyncLocalStorage<{
|
|
171
|
+
prefix: string;
|
|
172
|
+
groupMiddlewares: any[];
|
|
173
|
+
}>;
|
|
174
|
+
routes: Array<Route<any, any, any>>;
|
|
175
|
+
routesByPathMethod: Record<string, Route<any, any, any>>;
|
|
176
|
+
routesByMethod: { [method in Uppercase<HttpMethod>]?: Array<Route<any, any, any>> };
|
|
177
|
+
prefix: string;
|
|
178
|
+
groupMiddlewares: any[];
|
|
179
|
+
globalMiddlewares: any[];
|
|
180
|
+
};
|
|
181
|
+
protected static bindStateAccessors(this: any): void;
|
|
157
182
|
protected static createDefaultOptionsHandler(): any;
|
|
158
183
|
static config: RouterConfig;
|
|
159
184
|
protected static groupContext: AsyncLocalStorage<{
|
package/package.json
CHANGED