clear-router 2.8.3 → 2.8.5

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 (61) hide show
  1. package/dist/ClearRequest.d.cts +5 -5
  2. package/dist/ClearRequest.d.mts +1 -1
  3. package/dist/Controller.d.mts +1 -1
  4. package/dist/ResourceRouteSelection.d.cts +3 -3
  5. package/dist/ResourceRoutes.cjs +1 -1
  6. package/dist/ResourceRoutes.d.cts +4 -4
  7. package/dist/ResourceRoutes.d.mts +1 -1
  8. package/dist/ResourceRoutes.mjs +1 -1
  9. package/dist/Route.d.cts +4 -4
  10. package/dist/Route.d.mts +1 -1
  11. package/dist/RouteGroup.cjs +36 -6
  12. package/dist/RouteGroup.d.cts +14 -5
  13. package/dist/RouteGroup.d.mts +12 -3
  14. package/dist/RouteGroup.mjs +36 -6
  15. package/dist/core/CoreRouter.cjs +2 -2
  16. package/dist/core/CoreRouter.d.cts +4 -4
  17. package/dist/core/CoreRouter.d.mts +1 -1
  18. package/dist/core/CoreRouter.mjs +2 -2
  19. package/dist/core/Request.d.cts +1 -1
  20. package/dist/core/Request.d.mts +2 -2
  21. package/dist/core/bindings.d.cts +6 -1
  22. package/dist/core/helpers.d.cts +1 -1
  23. package/dist/core/helpers.d.mts +1 -1
  24. package/dist/core/index.cjs +9 -0
  25. package/dist/core/index.mjs +2 -2
  26. package/dist/core/plugins.d.cts +2 -2
  27. package/dist/core/plugins.d.mts +1 -1
  28. package/dist/decorators/setup.d.mts +1 -0
  29. package/dist/express/router.d.cts +15 -15
  30. package/dist/express/router.d.mts +15 -15
  31. package/dist/fastify/router.d.cts +15 -15
  32. package/dist/fastify/router.d.mts +15 -15
  33. package/dist/h3/router.d.cts +15 -15
  34. package/dist/h3/router.d.mts +15 -15
  35. package/dist/hono/router.d.cts +15 -15
  36. package/dist/hono/router.d.mts +15 -15
  37. package/dist/index.d.cts +2 -2
  38. package/dist/index.d.mts +2 -2
  39. package/dist/koa/router.d.cts +17 -17
  40. package/dist/koa/router.d.mts +17 -17
  41. package/dist/types/basic.cjs +0 -0
  42. package/dist/types/basic.d.cts +8 -3
  43. package/dist/types/basic.d.mts +5 -4
  44. package/dist/types/express.cjs +0 -0
  45. package/dist/types/express.d.cts +36 -2
  46. package/dist/types/express.d.mts +3 -3
  47. package/dist/types/fastify.cjs +0 -0
  48. package/dist/types/fastify.d.cts +15 -3
  49. package/dist/types/fastify.d.mts +3 -3
  50. package/dist/types/h3.cjs +0 -0
  51. package/dist/types/h3.d.cts +42 -5
  52. package/dist/types/h3.d.mts +8 -6
  53. package/dist/types/hono.cjs +0 -0
  54. package/dist/types/hono.d.cts +18 -3
  55. package/dist/types/hono.d.mts +4 -3
  56. package/dist/types/koa.cjs +0 -0
  57. package/dist/types/koa.d.cts +21 -2
  58. package/dist/types/koa.d.mts +4 -3
  59. package/package.json +25 -7
  60. package/dist/Route-tq-rge1g.d.mts +0 -136
  61. package/dist/types/index.d.mts +0 -1
@@ -1,13 +1,13 @@
1
- import { Middleware } from "./types/h3.cjs";
2
- import { Route } from "./Route.cjs";
3
1
  import { RequestData } from "./types/basic.cjs";
4
- import { Middleware as Middleware$1 } from "./types/express.cjs";
5
- import { Middleware as Middleware$2 } from "./types/fastify.cjs";
2
+ import { Middleware } from "./types/express.cjs";
3
+ import { Middleware as Middleware$1 } from "./types/fastify.cjs";
4
+ import { Middleware as Middleware$2 } from "./types/h3.cjs";
6
5
  import { Middleware as Middleware$3 } from "./types/hono.cjs";
7
6
  import { Middleware as Middleware$4 } from "./types/koa.cjs";
7
+ import { Route } from "./Route.cjs";
8
8
 
