clear-router 2.0.4 → 2.0.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.
@@ -86,9 +86,10 @@ var Router = class {
86
86
  };
87
87
  const only = options?.only || Object.keys(actions);
88
88
  const except = options?.except || [];
89
+ const preController = typeof controller === "function" ? new controller() : controller;
89
90
  for (const action of only) {
90
91
  if (except.includes(action)) continue;
91
- if (typeof controller[action] === "function") {
92
+ if (typeof preController[action] === "function") {
92
93
  const { method, path } = actions[action];
93
94
  this.add(method, `${basePath}${path}`, [controller, action]);
94
95
  }
@@ -84,9 +84,10 @@ var Router = class {
84
84
  };
85
85
  const only = options?.only || Object.keys(actions);
86
86
  const except = options?.except || [];
87
+ const preController = typeof controller === "function" ? new controller() : controller;
87
88
  for (const action of only) {
88
89
  if (except.includes(action)) continue;
89
- if (typeof controller[action] === "function") {
90
+ if (typeof preController[action] === "function") {
90
91
  const { method, path } = actions[action];
91
92
  this.add(method, `${basePath}${path}`, [controller, action]);
92
93
  }
@@ -85,9 +85,10 @@ var Router = class {
85
85
  };
86
86
  const only = options?.only || Object.keys(actions);
87
87
  const except = options?.except || [];
88
+ const preController = typeof controller === "function" ? new controller() : controller;
88
89
  for (const action of only) {
89
90
  if (except.includes(action)) continue;
90
- if (typeof controller[action] === "function") {
91
+ if (typeof preController[action] === "function") {
91
92
  const { method, path } = actions[action];
92
93
  this.add(method, `${basePath}${path}`, [controller, action]);
93
94
  }
@@ -83,9 +83,10 @@ var Router = class {
83
83
  };
84
84
  const only = options?.only || Object.keys(actions);
85
85
  const except = options?.except || [];
86
+ const preController = typeof controller === "function" ? new controller() : controller;
86
87
  for (const action of only) {
87
88
  if (except.includes(action)) continue;
88
- if (typeof controller[action] === "function") {
89
+ if (typeof preController[action] === "function") {
89
90
  const { method, path } = actions[action];
90
91
  this.add(method, `${basePath}${path}`, [controller, action]);
91
92
  }
@@ -3,5 +3,22 @@
3
3
  * Controller method reference
4
4
  */
5
5
  type ControllerHandler = [any, string];
6
+ /**
7
+ * HTTP methods supported by the router
8
+ */
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
+ /**
20
+ * Common controller action names
21
+ */
22
+ type ControllerAction = 'index' | 'show' | 'create' | 'update' | 'destroy';
6
23
  //#endregion
7
- export { ControllerHandler };
24
+ export { ControllerAction, ControllerHandler, HttpMethod, RouteInfo };
@@ -0,0 +1 @@
1
+ export { };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clear-router",
3
- "version": "2.0.4",
3
+ "version": "2.0.6",
4
4
  "description": "Laravel-style routing system for Express.js and H3, with CommonJS, ESM, and TypeScript support",
5
5
  "keywords": [
6
6
  "h3",
@@ -32,16 +32,17 @@
32
32
  "module": "dist/express/routes.mjs",
33
33
  "types": "dist/express/routes.d.mts",
34
34
  "exports": {
35
- "./express": "./dist/types/express.mjs",
36
35
  "./express/router": {
37
36
  "import": "./dist/express/router.mjs",
38
37
  "require": "./dist/express/router.cjs"
39
38
  },
40
- "./h3": "./dist/types/h3.mjs",
41
39
  "./h3/router": {
42
40
  "import": "./dist/h3/router.mjs",
43
41
  "require": "./dist/h3/router.cjs"
44
42
  },
43
+ "./types/basic": "./dist/types/basic.mjs",
44
+ "./types/express": "./dist/types/express.mjs",
45
+ "./types/h3": "./dist/types/h3.mjs",
45
46
  "./package.json": "./package.json"
46
47
  },
47
48
  "files": [