@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.
- package/LICENSE.md +21 -0
- package/README.md +2 -1
- package/lib/CHANGELOG.md +19 -0
- package/lib/README.md +2 -1
- package/lib/cjs/application/app-container.js +40 -28
- package/lib/cjs/application/application.js +108 -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 +103 -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
|
@@ -1,17 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
/**
|
|
2
|
+
* LogLevel enumeration defines the available log levels.
|
|
3
|
+
*/
|
|
4
|
+
declare enum LogLevel {
|
|
5
|
+
Debug = 0,
|
|
6
|
+
Error = 1,
|
|
7
|
+
Info = 2
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* GeneralLogger class is a utility class to manage logging within the application.
|
|
11
|
+
*/
|
|
12
|
+
declare class GeneralLogger {
|
|
13
|
+
private logger;
|
|
14
|
+
constructor();
|
|
15
|
+
/**
|
|
16
|
+
* Creates a console transport for logging.
|
|
17
|
+
* @returns {transports.ConsoleTransportInstance} A Winston console transport instance.
|
|
18
|
+
*/
|
|
19
|
+
private createConsoleTransport;
|
|
20
|
+
/**
|
|
21
|
+
* Creates a rotational file transport for logging.
|
|
22
|
+
* @returns {DailyRotateFile} A Winston daily rotate file transport instance.
|
|
23
|
+
*/
|
|
24
|
+
private createRotationalFileTransport;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a logger options object for Winston.
|
|
27
|
+
* @returns {LoggerOptions} A Winston logger options object.
|
|
28
|
+
*/
|
|
29
|
+
private createLoggerOptions;
|
|
30
|
+
/**
|
|
31
|
+
* Retrieves the path and line number of the error.
|
|
32
|
+
* @param error - An Error object containing error details.
|
|
33
|
+
* @returns {string} A string containing the path and line number of the error.
|
|
34
|
+
*/
|
|
35
|
+
private getPathAndLine;
|
|
36
|
+
/**
|
|
37
|
+
* Logs a message or error with the specified log level and service.
|
|
38
|
+
* @param logLevel - The log level to use (Debug, Error, or Info).
|
|
39
|
+
* @param content - The message or Error object to log.
|
|
40
|
+
* @param service - The service name (optional) associated with the log.
|
|
41
|
+
*/
|
|
42
|
+
log(logLevel: LogLevel, content: Error | string, service?: string): void;
|
|
43
|
+
}
|
|
44
|
+
declare const log: (logLevel: LogLevel, content: Error | string, service?: string) => void;
|
|
45
|
+
export { LogLevel, GeneralLogger, log };
|
|
17
46
|
//# sourceMappingURL=general-logger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"general-logger.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/logger/general-logger.ts"],"names":[],"mappings":"AAIA,aAAK,QAAQ;IACT,KAAK,IAAA;IACL,KAAK,IAAA;IACL,IAAI,IAAA;CACP;AAED,cACM,aAAa;IAEf,OAAO,CAAC,MAAM,CAAS;;IAMvB,OAAO,CAAC,sBAAsB;IAW9B,OAAO,CAAC,6BAA6B;IAerC,OAAO,CAAC,mBAAmB;IAqB3B,OAAO,CAAC,cAAc;
|
|
1
|
+
{"version":3,"file":"general-logger.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/logger/general-logger.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,aAAK,QAAQ;IACT,KAAK,IAAA;IACL,KAAK,IAAA;IACL,IAAI,IAAA;CACP;AAED;;GAEG;AACH,cACM,aAAa;IAEf,OAAO,CAAC,MAAM,CAAS;;IAMvB;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IAW9B;;;OAGG;IACH,OAAO,CAAC,6BAA6B;IAerC;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAqB3B;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAYtB;;;;;OAKG;IACI,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,GAAG,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;CAwB3E;AAGD,QAAA,MAAM,GAAG,aA3BgB,QAAQ,WAAW,KAAK,GAAG,MAAM,YAAY,MAAM,SA2B9C,CAAC;AAE/B,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,EAAE,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { GeneralLogger, LogLevel, log } from './general-logger';
|
|
1
|
+
export { GeneralLogger, LogLevel, log } from './general-logger';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,26 +1,38 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
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;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
|
-
var AppContainer_1;
|
|
11
|
-
import { Container } from "inversify";
|
|
12
|
-
import { buildProviderModule, provide } from "inversify-binding-decorators";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var AppContainer_1;
|
|
11
|
+
import { Container } from "inversify";
|
|
12
|
+
import { buildProviderModule, provide } from "inversify-binding-decorators";
|
|
13
|
+
/**
|
|
14
|
+
* The AppContainer class provides a container for managing dependency injection.
|
|
15
|
+
* @provide AppContainer
|
|
16
|
+
*/
|
|
17
|
+
let AppContainer = AppContainer_1 = class AppContainer {
|
|
18
|
+
container;
|
|
19
|
+
/**
|
|
20
|
+
* Constructs a new instance of the AppContainer class.
|
|
21
|
+
*/
|
|
22
|
+
constructor() { }
|
|
23
|
+
/**
|
|
24
|
+
* Creates and configures a new dependency injection container.
|
|
25
|
+
* @param modules - An array of ContainerModule instances to load into the container.
|
|
26
|
+
* @returns The configured dependency injection container.
|
|
27
|
+
*/
|
|
28
|
+
create(modules) {
|
|
29
|
+
this.container = new Container();
|
|
30
|
+
this.container.load(buildProviderModule(), ...modules);
|
|
31
|
+
return this.container;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
AppContainer = AppContainer_1 = __decorate([
|
|
35
|
+
provide(AppContainer_1),
|
|
36
|
+
__metadata("design:paramtypes", [])
|
|
37
|
+
], AppContainer);
|
|
38
|
+
export { AppContainer };
|
|
@@ -1,68 +1,103 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
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;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
|
-
var Application_1;
|
|
11
|
-
import express from "express";
|
|
12
|
-
import { provide } from "inversify-binding-decorators";
|
|
13
|
-
import { InversifyExpressServer } from "inversify-express-utils";
|
|
14
|
-
import process from "process";
|
|
15
|
-
import { Console } from "../console/console";
|
|
16
|
-
import errorHandler from "../error/error-handler-middleware";
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var Application_1;
|
|
11
|
+
import express from "express";
|
|
12
|
+
import { provide } from "inversify-binding-decorators";
|
|
13
|
+
import { InversifyExpressServer } from "inversify-express-utils";
|
|
14
|
+
import process from "process";
|
|
15
|
+
import { Console } from "../console/console";
|
|
16
|
+
import errorHandler from "../error/error-handler-middleware";
|
|
17
|
+
/**
|
|
18
|
+
* Enum representing possible server environments.
|
|
19
|
+
*/
|
|
20
|
+
var ServerEnvironment;
|
|
21
|
+
(function (ServerEnvironment) {
|
|
22
|
+
ServerEnvironment["Development"] = "development";
|
|
23
|
+
ServerEnvironment["Staging"] = "staging";
|
|
24
|
+
ServerEnvironment["Production"] = "production";
|
|
25
|
+
})(ServerEnvironment || (ServerEnvironment = {}));
|
|
26
|
+
/**
|
|
27
|
+
* The Application class provides a way to configure and manage an Express application.
|
|
28
|
+
* @provide Application
|
|
29
|
+
*/
|
|
30
|
+
let Application = Application_1 = class Application {
|
|
31
|
+
app;
|
|
32
|
+
port;
|
|
33
|
+
environment;
|
|
34
|
+
/**
|
|
35
|
+
* Constructs a new instance of the Application class.
|
|
36
|
+
*/
|
|
37
|
+
constructor() { }
|
|
38
|
+
/**
|
|
39
|
+
* Configure services that should be initialized before the server starts.
|
|
40
|
+
*/
|
|
41
|
+
configureServices() { }
|
|
42
|
+
/**
|
|
43
|
+
* Configure services that should be executed after the server starts.
|
|
44
|
+
*/
|
|
45
|
+
postServerInitialization() { }
|
|
46
|
+
/**
|
|
47
|
+
* Perform actions or cleanup after the server is shutdown.
|
|
48
|
+
*/
|
|
49
|
+
serverShutdown() {
|
|
50
|
+
process.exit(0);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Create and configure the Express application.
|
|
54
|
+
* @param container - The InversifyJS container.
|
|
55
|
+
* @param middlewares - An array of Express middlewares to be applied.
|
|
56
|
+
* @returns The configured Application instance.
|
|
57
|
+
*/
|
|
58
|
+
create(container, middlewares = []) {
|
|
59
|
+
this.configureServices();
|
|
60
|
+
const expressServer = new InversifyExpressServer(container);
|
|
61
|
+
expressServer.setConfig((app) => {
|
|
62
|
+
// Detect if a middleware in the array has a body parser. If so, replace the default body parser.
|
|
63
|
+
const hasCustomBodyParser = middlewares.some(middleware => {
|
|
64
|
+
const middlewareName = middleware.name.toLowerCase();
|
|
65
|
+
return middlewareName.includes("json") || middlewareName.includes("urlencoded");
|
|
66
|
+
});
|
|
67
|
+
if (!hasCustomBodyParser) {
|
|
68
|
+
/* Default body parser application/json */
|
|
69
|
+
app.use(express.json());
|
|
70
|
+
/* Default body parser application/x-www-form-urlencoded */
|
|
71
|
+
app.use(express.urlencoded({ extended: true }));
|
|
72
|
+
}
|
|
73
|
+
middlewares.forEach(middleware => {
|
|
74
|
+
app.use(middleware);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
this.app = expressServer.build();
|
|
78
|
+
/* Add the error handler middleware */
|
|
79
|
+
this.app.use(errorHandler);
|
|
80
|
+
return this;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Start listening on the given port and environment.
|
|
84
|
+
* @param port - The port number to listen on.
|
|
85
|
+
* @param environment - The server environment.
|
|
86
|
+
* @param consoleMessage - Optional message to display in the console.
|
|
87
|
+
*/
|
|
88
|
+
listen(port, environment, consoleMessage) {
|
|
89
|
+
this.port = port;
|
|
90
|
+
this.environment = environment;
|
|
91
|
+
this.app.listen(this.port, () => {
|
|
92
|
+
new Console().messageServer(this.port, this.environment, consoleMessage);
|
|
93
|
+
process.on("SIGINT", this.serverShutdown.bind(this));
|
|
94
|
+
});
|
|
95
|
+
this.postServerInitialization();
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
Application = Application_1 = __decorate([
|
|
99
|
+
provide(Application_1),
|
|
100
|
+
__metadata("design:paramtypes", [])
|
|
101
|
+
], Application);
|
|
102
|
+
const appServerInstance = new Application();
|
|
103
|
+
export { appServerInstance as AppInstance, Application, ServerEnvironment };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { AppInstance, Application, ServerEnvironment } from './application';
|
|
2
|
-
export { AppContainer } from './app-container';
|
|
1
|
+
export { AppInstance, Application, ServerEnvironment } from './application';
|
|
2
|
+
export { AppContainer } from './app-container';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,58 +1,76 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
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;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var Console_1;
|
|
8
|
-
import chalk from "chalk";
|
|
9
|
-
import { provide } from "inversify-binding-decorators";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
ColorStyle[ColorStyle["
|
|
16
|
-
ColorStyle[ColorStyle["
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
async
|
|
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
|
-
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var Console_1;
|
|
8
|
+
import chalk from "chalk";
|
|
9
|
+
import { provide } from "inversify-binding-decorators";
|
|
10
|
+
/**
|
|
11
|
+
* Enum representing possible color styles for console output.
|
|
12
|
+
*/
|
|
13
|
+
var ColorStyle;
|
|
14
|
+
(function (ColorStyle) {
|
|
15
|
+
ColorStyle[ColorStyle["None"] = 0] = "None";
|
|
16
|
+
ColorStyle[ColorStyle["Yellow"] = 1] = "Yellow";
|
|
17
|
+
ColorStyle[ColorStyle["Blue"] = 2] = "Blue";
|
|
18
|
+
ColorStyle[ColorStyle["Green"] = 3] = "Green";
|
|
19
|
+
ColorStyle[ColorStyle["Red"] = 4] = "Red";
|
|
20
|
+
})(ColorStyle || (ColorStyle = {}));
|
|
21
|
+
/**
|
|
22
|
+
* The Console class provides methods for displaying styled messages in the console.
|
|
23
|
+
* @provide Console
|
|
24
|
+
*/
|
|
25
|
+
let Console = Console_1 = class Console {
|
|
26
|
+
/**
|
|
27
|
+
* Print a message to the console with the specified color style.
|
|
28
|
+
* @param message - The message to be printed.
|
|
29
|
+
* @param colorStyle - The color style for the message.
|
|
30
|
+
*/
|
|
31
|
+
async printColor(message, colorStyle) {
|
|
32
|
+
switch (colorStyle) {
|
|
33
|
+
case ColorStyle.Yellow:
|
|
34
|
+
return console.log(chalk.bgYellow.black(message));
|
|
35
|
+
case ColorStyle.Blue:
|
|
36
|
+
return console.log(chalk.bgBlue.black(message));
|
|
37
|
+
case ColorStyle.Green:
|
|
38
|
+
return console.log(chalk.bgGreen.black(message));
|
|
39
|
+
case ColorStyle.Red:
|
|
40
|
+
return console.log(chalk.bgRed.black(message));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Display a message in the console with details about the running server.
|
|
45
|
+
* @param port - The port number the server is running on.
|
|
46
|
+
* @param environment - The server environment.
|
|
47
|
+
* @param consoleMessage - Optional application message details for console output.
|
|
48
|
+
*/
|
|
49
|
+
async messageServer(port, environment, consoleMessage) {
|
|
50
|
+
const appConsoleMessage = {
|
|
51
|
+
appName: consoleMessage?.appName || "Application",
|
|
52
|
+
appVersion: 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
|
+
Console = Console_1 = __decorate([
|
|
74
|
+
provide(Console_1)
|
|
75
|
+
], Console);
|
|
76
|
+
export { Console };
|
package/lib/esm/console/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Console } from "./console";
|
|
1
|
+
export { Console } from "./console";
|
|
@@ -1,39 +1,53 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
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;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
|
-
var BaseModule_1;
|
|
11
|
-
import { ContainerModule } from "inversify";
|
|
12
|
-
import { provide } from "inversify-binding-decorators";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
static
|
|
25
|
-
const symbols =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var BaseModule_1;
|
|
11
|
+
import { ContainerModule } from "inversify";
|
|
12
|
+
import { provide } from "inversify-binding-decorators";
|
|
13
|
+
/**
|
|
14
|
+
* The BaseModule class provides methods for creating InversifyJS container modules.
|
|
15
|
+
* @provide BaseModule
|
|
16
|
+
*/
|
|
17
|
+
let BaseModule = BaseModule_1 = class BaseModule {
|
|
18
|
+
constructor() { }
|
|
19
|
+
/**
|
|
20
|
+
* Create a map of symbols for the provided controllers.
|
|
21
|
+
* @param controllers - An array of controller classes.
|
|
22
|
+
* @returns A map of symbols mapped to controller constructor functions.
|
|
23
|
+
*/
|
|
24
|
+
static createSymbols(controllers) {
|
|
25
|
+
const symbols = new Map();
|
|
26
|
+
for (const controller of controllers) {
|
|
27
|
+
const target = controller;
|
|
28
|
+
const symbol = Symbol.for(target.name);
|
|
29
|
+
symbols.set(symbol, target);
|
|
30
|
+
}
|
|
31
|
+
return symbols;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Create an InversifyJS ContainerModule for the provided controllers.
|
|
35
|
+
* @param controllers - An array of controller classes.
|
|
36
|
+
* @returns A ContainerModule with the controller bindings.
|
|
37
|
+
*/
|
|
38
|
+
static createContainerModule(controllers) {
|
|
39
|
+
const symbols = BaseModule_1.createSymbols(controllers);
|
|
40
|
+
return new ContainerModule(bind => {
|
|
41
|
+
for (const symbol of symbols) {
|
|
42
|
+
const target = symbol.valueOf();
|
|
43
|
+
bind(target[0]).to(target[1]);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
BaseModule = BaseModule_1 = __decorate([
|
|
49
|
+
provide(BaseModule_1),
|
|
50
|
+
__metadata("design:paramtypes", [])
|
|
51
|
+
], BaseModule);
|
|
52
|
+
const CreateModule = BaseModule.createContainerModule;
|
|
53
|
+
export { CreateModule };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { CreateModule } from "./container-module";
|
|
1
|
+
export { CreateModule } from "./container-module";
|