@expressots/core 2.10.0 → 2.12.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 +11 -0
- package/lib/CHANGELOG.md +72 -0
- package/lib/README.md +11 -0
- package/lib/cjs/application/{app-container.js → application-container.js} +8 -6
- package/lib/cjs/application/application-factory.js +19 -54
- package/lib/cjs/application/index.js +2 -2
- package/lib/cjs/console/console.js +7 -7
- package/lib/cjs/container-module/container-module.js +26 -31
- package/lib/cjs/provider/dto-validator/dto-validator.provider.js +3 -3
- package/lib/cjs/provider/logger/logger.provider.js +2 -2
- package/lib/cjs/types/application/{app-container.d.ts → application-container.d.ts} +8 -6
- package/lib/cjs/types/application/application-factory.d.ts +6 -21
- package/lib/cjs/types/application/index.d.ts +1 -1
- package/lib/cjs/types/common/index.d.ts +1 -1
- package/lib/cjs/types/container-module/container-module.d.ts +6 -1
- package/lib/package.json +9 -7
- package/package.json +9 -7
- /package/lib/cjs/common/{color-service.provider.js → color-codes.js} +0 -0
- /package/lib/cjs/common/{package-resolver.provider.js → package-resolver.js} +0 -0
- /package/lib/cjs/common/{project-config.provider.js → project-config.js} +0 -0
- /package/lib/cjs/types/common/{color-service.provider.d.ts → color-codes.d.ts} +0 -0
- /package/lib/cjs/types/common/{package-resolver.provider.d.ts → package-resolver.d.ts} +0 -0
- /package/lib/cjs/types/common/{project-config.provider.d.ts → project-config.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
<a name="readme-top"></a>
|
|
2
2
|
|
|
3
3
|
<!-- PROJECT SHIELDS -->
|
|
4
|
+
|
|
5
|
+
[![Codecov][codecov-shield]][codecov-url]
|
|
6
|
+
[![NPM][npm-shield]][npm-url]
|
|
7
|
+
![Build][build-shield]
|
|
4
8
|
[![Contributors][contributors-shield]][contributors-url]
|
|
5
9
|
[![Forks][forks-shield]][forks-url]
|
|
6
10
|
[![Stargazers][stars-shield]][stars-url]
|
|
@@ -44,6 +48,7 @@
|
|
|
44
48
|
</details>
|
|
45
49
|
|
|
46
50
|
<!-- ABOUT THE PROJECT -->
|
|
51
|
+
|
|
47
52
|
# About The Project
|
|
48
53
|
|
|
49
54
|
ExpressoTS is a [Typescript](https://www.typescriptlang.org/) + [Node.js](https://nodejs.org/en/) lightweight framework for quick building scalable, easy to read and maintain, server-side applications 🐎
|
|
@@ -92,6 +97,12 @@ Distributed under the MIT License. See [`LICENSE.txt`](https://github.com/expres
|
|
|
92
97
|
|
|
93
98
|
<!-- MARKDOWN LINKS & IMAGES -->
|
|
94
99
|
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
|
|
100
|
+
|
|
101
|
+
[codecov-url]: https://codecov.io/gh/expressots/expressots
|
|
102
|
+
[codecov-shield]: https://img.shields.io/codecov/c/gh/expressots/expressots/main?style=for-the-badge&logo=codecov&labelColor=FB9AD1
|
|
103
|
+
[npm-url]: https://www.npmjs.com/package/@expressots/core
|
|
104
|
+
[npm-shield]: https://img.shields.io/npm/v/%40expressots%2Fcore?style=for-the-badge&logo=npm&color=9B3922
|
|
105
|
+
[build-shield]: https://img.shields.io/github/actions/workflow/status/expressots/expressots/build.yml?branch=main&style=for-the-badge&logo=github
|
|
95
106
|
[contributors-shield]: https://img.shields.io/github/contributors/expressots/expressots?style=for-the-badge
|
|
96
107
|
[contributors-url]: https://github.com/expressots/expressots/graphs/contributors
|
|
97
108
|
[forks-shield]: https://img.shields.io/github/forks/expressots/expressots?style=for-the-badge
|
package/lib/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,77 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
+
## [2.12.0](https://github.com/expressots/expressots/compare/2.11.0...2.12.0) (2024-06-07)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add code coverage report ([b4d4982](https://github.com/expressots/expressots/commit/b4d4982cf4cd8a0af647c5c20c5ce9aa1818d754))
|
|
9
|
+
* add codecov plugin bundler ([9cef3c2](https://github.com/expressots/expressots/commit/9cef3c2cf6624d24eb82b70e87dd0a2ba4ed50f6))
|
|
10
|
+
* add codecov plugin bundler ([1edd11f](https://github.com/expressots/expressots/commit/1edd11ff618aaeb0c51d286941c0792038fab982))
|
|
11
|
+
* bump @expressots/adapter-express from 1.2.1 to 1.2.2 ([6492983](https://github.com/expressots/expressots/commit/6492983a14a37589937a0586975b92969c7cbfa6))
|
|
12
|
+
* bump @types/node from 20.12.3 to 20.12.5 ([74924bf](https://github.com/expressots/expressots/commit/74924bf07cb5b7033c8faa70afa2462c6b37a527))
|
|
13
|
+
* bump @types/node from 20.12.5 to 20.12.7 ([a040456](https://github.com/expressots/expressots/commit/a04045644b140044f75ffa950adc8f132648da00))
|
|
14
|
+
* bump @typescript-eslint/eslint-plugin from 7.5.0 to 7.6.0 ([05e60bc](https://github.com/expressots/expressots/commit/05e60bc05e8b183b0a219df185a8fbb371e78e4e))
|
|
15
|
+
* bump @typescript-eslint/parser from 6.6.0 to 7.5.0 ([d2ade4b](https://github.com/expressots/expressots/commit/d2ade4b11bf3eebf996d34a8df7bf4ef96a33fcf))
|
|
16
|
+
* bump @typescript-eslint/parser from 7.5.0 to 7.6.0 ([6e06f7c](https://github.com/expressots/expressots/commit/6e06f7c71dc332908ac309a1ddb009b5d21c4d13))
|
|
17
|
+
* bump prettier from 3.2.5 to 3.3.0 ([8f68fa4](https://github.com/expressots/expressots/commit/8f68fa442cc58c92ada69577d3956e7681f701f2))
|
|
18
|
+
* update adapter express ver ([afcfd42](https://github.com/expressots/expressots/commit/afcfd4242e7c26291c84cacbde56902901a526bc))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* update codecov actions ([e1637e1](https://github.com/expressots/expressots/commit/e1637e19aabdd93960f29d3c1bd11ca7504443ee))
|
|
24
|
+
* update codecov actions ([4c2330f](https://github.com/expressots/expressots/commit/4c2330f01426332b01233c1ecd91e9e68b353ba1))
|
|
25
|
+
* upgrade dotenv from 16.0.3 to 16.4.5 ([29fb00f](https://github.com/expressots/expressots/commit/29fb00f3de2ce398634662244ef454efebceb20a))
|
|
26
|
+
* upgrade dotenv from 16.0.3 to 16.4.5 ([de7f53e](https://github.com/expressots/expressots/commit/de7f53e4d442296bd8e6da5bf41a2acbb0f421f1))
|
|
27
|
+
* upgrade dotenv from 16.0.3 to 16.4.5 ([e325d6c](https://github.com/expressots/expressots/commit/e325d6cdfa834b8cde67dd993e9f1c7b9cd19e84))
|
|
28
|
+
* upgrade inversify from 6.0.1 to 6.0.2 ([0975b5c](https://github.com/expressots/expressots/commit/0975b5c02079575104e0c2b151c4ec0e85dcbd0e))
|
|
29
|
+
* upgrade reflect-metadata from 0.2.1 to 0.2.2 ([ff93c46](https://github.com/expressots/expressots/commit/ff93c4698630bd0c202012188e13fcd1b06c0c15))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Documentation
|
|
33
|
+
|
|
34
|
+
* add codecov badge ([3964037](https://github.com/expressots/expressots/commit/39640373ed98db226b4d7ec4b6dce0fe48d6b53c))
|
|
35
|
+
* add npm and build badge ([79a0b87](https://github.com/expressots/expressots/commit/79a0b87b0c09007221cf618e664a4ae9fedea67d))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
### Code Refactoring
|
|
39
|
+
|
|
40
|
+
* container module scope binding for unit test and remove vitest config from tsconfig base ([a93bd31](https://github.com/expressots/expressots/commit/a93bd3115ad855281f9783915d93c74d689c3fae))
|
|
41
|
+
* remove vitest/eslint conflict, review pr template ([5e63d64](https://github.com/expressots/expressots/commit/5e63d6475034ca62db4991a77bc5fb0581b1b0e0))
|
|
42
|
+
* update adapter version to 1.4 ([ab53902](https://github.com/expressots/expressots/commit/ab53902edbc94d79b69a814d90d26030702c7465))
|
|
43
|
+
* update dependencies and jest config ([807c03e](https://github.com/expressots/expressots/commit/807c03e3dbf3441d3535392ecabd5246e462059a))
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
### Tests
|
|
47
|
+
|
|
48
|
+
* add unit test application, common, console ([78c1989](https://github.com/expressots/expressots/commit/78c19895c1ed441fb5eee255fd28f1639fa89989))
|
|
49
|
+
* add unit test container, controller. decorator ([20591ea](https://github.com/expressots/expressots/commit/20591ea164a95fd2bbe5caa3483fd25d3582c2d7))
|
|
50
|
+
* add unit test env validator ([4eb63d5](https://github.com/expressots/expressots/commit/4eb63d5f16f4dcc73c4b3dff56c9cd07ef4f4f0d))
|
|
51
|
+
* add unit test error module ([4442d8e](https://github.com/expressots/expressots/commit/4442d8e9130fd16ed5698c6d395adf391d5c6224))
|
|
52
|
+
* add unit test middleware, provider, db, dto ([65e88ce](https://github.com/expressots/expressots/commit/65e88ce942aa8053b2a2cf6b0ae8283538ae44f0))
|
|
53
|
+
|
|
54
|
+
## [2.11.0](https://github.com/expressots/expressots/compare/2.10.0...2.11.0) (2024-04-04)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
### Features
|
|
58
|
+
|
|
59
|
+
* bump @types/node from 20.12.2 to 20.12.3 ([430ada9](https://github.com/expressots/expressots/commit/430ada937b04ad12ca26dad1decabffe0b5299ab))
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
### Bug Fixes
|
|
63
|
+
|
|
64
|
+
* update adpater version to latest ([89c671d](https://github.com/expressots/expressots/commit/89c671d2905ceea8877ee5cc6c6fc8ddae262549))
|
|
65
|
+
* update console tests ([c639466](https://github.com/expressots/expressots/commit/c6394663749fe4ebda9ce0b54ccaa7e83593d0df))
|
|
66
|
+
* upgrade tsconfig-paths from 4.1.2 to 4.2.0 ([fc373a6](https://github.com/expressots/expressots/commit/fc373a64d41174351439a356afd3708aba0e8661))
|
|
67
|
+
* upgrade tsconfig-paths from 4.1.2 to 4.2.0 ([e8f0d68](https://github.com/expressots/expressots/commit/e8f0d68a02999d8bcf9936c1973b62a9c97119ac))
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
### Code Refactoring
|
|
71
|
+
|
|
72
|
+
* appfactory class ([3fde40a](https://github.com/expressots/expressots/commit/3fde40a8754e22ad377e58d2c5a0b16fcf116dd0))
|
|
73
|
+
* rename items for standardization and improve doc ([d01f4d1](https://github.com/expressots/expressots/commit/d01f4d191a09716fde688404506ea7895efaf127))
|
|
74
|
+
|
|
3
75
|
## [2.10.0](https://github.com/expressots/expressots/compare/2.9.1...2.10.0) (2024-03-31)
|
|
4
76
|
|
|
5
77
|
|
package/lib/README.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
<a name="readme-top"></a>
|
|
2
2
|
|
|
3
3
|
<!-- PROJECT SHIELDS -->
|
|
4
|
+
|
|
5
|
+
[![Codecov][codecov-shield]][codecov-url]
|
|
6
|
+
[![NPM][npm-shield]][npm-url]
|
|
7
|
+
![Build][build-shield]
|
|
4
8
|
[![Contributors][contributors-shield]][contributors-url]
|
|
5
9
|
[![Forks][forks-shield]][forks-url]
|
|
6
10
|
[![Stargazers][stars-shield]][stars-url]
|
|
@@ -44,6 +48,7 @@
|
|
|
44
48
|
</details>
|
|
45
49
|
|
|
46
50
|
<!-- ABOUT THE PROJECT -->
|
|
51
|
+
|
|
47
52
|
# About The Project
|
|
48
53
|
|
|
49
54
|
ExpressoTS is a [Typescript](https://www.typescriptlang.org/) + [Node.js](https://nodejs.org/en/) lightweight framework for quick building scalable, easy to read and maintain, server-side applications 🐎
|
|
@@ -92,6 +97,12 @@ Distributed under the MIT License. See [`LICENSE.txt`](https://github.com/expres
|
|
|
92
97
|
|
|
93
98
|
<!-- MARKDOWN LINKS & IMAGES -->
|
|
94
99
|
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
|
|
100
|
+
|
|
101
|
+
[codecov-url]: https://codecov.io/gh/expressots/expressots
|
|
102
|
+
[codecov-shield]: https://img.shields.io/codecov/c/gh/expressots/expressots/main?style=for-the-badge&logo=codecov&labelColor=FB9AD1
|
|
103
|
+
[npm-url]: https://www.npmjs.com/package/@expressots/core
|
|
104
|
+
[npm-shield]: https://img.shields.io/npm/v/%40expressots%2Fcore?style=for-the-badge&logo=npm&color=9B3922
|
|
105
|
+
[build-shield]: https://img.shields.io/github/actions/workflow/status/expressots/expressots/build.yml?branch=main&style=for-the-badge&logo=github
|
|
95
106
|
[contributors-shield]: https://img.shields.io/github/contributors/expressots/expressots?style=for-the-badge
|
|
96
107
|
[contributors-url]: https://github.com/expressots/expressots/graphs/contributors
|
|
97
108
|
[forks-shield]: https://img.shields.io/github/forks/expressots/expressots?style=for-the-badge
|
|
@@ -18,16 +18,18 @@ const inversify_binding_decorators_1 = require("inversify-binding-decorators");
|
|
|
18
18
|
* and the ability to skip base class checks. The container can be loaded with multiple
|
|
19
19
|
* ContainerModule instances, facilitating modular and organized code.
|
|
20
20
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* const container =
|
|
24
|
-
*
|
|
25
|
-
* @provide AppContainer
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const container = new AppContainer();
|
|
24
|
+
* container.create([new MyModule()]);
|
|
26
25
|
*/
|
|
27
26
|
let AppContainer = class AppContainer {
|
|
28
27
|
/**
|
|
29
28
|
* Constructs the AppContainer instance.
|
|
30
|
-
* @param options - The options for creating the container
|
|
29
|
+
* @param options - The options for creating the container with default request scope.
|
|
30
|
+
* @option options.defaultScope - The default scope for bindings in the container.
|
|
31
|
+
* @option options.skipBaseClassChecks - Allows skipping of base class checks when working with derived classes.
|
|
32
|
+
* @option options.autoBindInjectable - Allows auto-binding of injectable classes.
|
|
31
33
|
*/
|
|
32
34
|
constructor(options) {
|
|
33
35
|
this.options = {
|
|
@@ -2,73 +2,38 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AppFactory = void 0;
|
|
4
4
|
const logger_provider_1 = require("../provider/logger/logger.provider");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Type guard to check if input is a constructor type of IWebServer.
|
|
7
|
+
* @param input - Input to check.
|
|
8
|
+
* @returns True if input is a constructor type of IWebServer.
|
|
9
|
+
*/
|
|
10
|
+
function isWebServerConstructor(input) {
|
|
11
|
+
return input && typeof input === "function";
|
|
12
|
+
}
|
|
9
13
|
/**
|
|
10
14
|
* AppFactory Class
|
|
11
15
|
*
|
|
12
|
-
* Responsible for creating an instance of the
|
|
13
|
-
* either using a custom application type or with provided middlewares.
|
|
16
|
+
* Responsible for creating an instance of the IWebServer implementation using a custom application type.
|
|
14
17
|
*/
|
|
15
18
|
class AppFactory {
|
|
16
|
-
/* public static async create(
|
|
17
|
-
container: Container,
|
|
18
|
-
middlewares: Array<express.RequestHandler>,
|
|
19
|
-
httpServerFactory?: new () => AppFastify,
|
|
20
|
-
): Promise<AppFastify>; */
|
|
21
19
|
/**
|
|
22
|
-
*
|
|
20
|
+
* Create an instance of a web server.
|
|
23
21
|
* @param container - InversifyJS container to resolve dependencies.
|
|
24
|
-
* @param
|
|
25
|
-
* @returns
|
|
22
|
+
* @param webServerType - Constructor of a class that implements IWebServer, or array of middlewares.
|
|
23
|
+
* @returns A promise that resolves to an instance of IWebServer.
|
|
26
24
|
*/
|
|
27
|
-
static async create(container,
|
|
28
|
-
// Set the container for the application global access
|
|
25
|
+
static async create(container, webServerType) {
|
|
29
26
|
AppFactory.container = container;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
}
|
|
27
|
+
if (isWebServerConstructor(webServerType)) {
|
|
28
|
+
const webServerInstance = new webServerType();
|
|
29
|
+
await webServerInstance.configure(container);
|
|
30
|
+
return webServerInstance;
|
|
46
31
|
}
|
|
47
32
|
else {
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
}
|
|
33
|
+
this.logger.error("Invalid web server type.", "app-factory:create");
|
|
34
|
+
throw new Error("Invalid web server type.");
|
|
62
35
|
}
|
|
63
36
|
}
|
|
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
37
|
}
|
|
73
38
|
exports.AppFactory = AppFactory;
|
|
74
39
|
AppFactory.logger = new logger_provider_1.Logger();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AppFactory = exports.AppContainer = void 0;
|
|
4
|
-
var
|
|
5
|
-
Object.defineProperty(exports, "AppContainer", { enumerable: true, get: function () { return
|
|
4
|
+
var application_container_1 = require("./application-container");
|
|
5
|
+
Object.defineProperty(exports, "AppContainer", { enumerable: true, get: function () { return application_container_1.AppContainer; } });
|
|
6
6
|
var application_factory_1 = require("./application-factory");
|
|
7
7
|
Object.defineProperty(exports, "AppFactory", { enumerable: true, get: function () { return application_factory_1.AppFactory; } });
|
|
@@ -8,7 +8,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.Console = void 0;
|
|
10
10
|
const inversify_binding_decorators_1 = require("inversify-binding-decorators");
|
|
11
|
-
const
|
|
11
|
+
const color_codes_1 = require("../common/color-codes");
|
|
12
12
|
/**
|
|
13
13
|
* The Console class provides methods for displaying styled messages in the console.
|
|
14
14
|
* @provide Console
|
|
@@ -22,7 +22,7 @@ let Console = class Console {
|
|
|
22
22
|
async printColor(message, colorStyle) {
|
|
23
23
|
const textColor = "black";
|
|
24
24
|
const bgColor = colorStyle;
|
|
25
|
-
console.log(`${
|
|
25
|
+
console.log(`${color_codes_1.bgColorCodes[bgColor]}${color_codes_1.colorCodes[textColor]}${message}\x1b[0m`);
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* Display a message in the console with details about the running server.
|
|
@@ -35,19 +35,19 @@ let Console = class Console {
|
|
|
35
35
|
appName: consoleMessage?.appName || "Application",
|
|
36
36
|
appVersion: consoleMessage?.appVersion || "not provided",
|
|
37
37
|
};
|
|
38
|
-
let terminalColor =
|
|
38
|
+
let terminalColor = color_codes_1.ColorStyle.None;
|
|
39
39
|
switch (environment.toLowerCase()) {
|
|
40
40
|
case "development":
|
|
41
|
-
terminalColor =
|
|
41
|
+
terminalColor = color_codes_1.ColorStyle.Yellow;
|
|
42
42
|
break;
|
|
43
43
|
case "staging":
|
|
44
|
-
terminalColor =
|
|
44
|
+
terminalColor = color_codes_1.ColorStyle.Blue;
|
|
45
45
|
break;
|
|
46
46
|
case "production":
|
|
47
|
-
terminalColor =
|
|
47
|
+
terminalColor = color_codes_1.ColorStyle.Green;
|
|
48
48
|
break;
|
|
49
49
|
default:
|
|
50
|
-
terminalColor =
|
|
50
|
+
terminalColor = color_codes_1.ColorStyle.Red;
|
|
51
51
|
break;
|
|
52
52
|
}
|
|
53
53
|
this.printColor(`${appConsoleMessage.appName} version ${appConsoleMessage.appVersion} is running on ` +
|
|
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
};
|
|
8
8
|
var BaseModule_1;
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.scope = exports.CreateModule = void 0;
|
|
10
|
+
exports.scope = exports.CreateModule = exports.BaseModule = exports.BINDING_TYPE_METADATA_KEY = void 0;
|
|
11
11
|
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
12
12
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
13
13
|
const inversify_1 = require("inversify");
|
|
@@ -16,7 +16,7 @@ const decorator_1 = require("../decorator");
|
|
|
16
16
|
/**
|
|
17
17
|
* Key to be used for storing and retrieving binding type metadata.
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
exports.BINDING_TYPE_METADATA_KEY = "binding-type";
|
|
20
20
|
/**
|
|
21
21
|
* The scope decorator is a higher order function that can be used to decorate a class with a binding type.
|
|
22
22
|
* @param binding An instance of interfaces.BindingScope which represents the binding type.
|
|
@@ -24,8 +24,8 @@ const BINDING_TYPE_METADATA_KEY = "binding-type";
|
|
|
24
24
|
*/
|
|
25
25
|
const scope = (binding) => {
|
|
26
26
|
return function (target) {
|
|
27
|
-
if (!Reflect.hasMetadata(BINDING_TYPE_METADATA_KEY, target)) {
|
|
28
|
-
Reflect.defineMetadata(BINDING_TYPE_METADATA_KEY, binding, target);
|
|
27
|
+
if (!Reflect.hasMetadata(exports.BINDING_TYPE_METADATA_KEY, target)) {
|
|
28
|
+
Reflect.defineMetadata(exports.BINDING_TYPE_METADATA_KEY, binding, target);
|
|
29
29
|
switch (binding) {
|
|
30
30
|
case inversify_1.BindingScopeEnum.Singleton:
|
|
31
31
|
(0, decorator_1.provideSingleton)(target);
|
|
@@ -60,6 +60,23 @@ let BaseModule = BaseModule_1 = class BaseModule {
|
|
|
60
60
|
}
|
|
61
61
|
return symbols;
|
|
62
62
|
}
|
|
63
|
+
static bindToScope(symbol, target, bindingType, bind) {
|
|
64
|
+
switch (bindingType) {
|
|
65
|
+
case inversify_1.BindingScopeEnum.Singleton:
|
|
66
|
+
bind(symbol).to(target).inSingletonScope();
|
|
67
|
+
break;
|
|
68
|
+
case inversify_1.BindingScopeEnum.Transient:
|
|
69
|
+
bind(symbol).to(target).inTransientScope();
|
|
70
|
+
(0, decorator_1.provideTransient)(target);
|
|
71
|
+
break;
|
|
72
|
+
case inversify_1.BindingScopeEnum.Request:
|
|
73
|
+
bind(symbol).to(target).inRequestScope();
|
|
74
|
+
break;
|
|
75
|
+
default:
|
|
76
|
+
bind(symbol).to(target).inRequestScope();
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
63
80
|
/**
|
|
64
81
|
* Create an InversifyJS ContainerModule for the provided controllers.
|
|
65
82
|
* @param controllers - An array of controller classes.
|
|
@@ -71,40 +88,18 @@ let BaseModule = BaseModule_1 = class BaseModule {
|
|
|
71
88
|
return new inversify_1.ContainerModule((bind) => {
|
|
72
89
|
for (const [symbol, target] of symbols) {
|
|
73
90
|
if (scope) {
|
|
74
|
-
|
|
75
|
-
case inversify_1.BindingScopeEnum.Singleton:
|
|
76
|
-
bind(symbol).to(target).inSingletonScope();
|
|
77
|
-
break;
|
|
78
|
-
case inversify_1.BindingScopeEnum.Transient:
|
|
79
|
-
bind(symbol).to(target).inTransientScope();
|
|
80
|
-
break;
|
|
81
|
-
case inversify_1.BindingScopeEnum.Request:
|
|
82
|
-
bind(symbol).to(target).inRequestScope();
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
91
|
+
BaseModule_1.bindToScope(symbol, target, scope, bind);
|
|
85
92
|
}
|
|
86
93
|
else {
|
|
87
|
-
const bindingType = Reflect.getMetadata(BINDING_TYPE_METADATA_KEY, target);
|
|
88
|
-
|
|
89
|
-
case inversify_1.BindingScopeEnum.Singleton:
|
|
90
|
-
bind(symbol).to(target).inSingletonScope();
|
|
91
|
-
break;
|
|
92
|
-
case inversify_1.BindingScopeEnum.Transient:
|
|
93
|
-
bind(symbol).to(target).inTransientScope();
|
|
94
|
-
break;
|
|
95
|
-
case inversify_1.BindingScopeEnum.Request:
|
|
96
|
-
bind(symbol).to(target).inRequestScope();
|
|
97
|
-
break;
|
|
98
|
-
default:
|
|
99
|
-
bind(symbol).to(target).inRequestScope();
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
94
|
+
const bindingType = Reflect.getMetadata(exports.BINDING_TYPE_METADATA_KEY, target);
|
|
95
|
+
BaseModule_1.bindToScope(symbol, target, bindingType, bind);
|
|
102
96
|
}
|
|
103
97
|
}
|
|
104
98
|
});
|
|
105
99
|
}
|
|
106
100
|
};
|
|
107
|
-
BaseModule =
|
|
101
|
+
exports.BaseModule = BaseModule;
|
|
102
|
+
exports.BaseModule = BaseModule = BaseModule_1 = __decorate([
|
|
108
103
|
(0, inversify_binding_decorators_1.provide)(BaseModule)
|
|
109
104
|
], BaseModule);
|
|
110
105
|
const CreateModule = BaseModule.createContainerModule;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ValidateDTO = void 0;
|
|
4
4
|
require("reflect-metadata");
|
|
5
5
|
const status_code_1 = require("../../error/status-code");
|
|
6
|
-
const
|
|
6
|
+
const package_resolver_1 = require("../../common/package-resolver");
|
|
7
7
|
const logger_provider_1 = require("../logger/logger.provider");
|
|
8
8
|
/**
|
|
9
9
|
* Validate the DTO using class-validator and class-transformer.
|
|
@@ -15,8 +15,8 @@ const logger_provider_1 = require("../logger/logger.provider");
|
|
|
15
15
|
function ValidateDTO(type) {
|
|
16
16
|
return async (req, res, next) => {
|
|
17
17
|
const logger = new logger_provider_1.Logger();
|
|
18
|
-
const classValidator = (0,
|
|
19
|
-
const classTransformer = (0,
|
|
18
|
+
const classValidator = (0, package_resolver_1.packageResolver)("class-validator");
|
|
19
|
+
const classTransformer = (0, package_resolver_1.packageResolver)("class-transformer");
|
|
20
20
|
if (!classValidator || !classTransformer) {
|
|
21
21
|
return next();
|
|
22
22
|
}
|
|
@@ -11,7 +11,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.Logger = void 0;
|
|
13
13
|
const inversify_1 = require("inversify");
|
|
14
|
-
const
|
|
14
|
+
const color_codes_1 = require("../../common/color-codes");
|
|
15
15
|
/**
|
|
16
16
|
* Applies a specified color to a text string.
|
|
17
17
|
*
|
|
@@ -20,7 +20,7 @@ const color_service_provider_1 = require("../../common/color-service.provider");
|
|
|
20
20
|
* @returns The colored text.
|
|
21
21
|
*/
|
|
22
22
|
function colorText(text, color) {
|
|
23
|
-
return `${
|
|
23
|
+
return `${color_codes_1.colorCodes[color]}${text}\x1b[0m`;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* Class that provides logging functionality with colorized text.
|
|
@@ -23,18 +23,20 @@ interface ContainerOptions {
|
|
|
23
23
|
* and the ability to skip base class checks. The container can be loaded with multiple
|
|
24
24
|
* ContainerModule instances, facilitating modular and organized code.
|
|
25
25
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* const container =
|
|
29
|
-
*
|
|
30
|
-
* @provide AppContainer
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const container = new AppContainer();
|
|
29
|
+
* container.create([new MyModule()]);
|
|
31
30
|
*/
|
|
32
31
|
declare class AppContainer {
|
|
33
32
|
private container;
|
|
34
33
|
private options;
|
|
35
34
|
/**
|
|
36
35
|
* Constructs the AppContainer instance.
|
|
37
|
-
* @param options - The options for creating the container
|
|
36
|
+
* @param options - The options for creating the container with default request scope.
|
|
37
|
+
* @option options.defaultScope - The default scope for bindings in the container.
|
|
38
|
+
* @option options.skipBaseClassChecks - Allows skipping of base class checks when working with derived classes.
|
|
39
|
+
* @option options.autoBindInjectable - Allows auto-binding of injectable classes.
|
|
38
40
|
*/
|
|
39
41
|
constructor(options?: ContainerOptions);
|
|
40
42
|
/**
|
|
@@ -1,34 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { IWebServer, IWebServerPublic, IWebServerConstructor } from "@expressots/adapter-express";
|
|
2
2
|
import { Container } from "inversify";
|
|
3
|
-
import { AppExpress, IApplicationExpress } from "@expressots/adapter-express";
|
|
4
3
|
/**
|
|
5
4
|
* AppFactory Class
|
|
6
5
|
*
|
|
7
|
-
* Responsible for creating an instance of the
|
|
8
|
-
* either using a custom application type or with provided middlewares.
|
|
6
|
+
* Responsible for creating an instance of the IWebServer implementation using a custom application type.
|
|
9
7
|
*/
|
|
10
8
|
declare class AppFactory {
|
|
11
9
|
static container: Container;
|
|
12
10
|
private static logger;
|
|
13
11
|
/**
|
|
14
|
-
*
|
|
12
|
+
* Create an instance of a web server.
|
|
15
13
|
* @param container - InversifyJS container to resolve dependencies.
|
|
16
|
-
* @param
|
|
17
|
-
* @returns
|
|
14
|
+
* @param webServerType - Constructor of a class that implements IWebServer, or array of middlewares.
|
|
15
|
+
* @returns A promise that resolves to an instance of IWebServer.
|
|
18
16
|
*/
|
|
19
|
-
static create(container: Container,
|
|
20
|
-
/**
|
|
21
|
-
* Creates an instance of the application with provided middlewares.
|
|
22
|
-
* @param container - InversifyJS container to resolve dependencies.
|
|
23
|
-
* @param middlewares - Array of Express middlewares to be applied.
|
|
24
|
-
* @returns Instance of the application.
|
|
25
|
-
*/
|
|
26
|
-
static create(container: Container, middlewares: Array<express.RequestHandler>, httpServerFactory?: new () => AppExpress): Promise<AppExpress>;
|
|
27
|
-
/**
|
|
28
|
-
* Checks if the provided parameter is a custom application type.
|
|
29
|
-
* @param appTypeOrMiddlewares - Custom application class or array of middlewares.
|
|
30
|
-
* @returns True if the provided parameter is a custom application type.
|
|
31
|
-
*/
|
|
32
|
-
private static isOpinionated;
|
|
17
|
+
static create<T extends IWebServer>(container: Container, webServerType: IWebServerConstructor<T>): Promise<IWebServerPublic>;
|
|
33
18
|
}
|
|
34
19
|
export { AppFactory };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { AppContainer } from "./
|
|
1
|
+
export { AppContainer } from "./application-container";
|
|
2
2
|
export { AppFactory } from "./application-factory";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Pattern, ExpressoConfig } from "./project-config
|
|
1
|
+
export { Pattern, ExpressoConfig } from "./project-config";
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { ContainerModule, interfaces } from "inversify";
|
|
2
|
+
/**
|
|
3
|
+
* Key to be used for storing and retrieving binding type metadata.
|
|
4
|
+
*/
|
|
5
|
+
export declare const BINDING_TYPE_METADATA_KEY = "binding-type";
|
|
2
6
|
/**
|
|
3
7
|
* The scope decorator is a higher order function that can be used to decorate a class with a binding type.
|
|
4
8
|
* @param binding An instance of interfaces.BindingScope which represents the binding type.
|
|
@@ -9,13 +13,14 @@ declare const scope: (binding: interfaces.BindingScope) => (target: any) => void
|
|
|
9
13
|
* The BaseModule class provides methods for creating InversifyJS container modules.
|
|
10
14
|
* @provide BaseModule
|
|
11
15
|
*/
|
|
12
|
-
declare class BaseModule {
|
|
16
|
+
export declare class BaseModule {
|
|
13
17
|
/**
|
|
14
18
|
* Create a map of symbols for the provided controllers.
|
|
15
19
|
* @param controllers - An array of controller classes.
|
|
16
20
|
* @returns A map of symbols mapped to controller constructor functions.
|
|
17
21
|
*/
|
|
18
22
|
private static createSymbols;
|
|
23
|
+
static bindToScope(symbol: symbol, target: new () => any, bindingType: interfaces.BindingScope, bind: interfaces.Bind): void;
|
|
19
24
|
/**
|
|
20
25
|
* Create an InversifyJS ContainerModule for the provided controllers.
|
|
21
26
|
* @param controllers - An array of controller classes.
|
package/lib/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expressots/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.0",
|
|
4
4
|
"description": "Expressots - modern, fast, lightweight nodejs web framework (@core)",
|
|
5
5
|
"author": "Richard Zampieri",
|
|
6
6
|
"main": "./lib/cjs/index.js",
|
|
@@ -73,22 +73,24 @@
|
|
|
73
73
|
"reflect-metadata": "0.2.2"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
|
+
"@codecov/vite-plugin": "^0.0.1-beta.5",
|
|
76
77
|
"@commitlint/cli": "19.2.1",
|
|
77
78
|
"@commitlint/config-conventional": "19.1.0",
|
|
78
|
-
"@expressots/adapter-express": "
|
|
79
|
+
"@expressots/adapter-express": "1.4.0",
|
|
79
80
|
"@release-it/conventional-changelog": "7.0.2",
|
|
80
81
|
"@types/express": "4.17.21",
|
|
81
|
-
"@types/node": "20.12.
|
|
82
|
-
"@typescript-eslint/eslint-plugin": "6.
|
|
83
|
-
"@typescript-eslint/parser": "
|
|
82
|
+
"@types/node": "20.12.7",
|
|
83
|
+
"@typescript-eslint/eslint-plugin": "7.6.0",
|
|
84
|
+
"@typescript-eslint/parser": "7.6.0",
|
|
84
85
|
"@vitest/coverage-v8": "1.4.0",
|
|
85
86
|
"eslint": "8.57.0",
|
|
86
87
|
"eslint-config-prettier": "9.1.0",
|
|
87
88
|
"husky": "9.0.11",
|
|
88
|
-
"prettier": "3.
|
|
89
|
+
"prettier": "3.3.0",
|
|
89
90
|
"release-it": "16.3.0",
|
|
90
91
|
"typescript": "5.2.2",
|
|
91
|
-
"vite": "5.2.
|
|
92
|
+
"vite": "5.2.8",
|
|
93
|
+
"vite-tsconfig-paths": "4.3.2",
|
|
92
94
|
"vitest": "1.4.0"
|
|
93
95
|
},
|
|
94
96
|
"release-it": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expressots/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.0",
|
|
4
4
|
"description": "Expressots - modern, fast, lightweight nodejs web framework (@core)",
|
|
5
5
|
"author": "Richard Zampieri",
|
|
6
6
|
"main": "./lib/cjs/index.js",
|
|
@@ -73,22 +73,24 @@
|
|
|
73
73
|
"reflect-metadata": "0.2.2"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
|
+
"@codecov/vite-plugin": "^0.0.1-beta.5",
|
|
76
77
|
"@commitlint/cli": "19.2.1",
|
|
77
78
|
"@commitlint/config-conventional": "19.1.0",
|
|
78
|
-
"@expressots/adapter-express": "
|
|
79
|
+
"@expressots/adapter-express": "1.4.0",
|
|
79
80
|
"@release-it/conventional-changelog": "7.0.2",
|
|
80
81
|
"@types/express": "4.17.21",
|
|
81
|
-
"@types/node": "20.12.
|
|
82
|
-
"@typescript-eslint/eslint-plugin": "6.
|
|
83
|
-
"@typescript-eslint/parser": "
|
|
82
|
+
"@types/node": "20.12.7",
|
|
83
|
+
"@typescript-eslint/eslint-plugin": "7.6.0",
|
|
84
|
+
"@typescript-eslint/parser": "7.6.0",
|
|
84
85
|
"@vitest/coverage-v8": "1.4.0",
|
|
85
86
|
"eslint": "8.57.0",
|
|
86
87
|
"eslint-config-prettier": "9.1.0",
|
|
87
88
|
"husky": "9.0.11",
|
|
88
|
-
"prettier": "3.
|
|
89
|
+
"prettier": "3.3.0",
|
|
89
90
|
"release-it": "16.3.0",
|
|
90
91
|
"typescript": "5.2.2",
|
|
91
|
-
"vite": "5.2.
|
|
92
|
+
"vite": "5.2.8",
|
|
93
|
+
"vite-tsconfig-paths": "4.3.2",
|
|
92
94
|
"vitest": "1.4.0"
|
|
93
95
|
},
|
|
94
96
|
"release-it": {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|