@expressots/core 2.8.0 → 2.9.1
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 +41 -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 -32
- 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 -2
- 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 -73
- package/lib/cjs/middleware/middleware-service.js +481 -479
- 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 +56 -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 -13
- 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 -207
- 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 -255
- 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 -368
- 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 +19 -18
- package/package.json +19 -18
- 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,46 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
+
## [2.9.1](https://github.com/expressots/expressots/compare/2.9.0...2.9.1) (2024-03-29)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* add non opinionated scaffold schematics name change ([35cf0cb](https://github.com/expressots/expressots/commit/35cf0cb32c621d7b5112b0306b2001bb34c210ed))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Code Refactoring
|
|
12
|
+
|
|
13
|
+
* add expressots project commands ([523cf19](https://github.com/expressots/expressots/commit/523cf1908f3ba36377738082bf24783e45117626))
|
|
14
|
+
* adjust expressots build, dev, prod ([7be37a7](https://github.com/expressots/expressots/commit/7be37a7b8291ea88ab69ce72b4723780d278d405))
|
|
15
|
+
|
|
16
|
+
## [2.9.0](https://github.com/expressots/expressots/compare/2.8.0...2.9.0) (2024-03-18)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Features
|
|
20
|
+
|
|
21
|
+
* add plugin pattern on provider manager ([f56d5b3](https://github.com/expressots/expressots/commit/f56d5b3a2ebdcca8e61e91e831ce43e6e2a90c57))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Bug Fixes
|
|
25
|
+
|
|
26
|
+
* change expressots version to latest ([d42f0c9](https://github.com/expressots/expressots/commit/d42f0c9987ffa7a8ecc213500e39364182ba800e))
|
|
27
|
+
* lock lib ver, add tsconfig to package ([298201c](https://github.com/expressots/expressots/commit/298201c1442821cf63f7ed788d7f76a6a7fe79e0))
|
|
28
|
+
* lock versions, update to es2021 ([1ca53ca](https://github.com/expressots/expressots/commit/1ca53ca8ad6e52aea136fe48a99aab389456de93))
|
|
29
|
+
* remove the appcontainer return dictionary method ([3dddb86](https://github.com/expressots/expressots/commit/3dddb86bf35e08e42f43c960e796756f2b938805))
|
|
30
|
+
* rename logger-service to logger.provider ([3344717](https://github.com/expressots/expressots/commit/33447175665ed36c3581143bc451bf27fb4b778b))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Code Refactoring
|
|
34
|
+
|
|
35
|
+
* adjust core op template and add full example ([ca5a843](https://github.com/expressots/expressots/commit/ca5a8436ae5a2afb57f426f6dc8b8efa0050f6b1))
|
|
36
|
+
* non opinionated templated structure change ([8caf0d1](https://github.com/expressots/expressots/commit/8caf0d12b3751c61dfa16bb4a70722c64763ffcd))
|
|
37
|
+
* update eslint config inferrable types ([845101f](https://github.com/expressots/expressots/commit/845101fa6472ab4874a220ef63ea4e8296fbd7a6))
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
### Continuous Integrations
|
|
41
|
+
|
|
42
|
+
* add prepublish script ([7b1478e](https://github.com/expressots/expressots/commit/7b1478e7cf1ec44b63e9f1a99354e49cb4ddaa7d))
|
|
43
|
+
|
|
3
44
|
## [2.8.0](https://github.com/expressots/expressots/compare/2.7.0...2.8.0) (2024-3-5)
|
|
4
45
|
|
|
5
46
|
|
|
@@ -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 });
|