@expressots/core 1.1.0 → 1.2.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/LICENSE.md +21 -0
- package/lib/CHANGELOG.md +19 -0
- package/lib/cjs/application/app-container.js +40 -28
- package/lib/cjs/application/application.js +101 -73
- package/lib/cjs/application/index.js +9 -9
- package/lib/cjs/common/index.js +2 -0
- package/lib/cjs/common/project-config.provider.js +2 -0
- package/lib/cjs/console/console.js +95 -77
- package/lib/cjs/console/index.js +5 -5
- package/lib/cjs/container-module/container-module.js +56 -42
- package/lib/cjs/container-module/index.js +5 -5
- package/lib/cjs/controller/base-controller.js +77 -56
- package/lib/cjs/controller/index.js +5 -5
- package/lib/cjs/environment/env-validator.js +87 -72
- package/lib/cjs/environment/index.js +5 -5
- package/lib/cjs/error/application-error.js +37 -26
- package/lib/cjs/error/error-handler-middleware.js +17 -9
- package/lib/cjs/error/index.js +9 -9
- package/lib/cjs/error/report.js +27 -20
- package/lib/cjs/error/status-code.js +83 -83
- package/lib/cjs/index.js +24 -23
- package/lib/cjs/logger/general-logger.js +132 -103
- package/lib/cjs/logger/index.js +7 -7
- package/lib/cjs/types/application/app-container.d.ts +19 -7
- package/lib/cjs/types/application/app-container.d.ts.map +1 -1
- package/lib/cjs/types/application/application.d.ts +52 -21
- package/lib/cjs/types/application/application.d.ts.map +1 -1
- package/lib/cjs/types/application/index.d.ts +2 -2
- package/lib/cjs/types/common/index.d.ts +2 -0
- package/lib/cjs/types/common/index.d.ts.map +1 -0
- package/lib/cjs/types/common/project-config.provider.d.ts +22 -0
- package/lib/cjs/types/common/project-config.provider.d.ts.map +1 -0
- package/lib/cjs/types/console/console.d.ts +27 -9
- package/lib/cjs/types/console/console.d.ts.map +1 -1
- package/lib/cjs/types/console/index.d.ts +1 -1
- package/lib/cjs/types/container-module/container-module.d.ts +22 -8
- package/lib/cjs/types/container-module/container-module.d.ts.map +1 -1
- package/lib/cjs/types/container-module/index.d.ts +1 -1
- package/lib/cjs/types/controller/base-controller.d.ts +29 -8
- package/lib/cjs/types/controller/base-controller.d.ts.map +1 -1
- package/lib/cjs/types/controller/index.d.ts +1 -1
- package/lib/cjs/types/environment/env-validator.d.ts +27 -12
- package/lib/cjs/types/environment/env-validator.d.ts.map +1 -1
- package/lib/cjs/types/environment/index.d.ts +1 -1
- package/lib/cjs/types/error/application-error.d.ts +17 -6
- package/lib/cjs/types/error/application-error.d.ts.map +1 -1
- package/lib/cjs/types/error/error-handler-middleware.d.ts +12 -4
- package/lib/cjs/types/error/error-handler-middleware.d.ts.map +1 -1
- package/lib/cjs/types/error/index.d.ts +3 -3
- package/lib/cjs/types/error/report.d.ts +12 -5
- package/lib/cjs/types/error/report.d.ts.map +1 -1
- package/lib/cjs/types/error/status-code.d.ts +136 -136
- package/lib/cjs/types/index.d.ts +8 -7
- package/lib/cjs/types/index.d.ts.map +1 -1
- package/lib/cjs/types/logger/general-logger.d.ts +45 -16
- package/lib/cjs/types/logger/general-logger.d.ts.map +1 -1
- package/lib/cjs/types/logger/index.d.ts +1 -1
- package/lib/esm/application/app-container.js +38 -26
- package/lib/esm/application/application.js +96 -68
- package/lib/esm/application/index.js +2 -2
- package/lib/esm/common/index.js +1 -0
- package/lib/esm/common/project-config.provider.js +1 -0
- package/lib/esm/console/console.js +76 -58
- package/lib/esm/console/index.js +1 -1
- package/lib/esm/container-module/container-module.js +53 -39
- package/lib/esm/container-module/index.js +1 -1
- package/lib/esm/controller/base-controller.js +64 -43
- package/lib/esm/controller/index.js +1 -1
- package/lib/esm/environment/env-validator.js +80 -65
- package/lib/esm/environment/index.js +1 -1
- package/lib/esm/error/application-error.js +36 -25
- package/lib/esm/error/error-handler-middleware.js +15 -7
- package/lib/esm/error/index.js +3 -3
- package/lib/esm/error/report.js +24 -17
- package/lib/esm/error/status-code.js +80 -80
- package/lib/esm/index.mjs +8 -7
- package/lib/esm/logger/general-logger.js +125 -96
- package/lib/esm/logger/index.js +1 -1
- package/lib/esm/types/application/app-container.d.ts +19 -7
- package/lib/esm/types/application/app-container.d.ts.map +1 -1
- package/lib/esm/types/application/application.d.ts +52 -21
- package/lib/esm/types/application/application.d.ts.map +1 -1
- package/lib/esm/types/application/index.d.ts +2 -2
- package/lib/esm/types/common/index.d.ts +2 -0
- package/lib/esm/types/common/index.d.ts.map +1 -0
- package/lib/esm/types/common/project-config.provider.d.ts +22 -0
- package/lib/esm/types/common/project-config.provider.d.ts.map +1 -0
- package/lib/esm/types/console/console.d.ts +27 -9
- package/lib/esm/types/console/console.d.ts.map +1 -1
- package/lib/esm/types/console/index.d.ts +1 -1
- package/lib/esm/types/container-module/container-module.d.ts +22 -8
- package/lib/esm/types/container-module/container-module.d.ts.map +1 -1
- package/lib/esm/types/container-module/index.d.ts +1 -1
- package/lib/esm/types/controller/base-controller.d.ts +29 -8
- package/lib/esm/types/controller/base-controller.d.ts.map +1 -1
- package/lib/esm/types/controller/index.d.ts +1 -1
- package/lib/esm/types/environment/env-validator.d.ts +27 -12
- package/lib/esm/types/environment/env-validator.d.ts.map +1 -1
- package/lib/esm/types/environment/index.d.ts +1 -1
- package/lib/esm/types/error/application-error.d.ts +17 -6
- package/lib/esm/types/error/application-error.d.ts.map +1 -1
- package/lib/esm/types/error/error-handler-middleware.d.ts +12 -4
- package/lib/esm/types/error/error-handler-middleware.d.ts.map +1 -1
- package/lib/esm/types/error/index.d.ts +3 -3
- package/lib/esm/types/error/report.d.ts +12 -5
- package/lib/esm/types/error/report.d.ts.map +1 -1
- package/lib/esm/types/error/status-code.d.ts +136 -136
- package/lib/esm/types/index.d.ts +8 -7
- package/lib/esm/types/index.d.ts.map +1 -1
- package/lib/esm/types/logger/general-logger.d.ts +45 -16
- package/lib/esm/types/logger/general-logger.d.ts.map +1 -1
- package/lib/esm/types/logger/index.d.ts +1 -1
- package/lib/package.json +2 -2
- package/package.json +2 -2
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Richard Zampieri
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/lib/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
+
## [1.2.0](https://github.com/expressots/expressots/compare/v1.1.0...v1.2.0) (2023-04-08)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add doc & config types for cli ([a72db25](https://github.com/expressots/expressots/commit/a72db25088a8c2d0a18cd8fc71dde40e01cd4c22))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* template folder path issue ([babdce9](https://github.com/expressots/expressots/commit/babdce9367f85ddd2075c4bed854ab83ee339add))
|
|
14
|
+
|
|
15
|
+
## [1.1.1](https://github.com/expressots/expressots/compare/v1.1.0...v1.1.1) (2023-04-04)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* template folder path issue ([babdce9](https://github.com/expressots/expressots/commit/babdce9367f85ddd2075c4bed854ab83ee339add))
|
|
21
|
+
|
|
3
22
|
## [1.1.0](https://github.com/expressots/expressots/compare/v1.1.0-42-gc6f184868daa1b6862337621c69b5370b70a2772...v1.1.0) (2023-03-31)
|
|
4
23
|
|
|
5
24
|
## [1.2.0](https://github.com/expressots/expressots/compare/v1.1.0-41-gf2a0fd59ba849c6ee880121d773da15fe2580cb1...v1.2.0) (2023-03-31)
|
|
@@ -1,28 +1,40 @@
|
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
+
* @provide AppContainer
|
|
19
|
+
*/
|
|
20
|
+
let AppContainer = AppContainer_1 = class AppContainer {
|
|
21
|
+
/**
|
|
22
|
+
* Constructs a new instance of the AppContainer class.
|
|
23
|
+
*/
|
|
24
|
+
constructor() { }
|
|
25
|
+
/**
|
|
26
|
+
* Creates and configures a new dependency injection container.
|
|
27
|
+
* @param modules - An array of ContainerModule instances to load into the container.
|
|
28
|
+
* @returns The configured dependency injection container.
|
|
29
|
+
*/
|
|
30
|
+
create(modules) {
|
|
31
|
+
this.container = new inversify_1.Container();
|
|
32
|
+
this.container.load((0, inversify_binding_decorators_1.buildProviderModule)(), ...modules);
|
|
33
|
+
return this.container;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
AppContainer = AppContainer_1 = __decorate([
|
|
37
|
+
(0, inversify_binding_decorators_1.provide)(AppContainer_1),
|
|
38
|
+
__metadata("design:paramtypes", [])
|
|
39
|
+
], AppContainer);
|
|
40
|
+
exports.AppContainer = AppContainer;
|
|
@@ -1,73 +1,101 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
var Application_1;
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.ServerEnvironment = exports.Application = exports.AppInstance = void 0;
|
|
17
|
-
const express_1 = __importDefault(require("express"));
|
|
18
|
-
const inversify_binding_decorators_1 = require("inversify-binding-decorators");
|
|
19
|
-
const inversify_express_utils_1 = require("inversify-express-utils");
|
|
20
|
-
const process_1 = __importDefault(require("process"));
|
|
21
|
-
const console_1 = require("../console/console");
|
|
22
|
-
const error_handler_middleware_1 = __importDefault(require("../error/error-handler-middleware"));
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
var Application_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.ServerEnvironment = exports.Application = exports.AppInstance = void 0;
|
|
17
|
+
const express_1 = __importDefault(require("express"));
|
|
18
|
+
const inversify_binding_decorators_1 = require("inversify-binding-decorators");
|
|
19
|
+
const inversify_express_utils_1 = require("inversify-express-utils");
|
|
20
|
+
const process_1 = __importDefault(require("process"));
|
|
21
|
+
const console_1 = require("../console/console");
|
|
22
|
+
const error_handler_middleware_1 = __importDefault(require("../error/error-handler-middleware"));
|
|
23
|
+
/**
|
|
24
|
+
* Enum representing possible server environments.
|
|
25
|
+
*/
|
|
26
|
+
var ServerEnvironment;
|
|
27
|
+
(function (ServerEnvironment) {
|
|
28
|
+
ServerEnvironment["Development"] = "development";
|
|
29
|
+
ServerEnvironment["Staging"] = "staging";
|
|
30
|
+
ServerEnvironment["Production"] = "production";
|
|
31
|
+
})(ServerEnvironment || (ServerEnvironment = {}));
|
|
32
|
+
exports.ServerEnvironment = ServerEnvironment;
|
|
33
|
+
/**
|
|
34
|
+
* The Application class provides a way to configure and manage an Express application.
|
|
35
|
+
* @provide Application
|
|
36
|
+
*/
|
|
37
|
+
let Application = Application_1 = class Application {
|
|
38
|
+
/**
|
|
39
|
+
* Constructs a new instance of the Application class.
|
|
40
|
+
*/
|
|
41
|
+
constructor() { }
|
|
42
|
+
/**
|
|
43
|
+
* Configure services that should be initialized before the server starts.
|
|
44
|
+
*/
|
|
45
|
+
configureServices() { }
|
|
46
|
+
/**
|
|
47
|
+
* Configure services that should be executed after the server starts.
|
|
48
|
+
*/
|
|
49
|
+
postServerInitialization() { }
|
|
50
|
+
/**
|
|
51
|
+
* Perform actions or cleanup after the server is shutdown.
|
|
52
|
+
*/
|
|
53
|
+
serverShutdown() {
|
|
54
|
+
process_1.default.exit(0);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Create and configure the Express application.
|
|
58
|
+
* @param container - The InversifyJS container.
|
|
59
|
+
* @param middlewares - An array of Express middlewares to be applied.
|
|
60
|
+
* @returns The configured Application instance.
|
|
61
|
+
*/
|
|
62
|
+
create(container, middlewares = []) {
|
|
63
|
+
this.configureServices();
|
|
64
|
+
const expressServer = new inversify_express_utils_1.InversifyExpressServer(container);
|
|
65
|
+
expressServer.setConfig((app) => {
|
|
66
|
+
/* Default body parser application/json */
|
|
67
|
+
app.use(express_1.default.json());
|
|
68
|
+
/* Default body parser application/x-www-form-urlencoded */
|
|
69
|
+
app.use(express_1.default.urlencoded({ extended: true }));
|
|
70
|
+
middlewares.forEach(middleware => {
|
|
71
|
+
app.use(middleware);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
this.app = expressServer.build();
|
|
75
|
+
/* Add the error handler middleware */
|
|
76
|
+
this.app.use(error_handler_middleware_1.default);
|
|
77
|
+
return this;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Start listening on the given port and environment.
|
|
81
|
+
* @param port - The port number to listen on.
|
|
82
|
+
* @param environment - The server environment.
|
|
83
|
+
* @param consoleMessage - Optional message to display in the console.
|
|
84
|
+
*/
|
|
85
|
+
listen(port, environment, consoleMessage) {
|
|
86
|
+
this.port = port;
|
|
87
|
+
this.environment = environment;
|
|
88
|
+
this.app.listen(this.port, () => {
|
|
89
|
+
new console_1.Console().messageServer(this.port, this.environment, consoleMessage);
|
|
90
|
+
process_1.default.on("SIGINT", this.serverShutdown.bind(this));
|
|
91
|
+
});
|
|
92
|
+
this.postServerInitialization();
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
Application = Application_1 = __decorate([
|
|
96
|
+
(0, inversify_binding_decorators_1.provide)(Application_1),
|
|
97
|
+
__metadata("design:paramtypes", [])
|
|
98
|
+
], Application);
|
|
99
|
+
exports.Application = Application;
|
|
100
|
+
const appServerInstance = new Application();
|
|
101
|
+
exports.AppInstance = appServerInstance;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AppContainer = exports.ServerEnvironment = exports.Application = exports.AppInstance = void 0;
|
|
4
|
-
var application_1 = require("./application");
|
|
5
|
-
Object.defineProperty(exports, "AppInstance", { enumerable: true, get: function () { return application_1.AppInstance; } });
|
|
6
|
-
Object.defineProperty(exports, "Application", { enumerable: true, get: function () { return application_1.Application; } });
|
|
7
|
-
Object.defineProperty(exports, "ServerEnvironment", { enumerable: true, get: function () { return application_1.ServerEnvironment; } });
|
|
8
|
-
var app_container_1 = require("./app-container");
|
|
9
|
-
Object.defineProperty(exports, "AppContainer", { enumerable: true, get: function () { return app_container_1.AppContainer; } });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppContainer = exports.ServerEnvironment = exports.Application = exports.AppInstance = void 0;
|
|
4
|
+
var application_1 = require("./application");
|
|
5
|
+
Object.defineProperty(exports, "AppInstance", { enumerable: true, get: function () { return application_1.AppInstance; } });
|
|
6
|
+
Object.defineProperty(exports, "Application", { enumerable: true, get: function () { return application_1.Application; } });
|
|
7
|
+
Object.defineProperty(exports, "ServerEnvironment", { enumerable: true, get: function () { return application_1.ServerEnvironment; } });
|
|
8
|
+
var app_container_1 = require("./app-container");
|
|
9
|
+
Object.defineProperty(exports, "AppContainer", { enumerable: true, get: function () { return app_container_1.AppContainer; } });
|
|
@@ -1,77 +1,95 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
-
};
|
|
20
|
-
var Console_1;
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.Console = void 0;
|
|
23
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
24
|
-
const inversify_binding_decorators_1 = require("inversify-binding-decorators");
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
ColorStyle[ColorStyle["
|
|
31
|
-
ColorStyle[ColorStyle["
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
var Console_1;
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.Console = void 0;
|
|
23
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
24
|
+
const inversify_binding_decorators_1 = require("inversify-binding-decorators");
|
|
25
|
+
/**
|
|
26
|
+
* Enum representing possible color styles for console output.
|
|
27
|
+
*/
|
|
28
|
+
var ColorStyle;
|
|
29
|
+
(function (ColorStyle) {
|
|
30
|
+
ColorStyle[ColorStyle["None"] = 0] = "None";
|
|
31
|
+
ColorStyle[ColorStyle["Yellow"] = 1] = "Yellow";
|
|
32
|
+
ColorStyle[ColorStyle["Blue"] = 2] = "Blue";
|
|
33
|
+
ColorStyle[ColorStyle["Green"] = 3] = "Green";
|
|
34
|
+
ColorStyle[ColorStyle["Red"] = 4] = "Red";
|
|
35
|
+
})(ColorStyle || (ColorStyle = {}));
|
|
36
|
+
/**
|
|
37
|
+
* The Console class provides methods for displaying styled messages in the console.
|
|
38
|
+
* @provide Console
|
|
39
|
+
*/
|
|
40
|
+
let Console = Console_1 = class Console {
|
|
41
|
+
/**
|
|
42
|
+
* Print a message to the console with the specified color style.
|
|
43
|
+
* @param message - The message to be printed.
|
|
44
|
+
* @param colorStyle - The color style for the message.
|
|
45
|
+
*/
|
|
46
|
+
printColor(message, colorStyle) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
switch (colorStyle) {
|
|
49
|
+
case ColorStyle.Yellow:
|
|
50
|
+
return console.log(chalk_1.default.bgYellow.black(message));
|
|
51
|
+
case ColorStyle.Blue:
|
|
52
|
+
return console.log(chalk_1.default.bgBlue.black(message));
|
|
53
|
+
case ColorStyle.Green:
|
|
54
|
+
return console.log(chalk_1.default.bgGreen.black(message));
|
|
55
|
+
case ColorStyle.Red:
|
|
56
|
+
return console.log(chalk_1.default.bgRed.black(message));
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Display a message in the console with details about the running server.
|
|
62
|
+
* @param port - The port number the server is running on.
|
|
63
|
+
* @param environment - The server environment.
|
|
64
|
+
* @param consoleMessage - Optional application message details for console output.
|
|
65
|
+
*/
|
|
66
|
+
messageServer(port, environment, consoleMessage) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
const appConsoleMessage = {
|
|
69
|
+
appName: (consoleMessage === null || consoleMessage === void 0 ? void 0 : consoleMessage.appName) || "Application",
|
|
70
|
+
appVersion: (consoleMessage === null || consoleMessage === void 0 ? void 0 : consoleMessage.appVersion) || "not provided",
|
|
71
|
+
};
|
|
72
|
+
let terminalColor = ColorStyle.None;
|
|
73
|
+
switch (environment.toLowerCase()) {
|
|
74
|
+
case "development":
|
|
75
|
+
terminalColor = ColorStyle.Yellow;
|
|
76
|
+
break;
|
|
77
|
+
case "staging":
|
|
78
|
+
terminalColor = ColorStyle.Blue;
|
|
79
|
+
break;
|
|
80
|
+
case "production":
|
|
81
|
+
terminalColor = ColorStyle.Green;
|
|
82
|
+
break;
|
|
83
|
+
default:
|
|
84
|
+
terminalColor = ColorStyle.Red;
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
this.printColor(`${appConsoleMessage.appName} version ${appConsoleMessage.appVersion} is running on ` +
|
|
88
|
+
`port ${port} - Environment: ${environment}`, terminalColor);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
Console = Console_1 = __decorate([
|
|
93
|
+
(0, inversify_binding_decorators_1.provide)(Console_1)
|
|
94
|
+
], Console);
|
|
95
|
+
exports.Console = Console;
|
package/lib/cjs/console/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Console = void 0;
|
|
4
|
-
var console_1 = require("./console");
|
|
5
|
-
Object.defineProperty(exports, "Console", { enumerable: true, get: function () { return console_1.Console; } });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Console = void 0;
|
|
4
|
+
var console_1 = require("./console");
|
|
5
|
+
Object.defineProperty(exports, "Console", { enumerable: true, get: function () { return console_1.Console; } });
|
|
@@ -1,42 +1,56 @@
|
|
|
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 BaseModule_1;
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.CreateModule = void 0;
|
|
14
|
-
const inversify_1 = require("inversify");
|
|
15
|
-
const inversify_binding_decorators_1 = require("inversify-binding-decorators");
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
static
|
|
28
|
-
const symbols =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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 BaseModule_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.CreateModule = void 0;
|
|
14
|
+
const inversify_1 = require("inversify");
|
|
15
|
+
const inversify_binding_decorators_1 = require("inversify-binding-decorators");
|
|
16
|
+
/**
|
|
17
|
+
* The BaseModule class provides methods for creating InversifyJS container modules.
|
|
18
|
+
* @provide BaseModule
|
|
19
|
+
*/
|
|
20
|
+
let BaseModule = BaseModule_1 = class BaseModule {
|
|
21
|
+
constructor() { }
|
|
22
|
+
/**
|
|
23
|
+
* Create a map of symbols for the provided controllers.
|
|
24
|
+
* @param controllers - An array of controller classes.
|
|
25
|
+
* @returns A map of symbols mapped to controller constructor functions.
|
|
26
|
+
*/
|
|
27
|
+
static createSymbols(controllers) {
|
|
28
|
+
const symbols = new Map();
|
|
29
|
+
for (const controller of controllers) {
|
|
30
|
+
const target = controller;
|
|
31
|
+
const symbol = Symbol.for(target.name);
|
|
32
|
+
symbols.set(symbol, target);
|
|
33
|
+
}
|
|
34
|
+
return symbols;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Create an InversifyJS ContainerModule for the provided controllers.
|
|
38
|
+
* @param controllers - An array of controller classes.
|
|
39
|
+
* @returns A ContainerModule with the controller bindings.
|
|
40
|
+
*/
|
|
41
|
+
static createContainerModule(controllers) {
|
|
42
|
+
const symbols = BaseModule_1.createSymbols(controllers);
|
|
43
|
+
return new inversify_1.ContainerModule(bind => {
|
|
44
|
+
for (const symbol of symbols) {
|
|
45
|
+
const target = symbol.valueOf();
|
|
46
|
+
bind(target[0]).to(target[1]);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
BaseModule = BaseModule_1 = __decorate([
|
|
52
|
+
(0, inversify_binding_decorators_1.provide)(BaseModule_1),
|
|
53
|
+
__metadata("design:paramtypes", [])
|
|
54
|
+
], BaseModule);
|
|
55
|
+
const CreateModule = BaseModule.createContainerModule;
|
|
56
|
+
exports.CreateModule = CreateModule;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CreateModule = void 0;
|
|
4
|
-
var container_module_1 = require("./container-module");
|
|
5
|
-
Object.defineProperty(exports, "CreateModule", { enumerable: true, get: function () { return container_module_1.CreateModule; } });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CreateModule = void 0;
|
|
4
|
+
var container_module_1 = require("./container-module");
|
|
5
|
+
Object.defineProperty(exports, "CreateModule", { enumerable: true, get: function () { return container_module_1.CreateModule; } });
|