@expressots/core 1.2.1 → 1.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.
- package/README.md +3 -3
- package/lib/CHANGELOG.md +89 -39
- package/lib/README.md +3 -3
- package/lib/cjs/application/app-container.js +28 -11
- package/lib/cjs/container-module/container-module.js +69 -16
- package/lib/cjs/container-module/index.js +2 -1
- package/lib/cjs/controller/base-controller.js +1 -1
- package/lib/cjs/decorator/index.js +17 -0
- package/lib/cjs/decorator/scope-binding.js +12 -0
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/types/application/app-container.d.ts +18 -6
- package/lib/cjs/types/application/app-container.d.ts.map +1 -1
- package/lib/cjs/types/container-module/container-module.d.ts +14 -8
- package/lib/cjs/types/container-module/container-module.d.ts.map +1 -1
- package/lib/cjs/types/container-module/index.d.ts +1 -1
- package/lib/cjs/types/container-module/index.d.ts.map +1 -1
- package/lib/cjs/types/controller/base-controller.d.ts +1 -1
- package/lib/cjs/types/controller/base-controller.d.ts.map +1 -1
- package/lib/cjs/types/decorator/index.d.ts +2 -0
- package/lib/cjs/types/decorator/index.d.ts.map +1 -0
- package/lib/cjs/types/decorator/scope-binding.d.ts +4 -0
- package/lib/cjs/types/decorator/scope-binding.d.ts.map +1 -0
- package/lib/cjs/types/index.d.ts +1 -0
- package/lib/cjs/types/index.d.ts.map +1 -1
- package/lib/esm/application/app-container.js +29 -12
- package/lib/esm/container-module/container-module.js +69 -17
- package/lib/esm/container-module/index.js +1 -1
- package/lib/esm/controller/base-controller.js +1 -1
- package/lib/esm/decorator/index.js +1 -0
- package/lib/esm/decorator/scope-binding.js +8 -0
- package/lib/esm/index.mjs +1 -0
- package/lib/esm/types/application/app-container.d.ts +18 -6
- package/lib/esm/types/application/app-container.d.ts.map +1 -1
- package/lib/esm/types/container-module/container-module.d.ts +14 -8
- package/lib/esm/types/container-module/container-module.d.ts.map +1 -1
- package/lib/esm/types/container-module/index.d.ts +1 -1
- package/lib/esm/types/container-module/index.d.ts.map +1 -1
- package/lib/esm/types/controller/base-controller.d.ts +1 -1
- package/lib/esm/types/controller/base-controller.d.ts.map +1 -1
- package/lib/esm/types/decorator/index.d.ts +2 -0
- package/lib/esm/types/decorator/index.d.ts.map +1 -0
- package/lib/esm/types/decorator/scope-binding.d.ts +4 -0
- package/lib/esm/types/decorator/scope-binding.d.ts.map +1 -0
- package/lib/esm/types/index.d.ts +1 -0
- package/lib/esm/types/index.d.ts.map +1 -1
- package/lib/package.json +3 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<a href="https://expresso-ts.com/" target="blank"><img src="https://github.com/expressots/expressots/blob/main/media/
|
|
2
|
+
<a href="https://expresso-ts.com/" target="blank"><img src="https://github.com/expressots/expressots/blob/main/media/expressots.png" width="120" alt="Expresso TS Logo" /></a>
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
# Expresso TS
|
|
@@ -46,7 +46,7 @@ ExpressoTS is an MIT-licensed open source project. It's an independent project w
|
|
|
46
46
|
- [Daniel Boll](https://github.com/daniel-boll)
|
|
47
47
|
- [Felipe Fontana](https://github.com/f0ntana)
|
|
48
48
|
- [Juliano Soares](https://github.com/juliano-soares)
|
|
49
|
-
- [Vitor Caminha](https://github.com/VitorCaminha)
|
|
49
|
+
- [Vitor Caminha](https://github.com/VitorCaminha)
|
|
50
50
|
- [Ariel Betti](https://github.com/ArielBetti)
|
|
51
51
|
- [Rodrigo da Hora](https://github.com/dahorarodrigo)
|
|
52
52
|
|
|
@@ -62,4 +62,4 @@ ExpressoTS is an MIT-licensed open source project. It's an independent project w
|
|
|
62
62
|
|
|
63
63
|
## License
|
|
64
64
|
|
|
65
|
-
ExpressoTS is **[MIT licensed](LICENSE.md)**
|
|
65
|
+
ExpressoTS is **[MIT licensed](LICENSE.md)**
|
package/lib/CHANGELOG.md
CHANGED
|
@@ -1,22 +1,72 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
## [1.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
## [1.4.0](https://github.com/expressots/expressots/compare/v1.3.0...v1.4.0) (2023-05-14)
|
|
4
|
+
|
|
5
|
+
* add DI (dependency injection) singleton, transient, scope to container, providers, entities, etc
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
* update sponsor link on package
|
|
10
|
+
* add example with controller only ([11b4ce3](https://github.com/expressots/expressots/commit/11b4ce3124482122a4f47fb27b7a1b1e02731621))
|
|
11
|
+
* opinionated template ientity id ([dd50ca0](https://github.com/expressots/expressots/commit/dd50ca0926c98890cbe1342f804ca34152c4a9f9))
|
|
12
|
+
|
|
13
|
+
## [1.3.0](https://github.com/expressots/expressots/compare/v1.2.1...v1.3.0) (2023-04-21)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* add user repository as singleton provider in opinionated template ([#24](https://github.com/expressots/expressots/issues/24)) ([3b5bded](https://github.com/expressots/expressots/commit/3b5bded07769d51f69b481e4b5e9b45c27d13a69))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* add gitignore on opinionated template ([315d355](https://github.com/expressots/expressots/commit/315d355ed87eb6be85daddc250289d5e0d41cd21))
|
|
24
|
+
* findall use case query db in memory ([ff8feea](https://github.com/expressots/expressots/commit/ff8feeaf36d0b74eebd9ab4e22f1910cff0a4df8))
|
|
25
|
+
* the number of constructor arguments ([ccf2a48](https://github.com/expressots/expressots/commit/ccf2a4878e795e0182608546eae8cd83e3bea775))
|
|
26
|
+
* update core pkg templates to always download latest ([ca443eb](https://github.com/expressots/expressots/commit/ca443eb6be103725c73442f49e2fec14d797bba1))
|
|
27
|
+
|
|
28
|
+
## [1.2.1](https://github.com/expressots/expressots/compare/v1.2.0...v1.2.1) (2023-04-18)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
|
|
33
|
+
* add bug report template ([8a160c4](https://github.com/expressots/expressots/commit/8a160c4b0b53be39a0fa42315936291be6694c8c))
|
|
34
|
+
* add feature request template ([9d264c6](https://github.com/expressots/expressots/commit/9d264c68e44fee754c906846aaa7a7c89cb6b571))
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### Bug Fixes
|
|
38
|
+
|
|
39
|
+
* add expresso config ([086ba59](https://github.com/expressots/expressots/commit/086ba59aba1d430877c3807eb77df9460413dbce))
|
|
40
|
+
* add PR template ([1ce4b65](https://github.com/expressots/expressots/commit/1ce4b651a16d602ed459049eeac4200bb80e7651))
|
|
41
|
+
* config-path for build ([72d8086](https://github.com/expressots/expressots/commit/72d8086cc1067add1a3d69c8c13bc5b5d6b7e024))
|
|
42
|
+
* expose express.json() config ([717f677](https://github.com/expressots/expressots/commit/717f6779e033d0e616f7fd464b81edb6bf95c1a9))
|
|
43
|
+
* template import errors from dtos ([#25](https://github.com/expressots/expressots/issues/25)) ([471e311](https://github.com/expressots/expressots/commit/471e3114a4afa9a9dc4af16b872e75f6ef436ae3))
|
|
44
|
+
* update doc contributor ([75cc0cc](https://github.com/expressots/expressots/commit/75cc0cc6f7a0b0527b566c5a4e842c9d13c68ee9))
|
|
45
|
+
* update expressots version ([e170a1f](https://github.com/expressots/expressots/commit/e170a1fd1aab61fd2403707a54c8b027139eb26c))
|
|
46
|
+
* update jest config ([6b33fd6](https://github.com/expressots/expressots/commit/6b33fd6117d32a29d2516831b3a8e7ecd16dfb65))
|
|
47
|
+
* update non-opinionated config ([1b10e0e](https://github.com/expressots/expressots/commit/1b10e0e3ba9f679b2cc59d4c3ec75a8c2e238d43))
|
|
48
|
+
* update opinionated template ([b7bde50](https://github.com/expressots/expressots/commit/b7bde50ec10b9ad9c2d855d1189ad3ccf4e68108))
|
|
49
|
+
* update opinionated template ([cae55a0](https://github.com/expressots/expressots/commit/cae55a04d1282c08668ee5ef12b9976400e2acfd))
|
|
50
|
+
* update templates ([e58af09](https://github.com/expressots/expressots/commit/e58af0995c8f71ad104d1cc4cab79e74ba257bb1))
|
|
51
|
+
* update test coverage path ([0804c5c](https://github.com/expressots/expressots/commit/0804c5c4b6fd4437a69330a40621408273ffdfac))
|
|
52
|
+
|
|
53
|
+
## [1.2.0](https://github.com/expressots/expressots/compare/v1.1.0...v1.2.0) (2023-04-08)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
### Features
|
|
57
|
+
|
|
58
|
+
* add doc & config types for cli ([a72db25](https://github.com/expressots/expressots/commit/a72db25088a8c2d0a18cd8fc71dde40e01cd4c22))
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
### Bug Fixes
|
|
62
|
+
|
|
13
63
|
* template folder path issue ([babdce9](https://github.com/expressots/expressots/commit/babdce9367f85ddd2075c4bed854ab83ee339add))
|
|
14
64
|
|
|
15
|
-
## [1.1.1](https://github.com/expressots/expressots/compare/v1.1.0...v1.1.1) (2023-04-04)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
### Bug Fixes
|
|
19
|
-
|
|
65
|
+
## [1.1.1](https://github.com/expressots/expressots/compare/v1.1.0...v1.1.1) (2023-04-04)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
### Bug Fixes
|
|
69
|
+
|
|
20
70
|
* template folder path issue ([babdce9](https://github.com/expressots/expressots/commit/babdce9367f85ddd2075c4bed854ab83ee339add))
|
|
21
71
|
|
|
22
72
|
## [1.1.0](https://github.com/expressots/expressots/compare/v1.1.0-42-gc6f184868daa1b6862337621c69b5370b70a2772...v1.1.0) (2023-03-31)
|
|
@@ -35,30 +85,30 @@
|
|
|
35
85
|
|
|
36
86
|
## [1.2.0](https://github.com/expressots/expressots/compare/v1.1.0-27-g56b160429e341c190355e4003901cb8b0ddbe792...v1.2.0) (2023-03-31)
|
|
37
87
|
|
|
38
|
-
## [1.1.0](https://github.com/expressots/expressots/compare/v0.0.2...v1.1.0) (2023-02-19)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
### Features
|
|
42
|
-
|
|
43
|
-
* add eslint prettier config ([906cdcc](https://github.com/expressots/expressots/commit/906cdcc0ebf00bee55c8cab66e95dd74c9296cb8))
|
|
44
|
-
* add opinionated template ([d1eb222](https://github.com/expressots/expressots/commit/d1eb222016c809a1a4576cce5b51660d55ad7c19))
|
|
45
|
-
* add readme ([557e1ff](https://github.com/expressots/expressots/commit/557e1ffcd41d1e482372183a0ea72820531740d7))
|
|
46
|
-
* update 01_base template ([d289c57](https://github.com/expressots/expressots/commit/d289c5752bb78ad6bce7f35fcdb7019e7cc38b6a))
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
### Bug Fixes
|
|
50
|
-
|
|
51
|
-
* add ping controller ([ca7b005](https://github.com/expressots/expressots/commit/ca7b005be099eadc35b5e6b96aaf82c0e3840c81))
|
|
52
|
-
* fix index.js main on package ([26596b7](https://github.com/expressots/expressots/commit/26596b7982143e63186461bde1324a81a8901446))
|
|
53
|
-
* fix jest compilation error ([9c5be2e](https://github.com/expressots/expressots/commit/9c5be2e8a1dc062618d048183dfeef08d67d8e70))
|
|
54
|
-
* fix release tag pipeline ([#12](https://github.com/expressots/expressots/issues/12)) ([d2a5491](https://github.com/expressots/expressots/commit/d2a5491dce149feb2a7b143d57ba1e08d8a2d68b))
|
|
55
|
-
* logo update on doc ([b2fe55b](https://github.com/expressots/expressots/commit/b2fe55b54fcac09bf261b5ea5cab4ebdbe20dee1))
|
|
56
|
-
* logo update on doc, build update ([b36889d](https://github.com/expressots/expressots/commit/b36889d513ed07678b43f7107ef9cd49ab5f8afa))
|
|
57
|
-
* non opinionated folder and prettier ([61d1e1b](https://github.com/expressots/expressots/commit/61d1e1b45e9bd240d4a6fd12a71f814e0426a436))
|
|
58
|
-
* prettier eslint jest setup ([0f29452](https://github.com/expressots/expressots/commit/0f29452c796abefe205ece8b943efda24b383905))
|
|
59
|
-
* remove test-app ([767c7a5](https://github.com/expressots/expressots/commit/767c7a54ea65c228a94ba3d63e5b6739c474a96e))
|
|
60
|
-
* set pipeline only pr merge ([2936442](https://github.com/expressots/expressots/commit/293644285f4dd611ab6b600c462a6559f9625605))
|
|
61
|
-
* update main remove index.js ([8b40b11](https://github.com/expressots/expressots/commit/8b40b11c51da728db4f8760e75fee1e2724e98e0))
|
|
88
|
+
## [1.1.0](https://github.com/expressots/expressots/compare/v0.0.2...v1.1.0) (2023-02-19)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
### Features
|
|
92
|
+
|
|
93
|
+
* add eslint prettier config ([906cdcc](https://github.com/expressots/expressots/commit/906cdcc0ebf00bee55c8cab66e95dd74c9296cb8))
|
|
94
|
+
* add opinionated template ([d1eb222](https://github.com/expressots/expressots/commit/d1eb222016c809a1a4576cce5b51660d55ad7c19))
|
|
95
|
+
* add readme ([557e1ff](https://github.com/expressots/expressots/commit/557e1ffcd41d1e482372183a0ea72820531740d7))
|
|
96
|
+
* update 01_base template ([d289c57](https://github.com/expressots/expressots/commit/d289c5752bb78ad6bce7f35fcdb7019e7cc38b6a))
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
### Bug Fixes
|
|
100
|
+
|
|
101
|
+
* add ping controller ([ca7b005](https://github.com/expressots/expressots/commit/ca7b005be099eadc35b5e6b96aaf82c0e3840c81))
|
|
102
|
+
* fix index.js main on package ([26596b7](https://github.com/expressots/expressots/commit/26596b7982143e63186461bde1324a81a8901446))
|
|
103
|
+
* fix jest compilation error ([9c5be2e](https://github.com/expressots/expressots/commit/9c5be2e8a1dc062618d048183dfeef08d67d8e70))
|
|
104
|
+
* fix release tag pipeline ([#12](https://github.com/expressots/expressots/issues/12)) ([d2a5491](https://github.com/expressots/expressots/commit/d2a5491dce149feb2a7b143d57ba1e08d8a2d68b))
|
|
105
|
+
* logo update on doc ([b2fe55b](https://github.com/expressots/expressots/commit/b2fe55b54fcac09bf261b5ea5cab4ebdbe20dee1))
|
|
106
|
+
* logo update on doc, build update ([b36889d](https://github.com/expressots/expressots/commit/b36889d513ed07678b43f7107ef9cd49ab5f8afa))
|
|
107
|
+
* non opinionated folder and prettier ([61d1e1b](https://github.com/expressots/expressots/commit/61d1e1b45e9bd240d4a6fd12a71f814e0426a436))
|
|
108
|
+
* prettier eslint jest setup ([0f29452](https://github.com/expressots/expressots/commit/0f29452c796abefe205ece8b943efda24b383905))
|
|
109
|
+
* remove test-app ([767c7a5](https://github.com/expressots/expressots/commit/767c7a54ea65c228a94ba3d63e5b6739c474a96e))
|
|
110
|
+
* set pipeline only pr merge ([2936442](https://github.com/expressots/expressots/commit/293644285f4dd611ab6b600c462a6559f9625605))
|
|
111
|
+
* update main remove index.js ([8b40b11](https://github.com/expressots/expressots/commit/8b40b11c51da728db4f8760e75fee1e2724e98e0))
|
|
62
112
|
* update readme ([a2ef784](https://github.com/expressots/expressots/commit/a2ef7849a1c1466f8737f263ad1728f5d30b25ec))
|
|
63
113
|
|
|
64
114
|
## [0.0.7](https://github.com/expressots/expressots/compare/v0.0.2...v0.0.7) (2023-02-18)
|
package/lib/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<a href="https://expresso-ts.com/" target="blank"><img src="https://github.com/expressots/expressots/blob/main/media/
|
|
2
|
+
<a href="https://expresso-ts.com/" target="blank"><img src="https://github.com/expressots/expressots/blob/main/media/expressots.png" width="120" alt="Expresso TS Logo" /></a>
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
# Expresso TS
|
|
@@ -46,7 +46,7 @@ ExpressoTS is an MIT-licensed open source project. It's an independent project w
|
|
|
46
46
|
- [Daniel Boll](https://github.com/daniel-boll)
|
|
47
47
|
- [Felipe Fontana](https://github.com/f0ntana)
|
|
48
48
|
- [Juliano Soares](https://github.com/juliano-soares)
|
|
49
|
-
- [Vitor Caminha](https://github.com/VitorCaminha)
|
|
49
|
+
- [Vitor Caminha](https://github.com/VitorCaminha)
|
|
50
50
|
- [Ariel Betti](https://github.com/ArielBetti)
|
|
51
51
|
- [Rodrigo da Hora](https://github.com/dahorarodrigo)
|
|
52
52
|
|
|
@@ -62,4 +62,4 @@ ExpressoTS is an MIT-licensed open source project. It's an independent project w
|
|
|
62
62
|
|
|
63
63
|
## License
|
|
64
64
|
|
|
65
|
-
ExpressoTS is **[MIT licensed](LICENSE.md)**
|
|
65
|
+
ExpressoTS is **[MIT licensed](LICENSE.md)**
|
|
@@ -5,9 +5,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
8
|
var AppContainer_1;
|
|
12
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
10
|
exports.AppContainer = void 0;
|
|
@@ -18,23 +15,43 @@ const inversify_binding_decorators_1 = require("inversify-binding-decorators");
|
|
|
18
15
|
* @provide AppContainer
|
|
19
16
|
*/
|
|
20
17
|
let AppContainer = AppContainer_1 = class AppContainer {
|
|
21
|
-
/**
|
|
22
|
-
* Constructs a new instance of the AppContainer class.
|
|
23
|
-
*/
|
|
24
|
-
constructor() { }
|
|
25
18
|
/**
|
|
26
19
|
* Creates and configures a new dependency injection container.
|
|
27
20
|
* @param modules - An array of ContainerModule instances to load into the container.
|
|
21
|
+
* @param defaultScope - The default scope to use for bindings. Scoped (Request) by default, but offers Singleton and Transient as well.
|
|
28
22
|
* @returns The configured dependency injection container.
|
|
29
23
|
*/
|
|
30
|
-
create(modules) {
|
|
31
|
-
this.container = new inversify_1.Container(
|
|
24
|
+
create(modules, defaultScope = inversify_1.BindingScopeEnum.Request) {
|
|
25
|
+
this.container = new inversify_1.Container({
|
|
26
|
+
autoBindInjectable: true,
|
|
27
|
+
defaultScope,
|
|
28
|
+
});
|
|
32
29
|
this.container.load((0, inversify_binding_decorators_1.buildProviderModule)(), ...modules);
|
|
33
30
|
return this.container;
|
|
34
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Retrieves the binding dictionary of the container.
|
|
34
|
+
* @returns The binding dictionary of the container.
|
|
35
|
+
*/
|
|
36
|
+
getBindingDictionary() {
|
|
37
|
+
return this.container["_bindingDictionary"]._map;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Retrieves the container options.
|
|
41
|
+
* @returns The container options.
|
|
42
|
+
*/
|
|
43
|
+
getContainerOptions() {
|
|
44
|
+
return this.container["options"];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Retrieves the container.
|
|
48
|
+
* @returns The container.
|
|
49
|
+
*/
|
|
50
|
+
get Container() {
|
|
51
|
+
return this.container;
|
|
52
|
+
}
|
|
35
53
|
};
|
|
36
54
|
AppContainer = AppContainer_1 = __decorate([
|
|
37
|
-
(0, inversify_binding_decorators_1.provide)(AppContainer_1)
|
|
38
|
-
__metadata("design:paramtypes", [])
|
|
55
|
+
(0, inversify_binding_decorators_1.provide)(AppContainer_1)
|
|
39
56
|
], AppContainer);
|
|
40
57
|
exports.AppContainer = AppContainer;
|
|
@@ -5,20 +5,45 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
8
|
var BaseModule_1;
|
|
12
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.CreateModule = void 0;
|
|
10
|
+
exports.scope = exports.CreateModule = void 0;
|
|
14
11
|
const inversify_1 = require("inversify");
|
|
15
12
|
const inversify_binding_decorators_1 = require("inversify-binding-decorators");
|
|
13
|
+
const decorator_1 = require("../decorator");
|
|
14
|
+
/**
|
|
15
|
+
* Key to be used for storing and retrieving binding type metadata.
|
|
16
|
+
*/
|
|
17
|
+
const BINDING_TYPE_METADATA_KEY = "binding-type";
|
|
18
|
+
/**
|
|
19
|
+
* The scope decorator is a higher order function that can be used to decorate a class with a binding type.
|
|
20
|
+
* @param binding An instance of interfaces.BindingScope which represents the binding type.
|
|
21
|
+
* @returns A decorator function that can be used to decorate a class with a binding type.
|
|
22
|
+
*/
|
|
23
|
+
const scope = (binding) => {
|
|
24
|
+
return function (target) {
|
|
25
|
+
if (!Reflect.hasMetadata(BINDING_TYPE_METADATA_KEY, target)) {
|
|
26
|
+
Reflect.defineMetadata(BINDING_TYPE_METADATA_KEY, binding, target);
|
|
27
|
+
switch (binding) {
|
|
28
|
+
case inversify_1.BindingScopeEnum.Singleton:
|
|
29
|
+
(0, decorator_1.provideSingleton)(target);
|
|
30
|
+
break;
|
|
31
|
+
case inversify_1.BindingScopeEnum.Transient:
|
|
32
|
+
(0, decorator_1.provideTransient)(target);
|
|
33
|
+
break;
|
|
34
|
+
default:
|
|
35
|
+
(0, inversify_binding_decorators_1.provide)(target);
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
exports.scope = scope;
|
|
16
42
|
/**
|
|
17
43
|
* The BaseModule class provides methods for creating InversifyJS container modules.
|
|
18
44
|
* @provide BaseModule
|
|
19
45
|
*/
|
|
20
46
|
let BaseModule = BaseModule_1 = class BaseModule {
|
|
21
|
-
constructor() { }
|
|
22
47
|
/**
|
|
23
48
|
* Create a map of symbols for the provided controllers.
|
|
24
49
|
* @param controllers - An array of controller classes.
|
|
@@ -34,23 +59,51 @@ let BaseModule = BaseModule_1 = class BaseModule {
|
|
|
34
59
|
return symbols;
|
|
35
60
|
}
|
|
36
61
|
/**
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
62
|
+
* Create an InversifyJS ContainerModule for the provided controllers.
|
|
63
|
+
* @param controllers - An array of controller classes.
|
|
64
|
+
* @param scope - An optional binding scope to be used for all controllers.
|
|
65
|
+
* @returns A ContainerModule with the controller bindings.
|
|
66
|
+
*/
|
|
67
|
+
static createContainerModule(controllers, scope) {
|
|
42
68
|
const symbols = BaseModule_1.createSymbols(controllers);
|
|
43
|
-
return new inversify_1.ContainerModule(bind => {
|
|
44
|
-
for (const symbol of symbols) {
|
|
45
|
-
|
|
46
|
-
|
|
69
|
+
return new inversify_1.ContainerModule((bind) => {
|
|
70
|
+
for (const [symbol, target] of symbols) {
|
|
71
|
+
if (scope) {
|
|
72
|
+
switch (scope) {
|
|
73
|
+
case inversify_1.BindingScopeEnum.Singleton:
|
|
74
|
+
bind(symbol).to(target).inSingletonScope();
|
|
75
|
+
break;
|
|
76
|
+
case inversify_1.BindingScopeEnum.Transient:
|
|
77
|
+
bind(symbol).to(target).inTransientScope();
|
|
78
|
+
break;
|
|
79
|
+
case inversify_1.BindingScopeEnum.Request:
|
|
80
|
+
bind(symbol).to(target).inRequestScope();
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
const bindingType = Reflect.getMetadata(BINDING_TYPE_METADATA_KEY, target);
|
|
86
|
+
switch (bindingType) {
|
|
87
|
+
case inversify_1.BindingScopeEnum.Singleton:
|
|
88
|
+
bind(symbol).to(target).inSingletonScope();
|
|
89
|
+
break;
|
|
90
|
+
case inversify_1.BindingScopeEnum.Transient:
|
|
91
|
+
bind(symbol).to(target).inTransientScope();
|
|
92
|
+
break;
|
|
93
|
+
case inversify_1.BindingScopeEnum.Request:
|
|
94
|
+
bind(symbol).to(target).inRequestScope();
|
|
95
|
+
break;
|
|
96
|
+
default:
|
|
97
|
+
bind(symbol).to(target).inRequestScope();
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
47
101
|
}
|
|
48
102
|
});
|
|
49
103
|
}
|
|
50
104
|
};
|
|
51
105
|
BaseModule = BaseModule_1 = __decorate([
|
|
52
|
-
(0, inversify_binding_decorators_1.provide)(BaseModule_1)
|
|
53
|
-
__metadata("design:paramtypes", [])
|
|
106
|
+
(0, inversify_binding_decorators_1.provide)(BaseModule_1)
|
|
54
107
|
], BaseModule);
|
|
55
108
|
const CreateModule = BaseModule.createContainerModule;
|
|
56
109
|
exports.CreateModule = CreateModule;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CreateModule = void 0;
|
|
3
|
+
exports.scope = exports.CreateModule = void 0;
|
|
4
4
|
var container_module_1 = require("./container-module");
|
|
5
5
|
Object.defineProperty(exports, "CreateModule", { enumerable: true, get: function () { return container_module_1.CreateModule; } });
|
|
6
|
+
Object.defineProperty(exports, "scope", { enumerable: true, get: function () { return container_module_1.scope; } });
|
|
@@ -32,7 +32,7 @@ let BaseController = BaseController_1 = class BaseController {
|
|
|
32
32
|
* Constructs a new BaseController instance with a specified service name.
|
|
33
33
|
* @param serviceName - The name of the service associated with the controller.
|
|
34
34
|
*/
|
|
35
|
-
constructor(serviceName) {
|
|
35
|
+
constructor(serviceName = "") {
|
|
36
36
|
this.serviceName = serviceName;
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./scope-binding"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.provideTransient = exports.provideSingleton = void 0;
|
|
4
|
+
const inversify_binding_decorators_1 = require("inversify-binding-decorators");
|
|
5
|
+
const provideSingleton = (identifier) => {
|
|
6
|
+
return (0, inversify_binding_decorators_1.fluentProvide)(identifier).inSingletonScope().done();
|
|
7
|
+
};
|
|
8
|
+
exports.provideSingleton = provideSingleton;
|
|
9
|
+
const provideTransient = (identifier) => {
|
|
10
|
+
return (0, inversify_binding_decorators_1.fluentProvide)(identifier).inTransientScope().done();
|
|
11
|
+
};
|
|
12
|
+
exports.provideTransient = provideTransient;
|
package/lib/cjs/index.js
CHANGED
|
@@ -19,6 +19,7 @@ __exportStar(require("./common"), exports);
|
|
|
19
19
|
__exportStar(require("./console"), exports);
|
|
20
20
|
__exportStar(require("./container-module"), exports);
|
|
21
21
|
__exportStar(require("./controller"), exports);
|
|
22
|
+
__exportStar(require("./decorator"), exports);
|
|
22
23
|
__exportStar(require("./environment"), exports);
|
|
23
24
|
__exportStar(require("./error"), exports);
|
|
24
25
|
__exportStar(require("./logger"), exports);
|
|
@@ -1,20 +1,32 @@
|
|
|
1
|
-
import { Container, ContainerModule } from "inversify";
|
|
1
|
+
import { Container, ContainerModule, interfaces } from "inversify";
|
|
2
2
|
/**
|
|
3
3
|
* The AppContainer class provides a container for managing dependency injection.
|
|
4
4
|
* @provide AppContainer
|
|
5
5
|
*/
|
|
6
6
|
declare class AppContainer {
|
|
7
7
|
private container;
|
|
8
|
-
/**
|
|
9
|
-
* Constructs a new instance of the AppContainer class.
|
|
10
|
-
*/
|
|
11
|
-
constructor();
|
|
12
8
|
/**
|
|
13
9
|
* Creates and configures a new dependency injection container.
|
|
14
10
|
* @param modules - An array of ContainerModule instances to load into the container.
|
|
11
|
+
* @param defaultScope - The default scope to use for bindings. Scoped (Request) by default, but offers Singleton and Transient as well.
|
|
15
12
|
* @returns The configured dependency injection container.
|
|
16
13
|
*/
|
|
17
|
-
create(modules: ContainerModule[]): Container;
|
|
14
|
+
create(modules: ContainerModule[], defaultScope?: interfaces.BindingScope): Container;
|
|
15
|
+
/**
|
|
16
|
+
* Retrieves the binding dictionary of the container.
|
|
17
|
+
* @returns The binding dictionary of the container.
|
|
18
|
+
*/
|
|
19
|
+
getBindingDictionary(): Map<any, any>;
|
|
20
|
+
/**
|
|
21
|
+
* Retrieves the container options.
|
|
22
|
+
* @returns The container options.
|
|
23
|
+
*/
|
|
24
|
+
getContainerOptions(): interfaces.ContainerOptions;
|
|
25
|
+
/**
|
|
26
|
+
* Retrieves the container.
|
|
27
|
+
* @returns The container.
|
|
28
|
+
*/
|
|
29
|
+
get Container(): Container;
|
|
18
30
|
}
|
|
19
31
|
export { AppContainer };
|
|
20
32
|
//# sourceMappingURL=app-container.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-container.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/application/app-container.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"app-container.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/application/app-container.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,SAAS,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAGrF;;;GAGG;AACH,cACM,YAAY;IAEd,OAAO,CAAC,SAAS,CAAa;IAC9B;;;;;OAKG;IACI,MAAM,CACT,OAAO,EAAE,eAAe,EAAE,EAC1B,YAAY,GAAE,UAAU,CAAC,YAAuC,GACjE,SAAS;IAWZ;;;OAGG;IACI,oBAAoB,IAAI,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC;IAI5C;;;OAGG;IACI,mBAAmB,IAAI,UAAU,CAAC,gBAAgB;IAIzD;;;OAGG;IACH,IAAW,SAAS,IAAI,SAAS,CAEhC;CACJ;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { ContainerModule } from "inversify";
|
|
1
|
+
import { ContainerModule, interfaces } from "inversify";
|
|
2
|
+
/**
|
|
3
|
+
* The scope decorator is a higher order function that can be used to decorate a class with a binding type.
|
|
4
|
+
* @param binding An instance of interfaces.BindingScope which represents the binding type.
|
|
5
|
+
* @returns A decorator function that can be used to decorate a class with a binding type.
|
|
6
|
+
*/
|
|
7
|
+
declare const scope: (binding: interfaces.BindingScope) => (target: any) => void;
|
|
2
8
|
/**
|
|
3
9
|
* The BaseModule class provides methods for creating InversifyJS container modules.
|
|
4
10
|
* @provide BaseModule
|
|
5
11
|
*/
|
|
6
12
|
declare class BaseModule {
|
|
7
|
-
constructor();
|
|
8
13
|
/**
|
|
9
14
|
* Create a map of symbols for the provided controllers.
|
|
10
15
|
* @param controllers - An array of controller classes.
|
|
@@ -12,12 +17,13 @@ declare class BaseModule {
|
|
|
12
17
|
*/
|
|
13
18
|
private static createSymbols;
|
|
14
19
|
/**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
* Create an InversifyJS ContainerModule for the provided controllers.
|
|
21
|
+
* @param controllers - An array of controller classes.
|
|
22
|
+
* @param scope - An optional binding scope to be used for all controllers.
|
|
23
|
+
* @returns A ContainerModule with the controller bindings.
|
|
24
|
+
*/
|
|
25
|
+
static createContainerModule(controllers: any[], scope?: interfaces.BindingScope): ContainerModule;
|
|
20
26
|
}
|
|
21
27
|
declare const CreateModule: typeof BaseModule.createContainerModule;
|
|
22
|
-
export { CreateModule };
|
|
28
|
+
export { CreateModule, scope };
|
|
23
29
|
//# sourceMappingURL=container-module.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container-module.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/container-module/container-module.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"container-module.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/container-module/container-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,eAAe,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAS1E;;;;GAIG;AACH,QAAA,MAAM,KAAK,YAAa,WAAW,YAAY,cAClB,GAAG,SAiB/B,CAAC;AAOF;;;GAGG;AACH,cACM,UAAU;IACZ;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,aAAa;IAY5B;;;;;OAKG;WACW,qBAAqB,CAC/B,WAAW,EAAE,GAAG,EAAE,EAClB,KAAK,CAAC,EAAE,UAAU,CAAC,YAAY,GAChC,eAAe;CAyCrB;AAED,QAAA,MAAM,YAAY,yCAAmC,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { CreateModule } from "./container-module";
|
|
1
|
+
export { CreateModule, scope } from "./container-module";
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/container-module/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/container-module/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA"}
|
|
@@ -10,7 +10,7 @@ declare abstract class BaseController implements interfaces.Controller {
|
|
|
10
10
|
* Constructs a new BaseController instance with a specified service name.
|
|
11
11
|
* @param serviceName - The name of the service associated with the controller.
|
|
12
12
|
*/
|
|
13
|
-
constructor(serviceName
|
|
13
|
+
constructor(serviceName?: string);
|
|
14
14
|
/**
|
|
15
15
|
* Calls an asynchronous use case and sends an appropriate response based on the result.
|
|
16
16
|
* @param useCase - A promise representing the asynchronous use case to call.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-controller.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/controller/base-controller.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAGrD;;;;GAIG;AACH,uBACe,cAAe,YAAW,UAAU,CAAC,UAAU;IAE1D,OAAO,CAAC,WAAW,CAAS;IAE5B;;;OAGG;gBACS,WAAW,
|
|
1
|
+
{"version":3,"file":"base-controller.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/controller/base-controller.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAGrD;;;;GAIG;AACH,uBACe,cAAe,YAAW,UAAU,CAAC,UAAU;IAE1D,OAAO,CAAC,WAAW,CAAS;IAE5B;;;OAGG;gBACS,WAAW,GAAE,MAAS;IAIlC;;;;;OAKG;cACa,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,iBAAiB,EAAE,MAAM;IAa3F;;;;;OAKG;IACH,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,iBAAiB,EAAE,MAAM;CAc1E;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/decorator/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope-binding.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/decorator/scope-binding.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,gBAAgB,eAAgB,GAAG,yBAExC,CAAC;AAEF,QAAA,MAAM,gBAAgB,eAAgB,GAAG,yBAExC,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,CAAC"}
|
package/lib/cjs/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/core/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/core/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
|
|
@@ -4,11 +4,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
7
|
var AppContainer_1;
|
|
11
|
-
import { Container } from "inversify";
|
|
8
|
+
import { BindingScopeEnum, Container } from "inversify";
|
|
12
9
|
import { buildProviderModule, provide } from "inversify-binding-decorators";
|
|
13
10
|
/**
|
|
14
11
|
* The AppContainer class provides a container for managing dependency injection.
|
|
@@ -16,23 +13,43 @@ import { buildProviderModule, provide } from "inversify-binding-decorators";
|
|
|
16
13
|
*/
|
|
17
14
|
let AppContainer = AppContainer_1 = class AppContainer {
|
|
18
15
|
container;
|
|
19
|
-
/**
|
|
20
|
-
* Constructs a new instance of the AppContainer class.
|
|
21
|
-
*/
|
|
22
|
-
constructor() { }
|
|
23
16
|
/**
|
|
24
17
|
* Creates and configures a new dependency injection container.
|
|
25
18
|
* @param modules - An array of ContainerModule instances to load into the container.
|
|
19
|
+
* @param defaultScope - The default scope to use for bindings. Scoped (Request) by default, but offers Singleton and Transient as well.
|
|
26
20
|
* @returns The configured dependency injection container.
|
|
27
21
|
*/
|
|
28
|
-
create(modules) {
|
|
29
|
-
this.container = new Container(
|
|
22
|
+
create(modules, defaultScope = BindingScopeEnum.Request) {
|
|
23
|
+
this.container = new Container({
|
|
24
|
+
autoBindInjectable: true,
|
|
25
|
+
defaultScope,
|
|
26
|
+
});
|
|
30
27
|
this.container.load(buildProviderModule(), ...modules);
|
|
31
28
|
return this.container;
|
|
32
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Retrieves the binding dictionary of the container.
|
|
32
|
+
* @returns The binding dictionary of the container.
|
|
33
|
+
*/
|
|
34
|
+
getBindingDictionary() {
|
|
35
|
+
return this.container["_bindingDictionary"]._map;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Retrieves the container options.
|
|
39
|
+
* @returns The container options.
|
|
40
|
+
*/
|
|
41
|
+
getContainerOptions() {
|
|
42
|
+
return this.container["options"];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Retrieves the container.
|
|
46
|
+
* @returns The container.
|
|
47
|
+
*/
|
|
48
|
+
get Container() {
|
|
49
|
+
return this.container;
|
|
50
|
+
}
|
|
33
51
|
};
|
|
34
52
|
AppContainer = AppContainer_1 = __decorate([
|
|
35
|
-
provide(AppContainer_1)
|
|
36
|
-
__metadata("design:paramtypes", [])
|
|
53
|
+
provide(AppContainer_1)
|
|
37
54
|
], AppContainer);
|
|
38
55
|
export { AppContainer };
|
|
@@ -4,18 +4,42 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
7
|
var BaseModule_1;
|
|
11
|
-
import { ContainerModule } from "inversify";
|
|
8
|
+
import { BindingScopeEnum, ContainerModule } from "inversify";
|
|
12
9
|
import { provide } from "inversify-binding-decorators";
|
|
10
|
+
import { provideSingleton, provideTransient } from "../decorator";
|
|
11
|
+
/**
|
|
12
|
+
* Key to be used for storing and retrieving binding type metadata.
|
|
13
|
+
*/
|
|
14
|
+
const BINDING_TYPE_METADATA_KEY = "binding-type";
|
|
15
|
+
/**
|
|
16
|
+
* The scope decorator is a higher order function that can be used to decorate a class with a binding type.
|
|
17
|
+
* @param binding An instance of interfaces.BindingScope which represents the binding type.
|
|
18
|
+
* @returns A decorator function that can be used to decorate a class with a binding type.
|
|
19
|
+
*/
|
|
20
|
+
const scope = (binding) => {
|
|
21
|
+
return function (target) {
|
|
22
|
+
if (!Reflect.hasMetadata(BINDING_TYPE_METADATA_KEY, target)) {
|
|
23
|
+
Reflect.defineMetadata(BINDING_TYPE_METADATA_KEY, binding, target);
|
|
24
|
+
switch (binding) {
|
|
25
|
+
case BindingScopeEnum.Singleton:
|
|
26
|
+
provideSingleton(target);
|
|
27
|
+
break;
|
|
28
|
+
case BindingScopeEnum.Transient:
|
|
29
|
+
provideTransient(target);
|
|
30
|
+
break;
|
|
31
|
+
default:
|
|
32
|
+
provide(target);
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
};
|
|
13
38
|
/**
|
|
14
39
|
* The BaseModule class provides methods for creating InversifyJS container modules.
|
|
15
40
|
* @provide BaseModule
|
|
16
41
|
*/
|
|
17
42
|
let BaseModule = BaseModule_1 = class BaseModule {
|
|
18
|
-
constructor() { }
|
|
19
43
|
/**
|
|
20
44
|
* Create a map of symbols for the provided controllers.
|
|
21
45
|
* @param controllers - An array of controller classes.
|
|
@@ -31,23 +55,51 @@ let BaseModule = BaseModule_1 = class BaseModule {
|
|
|
31
55
|
return symbols;
|
|
32
56
|
}
|
|
33
57
|
/**
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
58
|
+
* Create an InversifyJS ContainerModule for the provided controllers.
|
|
59
|
+
* @param controllers - An array of controller classes.
|
|
60
|
+
* @param scope - An optional binding scope to be used for all controllers.
|
|
61
|
+
* @returns A ContainerModule with the controller bindings.
|
|
62
|
+
*/
|
|
63
|
+
static createContainerModule(controllers, scope) {
|
|
39
64
|
const symbols = BaseModule_1.createSymbols(controllers);
|
|
40
|
-
return new ContainerModule(bind => {
|
|
41
|
-
for (const symbol of symbols) {
|
|
42
|
-
|
|
43
|
-
|
|
65
|
+
return new ContainerModule((bind) => {
|
|
66
|
+
for (const [symbol, target] of symbols) {
|
|
67
|
+
if (scope) {
|
|
68
|
+
switch (scope) {
|
|
69
|
+
case BindingScopeEnum.Singleton:
|
|
70
|
+
bind(symbol).to(target).inSingletonScope();
|
|
71
|
+
break;
|
|
72
|
+
case BindingScopeEnum.Transient:
|
|
73
|
+
bind(symbol).to(target).inTransientScope();
|
|
74
|
+
break;
|
|
75
|
+
case BindingScopeEnum.Request:
|
|
76
|
+
bind(symbol).to(target).inRequestScope();
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
const bindingType = Reflect.getMetadata(BINDING_TYPE_METADATA_KEY, target);
|
|
82
|
+
switch (bindingType) {
|
|
83
|
+
case BindingScopeEnum.Singleton:
|
|
84
|
+
bind(symbol).to(target).inSingletonScope();
|
|
85
|
+
break;
|
|
86
|
+
case BindingScopeEnum.Transient:
|
|
87
|
+
bind(symbol).to(target).inTransientScope();
|
|
88
|
+
break;
|
|
89
|
+
case BindingScopeEnum.Request:
|
|
90
|
+
bind(symbol).to(target).inRequestScope();
|
|
91
|
+
break;
|
|
92
|
+
default:
|
|
93
|
+
bind(symbol).to(target).inRequestScope();
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
44
97
|
}
|
|
45
98
|
});
|
|
46
99
|
}
|
|
47
100
|
};
|
|
48
101
|
BaseModule = BaseModule_1 = __decorate([
|
|
49
|
-
provide(BaseModule_1)
|
|
50
|
-
__metadata("design:paramtypes", [])
|
|
102
|
+
provide(BaseModule_1)
|
|
51
103
|
], BaseModule);
|
|
52
104
|
const CreateModule = BaseModule.createContainerModule;
|
|
53
|
-
export { CreateModule };
|
|
105
|
+
export { CreateModule, scope };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { CreateModule } from "./container-module";
|
|
1
|
+
export { CreateModule, scope } from "./container-module";
|
|
@@ -21,7 +21,7 @@ let BaseController = BaseController_1 = class BaseController {
|
|
|
21
21
|
* Constructs a new BaseController instance with a specified service name.
|
|
22
22
|
* @param serviceName - The name of the service associated with the controller.
|
|
23
23
|
*/
|
|
24
|
-
constructor(serviceName) {
|
|
24
|
+
constructor(serviceName = "") {
|
|
25
25
|
this.serviceName = serviceName;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./scope-binding";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { fluentProvide } from "inversify-binding-decorators";
|
|
2
|
+
const provideSingleton = (identifier) => {
|
|
3
|
+
return fluentProvide(identifier).inSingletonScope().done();
|
|
4
|
+
};
|
|
5
|
+
const provideTransient = (identifier) => {
|
|
6
|
+
return fluentProvide(identifier).inTransientScope().done();
|
|
7
|
+
};
|
|
8
|
+
export { provideSingleton, provideTransient };
|
package/lib/esm/index.mjs
CHANGED
|
@@ -1,20 +1,32 @@
|
|
|
1
|
-
import { Container, ContainerModule } from "inversify";
|
|
1
|
+
import { Container, ContainerModule, interfaces } from "inversify";
|
|
2
2
|
/**
|
|
3
3
|
* The AppContainer class provides a container for managing dependency injection.
|
|
4
4
|
* @provide AppContainer
|
|
5
5
|
*/
|
|
6
6
|
declare class AppContainer {
|
|
7
7
|
private container;
|
|
8
|
-
/**
|
|
9
|
-
* Constructs a new instance of the AppContainer class.
|
|
10
|
-
*/
|
|
11
|
-
constructor();
|
|
12
8
|
/**
|
|
13
9
|
* Creates and configures a new dependency injection container.
|
|
14
10
|
* @param modules - An array of ContainerModule instances to load into the container.
|
|
11
|
+
* @param defaultScope - The default scope to use for bindings. Scoped (Request) by default, but offers Singleton and Transient as well.
|
|
15
12
|
* @returns The configured dependency injection container.
|
|
16
13
|
*/
|
|
17
|
-
create(modules: ContainerModule[]): Container;
|
|
14
|
+
create(modules: ContainerModule[], defaultScope?: interfaces.BindingScope): Container;
|
|
15
|
+
/**
|
|
16
|
+
* Retrieves the binding dictionary of the container.
|
|
17
|
+
* @returns The binding dictionary of the container.
|
|
18
|
+
*/
|
|
19
|
+
getBindingDictionary(): Map<any, any>;
|
|
20
|
+
/**
|
|
21
|
+
* Retrieves the container options.
|
|
22
|
+
* @returns The container options.
|
|
23
|
+
*/
|
|
24
|
+
getContainerOptions(): interfaces.ContainerOptions;
|
|
25
|
+
/**
|
|
26
|
+
* Retrieves the container.
|
|
27
|
+
* @returns The container.
|
|
28
|
+
*/
|
|
29
|
+
get Container(): Container;
|
|
18
30
|
}
|
|
19
31
|
export { AppContainer };
|
|
20
32
|
//# sourceMappingURL=app-container.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-container.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/application/app-container.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"app-container.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/application/app-container.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,SAAS,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAGrF;;;GAGG;AACH,cACM,YAAY;IAEd,OAAO,CAAC,SAAS,CAAa;IAC9B;;;;;OAKG;IACI,MAAM,CACT,OAAO,EAAE,eAAe,EAAE,EAC1B,YAAY,GAAE,UAAU,CAAC,YAAuC,GACjE,SAAS;IAWZ;;;OAGG;IACI,oBAAoB,IAAI,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC;IAI5C;;;OAGG;IACI,mBAAmB,IAAI,UAAU,CAAC,gBAAgB;IAIzD;;;OAGG;IACH,IAAW,SAAS,IAAI,SAAS,CAEhC;CACJ;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { ContainerModule } from "inversify";
|
|
1
|
+
import { ContainerModule, interfaces } from "inversify";
|
|
2
|
+
/**
|
|
3
|
+
* The scope decorator is a higher order function that can be used to decorate a class with a binding type.
|
|
4
|
+
* @param binding An instance of interfaces.BindingScope which represents the binding type.
|
|
5
|
+
* @returns A decorator function that can be used to decorate a class with a binding type.
|
|
6
|
+
*/
|
|
7
|
+
declare const scope: (binding: interfaces.BindingScope) => (target: any) => void;
|
|
2
8
|
/**
|
|
3
9
|
* The BaseModule class provides methods for creating InversifyJS container modules.
|
|
4
10
|
* @provide BaseModule
|
|
5
11
|
*/
|
|
6
12
|
declare class BaseModule {
|
|
7
|
-
constructor();
|
|
8
13
|
/**
|
|
9
14
|
* Create a map of symbols for the provided controllers.
|
|
10
15
|
* @param controllers - An array of controller classes.
|
|
@@ -12,12 +17,13 @@ declare class BaseModule {
|
|
|
12
17
|
*/
|
|
13
18
|
private static createSymbols;
|
|
14
19
|
/**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
* Create an InversifyJS ContainerModule for the provided controllers.
|
|
21
|
+
* @param controllers - An array of controller classes.
|
|
22
|
+
* @param scope - An optional binding scope to be used for all controllers.
|
|
23
|
+
* @returns A ContainerModule with the controller bindings.
|
|
24
|
+
*/
|
|
25
|
+
static createContainerModule(controllers: any[], scope?: interfaces.BindingScope): ContainerModule;
|
|
20
26
|
}
|
|
21
27
|
declare const CreateModule: typeof BaseModule.createContainerModule;
|
|
22
|
-
export { CreateModule };
|
|
28
|
+
export { CreateModule, scope };
|
|
23
29
|
//# sourceMappingURL=container-module.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container-module.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/container-module/container-module.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"container-module.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/container-module/container-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,eAAe,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAS1E;;;;GAIG;AACH,QAAA,MAAM,KAAK,YAAa,WAAW,YAAY,cAClB,GAAG,SAiB/B,CAAC;AAOF;;;GAGG;AACH,cACM,UAAU;IACZ;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,aAAa;IAY5B;;;;;OAKG;WACW,qBAAqB,CAC/B,WAAW,EAAE,GAAG,EAAE,EAClB,KAAK,CAAC,EAAE,UAAU,CAAC,YAAY,GAChC,eAAe;CAyCrB;AAED,QAAA,MAAM,YAAY,yCAAmC,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { CreateModule } from "./container-module";
|
|
1
|
+
export { CreateModule, scope } from "./container-module";
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/container-module/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/container-module/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA"}
|
|
@@ -10,7 +10,7 @@ declare abstract class BaseController implements interfaces.Controller {
|
|
|
10
10
|
* Constructs a new BaseController instance with a specified service name.
|
|
11
11
|
* @param serviceName - The name of the service associated with the controller.
|
|
12
12
|
*/
|
|
13
|
-
constructor(serviceName
|
|
13
|
+
constructor(serviceName?: string);
|
|
14
14
|
/**
|
|
15
15
|
* Calls an asynchronous use case and sends an appropriate response based on the result.
|
|
16
16
|
* @param useCase - A promise representing the asynchronous use case to call.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-controller.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/controller/base-controller.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAGrD;;;;GAIG;AACH,uBACe,cAAe,YAAW,UAAU,CAAC,UAAU;IAE1D,OAAO,CAAC,WAAW,CAAS;IAE5B;;;OAGG;gBACS,WAAW,
|
|
1
|
+
{"version":3,"file":"base-controller.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/controller/base-controller.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAGrD;;;;GAIG;AACH,uBACe,cAAe,YAAW,UAAU,CAAC,UAAU;IAE1D,OAAO,CAAC,WAAW,CAAS;IAE5B;;;OAGG;gBACS,WAAW,GAAE,MAAS;IAIlC;;;;;OAKG;cACa,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,iBAAiB,EAAE,MAAM;IAa3F;;;;;OAKG;IACH,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,iBAAiB,EAAE,MAAM;CAc1E;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/decorator/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope-binding.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/decorator/scope-binding.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,gBAAgB,eAAgB,GAAG,yBAExC,CAAC;AAEF,QAAA,MAAM,gBAAgB,eAAgB,GAAG,yBAExC,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,CAAC"}
|
package/lib/esm/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/core/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/core/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
|
package/lib/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expressots/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Expressots - modern, fast, lightweight nodejs web framework (@core)",
|
|
5
5
|
"author": "Richard Zampieri",
|
|
6
6
|
"main": "./lib/cjs/index.js",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"homepage": "https://expresso-ts.com",
|
|
25
25
|
"funding": {
|
|
26
|
-
"type": "",
|
|
27
|
-
"url": ""
|
|
26
|
+
"type": "github",
|
|
27
|
+
"url": "https://github.com/sponsors/expressots"
|
|
28
28
|
},
|
|
29
29
|
"repository": {
|
|
30
30
|
"type": "git",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expressots/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Expressots - modern, fast, lightweight nodejs web framework (@core)",
|
|
5
5
|
"author": "Richard Zampieri",
|
|
6
6
|
"main": "./lib/cjs/index.js",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"homepage": "https://expresso-ts.com",
|
|
25
25
|
"funding": {
|
|
26
|
-
"type": "",
|
|
27
|
-
"url": ""
|
|
26
|
+
"type": "github",
|
|
27
|
+
"url": "https://github.com/sponsors/expressots"
|
|
28
28
|
},
|
|
29
29
|
"repository": {
|
|
30
30
|
"type": "git",
|