9
9
  //#region src/ClearRequest.d.ts
10
- declare class ClearRequest<X = any, M = Middleware | Middleware$1 | Middleware$2 | Middleware$3 | Middleware$4> {
10
+ declare class ClearRequest<X = any, M = Middleware$2 | Middleware | Middleware$1 | Middleware$3 | Middleware$4> {
11
11
  [key: string]: any;
12
12
  /**
13
13
  * @param body - Parsed request body
@@ -1,10 +1,10 @@
1
+ import { RequestData } from "./types/basic.mjs";
1
2
  import { Middleware } from "./types/express.mjs";
2
3
  import { Middleware as Middleware$1 } from "./types/fastify.mjs";
3
4
  import { Middleware as Middleware$2 } from "./types/h3.mjs";
4
5
  import { Middleware as Middleware$3 } from "./types/hono.mjs";
5
6
  import { Middleware as Middleware$4 } from "./types/koa.mjs";
6
7
  import { Route } from "./Route.mjs";
7
- import { RequestData } from "./types/basic.mjs";
8
8
 
9
9
  //#region src/ClearRequest.d.ts
10
10
  declare class ClearRequest<X = any, M = Middleware$2 | Middleware | Middleware$1 | Middleware$3 | Middleware$4> {
@@ -1,5 +1,5 @@
1
- import { ClearRequest } from "./ClearRequest.mjs";
2
1
  import { RequestData } from "./types/basic.mjs";
2
+ import { ClearRequest } from "./ClearRequest.mjs";
3
3
 
4
4
  //#region src/Controller.d.ts
5
5
  declare abstract class Controller<X = any> {
@@ -1,9 +1,9 @@
1
- import { Middleware } from "./types/h3.cjs";
1
+ import { Middleware } from "./types/express.cjs";
2
+ import { Middleware as Middleware$1 } from "./types/h3.cjs";
2
3
  import { Route } from "./Route.cjs";
3
- import { Middleware as Middleware$1 } from "./types/express.cjs";
4
4
 
5
5
  //#region src/ResourceRouteSelection.d.ts
6
- declare class ResourceRouteSelection<X = any, M = Middleware | Middleware$1, H = any> {
6
+ declare class ResourceRouteSelection<X = any, M = Middleware$1 | Middleware, H = any> {
7
7
  readonly routes: Array<Route<X, M, H>>;
8
8
  constructor(routes: Array<Route<X, M, H>>);
9
9
  /**
@@ -1,5 +1,5 @@
1
- const require_ResourceRouteSelection = require('./ResourceRouteSelection.cjs');
2
1
  const require_helpers = require('./core/helpers.cjs');
2
+ const require_ResourceRouteSelection = require('./ResourceRouteSelection.cjs');
3
3
  require('./core/index.cjs');
4
4
 
5
5
  //#region src/ResourceRoutes.ts
@@ -1,7 +1,7 @@
1
- import { Middleware } from "./types/h3.cjs";
2
- import { Route } from "./Route.cjs";
3
1
  import { ApiResourceMiddleware, HttpMethod, ResourceAction, ResourceRouteDefinition, ResourceRouteRegistrar, ResourceRouteRemover, ResourceRoutesOptions } from "./types/basic.cjs";
4
- import { Middleware as Middleware$1 } from "./types/express.cjs";
2
+ import { Middleware } from "./types/express.cjs";
3
+ import { Middleware as Middleware$1 } from "./types/h3.cjs";
4
+ import { Route } from "./Route.cjs";
5
5
  import { ResourceRouteSelection } from "./ResourceRouteSelection.cjs";
6
6
 
7
7
  //#region src/ResourceRoutes.d.ts
@@ -11,7 +11,7 @@ import { ResourceRouteSelection } from "./ResourceRouteSelection.cjs";
11
11
  * @author 3m1n3nc3
12
12
  * @repository https://github.com/arkstack-tmp/clear-router
13
13
  */
14
- declare class ResourceRoutes<X = any, M = Middleware | Middleware$1, H = any> {
14
+ declare class ResourceRoutes<X = any, M = Middleware$1 | Middleware, H = any> {
15
15
  readonly basePath: string;
16
16
  readonly controller: any;
17
17
  readonly paramName: string;
@@ -1,7 +1,7 @@
1
+ import { ApiResourceMiddleware, HttpMethod, ResourceAction, ResourceRouteDefinition, ResourceRouteRegistrar, ResourceRouteRemover, ResourceRoutesOptions } from "./types/basic.mjs";
1
2
  import { Middleware } from "./types/express.mjs";
2
3
  import { Middleware as Middleware$1 } from "./types/h3.mjs";
3
4
  import { Route } from "./Route.mjs";
4
- import { ApiResourceMiddleware, HttpMethod, ResourceAction, ResourceRouteDefinition, ResourceRouteRegistrar, ResourceRouteRemover, ResourceRoutesOptions } from "./types/basic.mjs";
5
5
  import { ResourceRouteSelection } from "./ResourceRouteSelection.mjs";
6
6
 
7
7
  //#region src/ResourceRoutes.d.ts
@@ -1,5 +1,5 @@
1
- import { ResourceRouteSelection } from "./ResourceRouteSelection.mjs";
2
1
  import { wrap } from "./core/helpers.mjs";
2
+ import { ResourceRouteSelection } from "./ResourceRouteSelection.mjs";
3
3
  import "./core/index.mjs";
4
4
 
5
5
  //#region src/ResourceRoutes.ts
package/dist/Route.d.cts CHANGED
@@ -1,7 +1,7 @@
1
- import { RouteParameter } from "./Contracts.cjs";
2
- import { Middleware } from "./types/h3.cjs";
3
1
  import { HttpMethod, RequestData } from "./types/basic.cjs";
4
- import { Middleware as Middleware$1 } from "./types/express.cjs";
2
+ import { RouteParameter } from "./Contracts.cjs";
3
+ import { Middleware } from "./types/express.cjs";
4
+ import { Middleware as Middleware$1 } from "./types/h3.cjs";
5
5
  import { ClearRequest } from "./ClearRequest.cjs";
6
6
 
7
7
  //#region src/Route.d.ts
@@ -11,7 +11,7 @@ import { ClearRequest } from "./ClearRequest.cjs";
11
11
  * @author 3m1n3nc3
12
12
  * @repository https://github.com/arkstack-tmp/clear-router
13
13
  */
14
- declare class Route<X = any, M = Middleware | Middleware$1, H = any> {
14
+ declare class Route<X = any, M = Middleware$1 | Middleware, H = any> {
15
15
  ctx: X;
16
16
  body: RequestData;
17
17
  query: RequestData;
package/dist/Route.d.mts CHANGED
@@ -1,8 +1,8 @@
1
+ import { HttpMethod, RequestData } from "./types/basic.mjs";
1
2
  import { RouteParameter } from "./Contracts.mjs";
2
3
  import { Middleware } from "./types/express.mjs";
3
4
  import { Middleware as Middleware$1 } from "./types/h3.mjs";
4
5
  import { ClearRequest } from "./ClearRequest.mjs";
5
- import { HttpMethod, RequestData } from "./types/basic.mjs";
6
6
 
7
7
  //#region src/Route.d.ts
8
8
  /**
@@ -11,8 +11,10 @@ let node_fs_promises = require("node:fs/promises");
11
11
  */
12
12
  var RouteGroup = class {
13
13
  checks = [];
14
+ conditions = [];
14
15
  registration;
15
16
  routes = /* @__PURE__ */ new Set();
17
+ unfilteredSources = /* @__PURE__ */ new Set();
16
18
  constructor(options) {
17
19
  this.options = options;
18
20
  this.registration = this.register();
@@ -24,8 +26,13 @@ var RouteGroup = class {
24
26
  * @returns
25
27
  */
26
28
  when(condition) {
27
- this.checks.push(this.registration.then(async () => {
28
- if (!await condition(this.options.source)) this.rollback();
29
+ this.conditions.push(condition);
30
+ const unfilteredSources = Array.from(this.unfilteredSources);
31
+ if (unfilteredSources.length) this.checks.push(this.registration.then(async () => {
32
+ for (const source of unfilteredSources) if (!await condition(source)) {
33
+ this.rollback();
34
+ break;
35
+ }
29
36
  }));
30
37
  return this;
31
38
  }
@@ -67,20 +74,37 @@ var RouteGroup = class {
67
74
  await this.options.context.run(nextContext, async () => {
68
75
  for (const entry of Array.isArray(this.options.source) ? this.options.source : [this.options.source]) {
69
76
  if (typeof entry === "function") {
77
+ if (!this.conditions.length) this.unfilteredSources.add(entry);
78
+ else if (!await this.accepts(entry)) continue;
70
79
  await Promise.resolve(entry());
71
80
  continue;
72
81
  }
73
- for (const file of await this.resolveFiles(entry)) await require_helpers.importFile(file);
82
+ const resolved = await this.resolveFiles(entry);
83
+ if (!resolved.directory && !await this.accepts(entry)) continue;
84
+ for (const file of resolved.files) {
85
+ if (resolved.directory && !await this.accepts(file)) continue;
86
+ await require_helpers.importFile(file);
87
+ }
74
88
  }
75
89
  });
76
90
  }
77
91
  /**
78
- * Rollback the route registrations
92
+ * Rollback the route registration
79
93
  */
80
94
  rollback() {
81
95
  for (const route of this.routes) this.options.removeRoute(route);
82
96
  }
83
97
  /**
98
+ * Check whether a callback or path should be registered.
99
+ *
100
+ * @param source
101
+ * @returns
102
+ */
103
+ async accepts(source) {
104
+ for (const condition of this.conditions) if (!await condition(source)) return false;
105
+ return true;
106
+ }
107
+ /**
84
108
  * Resolve files from the group path
85
109
  *
86
110
  * @param source
@@ -94,9 +118,15 @@ var RouteGroup = class {
94
118
  } catch {
95
119
  throw new Error(`Route group source not found: ${source}`);
96
120
  }
97
- if (sourceStat.isFile()) return [resolved];
121
+ if (sourceStat.isFile()) return {
122
+ directory: false,
123
+ files: [resolved]
124
+ };
98
125
  if (!sourceStat.isDirectory()) throw new Error(`Route group source must be a file or directory: ${source}`);
99
- return this.readDirectory(resolved);
126
+ return {
127
+ directory: true,
128
+ files: await this.readDirectory(resolved)
129
+ };
100
130
  }
101
131
  /**
102
132
  * Read all the files in the configured directory
@@ -1,6 +1,6 @@
1
- import { Middleware } from "./types/h3.cjs";
2
1
  import { RouteGroupCondition, RouteGroupOptions } from "./types/basic.cjs";
3
- import { Middleware as Middleware$1 } from "./types/express.cjs";
2
+ import { Middleware } from "./types/express.cjs";
3
+ import { Middleware as Middleware$1 } from "./types/h3.cjs";
4
4
 
5
5
  //#region src/RouteGroup.d.ts
6
6
  /**
@@ -9,11 +9,13 @@ import { Middleware as Middleware$1 } from "./types/express.cjs";
9
9
  * @author 3m1n3nc3
10
10
  * @repository https://github.com/arkstack-tmp/clear-router
11
11
  */
12
- declare class RouteGroup<X = any, M = Middleware | Middleware$1, H = any> implements PromiseLike<void> {
12
+ declare class RouteGroup<X = any, M = Middleware$1 | Middleware, H = any> implements PromiseLike<void> {
13
13
  private readonly options;
14
14
  private readonly checks;
15
+ private readonly conditions;
15
16
  private readonly registration;
16
17
  private readonly routes;
18
+ private readonly unfilteredSources;
17
19
  constructor(options: RouteGroupOptions);
18
20
  /**
19
21
  * Returning a falsy value will stop route group registration
@@ -42,9 +44,16 @@ declare class RouteGroup<X = any, M = Middleware | Middleware$1, H = any> implem
42
44
  */
43
45
  private register;
44
46
  /**
45
- * Rollback the route registrations
46
- */
47
+ * Rollback the route registration
48
+ */
47
49
  private rollback;
50
+ /**
51
+ * Check whether a callback or path should be registered.
52
+ *
53
+ * @param source
54
+ * @returns
55
+ */
56
+ private accepts;
48
57
  /**
49
58
  * Resolve files from the group path
50
59
  *
@@ -1,6 +1,6 @@
1
+ import { RouteGroupCondition, RouteGroupOptions } from "./types/basic.mjs";
1
2
  import { Middleware } from "./types/express.mjs";
2
3
  import { Middleware as Middleware$1 } from "./types/h3.mjs";
3
- import { RouteGroupCondition, RouteGroupOptions } from "./types/basic.mjs";
4
4
 
5
5
  //#region src/RouteGroup.d.ts
6
6
  /**
@@ -12,8 +12,10 @@ import { RouteGroupCondition, RouteGroupOptions } from "./types/basic.mjs";
12
12
  declare class RouteGroup<X = any, M = Middleware$1 | Middleware, H = any> implements PromiseLike<void> {
13
13
  private readonly options;
14
14
  private readonly checks;
15
+ private readonly conditions;
15
16
  private readonly registration;
16
17
  private readonly routes;
18
+ private readonly unfilteredSources;
17
19
  constructor(options: RouteGroupOptions);
18
20
  /**
19
21
  * Returning a falsy value will stop route group registration
@@ -42,9 +44,16 @@ declare class RouteGroup<X = any, M = Middleware$1 | Middleware, H = any> implem
42
44
  */
43
45
  private register;
44
46
  /**
45
- * Rollback the route registrations
46
- */
47
+ * Rollback the route registration
48
+ */
47
49
  private rollback;
50
+ /**
51
+ * Check whether a callback or path should be registered.
52
+ *
53
+ * @param source
54
+ * @returns
55
+ */
56
+ private accepts;
48
57
  /**
49
58
  * Resolve files from the group path
50
59
  *
@@ -11,8 +11,10 @@ import { readdir, stat } from "node:fs/promises";
11
11
  */
12
12
  var RouteGroup = class {
13
13
  checks = [];
14
+ conditions = [];
14
15
  registration;
15
16
  routes = /* @__PURE__ */ new Set();
17
+ unfilteredSources = /* @__PURE__ */ new Set();
16
18
  constructor(options) {
17
19
  this.options = options;
18
20
  this.registration = this.register();
@@ -24,8 +26,13 @@ var RouteGroup = class {
24
26
  * @returns
25
27
  */
26
28
  when(condition) {
27
- this.checks.push(this.registration.then(async () => {
28
- if (!await condition(this.options.source)) this.rollback();
29
+ this.conditions.push(condition);
30
+ const unfilteredSources = Array.from(this.unfilteredSources);
31
+ if (unfilteredSources.length) this.checks.push(this.registration.then(async () => {
32
+ for (const source of unfilteredSources) if (!await condition(source)) {
33
+ this.rollback();
34
+ break;
35
+ }
29
36
  }));
30
37
  return this;
31
38
  }
@@ -67,20 +74,37 @@ var RouteGroup = class {
67
74
  await this.options.context.run(nextContext, async () => {
68
75
  for (const entry of Array.isArray(this.options.source) ? this.options.source : [this.options.source]) {
69
76
  if (typeof entry === "function") {
77
+ if (!this.conditions.length) this.unfilteredSources.add(entry);
78
+ else if (!await this.accepts(entry)) continue;
70
79
  await Promise.resolve(entry());
71
80
  continue;
72
81
  }
73
- for (const file of await this.resolveFiles(entry)) await importFile(file);
82
+ const resolved = await this.resolveFiles(entry);
83
+ if (!resolved.directory && !await this.accepts(entry)) continue;
84
+ for (const file of resolved.files) {
85
+ if (resolved.directory && !await this.accepts(file)) continue;
86
+ await importFile(file);
87
+ }
74
88
  }
75
89
  });
76
90
  }
77
91
  /**
78
- * Rollback the route registrations
92
+ * Rollback the route registration
79
93
  */
80
94
  rollback() {
81
95
  for (const route of this.routes) this.options.removeRoute(route);
82
96
  }
83
97
  /**
98
+ * Check whether a callback or path should be registered.
99
+ *
100
+ * @param source
101
+ * @returns
102
+ */
103
+ async accepts(source) {
104
+ for (const condition of this.conditions) if (!await condition(source)) return false;
105
+ return true;
106
+ }
107
+ /**
84
108
  * Resolve files from the group path
85
109
  *
86
110
  * @param source
@@ -94,9 +118,15 @@ var RouteGroup = class {
94
118
  } catch {
95
119
  throw new Error(`Route group source not found: ${source}`);
96
120
  }
97
- if (sourceStat.isFile()) return [resolved];
121
+ if (sourceStat.isFile()) return {
122
+ directory: false,
123
+ files: [resolved]
124
+ };
98
125
  if (!sourceStat.isDirectory()) throw new Error(`Route group source must be a file or directory: ${source}`);
99
- return this.readDirectory(resolved);
126
+ return {
127
+ directory: true,
128
+ files: await this.readDirectory(resolved)
129
+ };
100
130
  }
101
131
  /**
102
132
  * Read all the files in the configured directory
@@ -1,9 +1,9 @@
1
+ const require_Route = require('../Route.cjs');
2
+ const require_RouteGroup = require('../RouteGroup.cjs');
1
3
  const require_Request = require('./Request.cjs');
2
4
  const require_Response = require('./Response.cjs');
3
5
  const require_bindings = require('./bindings.cjs');
4
6
  const require_ResourceRoutes = require('../ResourceRoutes.cjs');
5
- const require_Route = require('../Route.cjs');
6
- const require_RouteGroup = require('../RouteGroup.cjs');
7
7
  let node_async_hooks = require("node:async_hooks");
8
8
  let node_module = require("node:module");
9
9
 
@@ -1,11 +1,11 @@
1
- import { Request } from "./Request.cjs";
1
+ import { ApiResourceMiddleware, HttpMethod, ResourceAction, RouteGroupContext, RouteGroupSource, RouterConfig } from "../types/basic.cjs";
2
2
  import { Response } from "./Response.cjs";
3
3
  import { Route } from "../Route.cjs";
4
- import { ApiResourceMiddleware, HttpMethod, ResourceAction, RouteGroupContext, RouteGroupSource, RouterConfig } from "../types/basic.cjs";
5
- import { Controller } from "../Controller.cjs";
6
- import { RouteGroup } from "../RouteGroup.cjs";
4
+ import { Request } from "./Request.cjs";
7
5
  import { ClearRouterPluginArgumentsContext, ClearRouterPluginInput, ClearRouterPluginRequestContext, PluginArgumentsResolver, PluginBind } from "./plugins.cjs";
6
+ import { Controller } from "../Controller.cjs";
8
7
  import { ResourceRoutes } from "../ResourceRoutes.cjs";
8
+ import { RouteGroup } from "../RouteGroup.cjs";
9
9
  import { AsyncLocalStorage } from "node:async_hooks";
10
10
 
11
11
  //#region src/core/CoreRouter.d.ts
@@ -1,6 +1,6 @@
1
+ import { ApiResourceMiddleware, HttpMethod, ResourceAction, RouteGroupContext, RouteGroupSource, RouterConfig } from "../types/basic.mjs";
1
2
  import { Response } from "./Response.mjs";
2
3
  import { Route } from "../Route.mjs";
3
- import { ApiResourceMiddleware, HttpMethod, ResourceAction, RouteGroupContext, RouteGroupSource, RouterConfig } from "../types/basic.mjs";
4
4
  import { Request } from "./Request.mjs";
5
5
  import { ClearRouterPluginArgumentsContext, ClearRouterPluginInput, ClearRouterPluginRequestContext, PluginArgumentsResolver, PluginBind } from "./plugins.mjs";
6
6
  import { Controller } from "../Controller.mjs";
@@ -1,9 +1,9 @@
1
+ import { Route } from "../Route.mjs";
2
+ import { RouteGroup } from "../RouteGroup.mjs";
1
3
  import { Request } from "./Request.mjs";
2
4
  import { Response } from "./Response.mjs";
3
5
  import { Container, getBindingMetadataFromTargets, getDesignParamTypes, getStandardMetadata, isClass } from "./bindings.mjs";
4
6
  import { ResourceRoutes } from "../ResourceRoutes.mjs";
5
- import { Route } from "../Route.mjs";
6
- import { RouteGroup } from "../RouteGroup.mjs";
7
7
  import { createRequire } from "node:module";
8
8
  import { AsyncLocalStorage } from "node:async_hooks";
9
9
 
@@ -1,5 +1,5 @@
1
- import { Route } from "../Route.cjs";
2
1
  import { HttpMethod, RequestData } from "../types/basic.cjs";
2
+ import { Route } from "../Route.cjs";
3
3
  import { ClearRequest } from "../ClearRequest.cjs";
4
4
 
5
5
  //#region src/core/Request.d.ts
@@ -1,6 +1,6 @@
1
- import { ClearRequest } from "../ClearRequest.mjs";
2
- import { Route } from "../Route.mjs";
3
1
  import { HttpMethod, RequestData } from "../types/basic.mjs";
2
+ import { Route } from "../Route.mjs";
3
+ import { ClearRequest } from "../ClearRequest.mjs";
4
4
 
5
5
  //#region src/core/Request.d.ts
6
6
  declare class Request<X = any, M = any> extends ClearRequest<X, M> {
@@ -2,6 +2,10 @@
2
2
  type BindToken<T = any> = abstract new (...args: any[]) => T;
3
3
  type BindFactory<T = any> = (ctx: any) => T | Promise<T>;
4
4
  type BindValue<T = any> = T | BindFactory<T> | BindToken<T>;
5
+ type BindDecorator = MethodDecorator & ClassDecorator & {
6
+ <This, Value extends (this: This, ...args: any[]) => any>(value: Value, context: ClassMethodDecoratorContext<This, Value>): void | Value;
7
+ <Value extends abstract new (...args: any[]) => any>(value: Value, context: ClassDecoratorContext<Value>): void | Value;
8
+ };
5
9
  declare class Container {
6
10
  private static readonly registry;
7
11
  static bind<T>(token: BindToken<T>, value: BindValue<T>): void;
@@ -16,5 +20,6 @@ declare class Container {
16
20
  private static staticPropsMatch;
17
21
  private static resolveBinding;
18
22
  }
23
+ declare function Bind(...tokens: BindToken[]): BindDecorator;
19
24
  //#endregion
20
- export { BindToken, BindValue, Container };
25
+ export { Bind, BindDecorator, BindFactory, BindToken, BindValue, Container };
@@ -1,4 +1,4 @@
1
- import { FileImporter } from "../types/basic.cjs";
1
+ import { FileImporter } from "src/types";
2
2
 
3
3
  //#region src/core/helpers.d.ts
4
4
  declare const wrap: <T>(value: T | T[] | null | undefined) => T[];
@@ -1,4 +1,4 @@
1
- import { FileImporter } from "../types/basic.mjs";
1
+ import { FileImporter } from "src/types";
2
2
 
3
3
  //#region src/core/helpers.d.ts
4
4
  declare const wrap: <T>(value: T | T[] | null | undefined) => T[];
@@ -1,6 +1,15 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1
2
  const require_helpers = require('./helpers.cjs');
2
3
  const require_RouteGroup = require('../RouteGroup.cjs');
3
4
  const require_Request = require('./Request.cjs');
4
5
  const require_Response = require('./Response.cjs');
5
6
  const require_plugins = require('./plugins.cjs');
6
7
  const require_CoreRouter = require('./CoreRouter.cjs');
8
+
9
+ exports.CoreRouter = require_CoreRouter.CoreRouter;
10
+ exports.Request = require_Request.Request;
11
+ exports.Response = require_Response.Response;
12
+ exports.RouteGroup = require_RouteGroup.RouteGroup;
13
+ exports.definePlugin = require_plugins.definePlugin;
14
+ exports.importFile = require_helpers.importFile;
15
+ exports.wrap = require_helpers.wrap;
@@ -1,8 +1,8 @@
1
+ import { importFile, wrap } from "./helpers.mjs";
2
+ import { RouteGroup } from "../RouteGroup.mjs";
1
3
  import { Request } from "./Request.mjs";
2
4
  import { Response } from "./Response.mjs";
3
5
  import { definePlugin } from "./plugins.mjs";
4
- import { importFile, wrap } from "./helpers.mjs";
5
- import { RouteGroup } from "../RouteGroup.mjs";
6
6
  import { CoreRouter } from "./CoreRouter.mjs";
7
7
 
8
8
  export { CoreRouter, Request, Response, RouteGroup, definePlugin, importFile, wrap };
@@ -1,6 +1,6 @@
1
- import { Request } from "./Request.cjs";
2
- import { Response } from "./Response.cjs";
3
1
  import { RouterConfig } from "../types/basic.cjs";
2
+ import { Response } from "./Response.cjs";
3
+ import { Request } from "./Request.cjs";
4
4
  import { BindToken, BindValue, Container } from "./bindings.cjs";
5
5
 
6
6
  //#region src/core/plugins.d.ts
@@ -1,5 +1,5 @@
1
- import { Response } from "./Response.mjs";
2
1
  import { RouterConfig } from "../types/basic.mjs";
2
+ import { Response } from "./Response.mjs";
3
3
  import { Request } from "./Request.mjs";
4
4
  import { BindToken, BindValue, Container } from "./bindings.mjs";
5
5
 
@@ -1,2 +1,3 @@
1
1
  import { Bind, BindDecorator, BindFactory, BindToken, BindValue, Container } from "../core/bindings.mjs";
2
+ import "reflect-metadata";
2
3
  export { Bind, BindDecorator, BindFactory, BindToken, BindValue, Container };
@@ -1,6 +1,6 @@
1
+ import { ApiResourceMiddleware, HttpMethod, ResourceAction, RouteGroupSource } from "../types/basic.cjs";
1
2
  import { Handler, HttpContext, Middleware } from "../types/express.cjs";
2
3
  import { Route } from "../Route.cjs";
3
- import { ApiResourceMiddleware, HttpMethod, ResourceAction, RouteGroupSource } from "../types/basic.cjs";
4
4
  import { ResourceRoutes } from "../ResourceRoutes.cjs";
5
5
  import { RouteGroup } from "../RouteGroup.cjs";
6
6
  import { CoreRouter } from "../core/CoreRouter.cjs";
@@ -26,7 +26,7 @@ declare class Router$1 extends CoreRouter {
26
26
  * @param handler
27
27
  * @param middlewares
28
28
  */
29
- static add(methods: HttpMethod | HttpMethod[], path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
29
+ static add<T = any>(methods: HttpMethod | HttpMethod[], path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
30
30
  /**
31
31
  * Define a resourceful API controller with standard CRUD routes
32
32
  *
@@ -46,7 +46,7 @@ declare class Router$1 extends CoreRouter {
46
46
  * @param handler
47
47
  * @param middlewares
48
48
  */
49
- static get(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
49
+ static get<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
50
50
  /**
51
51
  * Adds a new POST route to the router.
52
52
  *
@@ -54,7 +54,7 @@ declare class Router$1 extends CoreRouter {
54
54
  * @param handler
55
55
  * @param middlewares
56
56
  */
57
- static post(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
57
+ static post<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
58
58
  /**
59
59
  * Adds a new PUT route to the router.
60
60
  *
@@ -62,7 +62,7 @@ declare class Router$1 extends CoreRouter {
62
62
  * @param handler
63
63
  * @param middlewares
64
64
  */
65
- static put(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
65
+ static put<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
66
66
  /**
67
67
  * Adds a new DELETE route to the router.
68
68
  *
@@ -70,7 +70,7 @@ declare class Router$1 extends CoreRouter {
70
70
  * @param handler
71
71
  * @param middlewares
72
72
  */
73
- static delete(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
73
+ static delete<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
74
74
  /**
75
75
  * Adds a new PATCH route to the router.
76
76
  *
@@ -78,7 +78,7 @@ declare class Router$1 extends CoreRouter {
78
78
  * @param handler
79
79
  * @param middlewares
80
80
  */
81
- static patch(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
81
+ static patch<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
82
82
  /**
83
83
  * Adds a new OPTIONS route to the router.
84
84
  *
@@ -86,7 +86,7 @@ declare class Router$1 extends CoreRouter {
86
86
  * @param handler
87
87
  * @param middlewares
88
88
  */
89
- static options(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
89
+ static options<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
90
90
  /**
91
91
  * Adds a new HEAD route to the router.
92
92
  *
@@ -94,7 +94,7 @@ declare class Router$1 extends CoreRouter {
94
94
  * @param handler
95
95
  * @param middlewares
96
96
  */
97
- static head(path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler>;
97
+ static head<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
98
98
  /**
99
99
  * Defines a group of routes with a common prefix.
100
100
  *
@@ -102,7 +102,7 @@ declare class Router$1 extends CoreRouter {
102
102
  * @param callback
103
103
  * @param middlewares
104
104
  */
105
- static group(prefix: string, source: RouteGroupSource, middlewares?: Middleware[]): RouteGroup<HttpContext, Middleware, Handler>;
105
+ static group<T = any>(prefix: string, source: RouteGroupSource, middlewares?: Middleware[]): RouteGroup<HttpContext, Middleware, Handler<T>>;
106
106
  /**
107
107
  * Adds global middlewares to the router, which will be applied to all routes.
108
108
  *
@@ -115,11 +115,11 @@ declare class Router$1 extends CoreRouter {
115
115
  *
116
116
  * @param type
117
117
  */
118
- static allRoutes(): Array<Route<HttpContext, Middleware, Handler>>;
119
- static allRoutes(type: 'path'): Record<string, Route<HttpContext, Middleware, Handler>>;
120
- static allRoutes(type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<HttpContext, Middleware, Handler>> };
121
- static allRoutes(type: 'name'): Record<string, Route<HttpContext, Middleware, Handler>>;
122
- static route(name: string): Route<HttpContext, Middleware, Handler> | undefined;
118
+ static allRoutes<T = any>(): Array<Route<HttpContext, Middleware, Handler<T>>>;
119
+ static allRoutes<T = any>(type: 'path'): Record<string, Route<HttpContext, Middleware, Handler<T>>>;
120
+ static allRoutes<T = any>(type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<HttpContext, Middleware, Handler<T>>> };
121
+ static allRoutes<T = any>(type: 'name'): Record<string, Route<HttpContext, Middleware, Handler<T>>>;
122
+ static route<T = any>(name: string): Route<HttpContext, Middleware, Handler<T>> | undefined;
123
123
  /**
124
124
  * Applies the registered routes to the given Express router instance, setting up the necessary
125
125
  * handlers and middlewares for each route.