@expressots/core 1.1.0 → 1.2.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.
Files changed (116) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +2 -1
  3. package/lib/CHANGELOG.md +19 -0
  4. package/lib/README.md +2 -1
  5. package/lib/cjs/application/app-container.js +40 -28
  6. package/lib/cjs/application/application.js +108 -73
  7. package/lib/cjs/application/index.js +9 -9
  8. package/lib/cjs/common/index.js +2 -0
  9. package/lib/cjs/common/project-config.provider.js +2 -0
  10. package/lib/cjs/console/console.js +95 -77
  11. package/lib/cjs/console/index.js +5 -5
  12. package/lib/cjs/container-module/container-module.js +56 -42
  13. package/lib/cjs/container-module/index.js +5 -5
  14. package/lib/cjs/controller/base-controller.js +77 -56
  15. package/lib/cjs/controller/index.js +5 -5
  16. package/lib/cjs/environment/env-validator.js +87 -72
  17. package/lib/cjs/environment/index.js +5 -5
  18. package/lib/cjs/error/application-error.js +37 -26
  19. package/lib/cjs/error/error-handler-middleware.js +17 -9
  20. package/lib/cjs/error/index.js +9 -9
  21. package/lib/cjs/error/report.js +27 -20
  22. package/lib/cjs/error/status-code.js +83 -83
  23. package/lib/cjs/index.js +24 -23
  24. package/lib/cjs/logger/general-logger.js +132 -103
  25. package/lib/cjs/logger/index.js +7 -7
  26. package/lib/cjs/types/application/app-container.d.ts +19 -7
  27. package/lib/cjs/types/application/app-container.d.ts.map +1 -1
  28. package/lib/cjs/types/application/application.d.ts +52 -21
  29. package/lib/cjs/types/application/application.d.ts.map +1 -1
  30. package/lib/cjs/types/application/index.d.ts +2 -2
  31. package/lib/cjs/types/common/index.d.ts +2 -0
  32. package/lib/cjs/types/common/index.d.ts.map +1 -0
  33. package/lib/cjs/types/common/project-config.provider.d.ts +22 -0
  34. package/lib/cjs/types/common/project-config.provider.d.ts.map +1 -0
  35. package/lib/cjs/types/console/console.d.ts +27 -9
  36. package/lib/cjs/types/console/console.d.ts.map +1 -1
  37. package/lib/cjs/types/console/index.d.ts +1 -1
  38. package/lib/cjs/types/container-module/container-module.d.ts +22 -8
  39. package/lib/cjs/types/container-module/container-module.d.ts.map +1 -1
  40. package/lib/cjs/types/container-module/index.d.ts +1 -1
  41. package/lib/cjs/types/controller/base-controller.d.ts +29 -8
  42. package/lib/cjs/types/controller/base-controller.d.ts.map +1 -1
  43. package/lib/cjs/types/controller/index.d.ts +1 -1
  44. package/lib/cjs/types/environment/env-validator.d.ts +27 -12
  45. package/lib/cjs/types/environment/env-validator.d.ts.map +1 -1
  46. package/lib/cjs/types/environment/index.d.ts +1 -1
  47. package/lib/cjs/types/error/application-error.d.ts +17 -6
  48. package/lib/cjs/types/error/application-error.d.ts.map +1 -1
  49. package/lib/cjs/types/error/error-handler-middleware.d.ts +12 -4
  50. package/lib/cjs/types/error/error-handler-middleware.d.ts.map +1 -1
  51. package/lib/cjs/types/error/index.d.ts +3 -3
  52. package/lib/cjs/types/error/report.d.ts +12 -5
  53. package/lib/cjs/types/error/report.d.ts.map +1 -1
  54. package/lib/cjs/types/error/status-code.d.ts +136 -136
  55. package/lib/cjs/types/index.d.ts +8 -7
  56. package/lib/cjs/types/index.d.ts.map +1 -1
  57. package/lib/cjs/types/logger/general-logger.d.ts +45 -16
  58. package/lib/cjs/types/logger/general-logger.d.ts.map +1 -1
  59. package/lib/cjs/types/logger/index.d.ts +1 -1
  60. package/lib/esm/application/app-container.js +38 -26
  61. package/lib/esm/application/application.js +103 -68
  62. package/lib/esm/application/index.js +2 -2
  63. package/lib/esm/common/index.js +1 -0
  64. package/lib/esm/common/project-config.provider.js +1 -0
  65. package/lib/esm/console/console.js +76 -58
  66. package/lib/esm/console/index.js +1 -1
  67. package/lib/esm/container-module/container-module.js +53 -39
  68. package/lib/esm/container-module/index.js +1 -1
  69. package/lib/esm/controller/base-controller.js +64 -43
  70. package/lib/esm/controller/index.js +1 -1
  71. package/lib/esm/environment/env-validator.js +80 -65
  72. package/lib/esm/environment/index.js +1 -1
  73. package/lib/esm/error/application-error.js +36 -25
  74. package/lib/esm/error/error-handler-middleware.js +15 -7
  75. package/lib/esm/error/index.js +3 -3
  76. package/lib/esm/error/report.js +24 -17
  77. package/lib/esm/error/status-code.js +80 -80
  78. package/lib/esm/index.mjs +8 -7
  79. package/lib/esm/logger/general-logger.js +125 -96
  80. package/lib/esm/logger/index.js +1 -1
  81. package/lib/esm/types/application/app-container.d.ts +19 -7
  82. package/lib/esm/types/application/app-container.d.ts.map +1 -1
  83. package/lib/esm/types/application/application.d.ts +52 -21
  84. package/lib/esm/types/application/application.d.ts.map +1 -1
  85. package/lib/esm/types/application/index.d.ts +2 -2
  86. package/lib/esm/types/common/index.d.ts +2 -0
  87. package/lib/esm/types/common/index.d.ts.map +1 -0
  88. package/lib/esm/types/common/project-config.provider.d.ts +22 -0
  89. package/lib/esm/types/common/project-config.provider.d.ts.map +1 -0
  90. package/lib/esm/types/console/console.d.ts +27 -9
  91. package/lib/esm/types/console/console.d.ts.map +1 -1
  92. package/lib/esm/types/console/index.d.ts +1 -1
  93. package/lib/esm/types/container-module/container-module.d.ts +22 -8
  94. package/lib/esm/types/container-module/container-module.d.ts.map +1 -1
  95. package/lib/esm/types/container-module/index.d.ts +1 -1
  96. package/lib/esm/types/controller/base-controller.d.ts +29 -8
  97. package/lib/esm/types/controller/base-controller.d.ts.map +1 -1
  98. package/lib/esm/types/controller/index.d.ts +1 -1
  99. package/lib/esm/types/environment/env-validator.d.ts +27 -12
  100. package/lib/esm/types/environment/env-validator.d.ts.map +1 -1
  101. package/lib/esm/types/environment/index.d.ts +1 -1
  102. package/lib/esm/types/error/application-error.d.ts +17 -6
  103. package/lib/esm/types/error/application-error.d.ts.map +1 -1
  104. package/lib/esm/types/error/error-handler-middleware.d.ts +12 -4
  105. package/lib/esm/types/error/error-handler-middleware.d.ts.map +1 -1
  106. package/lib/esm/types/error/index.d.ts +3 -3
  107. package/lib/esm/types/error/report.d.ts +12 -5
  108. package/lib/esm/types/error/report.d.ts.map +1 -1
  109. package/lib/esm/types/error/status-code.d.ts +136 -136
  110. package/lib/esm/types/index.d.ts +8 -7
  111. package/lib/esm/types/index.d.ts.map +1 -1
  112. package/lib/esm/types/logger/general-logger.d.ts +45 -16
  113. package/lib/esm/types/logger/general-logger.d.ts.map +1 -1
  114. package/lib/esm/types/logger/index.d.ts +1 -1
  115. package/lib/package.json +2 -2
  116. package/package.json +2 -2
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 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/README.md CHANGED
@@ -44,10 +44,11 @@ ExpressoTS is an MIT-licensed open source project. It's an independent project w
44
44
  ## Contributors
