@e22m4u/ts-rest-router 0.4.0 → 0.4.2
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/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
MIT License
|
2
2
|
|
3
|
-
Copyright (c) 2024 e22m4u@yandex.ru
|
3
|
+
Copyright (c) 2024-2025 Mikhail Evstropov <e22m4u@yandex.ru>
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/dist/cjs/index.cjs
CHANGED
@@ -607,9 +607,9 @@ __name(httpResponse, "httpResponse");
|
|
607
607
|
var import_ts_data_schema4 = require("@e22m4u/ts-data-schema");
|
608
608
|
var _ControllerRegistry = class _ControllerRegistry extends DebuggableService {
|
609
609
|
/**
|
610
|
-
*
|
610
|
+
* Controller map.
|
611
611
|
*/
|
612
|
-
|
612
|
+
controllerMap = /* @__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.
|
675
|
+
this.controllerMap.set(ctor, options);
|
676
676
|
return this;
|
677
677
|
}
|
678
678
|
/**
|
@@ -681,7 +681,7 @@ var _ControllerRegistry = class _ControllerRegistry extends DebuggableService {
|
|
681
681
|
* @param ctor
|
682
682
|
*/
|
683
683
|
hasController(ctor) {
|
684
|
-
return this.
|
684
|
+
return this.controllerMap.has(ctor);
|
685
685
|
}
|
686
686
|
/**
|
687
687
|
* Get path prefix from controller root options.
|
@@ -13,17 +13,18 @@ export type ControllerRootOptions = {
|
|
13
13
|
};
|
14
14
|
/**
|
15
15
|
* В данном Map ключом является контроллер, а значением
|
16
|
-
* его
|
16
|
+
* его опции верхнего уровня, которые могут отсутствовать,
|
17
|
+
* если пользователь их не определил.
|
17
18
|
*/
|
18
|
-
export type
|
19
|
+
export type ControllerRootOptionsMap = Map<Constructor<object>, ControllerRootOptions | undefined>;
|
19
20
|
/**
|
20
21
|
* Controller registry.
|
21
22
|
*/
|
22
23
|
export declare class ControllerRegistry extends DebuggableService {
|
23
24
|
/**
|
24
|
-
*
|
25
|
+
* Controller map.
|
25
26
|
*/
|
26
|
-
|
27
|
+
controllerMap: ControllerRootOptionsMap;
|
27
28
|
/**
|
28
29
|
* Add controller.
|
29
30
|
*
|
@@ -17,9 +17,9 @@ import { RequestContextReflector } from './decorators/index.js';
|
|
17
17
|
*/
|
18
18
|
export class ControllerRegistry extends DebuggableService {
|
19
19
|
/**
|
20
|
-
*
|
20
|
+
* Controller map.
|
21
21
|
*/
|
22
|
-
|
22
|
+
controllerMap = 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.
|
103
|
+
this.controllerMap.set(ctor, options);
|
104
104
|
return this;
|
105
105
|
}
|
106
106
|
/**
|
@@ -109,7 +109,7 @@ export class ControllerRegistry extends DebuggableService {
|
|
109
109
|
* @param ctor
|
110
110
|
*/
|
111
111
|
hasController(ctor) {
|
112
|
-
return this.
|
112
|
+
return this.controllerMap.has(ctor);
|
113
113
|
}
|
114
114
|
/**
|
115
115
|
* Get path prefix from controller root options.
|
package/package.json
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
{
|
2
2
|
"name": "@e22m4u/ts-rest-router",
|
3
|
-
"version": "0.4.
|
3
|
+
"version": "0.4.2",
|
4
4
|
"description": "REST маршрутизатор на основе контроллеров для TypeScript",
|
5
|
-
"author": "
|
5
|
+
"author": "Mikhail Evstropov <e22m4u@yandex.ru>",
|
6
6
|
"license": "MIT",
|
7
7
|
"keywords": [
|
8
8
|
"rest",
|
@@ -43,26 +43,26 @@
|
|
43
43
|
"dependencies": {
|
44
44
|
"@e22m4u/js-debug": "~0.1.6",
|
45
45
|
"@e22m4u/js-format": "~0.1.8",
|
46
|
-
"@e22m4u/js-service": "~0.3.
|
46
|
+
"@e22m4u/js-service": "~0.3.3",
|
47
47
|
"@e22m4u/js-trie-router": "~0.1.0",
|
48
|
-
"@e22m4u/ts-data-schema": "~0.
|
48
|
+
"@e22m4u/ts-data-schema": "~0.3.0",
|
49
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.
|
55
|
+
"@eslint/js": "~9.32.0",
|
56
56
|
"@types/chai": "~5.2.2",
|
57
57
|
"@types/debug": "~4.1.12",
|
58
58
|
"@types/http-errors": "~2.0.5",
|
59
59
|
"@types/mocha": "~10.0.10",
|
60
|
-
"@types/node": "~24.0
|
60
|
+
"@types/node": "~24.2.0",
|
61
61
|
"c8": "~10.1.3",
|
62
|
-
"chai": "~5.2.
|
63
|
-
"esbuild": "~0.25.
|
64
|
-
"eslint": "~9.
|
65
|
-
"eslint-config-prettier": "~10.1.
|
62
|
+
"chai": "~5.2.1",
|
63
|
+
"esbuild": "~0.25.8",
|
64
|
+
"eslint": "~9.32.0",
|
65
|
+
"eslint-config-prettier": "~10.1.8",
|
66
66
|
"eslint-plugin-chai-expect": "~3.1.0",
|
67
67
|
"eslint-plugin-mocha": "~11.1.0",
|
68
68
|
"husky": "~9.1.7",
|
@@ -71,6 +71,6 @@
|
|
71
71
|
"rimraf": "~6.0.1",
|
72
72
|
"tsx": "~4.20.3",
|
73
73
|
"typescript": "~5.8.3",
|
74
|
-
"typescript-eslint": "~8.
|
74
|
+
"typescript-eslint": "~8.39.0"
|
75
75
|
}
|
76
76
|
}
|
@@ -42,10 +42,11 @@ 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
|
45
|
+
it('has a public property `controllerMap` with an empty Map', function () {
|
46
46
|
const S = new ControllerRegistry();
|
47
|
-
expect(S).to.have.property('
|
48
|
-
expect(S.
|
47
|
+
expect(S).to.have.property('controllerMap');
|
48
|
+
expect(S.controllerMap).to.be.instanceof(Map);
|
49
|
+
expect(S.controllerMap).to.be.empty;
|
49
50
|
});
|
50
51
|
|
51
52
|
describe('addController', function () {
|
@@ -30,9 +30,10 @@ export type ControllerRootOptions = {
|
|
30
30
|
|
31
31
|
/**
|
32
32
|
* В данном Map ключом является контроллер, а значением
|
33
|
-
* его
|
33
|
+
* его опции верхнего уровня, которые могут отсутствовать,
|
34
|
+
* если пользователь их не определил.
|
34
35
|
*/
|
35
|
-
export type
|
36
|
+
export type ControllerRootOptionsMap = Map<
|
36
37
|
Constructor<object>,
|
37
38
|
ControllerRootOptions | undefined
|
38
39
|
>;
|
@@ -42,9 +43,9 @@ export type ControllerRegistryMap = Map<
|
|
42
43
|
*/
|
43
44
|
export class ControllerRegistry extends DebuggableService {
|
44
45
|
/**
|
45
|
-
*
|
46
|
+
* Controller map.
|
46
47
|
*/
|
47
|
-
|
48
|
+
controllerMap: ControllerRootOptionsMap = new Map();
|
48
49
|
|
49
50
|
/**
|
50
51
|
* Add controller.
|
@@ -132,7 +133,7 @@ export class ControllerRegistry extends DebuggableService {
|
|
132
133
|
prefixedRoutePath,
|
133
134
|
);
|
134
135
|
});
|
135
|
-
this.
|
136
|
+
this.controllerMap.set(ctor, options);
|
136
137
|
return this;
|
137
138
|
}
|
138
139
|
|
@@ -142,7 +143,7 @@ export class ControllerRegistry extends DebuggableService {
|
|
142
143
|
* @param ctor
|
143
144
|
*/
|
144
145
|
hasController<T extends object>(ctor: Constructor<T>) {
|
145
|
-
return this.
|
146
|
+
return this.controllerMap.has(ctor);
|
146
147
|
}
|
147
148
|
|
148
149
|
/**
|