clear-router 2.1.5 → 2.1.6
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/{Route-BtmoiYq5.mjs → Route-BbPXcDGX.mjs} +8 -0
- package/dist/{Route-97p-tEbS.cjs → Route-DhC4kNPX.cjs} +8 -0
- package/dist/express/index.cjs +2 -7
- package/dist/express/index.d.cts +2 -2
- package/dist/express/index.d.mts +2 -2
- package/dist/express/index.mjs +2 -7
- package/dist/{express-WiUTZlHA.d.mts → express-D9GR9yTH.d.mts} +5 -10
- package/dist/{express-sjYra4oE.d.cts → express-JHxK-EqQ.d.cts} +5 -10
- package/dist/h3/index.cjs +2 -7
- package/dist/h3/index.d.cts +3 -2
- package/dist/h3/index.d.mts +3 -2
- package/dist/h3/index.mjs +2 -7
- package/dist/index.cjs +8 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.mjs +8 -0
- package/dist/types/Route.d.mts +4 -0
- package/dist/types/basic.d.mts +1 -10
- package/package.json +1 -1
|
@@ -30,11 +30,19 @@ var Route = class {
|
|
|
30
30
|
path;
|
|
31
31
|
handler;
|
|
32
32
|
middlewares;
|
|
33
|
+
controllerName;
|
|
34
|
+
actionName;
|
|
35
|
+
handlerType;
|
|
36
|
+
middlewareCount;
|
|
33
37
|
constructor(methods, path, handler, middlewares = []) {
|
|
34
38
|
this.methods = methods;
|
|
35
39
|
this.path = path;
|
|
36
40
|
this.handler = handler;
|
|
37
41
|
this.middlewares = middlewares;
|
|
42
|
+
this.handlerType = Array.isArray(handler) ? "controller" : "function";
|
|
43
|
+
this.middlewareCount = middlewares.length;
|
|
44
|
+
this.controllerName = Array.isArray(handler) ? handler[0]?.name : void 0;
|
|
45
|
+
this.actionName = Array.isArray(handler) ? handler[1] : typeof handler === "function" ? handler.constructor.name ?? handler.name : void 0;
|
|
38
46
|
}
|
|
39
47
|
};
|
|
40
48
|
|
|
@@ -31,11 +31,19 @@ var Route = class {
|
|
|
31
31
|
path;
|
|
32
32
|
handler;
|
|
33
33
|
middlewares;
|
|
34
|
+
controllerName;
|
|
35
|
+
actionName;
|
|
36
|
+
handlerType;
|
|
37
|
+
middlewareCount;
|
|
34
38
|
constructor(methods, path, handler, middlewares = []) {
|
|
35
39
|
this.methods = methods;
|
|
36
40
|
this.path = path;
|
|
37
41
|
this.handler = handler;
|
|
38
42
|
this.middlewares = middlewares;
|
|
43
|
+
this.handlerType = Array.isArray(handler) ? "controller" : "function";
|
|
44
|
+
this.middlewareCount = middlewares.length;
|
|
45
|
+
this.controllerName = Array.isArray(handler) ? handler[0]?.name : void 0;
|
|
46
|
+
this.actionName = Array.isArray(handler) ? handler[1] : typeof handler === "function" ? handler.constructor.name ?? handler.name : void 0;
|
|
39
47
|
}
|
|
40
48
|
};
|
|
41
49
|
|
package/dist/express/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_Route = require('../Route-
|
|
2
|
+
const require_Route = require('../Route-DhC4kNPX.cjs');
|
|
3
3
|
|
|
4
4
|
//#region src/express/router.ts
|
|
5
5
|
/**
|
|
@@ -189,12 +189,7 @@ var Router = class Router {
|
|
|
189
189
|
* @returns Array of route information objects
|
|
190
190
|
*/
|
|
191
191
|
static allRoutes() {
|
|
192
|
-
return this.routes
|
|
193
|
-
methods: route.methods,
|
|
194
|
-
path: route.path,
|
|
195
|
-
middlewareCount: route.middlewares.length,
|
|
196
|
-
handlerType: typeof route.handler === "function" ? "function" : "controller"
|
|
197
|
-
}));
|
|
192
|
+
return this.routes;
|
|
198
193
|
}
|
|
199
194
|
static async apply(router) {
|
|
200
195
|
for (const route of this.routes) {
|
package/dist/express/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as Route, l as ControllerAction, n as HttpContext, r as Middleware, t as Handler, u as HttpMethod } from "../express-JHxK-EqQ.cjs";
|
|
2
2
|
import { Router as Router$1 } from "express";
|
|
3
3
|
|
|
4
4
|
//#region src/express/router.d.ts
|
|
@@ -117,7 +117,7 @@ declare class Router {
|
|
|
117
117
|
* Get all registered routes with their information
|
|
118
118
|
* @returns Array of route information objects
|
|
119
119
|
*/
|
|
120
|
-
static allRoutes():
|
|
120
|
+
static allRoutes(): Route<HttpContext, Middleware>[];
|
|
121
121
|
/**
|
|
122
122
|
* Apply all registered routes to the provided Express Router instance
|
|
123
123
|
* Handles controller-method binding and middleware application
|
package/dist/express/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as Route, l as ControllerAction, n as HttpContext, r as Middleware, t as Handler, u as HttpMethod } from "../express-D9GR9yTH.mjs";
|
|
2
2
|
import { Router as Router$1 } from "express";
|
|
3
3
|
|
|
4
4
|
//#region src/express/router.d.ts
|
|
@@ -117,7 +117,7 @@ declare class Router {
|
|
|
117
117
|
* Get all registered routes with their information
|
|
118
118
|
* @returns Array of route information objects
|
|
119
119
|
*/
|
|
120
|
-
static allRoutes():
|
|
120
|
+
static allRoutes(): Route<HttpContext, Middleware>[];
|
|
121
121
|
/**
|
|
122
122
|
* Apply all registered routes to the provided Express Router instance
|
|
123
123
|
* Handles controller-method binding and middleware application
|
package/dist/express/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as ClearRequest, t as Route } from "../Route-
|
|
1
|
+
import { n as ClearRequest, t as Route } from "../Route-BbPXcDGX.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/express/router.ts
|
|
4
4
|
/**
|
|
@@ -188,12 +188,7 @@ var Router = class Router {
|
|
|
188
188
|
* @returns Array of route information objects
|
|
189
189
|
*/
|
|
190
190
|
static allRoutes() {
|
|
191
|
-
return this.routes
|
|
192
|
-
methods: route.methods,
|
|
193
|
-
path: route.path,
|
|
194
|
-
middlewareCount: route.middlewares.length,
|
|
195
|
-
handlerType: typeof route.handler === "function" ? "function" : "controller"
|
|
196
|
-
}));
|
|
191
|
+
return this.routes;
|
|
197
192
|
}
|
|
198
193
|
static async apply(router) {
|
|
199
194
|
for (const route of this.routes) {
|
|
@@ -10,15 +10,6 @@ type ControllerHandler = [any, string];
|
|
|
10
10
|
* HTTP methods supported by the router
|
|
11
11
|
*/
|
|
12
12
|
type HttpMethod = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' | 'head';
|
|
13
|
-
/**
|
|
14
|
-
* Route information object
|
|
15
|
-
*/
|
|
16
|
-
interface RouteInfo {
|
|
17
|
-
methods: HttpMethod[];
|
|
18
|
-
path: string;
|
|
19
|
-
middlewareCount: number;
|
|
20
|
-
handlerType: 'function' | 'controller';
|
|
21
|
-
}
|
|
22
13
|
/**
|
|
23
14
|
* Common controller action names
|
|
24
15
|
*/
|
|
@@ -66,6 +57,10 @@ declare class Route<X = any, M = Middleware$1 | Middleware> {
|
|
|
66
57
|
path: string;
|
|
67
58
|
handler: Handler$1;
|
|
68
59
|
middlewares: M[];
|
|
60
|
+
controllerName?: string;
|
|
61
|
+
actionName?: string;
|
|
62
|
+
handlerType: 'function' | 'controller';
|
|
63
|
+
middlewareCount: number;
|
|
69
64
|
constructor(methods: HttpMethod[], path: string, handler: Handler$1, middlewares?: M[]);
|
|
70
65
|
}
|
|
71
66
|
//#endregion
|
|
@@ -120,4 +115,4 @@ type Handler = RouteHandler | ControllerHandler;
|
|
|
120
115
|
*/
|
|
121
116
|
type Middleware = (req: Request, res: Response$1, next: NextFunction) => any | Promise<any>;
|
|
122
117
|
//#endregion
|
|
123
|
-
export { H3App as a, Middleware$1 as c,
|
|
118
|
+
export { H3App as a, Middleware$1 as c, Route as i, ControllerAction as l, HttpContext as n, Handler$1 as o, Middleware as r, HttpContext$1 as s, Handler as t, HttpMethod as u };
|
|
@@ -10,15 +10,6 @@ type ControllerHandler = [any, string];
|
|
|
10
10
|
* HTTP methods supported by the router
|
|
11
11
|
*/
|
|
12
12
|
type HttpMethod = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' | 'head';
|
|
13
|
-
/**
|
|
14
|
-
* Route information object
|
|
15
|
-
*/
|
|
16
|
-
interface RouteInfo {
|
|
17
|
-
methods: HttpMethod[];
|
|
18
|
-
path: string;
|
|
19
|
-
middlewareCount: number;
|
|
20
|
-
handlerType: 'function' | 'controller';
|
|
21
|
-
}
|
|
22
13
|
/**
|
|
23
14
|
* Common controller action names
|
|
24
15
|
*/
|
|
@@ -66,6 +57,10 @@ declare class Route<X = any, M = Middleware$1 | Middleware> {
|
|
|
66
57
|
path: string;
|
|
67
58
|
handler: Handler$1;
|
|
68
59
|
middlewares: M[];
|
|
60
|
+
controllerName?: string;
|
|
61
|
+
actionName?: string;
|
|
62
|
+
handlerType: 'function' | 'controller';
|
|
63
|
+
middlewareCount: number;
|
|
69
64
|
constructor(methods: HttpMethod[], path: string, handler: Handler$1, middlewares?: M[]);
|
|
70
65
|
}
|
|
71
66
|
//#endregion
|
|
@@ -120,4 +115,4 @@ type Handler = RouteHandler | ControllerHandler;
|
|
|
120
115
|
*/
|
|
121
116
|
type Middleware = (req: Request, res: Response$1, next: NextFunction) => any | Promise<any>;
|
|
122
117
|
//#endregion
|
|
123
|
-
export { H3App as a, Middleware$1 as c,
|
|
118
|
+
export { H3App as a, Middleware$1 as c, Route as i, ControllerAction as l, HttpContext as n, Handler$1 as o, Middleware as r, HttpContext$1 as s, Handler as t, HttpMethod as u };
|
package/dist/h3/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_Route = require('../Route-
|
|
2
|
+
const require_Route = require('../Route-DhC4kNPX.cjs');
|
|
3
3
|
let h3 = require("h3");
|
|
4
4
|
|
|
5
5
|
//#region src/h3/router.ts
|
|
@@ -189,12 +189,7 @@ var Router = class Router {
|
|
|
189
189
|
* @returns Array of route information objects
|
|
190
190
|
*/
|
|
191
191
|
static allRoutes() {
|
|
192
|
-
return this.routes
|
|
193
|
-
methods: route.methods,
|
|
194
|
-
path: route.path,
|
|
195
|
-
middlewareCount: route.middlewares.length,
|
|
196
|
-
handlerType: typeof route.handler === "function" ? "function" : "controller"
|
|
197
|
-
}));
|
|
192
|
+
return this.routes;
|
|
198
193
|
}
|
|
199
194
|
/**
|
|
200
195
|
* Apply all registered routes to the provided H3 Router instance
|
package/dist/h3/index.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { a as H3App, c as Middleware,
|
|
1
|
+
import { a as H3App, c as Middleware, i as Route, l as ControllerAction, o as Handler, s as HttpContext, u as HttpMethod } from "../express-JHxK-EqQ.cjs";
|
|
2
|
+
import * as h3 from "h3";
|
|
2
3
|
import { H3 } from "h3";
|
|
3
4
|
|
|
4
5
|
//#region src/h3/router.d.ts
|
|
@@ -116,7 +117,7 @@ declare class Router {
|
|
|
116
117
|
* Get all registered routes with their information
|
|
117
118
|
* @returns Array of route information objects
|
|
118
119
|
*/
|
|
119
|
-
static allRoutes():
|
|
120
|
+
static allRoutes(): Route<h3.H3Event<h3.EventHandlerRequest>, Middleware>[];
|
|
120
121
|
/**
|
|
121
122
|
* Apply all registered routes to the provided H3 Router instance
|
|
122
123
|
* Handles controller-method binding and middleware application
|
package/dist/h3/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { a as H3App, c as Middleware,
|
|
1
|
+
import { a as H3App, c as Middleware, i as Route, l as ControllerAction, o as Handler, s as HttpContext, u as HttpMethod } from "../express-D9GR9yTH.mjs";
|
|
2
|
+
import * as h3 from "h3";
|
|
2
3
|
import { H3 } from "h3";
|
|
3
4
|
|
|
4
5
|
//#region src/h3/router.d.ts
|
|
@@ -116,7 +117,7 @@ declare class Router {
|
|
|
116
117
|
* Get all registered routes with their information
|
|
117
118
|
* @returns Array of route information objects
|
|
118
119
|
*/
|
|
119
|
-
static allRoutes():
|
|
120
|
+
static allRoutes(): Route<h3.H3Event<h3.EventHandlerRequest>, Middleware>[];
|
|
120
121
|
/**
|
|
121
122
|
* Apply all registered routes to the provided H3 Router instance
|
|
122
123
|
* Handles controller-method binding and middleware application
|
package/dist/h3/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as ClearRequest, t as Route } from "../Route-
|
|
1
|
+
import { n as ClearRequest, t as Route } from "../Route-BbPXcDGX.mjs";
|
|
2
2
|
import { getQuery, getRouterParams, readBody } from "h3";
|
|
3
3
|
|
|
4
4
|
//#region src/h3/router.ts
|
|
@@ -188,12 +188,7 @@ var Router = class Router {
|
|
|
188
188
|
* @returns Array of route information objects
|
|
189
189
|
*/
|
|
190
190
|
static allRoutes() {
|
|
191
|
-
return this.routes
|
|
192
|
-
methods: route.methods,
|
|
193
|
-
path: route.path,
|
|
194
|
-
middlewareCount: route.middlewares.length,
|
|
195
|
-
handlerType: typeof route.handler === "function" ? "function" : "controller"
|
|
196
|
-
}));
|
|
191
|
+
return this.routes;
|
|
197
192
|
}
|
|
198
193
|
/**
|
|
199
194
|
* Apply all registered routes to the provided H3 Router instance
|
package/dist/index.cjs
CHANGED
|
@@ -42,11 +42,19 @@ var Route = class {
|
|
|
42
42
|
path;
|
|
43
43
|
handler;
|
|
44
44
|
middlewares;
|
|
45
|
+
controllerName;
|
|
46
|
+
actionName;
|
|
47
|
+
handlerType;
|
|
48
|
+
middlewareCount;
|
|
45
49
|
constructor(methods, path, handler, middlewares = []) {
|
|
46
50
|
this.methods = methods;
|
|
47
51
|
this.path = path;
|
|
48
52
|
this.handler = handler;
|
|
49
53
|
this.middlewares = middlewares;
|
|
54
|
+
this.handlerType = Array.isArray(handler) ? "controller" : "function";
|
|
55
|
+
this.middlewareCount = middlewares.length;
|
|
56
|
+
this.controllerName = Array.isArray(handler) ? handler[0]?.name : void 0;
|
|
57
|
+
this.actionName = Array.isArray(handler) ? handler[1] : typeof handler === "function" ? handler.constructor.name ?? handler.name : void 0;
|
|
50
58
|
}
|
|
51
59
|
};
|
|
52
60
|
|
package/dist/index.d.cts
CHANGED
|
@@ -56,6 +56,10 @@ declare class Route<X = any, M = Middleware | Middleware$1> {
|
|
|
56
56
|
path: string;
|
|
57
57
|
handler: Handler;
|
|
58
58
|
middlewares: M[];
|
|
59
|
+
controllerName?: string;
|
|
60
|
+
actionName?: string;
|
|
61
|
+
handlerType: 'function' | 'controller';
|
|
62
|
+
middlewareCount: number;
|
|
59
63
|
constructor(methods: HttpMethod[], path: string, handler: Handler, middlewares?: M[]);
|
|
60
64
|
}
|
|
61
65
|
//#endregion
|
package/dist/index.d.mts
CHANGED
|
@@ -56,6 +56,10 @@ declare class Route<X = any, M = Middleware | Middleware$1> {
|
|
|
56
56
|
path: string;
|
|
57
57
|
handler: Handler;
|
|
58
58
|
middlewares: M[];
|
|
59
|
+
controllerName?: string;
|
|
60
|
+
actionName?: string;
|
|
61
|
+
handlerType: 'function' | 'controller';
|
|
62
|
+
middlewareCount: number;
|
|
59
63
|
constructor(methods: HttpMethod[], path: string, handler: Handler, middlewares?: M[]);
|
|
60
64
|
}
|
|
61
65
|
//#endregion
|
package/dist/index.mjs
CHANGED
|
@@ -40,11 +40,19 @@ var Route = class {
|
|
|
40
40
|
path;
|
|
41
41
|
handler;
|
|
42
42
|
middlewares;
|
|
43
|
+
controllerName;
|
|
44
|
+
actionName;
|
|
45
|
+
handlerType;
|
|
46
|
+
middlewareCount;
|
|
43
47
|
constructor(methods, path, handler, middlewares = []) {
|
|
44
48
|
this.methods = methods;
|
|
45
49
|
this.path = path;
|
|
46
50
|
this.handler = handler;
|
|
47
51
|
this.middlewares = middlewares;
|
|
52
|
+
this.handlerType = Array.isArray(handler) ? "controller" : "function";
|
|
53
|
+
this.middlewareCount = middlewares.length;
|
|
54
|
+
this.controllerName = Array.isArray(handler) ? handler[0]?.name : void 0;
|
|
55
|
+
this.actionName = Array.isArray(handler) ? handler[1] : typeof handler === "function" ? handler.constructor.name ?? handler.name : void 0;
|
|
48
56
|
}
|
|
49
57
|
};
|
|
50
58
|
|
package/dist/types/Route.d.mts
CHANGED
|
@@ -14,6 +14,10 @@ declare class Route<X = any, M = Middleware | Middleware$1> {
|
|
|
14
14
|
path: string;
|
|
15
15
|
handler: Handler;
|
|
16
16
|
middlewares: M[];
|
|
17
|
+
controllerName?: string;
|
|
18
|
+
actionName?: string;
|
|
19
|
+
handlerType: 'function' | 'controller';
|
|
20
|
+
middlewareCount: number;
|
|
17
21
|
constructor(methods: HttpMethod[], path: string, handler: Handler, middlewares?: M[]);
|
|
18
22
|
}
|
|
19
23
|
//#endregion
|
package/dist/types/basic.d.mts
CHANGED
|
@@ -7,15 +7,6 @@ type ControllerHandler = [any, string];
|
|
|
7
7
|
* HTTP methods supported by the router
|
|
8
8
|
*/
|
|
9
9
|
type HttpMethod = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' | 'head';
|
|
10
|
-
/**
|
|
11
|
-
* Route information object
|
|
12
|
-
*/
|
|
13
|
-
interface RouteInfo {
|
|
14
|
-
methods: HttpMethod[];
|
|
15
|
-
path: string;
|
|
16
|
-
middlewareCount: number;
|
|
17
|
-
handlerType: 'function' | 'controller';
|
|
18
|
-
}
|
|
19
10
|
/**
|
|
20
11
|
* Common controller action names
|
|
21
12
|
*/
|
|
@@ -25,4 +16,4 @@ type ControllerAction = 'index' | 'show' | 'create' | 'update' | 'destroy';
|
|
|
25
16
|
*/
|
|
26
17
|
type RequestData = Record<string, any>;
|
|
27
18
|
//#endregion
|
|
28
|
-
export { ControllerAction, ControllerHandler, HttpMethod, RequestData
|
|
19
|
+
export { ControllerAction, ControllerHandler, HttpMethod, RequestData };
|