45
45
 
46
46
  - [Daniel Boll](https://github.com/daniel-boll)
47
- - [Eduardo Parreiras](https://github.com/duduzcouto)
48
47
  - [Felipe Fontana](https://github.com/f0ntana)
49
48
  - [Juliano Soares](https://github.com/juliano-soares)
50
49
  - [Vitor Caminha](https://github.com/VitorCaminha)
50
+ - [Ariel Betti](https://github.com/ArielBetti)
51
+ - [Rodrigo da Hora](https://github.com/dahorarodrigo)
51
52
 
52
53
  ## Backers
53
54
 
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)
package/lib/README.md CHANGED
@@ -44,10 +44,11 @@ ExpressoTS is an MIT-licensed open source project. It's an independent project w
44
44
  ## Contributors
45
45
 
46
46
  - [Daniel Boll](https://github.com/daniel-boll)
47
- - [Eduardo Parreiras](https://github.com/duduzcouto)
48
47
  - [Felipe Fontana](https://github.com/f0ntana)
49
48
  - [Juliano Soares](https://github.com/juliano-soares)
50
49
  - [Vitor Caminha](https://github.com/VitorCaminha)
50
+ - [Ariel Betti](https://github.com/ArielBetti)
51
+ - [Rodrigo da Hora](https://github.com/dahorarodrigo)
51
52
 
52
53
  ## Backers
53
54
 
@@ -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
- let AppContainer = AppContainer_1 = class AppContainer {
17
- constructor() { }
18
- create(modules) {
19
- this.container = new inversify_1.Container();
20
- this.container.load((0, inversify_binding_decorators_1.buildProviderModule)(), ...modules);
21
- return this.container;
22
- }
23
- };
24
- AppContainer = AppContainer_1 = __decorate([
25
- (0, inversify_binding_decorators_1.provide)(AppContainer_1),
26
- __metadata("design:paramtypes", [])
27
- ], AppContainer);
28
- exports.AppContainer = AppContainer;
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,108 @@
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
- var ServerEnvironment;
24
- (function (ServerEnvironment) {
25
- ServerEnvironment["Development"] = "development";
26
- ServerEnvironment["Staging"] = "staging";
27
- ServerEnvironment["Production"] = "production";
28
- })(ServerEnvironment || (ServerEnvironment = {}));
29
- exports.ServerEnvironment = ServerEnvironment;
30
- let Application = Application_1 = class Application {
31
- constructor() { }
32
- /* Add any service that you want to be initialized before the server starts */
33
- configureServices() { }
34
- /* Add any service that you want to execute after the server starts */
35
- postServerInitialization() { }
36
- /* Add any service that you want to execute after server is shutdown */
37
- serverShutdown() {
38
- process_1.default.exit(0);
39
- }
40
- create(container, middlewares = []) {
41
- this.configureServices();
42
- const expressServer = new inversify_express_utils_1.InversifyExpressServer(container);
43
- expressServer.setConfig((app) => {
44
- /* Default body parser application/json */
45
- app.use(express_1.default.json());
46
- /* Default body parser application/x-www-form-urlencoded */
47
- app.use(express_1.default.urlencoded({ extended: true }));
48
- middlewares.forEach(middleware => {
49
- app.use(middleware);
50
- });
51
- });
52
- this.app = expressServer.build();
53
- /* Add the error handler middleware */
54
- this.app.use(error_handler_middleware_1.default);
55
- return this;
56
- }
57
- listen(port, environment, consoleMessage) {
58
- this.port = port;
59
- this.environment = environment;
60
- this.app.listen(this.port, () => {
61
- new console_1.Console().messageServer(this.port, this.environment, consoleMessage);
62
- process_1.default.on("SIGINT", this.serverShutdown.bind(this));
63
- });
64
- this.postServerInitialization();
65
- }
66
- };
67
- Application = Application_1 = __decorate([
68
- (0, inversify_binding_decorators_1.provide)(Application_1),
69
- __metadata("design:paramtypes", [])
70
- ], Application);
71
- exports.Application = Application;
72
- const appServerInstance = new Application();
73
- exports.AppInstance = appServerInstance;
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
+ // Detect if a middleware in the array has a body parser. If so, replace the default body parser.
67
+ const hasCustomBodyParser = middlewares.some(middleware => {
68
+ const middlewareName = middleware.name.toLowerCase();
69
+ return middlewareName.includes("json") || middlewareName.includes("urlencoded");
70
+ });
71
+ if (!hasCustomBodyParser) {
72
+ /* Default body parser application/json */
73
+ app.use(express_1.default.json());
74
+ /* Default body parser application/x-www-form-urlencoded */
75
+ app.use(express_1.default.urlencoded({ extended: true }));
76
+ }
77
+ middlewares.forEach(middleware => {
78
+ app.use(middleware);
79
+ });
80
+ });
81
+ this.app = expressServer.build();
82
+ /* Add the error handler middleware */
83
+ this.app.use(error_handler_middleware_1.default);
84
+ return this;
85
+ }
86
+ /**
87
+ * Start listening on the given port and environment.
88
+ * @param port - The port number to listen on.
89
+ * @param environment - The server environment.
90
+ * @param consoleMessage - Optional message to display in the console.
91
+ */
92
+ listen(port, environment, consoleMessage) {
93
+ this.port = port;
94
+ this.environment = environment;
95
+ this.app.listen(this.port, () => {
96
+ new console_1.Console().messageServer(this.port, this.environment, consoleMessage);
97
+ process_1.default.on("SIGINT", this.serverShutdown.bind(this));
98
+ });
99
+ this.postServerInitialization();
100
+ }
101
+ };
102
+ Application = Application_1 = __decorate([
103
+ (0, inversify_binding_decorators_1.provide)(Application_1),
104
+ __metadata("design:paramtypes", [])
105
+ ], Application);
106
+ exports.Application = Application;
107
+ const appServerInstance = new Application();
108
+ 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; } });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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
- var ColorStyle;
26
- (function (ColorStyle) {
27
- ColorStyle[ColorStyle["None"] = 0] = "None";
28
- ColorStyle[ColorStyle["Yellow"] = 1] = "Yellow";
29
- ColorStyle[ColorStyle["Blue"] = 2] = "Blue";
30
- ColorStyle[ColorStyle["Green"] = 3] = "Green";
31
- ColorStyle[ColorStyle["Red"] = 4] = "Red";
32
- })(ColorStyle || (ColorStyle = {}));
33
- let Console = Console_1 = class Console {
34
- printColor(message, colorStyle) {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- switch (colorStyle) {
37
- case ColorStyle.Yellow:
38
- return console.log(chalk_1.default.bgYellow.black(message));
39
- case ColorStyle.Blue:
40
- return console.log(chalk_1.default.bgBlue.black(message));
41
- case ColorStyle.Green:
42
- return console.log(chalk_1.default.bgGreen.black(message));
43
- case ColorStyle.Red:
44
- return console.log(chalk_1.default.bgRed.black(message));
45
- }
46
- });
47
- }
48
- messageServer(port, environment, consoleMessage) {
49
- return __awaiter(this, void 0, void 0, function* () {
50
- const appConsoleMessage = {
51
- appName: (consoleMessage === null || consoleMessage === void 0 ? void 0 : consoleMessage.appName) || "Application",
52
- appVersion: (consoleMessage === null || consoleMessage === void 0 ? void 0 : consoleMessage.appVersion) || "not provided",
53
- };
54
- let terminalColor = ColorStyle.None;
55
- switch (environment.toLowerCase()) {
56
- case "development":
57
- terminalColor = ColorStyle.Yellow;
58
- break;
59
- case "staging":
60
- terminalColor = ColorStyle.Blue;
61
- break;
62
- case "production":
63
- terminalColor = ColorStyle.Green;
64
- break;
65
- default:
66
- terminalColor = ColorStyle.Red;
67
- break;
68
- }
69
- this.printColor(`${appConsoleMessage.appName} version ${appConsoleMessage.appVersion} is running on ` +
70
- `port ${port} - Environment: ${environment}`, terminalColor);
71
- });
72
- }
73
- };
74
- Console = Console_1 = __decorate([
75
- (0, inversify_binding_decorators_1.provide)(Console_1)
76
- ], Console);
77
- exports.Console = Console;
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;
@@ -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; } });