@expressots/core 2.7.0 → 2.9.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/lib/CHANGELOG.md +77 -0
- package/lib/cjs/application/app-container.js +94 -82
- package/lib/cjs/application/application-factory.js +74 -72
- package/lib/cjs/application/index.js +7 -7
- package/lib/cjs/common/color-service.provider.js +47 -46
- package/lib/cjs/common/index.js +2 -2
- package/lib/cjs/common/package-resolver.provider.js +35 -35
- package/lib/cjs/common/project-config.provider.js +2 -2
- package/lib/cjs/console/console.js +61 -61
- package/lib/cjs/console/index.js +5 -5
- package/lib/cjs/container-module/container-module.js +111 -111
- package/lib/cjs/container-module/index.js +6 -6
- package/lib/cjs/controller/base-controller.js +75 -75
- package/lib/cjs/controller/index.js +5 -5
- package/lib/cjs/decorator/index.js +17 -17
- package/lib/cjs/decorator/scope-binding.js +44 -44
- package/lib/cjs/error/app-error.js +26 -37
- package/lib/cjs/error/error-handler-middleware.js +28 -28
- package/lib/cjs/error/index.js +9 -9
- package/lib/cjs/error/report.js +54 -57
- package/lib/cjs/error/status-code.js +89 -89
- package/lib/cjs/index.js +26 -26
- package/lib/cjs/middleware/index.js +32 -29
- package/lib/cjs/middleware/interfaces/body-parser.interface.js +2 -2
- package/lib/cjs/middleware/interfaces/compression.interface.js +2 -2
- package/lib/cjs/middleware/interfaces/cookie-parser.interface.js +2 -2
- package/lib/cjs/middleware/interfaces/cookie-session/cookie-session.interface.js +2 -2
- package/lib/cjs/middleware/interfaces/cookie-session/keygrip.interface.js +2 -2
- package/lib/cjs/middleware/interfaces/cors.interface.js +2 -2
- package/lib/cjs/middleware/interfaces/express-rate-limit.interface.js +2 -2
- package/lib/cjs/middleware/interfaces/express-session.interface.js +2 -2
- package/lib/cjs/middleware/interfaces/helmet.interface.js +2 -2
- package/lib/cjs/middleware/interfaces/morgan.interface.js +2 -2
- package/lib/cjs/middleware/interfaces/multer.interface.js +2 -0
- package/lib/cjs/middleware/interfaces/serve-favicon.interface.js +2 -2
- package/lib/cjs/middleware/interfaces/serve-static.interface.js +2 -2
- package/lib/cjs/middleware/middleware-resolver.js +72 -72
- package/lib/cjs/middleware/middleware-service.js +481 -300
- package/lib/cjs/provider/db-in-memory/db-in-memory.provider.js +82 -75
- package/lib/cjs/provider/dto-validator/dto-validator.provider.js +53 -53
- package/lib/cjs/provider/environment/env-validator.provider.js +98 -96
- package/lib/cjs/provider/index.js +13 -13
- package/lib/cjs/provider/logger/{logger-service.js → logger.provider.js} +117 -115
- package/lib/cjs/provider/provider-manager.js +50 -0
- package/lib/cjs/render/handlebars.interface.js +2 -2
- package/lib/cjs/render/index.js +2 -2
- package/lib/cjs/render/render.type.js +2 -2
- package/lib/cjs/types/application/app-container.d.ts +62 -125
- package/lib/cjs/types/application/application-factory.d.ts +34 -33
- package/lib/cjs/types/application/index.d.ts +2 -2
- package/lib/cjs/types/common/color-service.provider.d.ts +29 -29
- package/lib/cjs/types/common/index.d.ts +1 -1
- package/lib/cjs/types/common/package-resolver.provider.d.ts +8 -8
- package/lib/cjs/types/common/project-config.provider.d.ts +47 -47
- package/lib/cjs/types/console/console.d.ts +27 -27
- package/lib/cjs/types/console/index.d.ts +1 -1
- package/lib/cjs/types/container-module/container-module.d.ts +28 -28
- package/lib/cjs/types/container-module/index.d.ts +1 -1
- package/lib/cjs/types/controller/base-controller.d.ts +48 -48
- package/lib/cjs/types/controller/index.d.ts +1 -1
- package/lib/cjs/types/decorator/index.d.ts +1 -1
- package/lib/cjs/types/decorator/scope-binding.d.ts +33 -33
- package/lib/cjs/types/error/app-error.d.ts +29 -29
- package/lib/cjs/types/error/error-handler-middleware.d.ts +11 -11
- package/lib/cjs/types/error/index.d.ts +3 -3
- package/lib/cjs/types/error/report.d.ts +25 -25
- package/lib/cjs/types/error/status-code.d.ts +136 -136
- package/lib/cjs/types/index.d.ts +10 -10
- package/lib/cjs/types/middleware/index.d.ts +13 -12
- package/lib/cjs/types/middleware/interfaces/body-parser.interface.d.ts +33 -33
- package/lib/cjs/types/middleware/interfaces/compression.interface.d.ts +98 -98
- package/lib/cjs/types/middleware/interfaces/cookie-parser.interface.d.ts +9 -9
- package/lib/cjs/types/middleware/interfaces/cookie-session/cookie-session.interface.d.ts +57 -57
- package/lib/cjs/types/middleware/interfaces/cookie-session/keygrip.interface.d.ts +27 -27
- package/lib/cjs/types/middleware/interfaces/cors.interface.d.ts +57 -57
- package/lib/cjs/types/middleware/interfaces/express-rate-limit.interface.d.ts +292 -292
- package/lib/cjs/types/middleware/interfaces/express-session.interface.d.ts +207 -208
- package/lib/cjs/types/middleware/interfaces/helmet.interface.d.ts +210 -210
- package/lib/cjs/types/middleware/interfaces/morgan.interface.d.ts +40 -40
- package/lib/cjs/types/middleware/interfaces/multer.interface.d.ts +255 -0
- package/lib/cjs/types/middleware/interfaces/serve-favicon.interface.d.ts +11 -11
- package/lib/cjs/types/middleware/interfaces/serve-static.interface.d.ts +70 -70
- package/lib/cjs/types/middleware/middleware-resolver.d.ts +11 -11
- package/lib/cjs/types/middleware/middleware-service.d.ts +368 -275
- package/lib/cjs/types/provider/db-in-memory/db-in-memory.provider.d.ts +43 -38
- package/lib/cjs/types/provider/dto-validator/dto-validator.provider.d.ts +11 -11
- package/lib/cjs/types/provider/environment/env-validator.provider.d.ts +35 -30
- package/lib/cjs/types/provider/index.d.ts +5 -5
- package/lib/cjs/types/provider/logger/{logger-service.d.ts → logger.provider.d.ts} +54 -49
- package/lib/cjs/types/provider/provider-manager.d.ts +16 -0
- package/lib/cjs/types/render/handlebars.interface.d.ts +46 -46
- package/lib/cjs/types/render/index.d.ts +2 -2
- package/lib/cjs/types/render/render.type.d.ts +12 -12
- package/lib/package.json +21 -20
- package/package.json +21 -20
- package/lib/cjs/provider/provider-service.js +0 -38
- package/lib/cjs/types/provider/provider-service.d.ts +0 -30
package/lib/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,82 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
+
## [2.9.0](https://github.com/expressots/expressots/compare/2.8.0...2.9.0) (2024-03-18)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add plugin pattern on provider manager ([f56d5b3](https://github.com/expressots/expressots/commit/f56d5b3a2ebdcca8e61e91e831ce43e6e2a90c57))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* change expressots version to latest ([d42f0c9](https://github.com/expressots/expressots/commit/d42f0c9987ffa7a8ecc213500e39364182ba800e))
|
|
14
|
+
* lock lib ver, add tsconfig to package ([298201c](https://github.com/expressots/expressots/commit/298201c1442821cf63f7ed788d7f76a6a7fe79e0))
|
|
15
|
+
* lock versions, update to es2021 ([1ca53ca](https://github.com/expressots/expressots/commit/1ca53ca8ad6e52aea136fe48a99aab389456de93))
|
|
16
|
+
* remove the appcontainer return dictionary method ([3dddb86](https://github.com/expressots/expressots/commit/3dddb86bf35e08e42f43c960e796756f2b938805))
|
|
17
|
+
* rename logger-service to logger.provider ([3344717](https://github.com/expressots/expressots/commit/33447175665ed36c3581143bc451bf27fb4b778b))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Code Refactoring
|
|
21
|
+
|
|
22
|
+
* adjust core op template and add full example ([ca5a843](https://github.com/expressots/expressots/commit/ca5a8436ae5a2afb57f426f6dc8b8efa0050f6b1))
|
|
23
|
+
* non opinionated templated structure change ([8caf0d1](https://github.com/expressots/expressots/commit/8caf0d12b3751c61dfa16bb4a70722c64763ffcd))
|
|
24
|
+
* update eslint config inferrable types ([845101f](https://github.com/expressots/expressots/commit/845101fa6472ab4874a220ef63ea4e8296fbd7a6))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Continuous Integrations
|
|
28
|
+
|
|
29
|
+
* add prepublish script ([7b1478e](https://github.com/expressots/expressots/commit/7b1478e7cf1ec44b63e9f1a99354e49cb4ddaa7d))
|
|
30
|
+
|
|
31
|
+
## [2.8.0](https://github.com/expressots/expressots/compare/2.7.0...2.8.0) (2024-3-5)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Features
|
|
35
|
+
|
|
36
|
+
* add middleware handler, config and expresso ([df60183](https://github.com/expressots/expressots/commit/df601837a771662723f25f185622de8c912f6721))
|
|
37
|
+
* add provide annotation to abstract class ExpressMiddleware ([49e762e](https://github.com/expressots/expressots/commit/49e762e035053d67a977d54d9f448334e931134b))
|
|
38
|
+
* Added it into options wiring ([58e58c1](https://github.com/expressots/expressots/commit/58e58c11693d8dfc8e235bbc5b8d62aa35493ec9))
|
|
39
|
+
* Added multer middleware for expressots ([522db5d](https://github.com/expressots/expressots/commit/522db5d58dd4521fd03528cf4178cbbc951a0537))
|
|
40
|
+
* bump @commitlint/cli from 17.8.1 to 18.0.0 ([4ddcbd4](https://github.com/expressots/expressots/commit/4ddcbd49ffe65cfa7a15b253515bb7f3446046ee))
|
|
41
|
+
* bump @commitlint/config-conventional from 17.8.1 to 18.0.0 ([91e1237](https://github.com/expressots/expressots/commit/91e12370f9736188805df20d4f7da378720ac43b))
|
|
42
|
+
* bump husky from 8.0.3 to 9.0.11 ([#170](https://github.com/expressots/expressots/issues/170)) ([342983f](https://github.com/expressots/expressots/commit/342983fe59d6ccc409f887f7a1c8f65c9469a8d7))
|
|
43
|
+
* bump prettier from 3.0.3 to 3.1.1 ([#145](https://github.com/expressots/expressots/issues/145)) ([2e7b812](https://github.com/expressots/expressots/commit/2e7b81226c65468edacae51407ce56c78c66a85b))
|
|
44
|
+
* bump prettier from 3.1.1 to 3.2.5 ([#166](https://github.com/expressots/expressots/issues/166)) ([49c148c](https://github.com/expressots/expressots/commit/49c148c2fae6b4e0260650fbbcf559c69075d9bc))
|
|
45
|
+
* bump reflect-metadata from 0.1.14 to 0.2.1 ([#148](https://github.com/expressots/expressots/issues/148)) ([f444982](https://github.com/expressots/expressots/commit/f444982ccbedb75f3c26b982a2a5d5d336857aae))
|
|
46
|
+
* bump vite from 4.4.11 to 4.5.0 ([344161c](https://github.com/expressots/expressots/commit/344161cdf0cd7f54ffaa069023241aaea04d7c5d))
|
|
47
|
+
* comments addressed ([8c3f55a](https://github.com/expressots/expressots/commit/8c3f55a901874c1e9c33d415157fa0a2beab9c56))
|
|
48
|
+
* correct expresso middleware path ([0879c10](https://github.com/expressots/expressots/commit/0879c104810256f5143dcb2206579debaf0e6a97))
|
|
49
|
+
* Include multer as resolver ([056d4d9](https://github.com/expressots/expressots/commit/056d4d99801f9f4af2932bcee333a1fa652b45a8))
|
|
50
|
+
* remove getmiddleware pipeline from interface ([0577527](https://github.com/expressots/expressots/commit/057752754e257552eddebf031cf977f663b093ed))
|
|
51
|
+
* Remove multer dependency / Added dynamic multer usage behavior ([6a4530b](https://github.com/expressots/expressots/commit/6a4530be243c961e5bfe50340d2c41742332e186))
|
|
52
|
+
* Remove multer dependency with interface defined ([5a0acd2](https://github.com/expressots/expressots/commit/5a0acd228166efc2de8f4be7078c21ed6fd34634))
|
|
53
|
+
* Remove multer dependency with interface defined ([8133621](https://github.com/expressots/expressots/commit/8133621108bb7f2017088d59ae6145da8606ebf7))
|
|
54
|
+
* update reflect metadata on templates ([#152](https://github.com/expressots/expressots/issues/152)) ([75a3312](https://github.com/expressots/expressots/commit/75a33122e0f468b9e28040b8e7eb6747252e4c6b))
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
### Bug Fixes
|
|
58
|
+
|
|
59
|
+
* interface types and middleware return multer ([b5223fd](https://github.com/expressots/expressots/commit/b5223fdc22eaaf1cb9b315b2aa77ad0e615e8ed3))
|
|
60
|
+
* remove codesee build ([#177](https://github.com/expressots/expressots/issues/177)) ([812e06d](https://github.com/expressots/expressots/commit/812e06da1b91cc7a4b0685ec70b0f0de1bd4517b))
|
|
61
|
+
|
|
62
|
+
## [2.7.0](https://github.com/expressots/expressots/compare/2.6.0...2.7.0) (2023-10-17)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
### Features
|
|
66
|
+
|
|
67
|
+
* add db in memory as provider ([b656f22](https://github.com/expressots/expressots/commit/b656f2297e0e985dd5184c611f795edddf6c5b2d))
|
|
68
|
+
* modify IMemoryDB interface name ([fd1d440](https://github.com/expressots/expressots/commit/fd1d440eb947f377955bfc2a969d3e7ca4ffaa3e))
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
### Bug Fixes
|
|
72
|
+
|
|
73
|
+
* remove db in memory from template opinionated ([0516c8c](https://github.com/expressots/expressots/commit/0516c8c4e9c0e1a4b8aae3fab5842136a0565a39))
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
### Tests
|
|
77
|
+
|
|
78
|
+
* improve collocation and fix console tests ([52bdf98](https://github.com/expressots/expressots/commit/52bdf98cfcbbffc58841b1b67c6ce2a1f6fe308b))
|
|
79
|
+
|
|
3
80
|
## [2.6.0](https://github.com/expressots/expressots/compare/2.5.0...2.6.0) (2023-10-09)
|
|
4
81
|
|
|
5
82
|
|
|
@@ -1,82 +1,94 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
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
|
-
var AppContainer_1;
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.AppContainer = void 0;
|
|
14
|
-
const inversify_1 = require("inversify");
|
|
15
|
-
const inversify_binding_decorators_1 = require("inversify-binding-decorators");
|
|
16
|
-
/**
|
|
17
|
-
* The AppContainer class provides a container for managing dependency injection.
|
|
18
|
-
* It allows the creation of a container with custom options, including default binding scope
|
|
19
|
-
* and the ability to skip base class checks. The container can be loaded with multiple
|
|
20
|
-
* ContainerModule instances, facilitating modular and organized code.
|
|
21
|
-
*
|
|
22
|
-
* Usage:
|
|
23
|
-
* const appContainer = new AppContainer(options);
|
|
24
|
-
* const container = appContainer.create(modules);
|
|
25
|
-
*
|
|
26
|
-
* @provide AppContainer
|
|
27
|
-
*/
|
|
28
|
-
let AppContainer = AppContainer_1 = class AppContainer {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
*
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
this.container
|
|
53
|
-
this.container.load((0, inversify_binding_decorators_1.buildProviderModule)(), ...modules);
|
|
54
|
-
return this.container;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Retrieves the binding dictionary of the container.
|
|
58
|
-
* @returns
|
|
59
|
-
*/
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
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
|
+
var AppContainer_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.AppContainer = void 0;
|
|
14
|
+
const inversify_1 = require("inversify");
|
|
15
|
+
const inversify_binding_decorators_1 = require("inversify-binding-decorators");
|
|
16
|
+
/**
|
|
17
|
+
* The AppContainer class provides a container for managing dependency injection.
|
|
18
|
+
* It allows the creation of a container with custom options, including default binding scope
|
|
19
|
+
* and the ability to skip base class checks. The container can be loaded with multiple
|
|
20
|
+
* ContainerModule instances, facilitating modular and organized code.
|
|
21
|
+
*
|
|
22
|
+
* Usage:
|
|
23
|
+
* const appContainer = new AppContainer(options);
|
|
24
|
+
* const container = appContainer.create(modules);
|
|
25
|
+
*
|
|
26
|
+
* @provide AppContainer
|
|
27
|
+
*/
|
|
28
|
+
let AppContainer = AppContainer_1 = class AppContainer {
|
|
29
|
+
/**
|
|
30
|
+
* Constructs the AppContainer instance.
|
|
31
|
+
* @param options - The options for creating the container. Can include custom default scope and skip base class checks setting.
|
|
32
|
+
*/
|
|
33
|
+
constructor(options) {
|
|
34
|
+
this.options = {
|
|
35
|
+
defaultScope: inversify_1.BindingScopeEnum.Request,
|
|
36
|
+
...options,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Creates and configures a new dependency injection container.
|
|
41
|
+
* @param modules - An array of ContainerModule instances to load into the container.
|
|
42
|
+
* @returns The configured dependency injection container.
|
|
43
|
+
*/
|
|
44
|
+
create(modules) {
|
|
45
|
+
const containerOptions = {
|
|
46
|
+
autoBindInjectable: this.options.autoBindInjectable
|
|
47
|
+
? this.options.autoBindInjectable
|
|
48
|
+
: true,
|
|
49
|
+
...this.options,
|
|
50
|
+
};
|
|
51
|
+
this.container = new inversify_1.Container(containerOptions);
|
|
52
|
+
this.container.bind(inversify_1.Container).toConstantValue(this.container);
|
|
53
|
+
this.container.load((0, inversify_binding_decorators_1.buildProviderModule)(), ...modules);
|
|
54
|
+
return this.container;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Retrieves the binding dictionary of the container.
|
|
58
|
+
* @returns(void) Print table of the binding dictionary of the container.
|
|
59
|
+
*/
|
|
60
|
+
viewContainerBindings() {
|
|
61
|
+
const dictionary = this.container["_bindingDictionary"]._map;
|
|
62
|
+
const entries = Array.from(dictionary.entries());
|
|
63
|
+
const table = entries
|
|
64
|
+
.map(([identifier, bindings]) => {
|
|
65
|
+
return bindings.map((binding) => ({
|
|
66
|
+
"Service Identifier": identifier,
|
|
67
|
+
Scope: binding.scope,
|
|
68
|
+
Type: binding.type,
|
|
69
|
+
Cache: binding.cache !== null ? "Yes" : "No",
|
|
70
|
+
}));
|
|
71
|
+
})
|
|
72
|
+
.flat();
|
|
73
|
+
console.table(table);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Retrieves the container options.
|
|
77
|
+
* @returns The container options.
|
|
78
|
+
*/
|
|
79
|
+
getContainerOptions() {
|
|
80
|
+
return this.container.options;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Retrieves the container.
|
|
84
|
+
* @returns The container.
|
|
85
|
+
*/
|
|
86
|
+
get Container() {
|
|
87
|
+
return this.container;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
AppContainer = AppContainer_1 = __decorate([
|
|
91
|
+
(0, inversify_binding_decorators_1.provide)(AppContainer_1),
|
|
92
|
+
__metadata("design:paramtypes", [Object])
|
|
93
|
+
], AppContainer);
|
|
94
|
+
exports.AppContainer = AppContainer;
|
|
@@ -1,72 +1,74 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AppFactory = void 0;
|
|
4
|
-
const
|
|
5
|
-
const adapter_express_1 = require("@expressots/adapter-express");
|
|
6
|
-
//import { AppFastify } from "./fastify/application-fastify";
|
|
7
|
-
//import { IApplicationFastify } from "./fastify/application-fastify.interface";
|
|
8
|
-
//import { Handler } from "@fastify/middie";
|
|
9
|
-
/**
|
|
10
|
-
* AppFactory Class
|
|
11
|
-
*
|
|
12
|
-
* Responsible for creating an instance of the Application,
|
|
13
|
-
* either using a custom application type or with provided middlewares.
|
|
14
|
-
*/
|
|
15
|
-
class AppFactory {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
*
|
|
24
|
-
* @param
|
|
25
|
-
* @
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
app.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
app.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
app.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
app.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
*
|
|
66
|
-
* @
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppFactory = void 0;
|
|
4
|
+
const logger_provider_1 = require("../provider/logger/logger.provider");
|
|
5
|
+
const adapter_express_1 = require("@expressots/adapter-express");
|
|
6
|
+
//import { AppFastify } from "./fastify/application-fastify";
|
|
7
|
+
//import { IApplicationFastify } from "./fastify/application-fastify.interface";
|
|
8
|
+
//import { Handler } from "@fastify/middie";
|
|
9
|
+
/**
|
|
10
|
+
* AppFactory Class
|
|
11
|
+
*
|
|
12
|
+
* Responsible for creating an instance of the Application,
|
|
13
|
+
* either using a custom application type or with provided middlewares.
|
|
14
|
+
*/
|
|
15
|
+
class AppFactory {
|
|
16
|
+
/* public static async create(
|
|
17
|
+
container: Container,
|
|
18
|
+
middlewares: Array<express.RequestHandler>,
|
|
19
|
+
httpServerFactory?: new () => AppFastify,
|
|
20
|
+
): Promise<AppFastify>; */
|
|
21
|
+
/**
|
|
22
|
+
* Implementation of the create method, handling both overloads.
|
|
23
|
+
* @param container - InversifyJS container to resolve dependencies.
|
|
24
|
+
* @param appTypeOrMiddlewares - Custom application class or array of middlewares.
|
|
25
|
+
* @returns Instance of the application.
|
|
26
|
+
*/
|
|
27
|
+
static async create(container, appTypeOrMiddlewares, httpServerFactory /*| AppFastify*/) {
|
|
28
|
+
// Set the container for the application global access
|
|
29
|
+
AppFactory.container = container;
|
|
30
|
+
let app /*| AppFastify*/ = {}; /*| AppFastify*/
|
|
31
|
+
if (this.isOpinionated(appTypeOrMiddlewares)) {
|
|
32
|
+
switch (httpServerFactory) {
|
|
33
|
+
case adapter_express_1.AppExpress:
|
|
34
|
+
app = container.resolve(appTypeOrMiddlewares);
|
|
35
|
+
app.create(container);
|
|
36
|
+
return app;
|
|
37
|
+
/* case AppFastify:
|
|
38
|
+
app = container.resolve(appTypeOrMiddlewares as new () => AppFastify);
|
|
39
|
+
await app.create(container);
|
|
40
|
+
return app as IApplicationFastify; */
|
|
41
|
+
default:
|
|
42
|
+
app = container.resolve(appTypeOrMiddlewares);
|
|
43
|
+
app.create(container);
|
|
44
|
+
return app;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
switch (httpServerFactory) {
|
|
49
|
+
case adapter_express_1.AppExpress:
|
|
50
|
+
app = container.get(adapter_express_1.AppExpress);
|
|
51
|
+
app.create(container, appTypeOrMiddlewares);
|
|
52
|
+
return app;
|
|
53
|
+
/* case AppFastify:
|
|
54
|
+
app = container.get<AppFastify>(AppFastify);
|
|
55
|
+
await app.create(container, appTypeOrMiddlewares as Array<Handler>);
|
|
56
|
+
return app as AppFastify; */
|
|
57
|
+
default:
|
|
58
|
+
app = container.get(adapter_express_1.AppExpress);
|
|
59
|
+
app.create(container, appTypeOrMiddlewares);
|
|
60
|
+
return app;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Checks if the provided parameter is a custom application type.
|
|
66
|
+
* @param appTypeOrMiddlewares - Custom application class or array of middlewares.
|
|
67
|
+
* @returns True if the provided parameter is a custom application type.
|
|
68
|
+
*/
|
|
69
|
+
static isOpinionated(appTypeOrMiddlewares) {
|
|
70
|
+
return typeof appTypeOrMiddlewares === "function";
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.AppFactory = AppFactory;
|
|
74
|
+
AppFactory.logger = new logger_provider_1.Logger();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AppFactory = exports.AppContainer = void 0;
|
|
4
|
-
var app_container_1 = require("./app-container");
|
|
5
|
-
Object.defineProperty(exports, "AppContainer", { enumerable: true, get: function () { return app_container_1.AppContainer; } });
|
|
6
|
-
var application_factory_1 = require("./application-factory");
|
|
7
|
-
Object.defineProperty(exports, "AppFactory", { enumerable: true, get: function () { return application_factory_1.AppFactory; } });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppFactory = exports.AppContainer = void 0;
|
|
4
|
+
var app_container_1 = require("./app-container");
|
|
5
|
+
Object.defineProperty(exports, "AppContainer", { enumerable: true, get: function () { return app_container_1.AppContainer; } });
|
|
6
|
+
var application_factory_1 = require("./application-factory");
|
|
7
|
+
Object.defineProperty(exports, "AppFactory", { enumerable: true, get: function () { return application_factory_1.AppFactory; } });
|
|
@@ -1,46 +1,47 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.bgColorCodes = exports.colorCodes = exports.ColorStyle = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Mapping of text color codes.
|
|
6
|
-
*
|
|
7
|
-
* @remarks
|
|
8
|
-
* Defines the ANSI escape codes for the corresponding colors in the terminal.
|
|
9
|
-
*/
|
|
10
|
-
const colorCodes = {
|
|
11
|
-
red: "\x1b[31m",
|
|
12
|
-
green: "\x1b[32m",
|
|
13
|
-
yellow: "\x1b[33m",
|
|
14
|
-
blue: "\x1b[34m",
|
|
15
|
-
white: "\x1b[37m",
|
|
16
|
-
black: "\x1b[30m",
|
|
17
|
-
none: "\x1b[0m",
|
|
18
|
-
};
|
|
19
|
-
exports.colorCodes = colorCodes;
|
|
20
|
-
/**
|
|
21
|
-
* ANSI escape color codes mapping for different background colors.
|
|
22
|
-
*/
|
|
23
|
-
const bgColorCodes = {
|
|
24
|
-
red: "\x1b[41m",
|
|
25
|
-
green: "\x1b[42m",
|
|
26
|
-
yellow: "\x1b[43m",
|
|
27
|
-
blue: "\x1b[44m",
|
|
28
|
-
white: "\x1b[47m",
|
|
29
|
-
black: "\x1b[40m",
|
|
30
|
-
none: "\x1b[0m",
|
|
31
|
-
};
|
|
32
|
-
exports.bgColorCodes = bgColorCodes;
|
|
33
|
-
/**
|
|
34
|
-
* Enum representing possible color styles for console output.
|
|
35
|
-
*
|
|
36
|
-
* @remarks
|
|
37
|
-
* Enum values correspond to the string representations of colors.
|
|
38
|
-
*/
|
|
39
|
-
var ColorStyle;
|
|
40
|
-
(function (ColorStyle) {
|
|
41
|
-
ColorStyle["None"] = "none";
|
|
42
|
-
ColorStyle["Yellow"] = "yellow";
|
|
43
|
-
ColorStyle["Blue"] = "blue";
|
|
44
|
-
ColorStyle["Green"] = "green";
|
|
45
|
-
ColorStyle["Red"] = "red";
|
|
46
|
-
})(ColorStyle || (
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bgColorCodes = exports.colorCodes = exports.ColorStyle = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Mapping of text color codes.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Defines the ANSI escape codes for the corresponding colors in the terminal.
|
|
9
|
+
*/
|
|
10
|
+
const colorCodes = {
|
|
11
|
+
red: "\x1b[31m",
|
|
12
|
+
green: "\x1b[32m",
|
|
13
|
+
yellow: "\x1b[33m",
|
|
14
|
+
blue: "\x1b[34m",
|
|
15
|
+
white: "\x1b[37m",
|
|
16
|
+
black: "\x1b[30m",
|
|
17
|
+
none: "\x1b[0m",
|
|
18
|
+
};
|
|
19
|
+
exports.colorCodes = colorCodes;
|
|
20
|
+
/**
|
|
21
|
+
* ANSI escape color codes mapping for different background colors.
|
|
22
|
+
*/
|
|
23
|
+
const bgColorCodes = {
|
|
24
|
+
red: "\x1b[41m",
|
|
25
|
+
green: "\x1b[42m",
|
|
26
|
+
yellow: "\x1b[43m",
|
|
27
|
+
blue: "\x1b[44m",
|
|
28
|
+
white: "\x1b[47m",
|
|
29
|
+
black: "\x1b[40m",
|
|
30
|
+
none: "\x1b[0m",
|
|
31
|
+
};
|
|
32
|
+
exports.bgColorCodes = bgColorCodes;
|
|
33
|
+
/**
|
|
34
|
+
* Enum representing possible color styles for console output.
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* Enum values correspond to the string representations of colors.
|
|
38
|
+
*/
|
|
39
|
+
var ColorStyle;
|
|
40
|
+
(function (ColorStyle) {
|
|
41
|
+
ColorStyle["None"] = "none";
|
|
42
|
+
ColorStyle["Yellow"] = "yellow";
|
|
43
|
+
ColorStyle["Blue"] = "blue";
|
|
44
|
+
ColorStyle["Green"] = "green";
|
|
45
|
+
ColorStyle["Red"] = "red";
|
|
46
|
+
})(ColorStyle || (ColorStyle = {}));
|
|
47
|
+
exports.ColorStyle = ColorStyle;
|
package/lib/cjs/common/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.packageResolver = void 0;
|
|
4
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
5
|
-
const
|
|
6
|
-
/**
|
|
7
|
-
* Resolve package from the current working directory.
|
|
8
|
-
* @param packageName
|
|
9
|
-
* @param options
|
|
10
|
-
* @returns
|
|
11
|
-
*/
|
|
12
|
-
function packageResolver(packageName, ...options) {
|
|
13
|
-
const logger = new
|
|
14
|
-
try {
|
|
15
|
-
const hasPackage = require.resolve(packageName, {
|
|
16
|
-
paths: [process.cwd()],
|
|
17
|
-
});
|
|
18
|
-
if (hasPackage) {
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
20
|
-
const packageResolved = require(hasPackage);
|
|
21
|
-
if (typeof packageResolved === "function") {
|
|
22
|
-
return packageResolved(...options);
|
|
23
|
-
}
|
|
24
|
-
if (packageResolved.default &&
|
|
25
|
-
typeof packageResolved.default === "function") {
|
|
26
|
-
return packageResolved.default(...options);
|
|
27
|
-
}
|
|
28
|
-
return packageResolved;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
logger.warn(`Package [${packageName}] not installed. Please install it using your package manager.`, "package-resolver");
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.packageResolver = packageResolver;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.packageResolver = void 0;
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
5
|
+
const logger_provider_1 = require("../provider/logger/logger.provider");
|
|
6
|
+
/**
|
|
7
|
+
* Resolve package from the current working directory.
|
|
8
|
+
* @param packageName
|
|
9
|
+
* @param options
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
function packageResolver(packageName, ...options) {
|
|
13
|
+
const logger = new logger_provider_1.Logger();
|
|
14
|
+
try {
|
|
15
|
+
const hasPackage = require.resolve(packageName, {
|
|
16
|
+
paths: [process.cwd()],
|
|
17
|
+
});
|
|
18
|
+
if (hasPackage) {
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
20
|
+
const packageResolved = require(hasPackage);
|
|
21
|
+
if (typeof packageResolved === "function") {
|
|
22
|
+
return packageResolved(...options);
|
|
23
|
+
}
|
|
24
|
+
if (packageResolved.default &&
|
|
25
|
+
typeof packageResolved.default === "function") {
|
|
26
|
+
return packageResolved.default(...options);
|
|
27
|
+
}
|
|
28
|
+
return packageResolved;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
logger.warn(`Package [${packageName}] not installed. Please install it using your package manager.`, "package-resolver");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.packageResolver = packageResolver;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|