@e22m4u/ts-rest-router 0.2.9 → 0.4.0

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.
@@ -609,7 +609,7 @@ var _ControllerRegistry = class _ControllerRegistry extends DebuggableService {
609
609
  /**
610
610
  * Controllers.
611
611
  */
612
- controllers = /* @__PURE__ */ new Set();
612
+ controllers = /* @__PURE__ */ new Map();
613
613
  /**
614
614
  * Add controller.
615
615
  *
@@ -672,7 +672,7 @@ var _ControllerRegistry = class _ControllerRegistry extends DebuggableService {
672
672
  });
673
673
  debug("Route %s %v is added.", actionMd.method.toUpperCase(), prefixedRoutePath);
674
674
  });
675
- this.controllers.add(ctor);
675
+ this.controllers.set(ctor, options);
676
676
  return this;
677
677
  }
678
678
  /**
@@ -11,6 +11,11 @@ export type ControllerRootOptions = {
11
11
  before?: RoutePreHandler | RoutePreHandler[];
12
12
  after?: RoutePostHandler | RoutePostHandler[];
13
13
  };
14
+ /**
15
+ * В данном Map ключом является контроллер, а значением
16
+ * его опции, которые могут отсутствовать.
17
+ */
18
+ export type ControllerRegistryMap = Map<Constructor<object>, ControllerRootOptions | undefined>;
14
19
  /**
15
20
  * Controller registry.
16
21
  */
@@ -18,7 +23,7 @@ export declare class ControllerRegistry extends DebuggableService {
18
23
  /**
19
24
  * Controllers.
20
25
  */
21
- controllers: Set<Constructor<object>>;
26
+ controllers: ControllerRegistryMap;
22
27
  /**
23
28
  * Add controller.
24
29
  *
@@ -19,7 +19,7 @@ export class ControllerRegistry extends DebuggableService {
19
19
  /**
20
20
  * Controllers.
21
21
  */
22
- controllers = new Set();
22
+ controllers = new Map();
23
23
  /**
24
24
  * Add controller.
25
25
  *
@@ -100,7 +100,7 @@ export class ControllerRegistry extends DebuggableService {
100
100
  });
101
101
  debug('Route %s %v is added.', actionMd.method.toUpperCase(), prefixedRoutePath);
102
102
  });
103
- this.controllers.add(ctor);
103
+ this.controllers.set(ctor, options);
104
104
  return this;
105
105
  }
106
106
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e22m4u/ts-rest-router",
3
- "version": "0.2.9",
3
+ "version": "0.4.0",
4
4
  "description": "REST маршрутизатор на основе контроллеров для TypeScript",
5
5
  "author": "e22m4u <e22m4u@yandex.ru>",
6
6
  "license": "MIT",
@@ -42,35 +42,35 @@
42
42
  },
43
43
  "dependencies": {
44
44
  "@e22m4u/js-debug": "~0.1.6",
45
- "@e22m4u/js-format": "~0.1.0",
46
- "@e22m4u/js-service": "~0.2.0",
47
- "@e22m4u/js-trie-router": "~0.0.1",
48
- "@e22m4u/ts-data-schema": "~0.2.1",
49
- "@e22m4u/ts-reflector": "~0.1.0",
45
+ "@e22m4u/js-format": "~0.1.8",
46
+ "@e22m4u/js-service": "~0.3.2",
47
+ "@e22m4u/js-trie-router": "~0.1.0",
48
+ "@e22m4u/ts-data-schema": "~0.2.2",
49
+ "@e22m4u/ts-reflector": "~0.1.7",
50
50
  "http-errors": "~2.0.0"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@commitlint/cli": "~19.8.1",
54
54
  "@commitlint/config-conventional": "~19.8.1",
55
- "@eslint/js": "~9.28.0",
55
+ "@eslint/js": "~9.30.1",
56
56
  "@types/chai": "~5.2.2",
57
57
  "@types/debug": "~4.1.12",
58
- "@types/http-errors": "~2.0.4",
58
+ "@types/http-errors": "~2.0.5",
59
59
  "@types/mocha": "~10.0.10",
60
- "@types/node": "~22.15.29",
60
+ "@types/node": "~24.0.10",
61
61
  "c8": "~10.1.3",
62
62
  "chai": "~5.2.0",
63
63
  "esbuild": "~0.25.5",
64
- "eslint": "~9.28.0",
64
+ "eslint": "~9.30.1",
65
65
  "eslint-config-prettier": "~10.1.5",
66
66
  "eslint-plugin-chai-expect": "~3.1.0",
67
67
  "eslint-plugin-mocha": "~11.1.0",
68
68
  "husky": "~9.1.7",
69
- "mocha": "~11.5.0",
70
- "prettier": "~3.5.3",
69
+ "mocha": "~11.7.1",
70
+ "prettier": "~3.6.2",
71
71
  "rimraf": "~6.0.1",
72
- "tsx": "~4.19.4",
72
+ "tsx": "~4.20.3",
73
73
  "typescript": "~5.8.3",
74
- "typescript-eslint": "~8.33.0"
74
+ "typescript-eslint": "~8.35.1"
75
75
  }
76
76
  }
@@ -42,10 +42,10 @@ const POST_HANDLER_1 = () => undefined;
42
42
  const POST_HANDLER_2 = () => undefined;
43
43
 
44
44
  describe('ControllerRegistry', function () {
45
- it('has a public property with set of controllers', function () {
45
+ it('has a public property with Map of controllers', function () {
46
46
  const S = new ControllerRegistry();
47
47
  expect(S).to.have.property('controllers');
48
- expect(S.controllers).to.be.instanceof(Set);
48
+ expect(S.controllers).to.be.instanceof(Map);
49
49
  });
50
50
 
51
51
  describe('addController', function () {
@@ -57,7 +57,7 @@ describe('ControllerRegistry', function () {
57
57
  expect(res).to.be.eq(S);
58
58
  });
59
59
 
60
- it('adds a given controller to controllers set', function () {
60
+ it('adds a given controller to controllers map', function () {
61
61
  const S = new ControllerRegistry();
62
62
  @restController()
63
63
  class MyController {}
@@ -28,6 +28,15 @@ export type ControllerRootOptions = {
28
28
  after?: RoutePostHandler | RoutePostHandler[];
29
29
  };
30
30
 
31
+ /**
32
+ * В данном Map ключом является контроллер, а значением
33
+ * его опции, которые могут отсутствовать.
34
+ */
35
+ export type ControllerRegistryMap = Map<
36
+ Constructor<object>,
37
+ ControllerRootOptions | undefined
38
+ >;
39
+
31
40
  /**
32
41
  * Controller registry.
33
42
  */
@@ -35,7 +44,7 @@ export class ControllerRegistry extends DebuggableService {
35
44
  /**
36
45
  * Controllers.
37
46
  */
38
- controllers: Set<Constructor<object>> = new Set();
47
+ controllers: ControllerRegistryMap = new Map();
39
48
 
40
49
  /**
41
50
  * Add controller.
@@ -123,7 +132,7 @@ export class ControllerRegistry extends DebuggableService {
123
132
  prefixedRoutePath,
124
133
  );
125
134
  });
126
- this.controllers.add(ctor);
135
+ this.controllers.set(ctor, options);
127
136
  return this;
128
137
  }
129
138