opticore-webapp 1.0.7 → 1.0.9
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/dist/index.cjs +139 -667
- package/dist/index.d.cts +5 -378
- package/dist/index.d.ts +5 -378
- package/dist/index.js +146 -661
- package/package.json +7 -6
- package/src/application/service/core.service.ts +11 -8
- package/src/core/handlers/eventProcess.handler.ts +8 -5
- package/src/core/utils/logMessage.utils.ts +2 -2
- package/src/core/utils/modulesLoaded.utils.ts +5 -4
- package/src/core/webServer.core.ts +25 -21
- package/src/domains/interfaces/routeDefinition.interface.ts +2 -2
- package/src/domains/types/kernelModule.type.ts +1 -1
- package/src/index.ts +1 -10
- package/tsup.config.ts +1 -1
- package/src/application/http/response.http.ts +0 -67
- package/src/core/events/errors/serverListen.event.error.ts +0 -335
- package/src/core/events/requestCalls.event.ts +0 -83
- package/src/core/handlers/errors/base/stackTraceError.ts +0 -23
- package/src/core/handlers/errors/stackTraceAssertionError.ts +0 -13
- package/src/core/handlers/errors/stackTraceEvalError.ts +0 -12
- package/src/core/handlers/errors/stackTraceGeneralError.ts +0 -13
- package/src/core/handlers/errors/stackTraceOpenSSLError.ts +0 -12
- package/src/core/handlers/errors/stackTraceRangeError.ts +0 -12
- package/src/core/handlers/errors/stackTraceReferenceError.ts +0 -13
- package/src/core/handlers/errors/stackTraceSyntaxError.ts +0 -12
- package/src/core/handlers/errors/stackTraceSystemError.ts +0 -14
- package/src/core/handlers/errors/stackTraceTypeError.ts +0 -13
- package/src/core/handlers/errors/stackTraceURIError.ts +0 -13
- package/src/domains/constants/errorName.constant.ts +0 -12
- package/src/domains/constants/event.constant.ts +0 -15
- package/src/domains/constants/eventNameError.constant.ts +0 -8
- package/src/domains/constants/httpStatusCodes.constant.ts +0 -375
- package/src/domains/constants/logLevel.constant.ts +0 -6
- package/src/domains/env/access.env.ts +0 -23
- package/src/domains/interfaces/envVariables.interface.ts +0 -16
- package/src/domains/interfaces/kernelModule.interface.ts +0 -6
- package/src/infrastructure/events/.gitkeep +0 -0
- package/src/infrastructure/handlers/.gitkeep +0 -0
- package/src/presentation/middleware/.gitkeep +0 -0
- /package/src/core/{errors → events}/.gitkeep +0 -0
package/dist/index.cjs
CHANGED
|
@@ -30,133 +30,117 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
-
|
|
34
|
-
WebServer: () => WebServerCore,
|
|
35
|
-
errorName: () => CErrorName,
|
|
36
|
-
event: () => CEvent,
|
|
37
|
-
eventName: () => CEventNameError,
|
|
38
|
-
getEnvVariable: () => getEnvVariable
|
|
33
|
+
WebServer: () => WebServerCore
|
|
39
34
|
});
|
|
40
35
|
module.exports = __toCommonJS(index_exports);
|
|
41
36
|
|
|
42
37
|
// src/core/webServer.core.ts
|
|
43
|
-
var import_express2 = __toESM(require("express"), 1);
|
|
44
38
|
var import_cors = __toESM(require("cors"), 1);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
var
|
|
48
|
-
var
|
|
49
|
-
var
|
|
50
|
-
appHost: String((_b = (_a = import_dotenv.default.config()) == null ? void 0 : _a.parsed) == null ? void 0 : _b.APP_HOST),
|
|
51
|
-
appPort: String((_d = (_c = import_dotenv.default.config()) == null ? void 0 : _c.parsed) == null ? void 0 : _d.APP_PORT),
|
|
52
|
-
prodEnv: String((_f = (_e = import_dotenv.default.config()) == null ? void 0 : _e.parsed) == null ? void 0 : _f.ENV_PROD),
|
|
53
|
-
devEnv: String((_h = (_g = import_dotenv.default.config()) == null ? void 0 : _g.parsed) == null ? void 0 : _h.ENV_DEV),
|
|
54
|
-
dataBaseHost: String((_j = (_i = import_dotenv.default.config()) == null ? void 0 : _i.parsed) == null ? void 0 : _j.DATA_BASE_HOST),
|
|
55
|
-
dataBasePort: String((_l = (_k = import_dotenv.default.config()) == null ? void 0 : _k.parsed) == null ? void 0 : _l.DATA_BASE_PORT),
|
|
56
|
-
dataBaseUser: String((_n = (_m = import_dotenv.default.config()) == null ? void 0 : _m.parsed) == null ? void 0 : _n.DATA_BASE_USER),
|
|
57
|
-
dataBasePassword: String((_p = (_o = import_dotenv.default.config()) == null ? void 0 : _o.parsed) == null ? void 0 : _p.DATA_BASE_PASSWORD),
|
|
58
|
-
dataBaseName: String((_r = (_q = import_dotenv.default.config()) == null ? void 0 : _q.parsed) == null ? void 0 : _r.DATA_BASE_NAME),
|
|
59
|
-
apiVersion: String((_t = (_s = import_dotenv.default.config()) == null ? void 0 : _s.parsed) == null ? void 0 : _t.API_VERSION),
|
|
60
|
-
usernameField: String((_v = (_u = import_dotenv.default.config()) == null ? void 0 : _u.parsed) == null ? void 0 : _v.USERNAME_FIELD),
|
|
61
|
-
passwordField: String((_x = (_w = import_dotenv.default.config()) == null ? void 0 : _w.parsed) == null ? void 0 : _x.PASSWORD_FIELD),
|
|
62
|
-
argumentsDatabaseConnection: String((_z = (_y = import_dotenv.default.config()) == null ? void 0 : _y.parsed) == null ? void 0 : _z.ARGUMENTS_DATABASE_CONNECTION),
|
|
63
|
-
logEnv: String((_B = (_A = import_dotenv.default.config()) == null ? void 0 : _A.parsed) == null ? void 0 : _B.LOG_ENVIRONMENT)
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
// src/domains/constants/httpStatusCodes.constant.ts
|
|
67
|
-
var HttpStatusCodesConstant = /* @__PURE__ */ ((HttpStatusCodesConstant2) => {
|
|
68
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["CONTINUE"] = 100] = "CONTINUE";
|
|
69
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
|
|
70
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["PROCESSING"] = 102] = "PROCESSING";
|
|
71
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["OK"] = 200] = "OK";
|
|
72
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["CREATED"] = 201] = "CREATED";
|
|
73
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["ACCEPTED"] = 202] = "ACCEPTED";
|
|
74
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["NON_AUTHORITATIVE_INFORMATION"] = 203] = "NON_AUTHORITATIVE_INFORMATION";
|
|
75
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["NO_CONTENT"] = 204] = "NO_CONTENT";
|
|
76
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["RESET_CONTENT"] = 205] = "RESET_CONTENT";
|
|
77
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT";
|
|
78
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["MULTI_STATUS"] = 207] = "MULTI_STATUS";
|
|
79
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["ALREADY_REPORTED"] = 208] = "ALREADY_REPORTED";
|
|
80
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["IM_USED"] = 226] = "IM_USED";
|
|
81
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["MULTIPLE_CHOICES"] = 300] = "MULTIPLE_CHOICES";
|
|
82
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["MOVED_PERMANENTLY"] = 301] = "MOVED_PERMANENTLY";
|
|
83
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["FOUND"] = 302] = "FOUND";
|
|
84
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["SEE_OTHER"] = 303] = "SEE_OTHER";
|
|
85
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
|
|
86
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["USE_PROXY"] = 305] = "USE_PROXY";
|
|
87
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["SWITCH_PROXY"] = 306] = "SWITCH_PROXY";
|
|
88
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
|
|
89
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["PERMANENT_REDIRECT"] = 308] = "PERMANENT_REDIRECT";
|
|
90
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["BAD_REQUEST"] = 400] = "BAD_REQUEST";
|
|
91
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
|
|
92
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
|
|
93
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["FORBIDDEN"] = 403] = "FORBIDDEN";
|
|
94
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["NOT_FOUND"] = 404] = "NOT_FOUND";
|
|
95
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
|
|
96
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
|
|
97
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
|
|
98
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
|
|
99
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["CONFLICT"] = 409] = "CONFLICT";
|
|
100
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["GONE"] = 410] = "GONE";
|
|
101
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
|
|
102
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
|
|
103
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
|
|
104
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["URI_TOO_LONG"] = 414] = "URI_TOO_LONG";
|
|
105
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
|
|
106
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["RANGE_NOT_SATISFIABLE"] = 416] = "RANGE_NOT_SATISFIABLE";
|
|
107
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
|
|
108
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["I_AM_A_TEAPOT"] = 418] = "I_AM_A_TEAPOT";
|
|
109
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["MISDIRECTED_REQUEST"] = 421] = "MISDIRECTED_REQUEST";
|
|
110
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
|
|
111
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["LOCKED"] = 423] = "LOCKED";
|
|
112
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
|
|
113
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["UPGRADE_REQUIRED"] = 426] = "UPGRADE_REQUIRED";
|
|
114
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
|
|
115
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
|
|
116
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["REQUEST_HEADER_FIELDS_TOO_LARGE"] = 431] = "REQUEST_HEADER_FIELDS_TOO_LARGE";
|
|
117
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["UNAVAILABLE_FOR_LEGAL_REASONS"] = 451] = "UNAVAILABLE_FOR_LEGAL_REASONS";
|
|
118
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
|
|
119
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
|
|
120
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
|
|
121
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
|
|
122
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
|
|
123
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
|
|
124
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["VARIANT_ALSO_NEGOTIATES"] = 506] = "VARIANT_ALSO_NEGOTIATES";
|
|
125
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["INSUFFICIENT_STORAGE"] = 507] = "INSUFFICIENT_STORAGE";
|
|
126
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["LOOP_DETECTED"] = 508] = "LOOP_DETECTED";
|
|
127
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["NOT_EXTENDED"] = 510] = "NOT_EXTENDED";
|
|
128
|
-
HttpStatusCodesConstant2[HttpStatusCodesConstant2["NETWORK_AUTHENTICATION_REQUIRED"] = 511] = "NETWORK_AUTHENTICATION_REQUIRED";
|
|
129
|
-
return HttpStatusCodesConstant2;
|
|
130
|
-
})(HttpStatusCodesConstant || {});
|
|
131
|
-
|
|
132
|
-
// src/core/handlers/errors/base/stackTraceError.ts
|
|
133
|
-
var StackTraceError = class extends Error {
|
|
134
|
-
// Centralized error objet that derives from Node's Error.
|
|
135
|
-
constructor(props, name, httpCode, isOperational) {
|
|
136
|
-
super(props);
|
|
137
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
138
|
-
this.name = name;
|
|
139
|
-
this.httpCode = httpCode;
|
|
140
|
-
this.isOperational = isOperational;
|
|
141
|
-
Error.captureStackTrace(this);
|
|
142
|
-
}
|
|
143
|
-
};
|
|
39
|
+
var import_opticore_catch_exception_error3 = require("opticore-catch-exception-error");
|
|
40
|
+
var import_opticore_express2 = require("opticore-express");
|
|
41
|
+
var import_opticore_env_access = require("opticore-env-access");
|
|
42
|
+
var import_opticore_requests_called_events = require("opticore-requests-called-events");
|
|
43
|
+
var import_opticore_http_response2 = require("opticore-http-response");
|
|
144
44
|
|
|
145
45
|
// src/core/handlers/eventProcess.handler.ts
|
|
146
|
-
var import_express = __toESM(require("express"), 1);
|
|
147
46
|
var import_node_process = __toESM(require("process"), 1);
|
|
148
47
|
var import_node_events = __toESM(require("events"), 1);
|
|
48
|
+
var import_opticore_express = require("opticore-express");
|
|
49
|
+
var import_opticore_catch_exception_error = require("opticore-catch-exception-error");
|
|
50
|
+
function eventProcessHandler() {
|
|
51
|
+
const errorEmitter = new import_node_events.default();
|
|
52
|
+
const app = (0, import_opticore_express.express)();
|
|
53
|
+
errorEmitter.on(import_opticore_catch_exception_error.CEventNameError.error, (error) => {
|
|
54
|
+
import_opticore_catch_exception_error.ServerListenEventError.listenerError(error);
|
|
55
|
+
});
|
|
56
|
+
import_node_process.default.on(import_opticore_catch_exception_error.CEvent.beforeExit, (code) => {
|
|
57
|
+
setTimeout(() => {
|
|
58
|
+
import_opticore_catch_exception_error.ServerListenEventError.processBeforeExit(code);
|
|
59
|
+
}, 100);
|
|
60
|
+
});
|
|
61
|
+
import_node_process.default.on(import_opticore_catch_exception_error.CEvent.disconnect, () => {
|
|
62
|
+
import_opticore_catch_exception_error.ServerListenEventError.processDisconnected();
|
|
63
|
+
});
|
|
64
|
+
import_node_process.default.on(import_opticore_catch_exception_error.CEvent.exit, (code) => {
|
|
65
|
+
import_opticore_catch_exception_error.ServerListenEventError.exited(code);
|
|
66
|
+
});
|
|
67
|
+
import_node_process.default.on(import_opticore_catch_exception_error.CEvent.rejectionHandled, (promise) => {
|
|
68
|
+
import_opticore_catch_exception_error.ServerListenEventError.promiseRejectionHandled(promise);
|
|
69
|
+
});
|
|
70
|
+
import_node_process.default.on(import_opticore_catch_exception_error.CEvent.uncaughtException, (error) => {
|
|
71
|
+
import_opticore_catch_exception_error.ServerListenEventError.uncaughtException(error);
|
|
72
|
+
});
|
|
73
|
+
import_node_process.default.on(import_opticore_catch_exception_error.CEvent.uncaughtExceptionMonitor, (error) => {
|
|
74
|
+
import_opticore_catch_exception_error.ServerListenEventError.uncaughtExceptionMonitor(error);
|
|
75
|
+
});
|
|
76
|
+
import_node_process.default.on(import_opticore_catch_exception_error.CEvent.unhandledRejection, (reason, promise) => {
|
|
77
|
+
import_opticore_catch_exception_error.ServerListenEventError.unhandledRejection(reason, promise);
|
|
78
|
+
});
|
|
79
|
+
import_node_process.default.on(import_opticore_catch_exception_error.CEvent.warning, (warning) => {
|
|
80
|
+
import_opticore_catch_exception_error.ServerListenEventError.warning(warning);
|
|
81
|
+
});
|
|
82
|
+
import_node_process.default.on(import_opticore_catch_exception_error.CEvent.message, (message) => {
|
|
83
|
+
import_opticore_catch_exception_error.ServerListenEventError.message(message);
|
|
84
|
+
});
|
|
85
|
+
import_node_process.default.on(import_opticore_catch_exception_error.CEvent.multipleResolves, (type, promise, reason) => {
|
|
86
|
+
import_opticore_catch_exception_error.ServerListenEventError.multipleResolves(type, promise, reason);
|
|
87
|
+
});
|
|
88
|
+
import_node_process.default.on(import_opticore_catch_exception_error.CEvent.sigint, () => {
|
|
89
|
+
import_opticore_catch_exception_error.ServerListenEventError.processInterrupted();
|
|
90
|
+
});
|
|
91
|
+
import_node_process.default.on(import_opticore_catch_exception_error.CEvent.sigterm, (signal) => {
|
|
92
|
+
import_opticore_catch_exception_error.ServerListenEventError.sigtermSignalReceived(signal);
|
|
93
|
+
});
|
|
94
|
+
app.use((err, req, res, next) => {
|
|
95
|
+
import_opticore_catch_exception_error.ServerListenEventError.expressErrorHandlingMiddleware(errorEmitter, err, req, res, next);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
149
98
|
|
|
150
|
-
// src/
|
|
151
|
-
var
|
|
152
|
-
var import_ansi_colors2 = __toESM(require("ansi-colors"), 1);
|
|
99
|
+
// src/application/service/core.service.ts
|
|
100
|
+
var import_node_process2 = __toESM(require("process"), 1);
|
|
153
101
|
var import_chalk = __toESM(require("chalk"), 1);
|
|
102
|
+
var path = __toESM(require("path"), 1);
|
|
103
|
+
var fs = __toESM(require("fs"), 1);
|
|
104
|
+
var import_ansi_colors4 = __toESM(require("ansi-colors"), 1);
|
|
105
|
+
var import_opticore_http_response = require("opticore-http-response");
|
|
106
|
+
var import_opticore_catch_exception_error2 = require("opticore-catch-exception-error");
|
|
107
|
+
|
|
108
|
+
// src/core/utils/modulesLoaded.utils.ts
|
|
109
|
+
var import_ansi_colors2 = __toESM(require("ansi-colors"), 1);
|
|
154
110
|
|
|
155
111
|
// src/core/utils/dateTimeFormatted.utils.ts
|
|
156
112
|
var dateTimeFormattedUtils = `${(/* @__PURE__ */ new Date()).getMonth()}-${(/* @__PURE__ */ new Date()).getDate()}-${(/* @__PURE__ */ new Date()).getFullYear()} ${(/* @__PURE__ */ new Date()).getHours()}:${(/* @__PURE__ */ new Date()).getMinutes()}:${(/* @__PURE__ */ new Date()).getSeconds()}`;
|
|
157
113
|
|
|
158
|
-
// src/
|
|
114
|
+
// src/core/utils/logMessage.utils.ts
|
|
159
115
|
var import_ansi_colors = __toESM(require("ansi-colors"), 1);
|
|
116
|
+
var LogMessageUtils = class {
|
|
117
|
+
static success(title, action, contentAction) {
|
|
118
|
+
console.log(`${import_ansi_colors.default.green(`\u2714`)} ${import_ansi_colors.default.bgGreen(` ${import_ansi_colors.default.bold(`${import_ansi_colors.default.white(`${title}`)}`)} `)} ${dateTimeFormattedUtils} | ${import_ansi_colors.default.bgGreen(`${import_ansi_colors.default.white(` Success `)}`)} [ ${action} ] ${contentAction} - [ Status ] ${import_ansi_colors.default.bgGreen(`${import_ansi_colors.default.white(` 200 `)}`)}`);
|
|
119
|
+
}
|
|
120
|
+
static warning(title, action, contentAction) {
|
|
121
|
+
console.warn(`${import_ansi_colors.default.yellow(`\u26A0\uFE0F`)} ${import_ansi_colors.default.bgYellow(` ${import_ansi_colors.default.bold(`${import_ansi_colors.default.white(`${title}`)}`)} `)} ${dateTimeFormattedUtils} | ${import_ansi_colors.default.bgYellow(`${import_ansi_colors.default.white(` Warning `)}`)} ${contentAction}`);
|
|
122
|
+
}
|
|
123
|
+
static info(title, action, contentAction) {
|
|
124
|
+
console.info(`${import_ansi_colors.default.cyan(`\u24D8`)} ${import_ansi_colors.default.bgCyan(` ${import_ansi_colors.default.bold(`${import_ansi_colors.default.white(`${title}`)}`)} `)} ${dateTimeFormattedUtils} | ${import_ansi_colors.default.bgCyan(`${import_ansi_colors.default.white(` Info `)}`)} ${contentAction}`);
|
|
125
|
+
}
|
|
126
|
+
static error(title, errorType, stackTrace, messageContent, httpCodeValue) {
|
|
127
|
+
console.error(`${import_ansi_colors.default.red(`\u2718`)} ${import_ansi_colors.default.bgRed(` ${import_ansi_colors.default.bold(`${import_ansi_colors.default.white(`${title}`)}`)} `)} | ${dateTimeFormattedUtils} | [ ${import_ansi_colors.default.red(`${import_ansi_colors.default.bold(` ${errorType} `)}`)} ] | [ ${import_ansi_colors.default.bold(`stack trace`)} ] ${import_ansi_colors.default.red(`${stackTrace}`)} - ${import_ansi_colors.default.red(`${messageContent}`)} - [ ${import_ansi_colors.default.red(`${import_ansi_colors.default.bold(` HttpCode `)}`)} ] ${import_ansi_colors.default.red(`${import_ansi_colors.default.bold(` ${httpCodeValue} `)}`)} `);
|
|
128
|
+
}
|
|
129
|
+
static requestError(title, errorName, errorMessage, errorCode) {
|
|
130
|
+
console.error(`[ ${import_ansi_colors.default.red(`${title}`)} ] ${dateTimeFormattedUtils} | ${import_ansi_colors.default.bgRed(`${import_ansi_colors.default.white(` ERROR `)}`)} ${import_ansi_colors.default.red(`[ ${errorName} ]`)} ${import_ansi_colors.default.red(`${errorMessage}`)} - [ Status ] ${import_ansi_colors.default.bgRed(`${import_ansi_colors.default.white(` ${errorCode} `)}`)}`);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// src/core/utils/modulesLoaded.utils.ts
|
|
135
|
+
function modulesLoadedUtils(allAppRoutes, dbConChecker) {
|
|
136
|
+
LogMessageUtils.success("Kernel", "load kernel", "Modules app have been successfully loaded");
|
|
137
|
+
console.log(`${import_ansi_colors2.default.whiteBright(` content`)} ${import_ansi_colors2.default.green("Kernel :")} ${import_ansi_colors2.default.cyan(`${import_ansi_colors2.default.bold(`server side`)}`)} has been loaded successfully ${import_ansi_colors2.default.green(`\u2714`)}`);
|
|
138
|
+
allAppRoutes ? console.log(`${import_ansi_colors2.default.whiteBright(` content`)} ${import_ansi_colors2.default.green("Kernel :")} ${import_ansi_colors2.default.cyan(`${import_ansi_colors2.default.bold(`Routers service`)} `)} has been loaded successfully ${import_ansi_colors2.default.green(`\u2714`)}`) : console.log(`${import_ansi_colors2.default.red(`\u2718`)} ${import_ansi_colors2.default.bgRed(` ${import_ansi_colors2.default.bold(`${import_ansi_colors2.default.white(` Register routes `)}`)} `)} | ${dateTimeFormattedUtils} | [ ${import_ansi_colors2.default.red(`${import_ansi_colors2.default.bold(` fail `)}`)} ] | [ ${import_ansi_colors2.default.bold(` loading `)} ] - ${import_ansi_colors2.default.red(` routers `)} - The route register failed to load `);
|
|
139
|
+
typeof dbConChecker == "function" ? console.log(`${import_ansi_colors2.default.whiteBright(` content`)} ${import_ansi_colors2.default.green("Kernel :")} ${import_ansi_colors2.default.cyan(`${import_ansi_colors2.default.bold(`database checker connection`)}`)} has been loaded successfully ${import_ansi_colors2.default.green(`\u2714`)}`) : "";
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// src/application/exceptions/messages.exception.ts
|
|
143
|
+
var import_ansi_colors3 = __toESM(require("ansi-colors"), 1);
|
|
160
144
|
var messageException = {
|
|
161
145
|
dbConnection: "DataBase connection",
|
|
162
146
|
dbConnectionClosed: "MySQL connection is closed",
|
|
@@ -220,485 +204,9 @@ var messageException = {
|
|
|
220
204
|
errorHost: "The host can't be empty or blank. Please define a string host in .env",
|
|
221
205
|
accessDeniedToDBCon: (user, password) => `Access denied for user ${user}. Database credentials in .env file are User: ${user} and Password: ${password}. '${user}''${password}'@'localhost'. Try to set user and password in .env file`,
|
|
222
206
|
unknownDB: (database) => `Database ${database} is unknown. Please try to use Database CLI to create your database, or do it manually in your Database Management System`,
|
|
223
|
-
errorDBHost: (host) => `A database host ${host} does not allow connection. Please either set the host like this: ${
|
|
207
|
+
errorDBHost: (host) => `A database host ${host} does not allow connection. Please either set the host like this: ${import_ansi_colors3.default.bgRed(`${import_ansi_colors3.default.white(`localhost`)}`)} in your .env file`
|
|
224
208
|
};
|
|
225
209
|
|
|
226
|
-
// src/domains/constants/eventNameError.constant.ts
|
|
227
|
-
var CEventNameError = {
|
|
228
|
-
error: "error",
|
|
229
|
-
listening: "listening",
|
|
230
|
-
close: "close",
|
|
231
|
-
connection: "connection",
|
|
232
|
-
drop: "drop",
|
|
233
|
-
request: "request"
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
// src/core/events/errors/serverListen.event.error.ts
|
|
237
|
-
var import_opticore_logger = require("opticore-logger");
|
|
238
|
-
var ServerListenEventError = class {
|
|
239
|
-
/**
|
|
240
|
-
*
|
|
241
|
-
*/
|
|
242
|
-
static hostPortUndefined() {
|
|
243
|
-
this.stackTrace = this.traceError(messageException.errorHostUrl, messageException.listening, 400 /* BAD_REQUEST */);
|
|
244
|
-
this.logger.error(this.stackTrace.message, messageException.webServer, messageException.badHost, this.stackTrace.stack, 400 /* BAD_REQUEST */);
|
|
245
|
-
import_process.default.exit();
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
*
|
|
249
|
-
*/
|
|
250
|
-
static hostUndefined() {
|
|
251
|
-
this.stackTrace = this.traceError(messageException.badHost, messageException.listening, 400 /* BAD_REQUEST */);
|
|
252
|
-
this.logger.error(this.stackTrace.message, messageException.webServer, messageException.badHost, this.stackTrace.stack, 400 /* BAD_REQUEST */);
|
|
253
|
-
import_process.default.exit();
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
*
|
|
257
|
-
*/
|
|
258
|
-
static portUndefined() {
|
|
259
|
-
this.stackTrace = this.traceError(messageException.badPort, messageException.listening, 400 /* BAD_REQUEST */);
|
|
260
|
-
this.logger.error(this.stackTrace.message, messageException.webServer, messageException.badHost, this.stackTrace.stack, 400 /* BAD_REQUEST */);
|
|
261
|
-
import_process.default.exit();
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
*
|
|
265
|
-
* @param err
|
|
266
|
-
*/
|
|
267
|
-
static onEventError(err) {
|
|
268
|
-
this.logger.error(err.message, "Server start error", "Error", err.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
*
|
|
272
|
-
* @param error
|
|
273
|
-
*/
|
|
274
|
-
static listenerError(error) {
|
|
275
|
-
this.stackTrace = this.traceError(error.message, error.name, 400 /* BAD_REQUEST */);
|
|
276
|
-
this.logger.error(this.stackTrace.message, "Event error", "Error", error.stack, 400 /* BAD_REQUEST */);
|
|
277
|
-
}
|
|
278
|
-
/**
|
|
279
|
-
*
|
|
280
|
-
* @param code
|
|
281
|
-
*/
|
|
282
|
-
static processBeforeExit(code) {
|
|
283
|
-
this.stackTrace = this.traceError(`Process will exit with code: ${code}`, "BeforeExit", 503 /* SERVICE_UNAVAILABLE */);
|
|
284
|
-
this.logger.error(this.stackTrace.message, "BeforeExit", "process before exit", this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
285
|
-
import_process.default.exit(code);
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
*
|
|
289
|
-
*/
|
|
290
|
-
static processDisconnected() {
|
|
291
|
-
this.stackTrace = this.traceError("Child process disconnected", "process disconnected", 503 /* SERVICE_UNAVAILABLE */);
|
|
292
|
-
this.logger.error(this.stackTrace.message, "Disconnected", "process disconnected", this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
293
|
-
import_process.default.exit();
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
*
|
|
297
|
-
* @param code
|
|
298
|
-
*/
|
|
299
|
-
static exited(code) {
|
|
300
|
-
switch (code) {
|
|
301
|
-
case 0:
|
|
302
|
-
this.logger.success("completed", "The process finished as expected and everything is ok");
|
|
303
|
-
console.log("");
|
|
304
|
-
const paddingLength = 35;
|
|
305
|
-
const msg0 = " ".padEnd(paddingLength, " ");
|
|
306
|
-
console.log(import_chalk.default.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
307
|
-
console.log(`${import_ansi_colors2.default.bgGreen(` [OK] The server shutting down `)}`);
|
|
308
|
-
console.log(import_chalk.default.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
309
|
-
break;
|
|
310
|
-
case 1:
|
|
311
|
-
this.stackTrace = this.traceError("Something went wrong", "General Errors", 503 /* SERVICE_UNAVAILABLE */);
|
|
312
|
-
this.logger.error(this.stackTrace.message, "Exited", "General Errors", this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
313
|
-
break;
|
|
314
|
-
case 2:
|
|
315
|
-
this.stackTrace = this.traceError("Incorrect using of shell commands", "Misuse of shell builtins", 503 /* SERVICE_UNAVAILABLE */);
|
|
316
|
-
this.logger.error(this.stackTrace.message, "Exited", "Incorrect using of shell commands", this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
317
|
-
break;
|
|
318
|
-
case 126:
|
|
319
|
-
this.stackTrace = this.traceError(
|
|
320
|
-
"Incorrect using of shell commands",
|
|
321
|
-
"The command is found but is not executable (e.g., trying to execute a directory)",
|
|
322
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
323
|
-
);
|
|
324
|
-
this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
325
|
-
break;
|
|
326
|
-
case 127:
|
|
327
|
-
this.stackTrace = this.traceError(
|
|
328
|
-
"Command not found",
|
|
329
|
-
"The command was not found in the system's PATH or is misspelled",
|
|
330
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
331
|
-
);
|
|
332
|
-
this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
333
|
-
break;
|
|
334
|
-
case 128:
|
|
335
|
-
this.stackTrace = this.traceError(
|
|
336
|
-
"The command was not found in the system's PATH or is misspelled",
|
|
337
|
-
"Invalid argument",
|
|
338
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
339
|
-
);
|
|
340
|
-
this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
341
|
-
break;
|
|
342
|
-
case 130:
|
|
343
|
-
this.stackTrace = this.traceError(
|
|
344
|
-
"Indicates that the script was manually terminated by the user using the Control-C (SIGINT) signal",
|
|
345
|
-
"Script terminated",
|
|
346
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
347
|
-
);
|
|
348
|
-
this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
349
|
-
break;
|
|
350
|
-
case 137:
|
|
351
|
-
this.stackTrace = this.traceError(
|
|
352
|
-
"Indicates that the process was terminated by a SIGKILL signal, possibly due to an out-of-memory situation",
|
|
353
|
-
"SIGKILL",
|
|
354
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
355
|
-
);
|
|
356
|
-
this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
357
|
-
break;
|
|
358
|
-
case 139:
|
|
359
|
-
this.stackTrace = this.traceError(
|
|
360
|
-
"Indicates that the process accessed an illegal memory address (segfault)",
|
|
361
|
-
"Segmentation fault",
|
|
362
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
363
|
-
);
|
|
364
|
-
this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
365
|
-
break;
|
|
366
|
-
case 143:
|
|
367
|
-
this.stackTrace = this.traceError(
|
|
368
|
-
"Indicates that the process received a SIGTERM signal to terminate",
|
|
369
|
-
"process received a SIGTERM",
|
|
370
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
371
|
-
);
|
|
372
|
-
this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
373
|
-
break;
|
|
374
|
-
case 255:
|
|
375
|
-
this.stackTrace = this.traceError(
|
|
376
|
-
"An exit code that is outside the allowable range (0-255 for Unix-like systems)",
|
|
377
|
-
"out of range",
|
|
378
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
379
|
-
);
|
|
380
|
-
this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
381
|
-
break;
|
|
382
|
-
default:
|
|
383
|
-
this.stackTrace = this.traceError(
|
|
384
|
-
"Error is occurring",
|
|
385
|
-
"errors",
|
|
386
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
387
|
-
);
|
|
388
|
-
this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
389
|
-
break;
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
*
|
|
394
|
-
* @param promise
|
|
395
|
-
*/
|
|
396
|
-
static promiseRejectionHandled(promise) {
|
|
397
|
-
this.stackTrace = this.traceError(
|
|
398
|
-
`Promise rejection is handled at : ${promise}`,
|
|
399
|
-
"rejection promise",
|
|
400
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
401
|
-
);
|
|
402
|
-
this.logger.error(this.stackTrace.message, "PromiseRejectionHandled", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
403
|
-
}
|
|
404
|
-
/**
|
|
405
|
-
*
|
|
406
|
-
* @param error
|
|
407
|
-
*/
|
|
408
|
-
static uncaughtException(error) {
|
|
409
|
-
if (error.message === "'app.router' is deprecated!\nPlease see the 3.x to 4.x migration guide for details on how to update your app.") {
|
|
410
|
-
console.log("");
|
|
411
|
-
} else {
|
|
412
|
-
this.stackTrace = this.traceError(error.message, "uncaught exception handled", 503 /* SERVICE_UNAVAILABLE */);
|
|
413
|
-
this.logger.error(this.stackTrace.message, "UncaughtException", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
/**
|
|
417
|
-
*
|
|
418
|
-
* @param error
|
|
419
|
-
*/
|
|
420
|
-
static uncaughtExceptionMonitor(error) {
|
|
421
|
-
if (error.message === "'app.router' is deprecated!\nPlease see the 3.x to 4.x migration guide for details on how to update your app.") {
|
|
422
|
-
console.log("");
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
/**
|
|
426
|
-
*
|
|
427
|
-
* @param reason
|
|
428
|
-
* @param promise
|
|
429
|
-
*/
|
|
430
|
-
static unhandledRejection(reason, promise) {
|
|
431
|
-
this.stackTrace = this.traceError(
|
|
432
|
-
`Unhandled Rejection at: Promise ${promise} -- reason ${reason}`,
|
|
433
|
-
"Unhandled rejection",
|
|
434
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
435
|
-
);
|
|
436
|
-
this.logger.error(this.stackTrace.message, "UnhandledRejection", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
437
|
-
}
|
|
438
|
-
/**
|
|
439
|
-
*
|
|
440
|
-
* @param warning
|
|
441
|
-
*/
|
|
442
|
-
static warning(warning) {
|
|
443
|
-
this.stackTrace = this.traceError(warning.message, "warning", 503 /* SERVICE_UNAVAILABLE */);
|
|
444
|
-
this.logger.error(this.stackTrace.message, "Warning", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
445
|
-
}
|
|
446
|
-
/**
|
|
447
|
-
*
|
|
448
|
-
* @param message
|
|
449
|
-
*/
|
|
450
|
-
static message(message) {
|
|
451
|
-
this.stackTrace = this.traceError(
|
|
452
|
-
`process got message ${message}`,
|
|
453
|
-
"message exception",
|
|
454
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
455
|
-
);
|
|
456
|
-
this.logger.error(this.stackTrace.message, "Message", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
457
|
-
}
|
|
458
|
-
/**
|
|
459
|
-
*
|
|
460
|
-
* @param type
|
|
461
|
-
* @param promise
|
|
462
|
-
* @param reason
|
|
463
|
-
*/
|
|
464
|
-
static multipleResolves(type, promise, reason) {
|
|
465
|
-
this.stackTrace = this.traceError(
|
|
466
|
-
`${promise} -- ${reason}`,
|
|
467
|
-
`Multiple resolves detected : ${type}`,
|
|
468
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
469
|
-
);
|
|
470
|
-
this.logger.error(this.stackTrace.message, "multipleResolves", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
471
|
-
}
|
|
472
|
-
/**
|
|
473
|
-
*
|
|
474
|
-
*/
|
|
475
|
-
static processInterrupted() {
|
|
476
|
-
this.logger.success("[ OK ] Success", "The Web server has been stopped !");
|
|
477
|
-
import_process.default.exit(0);
|
|
478
|
-
}
|
|
479
|
-
/**
|
|
480
|
-
*
|
|
481
|
-
* @param signal
|
|
482
|
-
*/
|
|
483
|
-
static sigtermSignalReceived(signal) {
|
|
484
|
-
this.stackTrace = this.traceError(
|
|
485
|
-
`Process ${import_process.default.pid} received a SIGTERM signal : ${signal.toString()}`,
|
|
486
|
-
"SIGTERM",
|
|
487
|
-
406 /* NOT_ACCEPTABLE */
|
|
488
|
-
);
|
|
489
|
-
this.logger.error(this.stackTrace.message, "SIGTERM", this.stackTrace.name, this.stackTrace.stack, 406 /* NOT_ACCEPTABLE */);
|
|
490
|
-
import_process.default.exit(0);
|
|
491
|
-
}
|
|
492
|
-
/**
|
|
493
|
-
*
|
|
494
|
-
*/
|
|
495
|
-
static serverClosing() {
|
|
496
|
-
console.log(`${import_ansi_colors2.default.bgCyanBright(` ${import_ansi_colors2.default.bold(`${import_ansi_colors2.default.white(` INFO `)}`)}`)} All processes are stopped`);
|
|
497
|
-
console.log(" Server is closed");
|
|
498
|
-
import_process.default.exit();
|
|
499
|
-
}
|
|
500
|
-
/**
|
|
501
|
-
*
|
|
502
|
-
*/
|
|
503
|
-
static dropNewConnection() {
|
|
504
|
-
console.log(`${import_ansi_colors2.default.cyan(`\u24D8`)} ${import_ansi_colors2.default.bgCyan(` ${import_ansi_colors2.default.bold(`${import_ansi_colors2.default.white(` Server maxConnection `)}`)} `)} ${dateTimeFormattedUtils} | ${import_ansi_colors2.default.bgCyan(`${import_ansi_colors2.default.white(` Info `)}`)} The server dropped new connections`);
|
|
505
|
-
}
|
|
506
|
-
/**
|
|
507
|
-
*
|
|
508
|
-
* @param errorEmitter
|
|
509
|
-
* @param err
|
|
510
|
-
* @param req
|
|
511
|
-
* @param res
|
|
512
|
-
* @param next
|
|
513
|
-
*/
|
|
514
|
-
static expressErrorHandlingMiddleware(errorEmitter, err, req, res, next) {
|
|
515
|
-
if (err) {
|
|
516
|
-
errorEmitter.emit(CEventNameError.error, err);
|
|
517
|
-
if (typeof res.status === "function") {
|
|
518
|
-
res.status(500).send("Internal Server Error");
|
|
519
|
-
} else {
|
|
520
|
-
console.error("res.status is not a function");
|
|
521
|
-
}
|
|
522
|
-
this.stackTrace = this.traceError(err.message, "Express error", 406 /* NOT_ACCEPTABLE */);
|
|
523
|
-
this.logger.error(this.stackTrace.message, "Express error-handling middleware", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
524
|
-
} else {
|
|
525
|
-
next();
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
static traceError(props, name, status) {
|
|
529
|
-
return new StackTraceError(props, name, status, true);
|
|
530
|
-
}
|
|
531
|
-
};
|
|
532
|
-
ServerListenEventError.logger = new import_opticore_logger.LoggerCore();
|
|
533
|
-
|
|
534
|
-
// src/core/handlers/eventProcess.handler.ts
|
|
535
|
-
function eventProcessHandler() {
|
|
536
|
-
const errorEmitter = new import_node_events.default();
|
|
537
|
-
const app = (0, import_express.default)();
|
|
538
|
-
errorEmitter.on(CEventNameError.error, (error) => {
|
|
539
|
-
ServerListenEventError.listenerError(error);
|
|
540
|
-
});
|
|
541
|
-
import_node_process.default.on(CEvent.beforeExit, (code) => {
|
|
542
|
-
setTimeout(() => {
|
|
543
|
-
ServerListenEventError.processBeforeExit(code);
|
|
544
|
-
}, 100);
|
|
545
|
-
});
|
|
546
|
-
import_node_process.default.on(CEvent.disconnect, () => {
|
|
547
|
-
ServerListenEventError.processDisconnected();
|
|
548
|
-
});
|
|
549
|
-
import_node_process.default.on(CEvent.exit, (code) => {
|
|
550
|
-
ServerListenEventError.exited(code);
|
|
551
|
-
});
|
|
552
|
-
import_node_process.default.on(CEvent.rejectionHandled, (promise) => {
|
|
553
|
-
ServerListenEventError.promiseRejectionHandled(promise);
|
|
554
|
-
});
|
|
555
|
-
import_node_process.default.on(CEvent.uncaughtException, (error) => {
|
|
556
|
-
ServerListenEventError.uncaughtException(error);
|
|
557
|
-
});
|
|
558
|
-
import_node_process.default.on(CEvent.uncaughtExceptionMonitor, (error) => {
|
|
559
|
-
ServerListenEventError.uncaughtExceptionMonitor(error);
|
|
560
|
-
});
|
|
561
|
-
import_node_process.default.on(CEvent.unhandledRejection, (reason, promise) => {
|
|
562
|
-
ServerListenEventError.unhandledRejection(reason, promise);
|
|
563
|
-
});
|
|
564
|
-
import_node_process.default.on(CEvent.warning, (warning) => {
|
|
565
|
-
ServerListenEventError.warning(warning);
|
|
566
|
-
});
|
|
567
|
-
import_node_process.default.on(CEvent.message, (message) => {
|
|
568
|
-
ServerListenEventError.message(message);
|
|
569
|
-
});
|
|
570
|
-
import_node_process.default.on(CEvent.multipleResolves, (type, promise, reason) => {
|
|
571
|
-
ServerListenEventError.multipleResolves(type, promise, reason);
|
|
572
|
-
});
|
|
573
|
-
import_node_process.default.on(CEvent.sigint, () => {
|
|
574
|
-
ServerListenEventError.processInterrupted();
|
|
575
|
-
});
|
|
576
|
-
import_node_process.default.on(CEvent.sigterm, (signal) => {
|
|
577
|
-
ServerListenEventError.sigtermSignalReceived(signal);
|
|
578
|
-
});
|
|
579
|
-
app.use((err, req, res, next) => {
|
|
580
|
-
ServerListenEventError.expressErrorHandlingMiddleware(errorEmitter, err, req, res, next);
|
|
581
|
-
});
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
// src/core/events/requestCalls.event.ts
|
|
585
|
-
var import_ansi_colors3 = __toESM(require("ansi-colors"), 1);
|
|
586
|
-
var import_opticore_logger2 = require("opticore-logger");
|
|
587
|
-
function requestCallsEvent(req, res, host, port, loadingTime) {
|
|
588
|
-
const logger = new import_opticore_logger2.LoggerCore();
|
|
589
|
-
const currentDatePath = `Request called`;
|
|
590
|
-
if (req.originalUrl === "undefined") {
|
|
591
|
-
console.log(`[ ${import_ansi_colors3.default.red(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors3.default.bgRed(`${import_ansi_colors3.default.white(` Not found `)}`)} [ Host ] http://${host}:${port} - [ Route ] The route do not exist. - [ Status ] ${import_ansi_colors3.default.red(`${import_ansi_colors3.default.white(` 404 `)}`)}`);
|
|
592
|
-
logger.error("The route do not exist.");
|
|
593
|
-
} else {
|
|
594
|
-
switch (res.statusCode) {
|
|
595
|
-
case 200:
|
|
596
|
-
switch (req.method) {
|
|
597
|
-
case "POST":
|
|
598
|
-
logger.info(`[ ${import_ansi_colors3.default.cyan(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors3.default.bgGreen(`${import_ansi_colors3.default.white(` Success `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ Status ] ${import_ansi_colors3.default.bgCyan(`${import_ansi_colors3.default.white(` 200 `)}`)}`);
|
|
599
|
-
break;
|
|
600
|
-
case "GET":
|
|
601
|
-
case "PUT":
|
|
602
|
-
logger.info(`[ ${import_ansi_colors3.default.cyan(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors3.default.bgGreen(`${import_ansi_colors3.default.white(` Success `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${import_ansi_colors3.default.bgCyan(`${import_ansi_colors3.default.white(` 200 `)}`)}`);
|
|
603
|
-
break;
|
|
604
|
-
case "DELETE":
|
|
605
|
-
logger.info(`[ ${import_ansi_colors3.default.cyan(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors3.default.bgGreen(`${import_ansi_colors3.default.white(` Success `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${import_ansi_colors3.default.bgCyan(`${import_ansi_colors3.default.white(` 200 `)}`)}`);
|
|
606
|
-
break;
|
|
607
|
-
}
|
|
608
|
-
break;
|
|
609
|
-
case 404:
|
|
610
|
-
switch (req.method) {
|
|
611
|
-
case "POST":
|
|
612
|
-
console.log(`[ ${import_ansi_colors3.default.red(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors3.default.bgRed(`${import_ansi_colors3.default.white(` Not found `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ Status ] ${import_ansi_colors3.default.red(`${import_ansi_colors3.default.white(` 404 `)}`)}`);
|
|
613
|
-
break;
|
|
614
|
-
case "GET":
|
|
615
|
-
console.log(`[ ${import_ansi_colors3.default.red(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors3.default.bgRed(`${import_ansi_colors3.default.white(` Not found `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${import_ansi_colors3.default.red(`${import_ansi_colors3.default.bold(` 404 `)}`)}`);
|
|
616
|
-
break;
|
|
617
|
-
case "PUT":
|
|
618
|
-
console.log(`[ ${import_ansi_colors3.default.red(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors3.default.bgRed(`${import_ansi_colors3.default.white(` Not found `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${import_ansi_colors3.default.red(`${import_ansi_colors3.default.bold(` 404 `)}`)}`);
|
|
619
|
-
break;
|
|
620
|
-
case "DELETE":
|
|
621
|
-
console.log(`[ ${import_ansi_colors3.default.red(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors3.default.bgRed(`${import_ansi_colors3.default.white(` Not found `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${import_ansi_colors3.default.red(`${import_ansi_colors3.default.bold(` 404 `)}`)}`);
|
|
622
|
-
break;
|
|
623
|
-
}
|
|
624
|
-
break;
|
|
625
|
-
case 401:
|
|
626
|
-
switch (req.method) {
|
|
627
|
-
case "POST":
|
|
628
|
-
console.log(`[ ${import_ansi_colors3.default.yellowBright(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors3.default.bgYellowBright(`${import_ansi_colors3.default.white(` Unauthorized `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ Status ] ${import_ansi_colors3.default.bgYellow(`${import_ansi_colors3.default.bold(` 401 `)}`)}`);
|
|
629
|
-
break;
|
|
630
|
-
case "GET":
|
|
631
|
-
console.log(`[ ${import_ansi_colors3.default.yellowBright(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors3.default.bgYellowBright(`${import_ansi_colors3.default.white(` Unauthorized `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ Status ] ${import_ansi_colors3.default.bgYellow(`${import_ansi_colors3.default.bold(` 401 `)}`)}`);
|
|
632
|
-
break;
|
|
633
|
-
case "PUT":
|
|
634
|
-
console.log(`[ ${import_ansi_colors3.default.yellowBright(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors3.default.bgYellowBright(`${import_ansi_colors3.default.white(` Unauthorized `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ Status ] ${import_ansi_colors3.default.bgYellow(`${import_ansi_colors3.default.bold(` 401 `)}`)}`);
|
|
635
|
-
break;
|
|
636
|
-
case "DELETE":
|
|
637
|
-
console.log(`[ ${import_ansi_colors3.default.yellowBright(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors3.default.bgYellowBright(`${import_ansi_colors3.default.white(` Unauthorized `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ Status ] ${import_ansi_colors3.default.bgYellow(`${import_ansi_colors3.default.bold(` 401 `)}`)}`);
|
|
638
|
-
break;
|
|
639
|
-
}
|
|
640
|
-
break;
|
|
641
|
-
case 500:
|
|
642
|
-
switch (req.method) {
|
|
643
|
-
case "POST":
|
|
644
|
-
console.log(`[ ${import_ansi_colors3.default.red(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors3.default.bgRed(`${import_ansi_colors3.default.white(` Server error `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ Status ] ${import_ansi_colors3.default.red(`${import_ansi_colors3.default.bold(` 500 `)}`)}`);
|
|
645
|
-
break;
|
|
646
|
-
case "GET":
|
|
647
|
-
console.log(`[ ${import_ansi_colors3.default.red(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors3.default.bgRed(`${import_ansi_colors3.default.white(` Server error `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${import_ansi_colors3.default.red(`${import_ansi_colors3.default.bold(` 500 `)}`)}`);
|
|
648
|
-
break;
|
|
649
|
-
case "PUT":
|
|
650
|
-
console.log(`[ ${import_ansi_colors3.default.red(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors3.default.bgRed(`${import_ansi_colors3.default.white(` Server error `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${import_ansi_colors3.default.red(`${import_ansi_colors3.default.bold(` 500 `)}`)}`);
|
|
651
|
-
break;
|
|
652
|
-
case "DELETE":
|
|
653
|
-
console.log(`[ ${import_ansi_colors3.default.red(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors3.default.bgRed(`${import_ansi_colors3.default.white(` Server error `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${import_ansi_colors3.default.red(`${import_ansi_colors3.default.bold(` 500 `)}`)}`);
|
|
654
|
-
break;
|
|
655
|
-
}
|
|
656
|
-
break;
|
|
657
|
-
default:
|
|
658
|
-
console.log(`[ ${import_ansi_colors3.default.blueBright(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors3.default.blueBright(` ${res.statusMessage} `)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ Status ] ${import_ansi_colors3.default.blueBright(` ${res.req.socket._httpMessage.statusCode} `)}`);
|
|
659
|
-
break;
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
// src/application/service/core.service.ts
|
|
665
|
-
var import_node_process2 = __toESM(require("process"), 1);
|
|
666
|
-
var import_chalk2 = __toESM(require("chalk"), 1);
|
|
667
|
-
var path = __toESM(require("path"), 1);
|
|
668
|
-
var fs = __toESM(require("fs"), 1);
|
|
669
|
-
var import_ansi_colors6 = __toESM(require("ansi-colors"), 1);
|
|
670
|
-
|
|
671
|
-
// src/core/utils/modulesLoaded.utils.ts
|
|
672
|
-
var import_ansi_colors5 = __toESM(require("ansi-colors"), 1);
|
|
673
|
-
|
|
674
|
-
// src/core/utils/logMessage.utils.ts
|
|
675
|
-
var import_ansi_colors4 = __toESM(require("ansi-colors"), 1);
|
|
676
|
-
var LogMessageUtils = class {
|
|
677
|
-
static success(title, action, contentAction) {
|
|
678
|
-
console.log(`${import_ansi_colors4.default.green(`\u2714`)} ${import_ansi_colors4.default.bgGreen(` ${import_ansi_colors4.default.bold(`${import_ansi_colors4.default.white(`${title}`)}`)} `)} ${dateTimeFormattedUtils} | ${import_ansi_colors4.default.bgGreen(`${import_ansi_colors4.default.white(` Success `)}`)} [ ${action} ] ${contentAction} - [ Status ] ${import_ansi_colors4.default.bgGreen(`${import_ansi_colors4.default.white(` 200 `)}`)}`);
|
|
679
|
-
}
|
|
680
|
-
static warning(title, action, contentAction) {
|
|
681
|
-
console.warn(`${import_ansi_colors4.default.yellow(`\u26A0\uFE0F`)} ${import_ansi_colors4.default.bgYellow(` ${import_ansi_colors4.default.bold(`${import_ansi_colors4.default.white(`${title}`)}`)} `)} ${dateTimeFormattedUtils} | ${import_ansi_colors4.default.bgYellow(`${import_ansi_colors4.default.white(` Warning `)}`)} ${contentAction}`);
|
|
682
|
-
}
|
|
683
|
-
static info(title, action, contentAction) {
|
|
684
|
-
console.info(`${import_ansi_colors4.default.cyan(`\u24D8`)} ${import_ansi_colors4.default.bgCyan(` ${import_ansi_colors4.default.bold(`${import_ansi_colors4.default.white(`${title}`)}`)} `)} ${dateTimeFormattedUtils} | ${import_ansi_colors4.default.bgCyan(`${import_ansi_colors4.default.white(` Info `)}`)} ${contentAction}`);
|
|
685
|
-
}
|
|
686
|
-
static error(title, errorType, stackTrace, messageContent, httpCodeValue) {
|
|
687
|
-
console.error(`${import_ansi_colors4.default.red(`\u2718`)} ${import_ansi_colors4.default.bgRed(` ${import_ansi_colors4.default.bold(`${import_ansi_colors4.default.white(`${title}`)}`)} `)} | ${dateTimeFormattedUtils} | [ ${import_ansi_colors4.default.red(`${import_ansi_colors4.default.bold(` ${errorType} `)}`)} ] | [ ${import_ansi_colors4.default.bold(`stack trace`)} ] ${import_ansi_colors4.default.red(`${stackTrace}`)} - ${import_ansi_colors4.default.red(`${messageContent}`)} - [ ${import_ansi_colors4.default.red(`${import_ansi_colors4.default.bold(` HttpCode `)}`)} ] ${import_ansi_colors4.default.red(`${import_ansi_colors4.default.bold(` ${httpCodeValue} `)}`)} `);
|
|
688
|
-
}
|
|
689
|
-
static requestError(title, errorName, errorMessage, errorCode) {
|
|
690
|
-
console.error(`[ ${import_ansi_colors4.default.red(`${title}`)} ] ${dateTimeFormattedUtils} | ${import_ansi_colors4.default.bgRed(`${import_ansi_colors4.default.white(` ERROR `)}`)} ${import_ansi_colors4.default.red(`[ ${errorName} ]`)} ${import_ansi_colors4.default.red(`${errorMessage}`)} - [ Status ] ${import_ansi_colors4.default.bgRed(`${import_ansi_colors4.default.white(` ${errorCode} `)}`)}`);
|
|
691
|
-
}
|
|
692
|
-
};
|
|
693
|
-
|
|
694
|
-
// src/core/utils/modulesLoaded.utils.ts
|
|
695
|
-
function modulesLoadedUtils(allAppRoutes, dbConChecker) {
|
|
696
|
-
LogMessageUtils.success("Kernel", "load kernel", "Modules app have been successfully loaded");
|
|
697
|
-
console.log(`${import_ansi_colors5.default.whiteBright(` content`)} ${import_ansi_colors5.default.green("Kernel :")} ${import_ansi_colors5.default.cyan(`${import_ansi_colors5.default.bold(`server side`)}`)} has been loaded successfully ${import_ansi_colors5.default.green(`\u2714`)}`);
|
|
698
|
-
allAppRoutes ? console.log(`${import_ansi_colors5.default.whiteBright(` content`)} ${import_ansi_colors5.default.green("Kernel :")} ${import_ansi_colors5.default.cyan(`${import_ansi_colors5.default.bold(`Routers service`)} `)} has been loaded successfully ${import_ansi_colors5.default.green(`\u2714`)}`) : console.log(`${import_ansi_colors5.default.red(`\u2718`)} ${import_ansi_colors5.default.bgRed(` ${import_ansi_colors5.default.bold(`${import_ansi_colors5.default.white(` Register routes `)}`)} `)} | ${dateTimeFormattedUtils} | [ ${import_ansi_colors5.default.red(`${import_ansi_colors5.default.bold(` fail `)}`)} ] | [ ${import_ansi_colors5.default.bold(` loading `)} ] - ${import_ansi_colors5.default.red(` routers `)} - The route register failed to load `);
|
|
699
|
-
typeof dbConChecker == "function" ? console.log(`${import_ansi_colors5.default.whiteBright(` content`)} ${import_ansi_colors5.default.green("Kernel :")} ${import_ansi_colors5.default.cyan(`${import_ansi_colors5.default.bold(`database checker connection`)}`)} has been loaded successfully ${import_ansi_colors5.default.green(`\u2714`)}`) : "";
|
|
700
|
-
}
|
|
701
|
-
|
|
702
210
|
// src/application/service/core.service.ts
|
|
703
211
|
var CoreService = class {
|
|
704
212
|
/**
|
|
@@ -792,33 +300,33 @@ var CoreService = class {
|
|
|
792
300
|
this.getEnvFileLoading(".env");
|
|
793
301
|
const isDevelopment = import_node_process2.default.env.NODE_ENV === "development";
|
|
794
302
|
if (isDevelopment) {
|
|
795
|
-
return `The server is running in ${
|
|
303
|
+
return `The server is running in ${import_ansi_colors4.default.bgBlue(`${import_ansi_colors4.default.bold(`${development}`)}`)} mode`;
|
|
796
304
|
} else {
|
|
797
|
-
return `The server is running in ${
|
|
305
|
+
return `The server is running in ${import_ansi_colors4.default.bgBlue(`${import_ansi_colors4.default.bold(`${production}`)}`)} mode`;
|
|
798
306
|
}
|
|
799
307
|
}
|
|
800
308
|
infoServer(nodeVersion, startingTime, host, port, rss, heapUsed, user, system) {
|
|
801
309
|
const paddingLength = 52;
|
|
802
310
|
const msg0 = " ".padEnd(paddingLength, " ");
|
|
803
311
|
const msg1 = " [OK] Web server listening";
|
|
804
|
-
const msg2Value = `${
|
|
312
|
+
const msg2Value = `${import_ansi_colors4.default.bgBlue(`${import_ansi_colors4.default.bold(`${nodeVersion}`)}`)}`;
|
|
805
313
|
const msg2 = ` The Web server is using Node.js version`;
|
|
806
|
-
const msg3Value = `${
|
|
314
|
+
const msg3Value = `${import_ansi_colors4.default.bgBlue(`${import_ansi_colors4.default.bold(`${startingTime}`)}`)}`;
|
|
807
315
|
const msg3 = ` Startup time:`;
|
|
808
316
|
const msg4 = ` ${this.getServerRunningMode("development", "production")}`;
|
|
809
|
-
const msg5 = ` ${
|
|
810
|
-
console.log(
|
|
811
|
-
console.log(
|
|
812
|
-
console.log(
|
|
813
|
-
console.log(
|
|
814
|
-
console.log(
|
|
815
|
-
console.log(
|
|
816
|
-
console.log(
|
|
317
|
+
const msg5 = ` ${import_ansi_colors4.default.underline(`http://${host}:${port}`)}`;
|
|
318
|
+
console.log(import_chalk.default.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
319
|
+
console.log(import_chalk.default.bgGreen.white(msg1.padEnd(paddingLength, " ")));
|
|
320
|
+
console.log(import_chalk.default.bgGreen.white(msg2, msg2Value.padEnd(30.5, " ")));
|
|
321
|
+
console.log(import_chalk.default.bgGreen.white(msg3, msg3Value.padEnd(56, " ")));
|
|
322
|
+
console.log(import_chalk.default.bgGreen.white(msg4.padEnd(71, " ")));
|
|
323
|
+
console.log(import_chalk.default.bgGreen.white(msg5.padEnd(61, " ")));
|
|
324
|
+
console.log(import_chalk.default.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
817
325
|
console.log(``);
|
|
818
|
-
console.log(`${`Resident Set Size - total memory allocated for the process execution :`} ${
|
|
819
|
-
console.log(`${`Actual memory used during the execution :`} ${
|
|
820
|
-
console.log(`${`Memory usage by user :`} ${
|
|
821
|
-
console.log(`${`Memory usage by system :`} ${
|
|
326
|
+
console.log(`${`Resident Set Size - total memory allocated for the process execution :`} ${import_ansi_colors4.default.cyan(`${import_ansi_colors4.default.bold(`${rss}`)}`)}`);
|
|
327
|
+
console.log(`${`Actual memory used during the execution :`} ${import_ansi_colors4.default.cyan(`${import_ansi_colors4.default.bold(`${heapUsed}`)}`)}`);
|
|
328
|
+
console.log(`${`Memory usage by user :`} ${import_ansi_colors4.default.cyan(`${import_ansi_colors4.default.bold(`${user}`)}`)}`);
|
|
329
|
+
console.log(`${`Memory usage by system :`} ${import_ansi_colors4.default.cyan(`${import_ansi_colors4.default.bold(`${system}`)}`)}`);
|
|
822
330
|
console.log(``);
|
|
823
331
|
}
|
|
824
332
|
coreListenerEventLoaderModuleService(kernelModule) {
|
|
@@ -837,10 +345,10 @@ var CoreService = class {
|
|
|
837
345
|
dbCon();
|
|
838
346
|
})();
|
|
839
347
|
} else {
|
|
840
|
-
const stackTrace = new StackTraceError(
|
|
348
|
+
const stackTrace = new import_opticore_catch_exception_error2.StackTraceError(
|
|
841
349
|
messageException.loadedModulesError,
|
|
842
350
|
messageException.loadedModules,
|
|
843
|
-
|
|
351
|
+
import_opticore_http_response.HttpStatusCode.NOT_ACCEPTABLE,
|
|
844
352
|
true
|
|
845
353
|
);
|
|
846
354
|
throw new Error(stackTrace.message);
|
|
@@ -852,14 +360,14 @@ var CoreService = class {
|
|
|
852
360
|
var WebServerCore = class {
|
|
853
361
|
constructor(app, corsOriginOptions) {
|
|
854
362
|
this.serverUtility = new CoreService();
|
|
855
|
-
this.expressApp = (0,
|
|
856
|
-
this.port = Number(getEnvVariable.appPort);
|
|
857
|
-
this.host = getEnvVariable.appHost;
|
|
363
|
+
this.expressApp = (0, import_opticore_express2.express)();
|
|
364
|
+
this.port = Number(import_opticore_env_access.getEnvVariable.appPort);
|
|
365
|
+
this.host = import_opticore_env_access.getEnvVariable.appHost;
|
|
858
366
|
this.routerExpressApp = app;
|
|
859
|
-
this.expressApp.use(
|
|
860
|
-
this.expressApp.use(
|
|
861
|
-
this.expressApp.use(
|
|
862
|
-
this.expressApp.use(
|
|
367
|
+
this.expressApp.use(import_opticore_express2.express.json());
|
|
368
|
+
this.expressApp.use(import_opticore_express2.express.raw());
|
|
369
|
+
this.expressApp.use(import_opticore_express2.express.text());
|
|
370
|
+
this.expressApp.use(import_opticore_express2.express.urlencoded({ extended: true }));
|
|
863
371
|
this.expressApp.use((0, import_cors.default)(corsOriginOptions));
|
|
864
372
|
this.stackTraceErrorHandling();
|
|
865
373
|
}
|
|
@@ -870,35 +378,35 @@ var WebServerCore = class {
|
|
|
870
378
|
() => {
|
|
871
379
|
try {
|
|
872
380
|
if (this.host === "" && this.port === 0) {
|
|
873
|
-
ServerListenEventError.hostPortUndefined();
|
|
381
|
+
import_opticore_catch_exception_error3.ServerListenEventError.hostPortUndefined();
|
|
874
382
|
} else if (this.host === "") {
|
|
875
|
-
ServerListenEventError.hostUndefined();
|
|
383
|
+
import_opticore_catch_exception_error3.ServerListenEventError.hostUndefined();
|
|
876
384
|
} else if (this.port === 0) {
|
|
877
|
-
ServerListenEventError.portUndefined();
|
|
385
|
+
import_opticore_catch_exception_error3.ServerListenEventError.portUndefined();
|
|
878
386
|
} else {
|
|
879
387
|
this.registerRoutes(routers);
|
|
880
388
|
}
|
|
881
389
|
} catch (err) {
|
|
882
|
-
this.traceError(err.message, "Error",
|
|
390
|
+
this.traceError(err.message, "Error", import_opticore_http_response2.HttpStatusCode.NOT_ACCEPTABLE);
|
|
883
391
|
}
|
|
884
392
|
}
|
|
885
393
|
);
|
|
886
394
|
}
|
|
887
395
|
onListeningOnServerEvent(serverWeb, kernelModule) {
|
|
888
|
-
serverWeb.on(CEventNameError.error, (err) => {
|
|
889
|
-
ServerListenEventError.onEventError(err);
|
|
890
|
-
}).on(CEventNameError.close, () => {
|
|
891
|
-
ServerListenEventError.serverClosing();
|
|
892
|
-
}).on(CEventNameError.drop, () => {
|
|
893
|
-
ServerListenEventError.dropNewConnection();
|
|
894
|
-
}).on(CEventNameError.listening, () => {
|
|
396
|
+
serverWeb.on(import_opticore_catch_exception_error3.CEventNameError.error, (err) => {
|
|
397
|
+
import_opticore_catch_exception_error3.ServerListenEventError.onEventError(err);
|
|
398
|
+
}).on(import_opticore_catch_exception_error3.CEventNameError.close, () => {
|
|
399
|
+
import_opticore_catch_exception_error3.ServerListenEventError.serverClosing();
|
|
400
|
+
}).on(import_opticore_catch_exception_error3.CEventNameError.drop, () => {
|
|
401
|
+
import_opticore_catch_exception_error3.ServerListenEventError.dropNewConnection();
|
|
402
|
+
}).on(import_opticore_catch_exception_error3.CEventNameError.listening, () => {
|
|
895
403
|
this.infoWebApp();
|
|
896
404
|
this.serverUtility.coreListenerEventLoaderModuleService(kernelModule);
|
|
897
405
|
});
|
|
898
406
|
}
|
|
899
407
|
onRequestOnServerEvent(serverWeb) {
|
|
900
|
-
serverWeb.on(CEventNameError.request, (req, res) => {
|
|
901
|
-
requestCallsEvent(req, res, this.host, this.port, dateTimeFormattedUtils);
|
|
408
|
+
serverWeb.on(import_opticore_catch_exception_error3.CEventNameError.request, (req, res) => {
|
|
409
|
+
(0, import_opticore_requests_called_events.requestCallsEvent)(req, res, this.host, this.port, dateTimeFormattedUtils);
|
|
902
410
|
});
|
|
903
411
|
}
|
|
904
412
|
kernelModules(registerRouter, dbConnection) {
|
|
@@ -918,55 +426,19 @@ var WebServerCore = class {
|
|
|
918
426
|
this.serverUtility.infoServer(
|
|
919
427
|
this.serverUtility.getVersions().nodeVersion,
|
|
920
428
|
this.serverUtility.getProjectInfo().startingTime,
|
|
921
|
-
getEnvVariable.appHost,
|
|
922
|
-
Number(getEnvVariable.appPort),
|
|
429
|
+
import_opticore_env_access.getEnvVariable.appHost,
|
|
430
|
+
Number(import_opticore_env_access.getEnvVariable.appPort),
|
|
923
431
|
this.serverUtility.getUsageMemory().rss,
|
|
924
432
|
this.serverUtility.getUsageMemory().heapUsed,
|
|
925
433
|
this.serverUtility.getUsageMemory().user,
|
|
926
434
|
this.serverUtility.getUsageMemory().system
|
|
927
435
|
);
|
|
928
436
|
}
|
|
929
|
-
traceError(props, name,
|
|
930
|
-
return new StackTraceError(props, name,
|
|
437
|
+
traceError(props, name, status2) {
|
|
438
|
+
return new import_opticore_catch_exception_error3.StackTraceError(props, name, status2, true);
|
|
931
439
|
}
|
|
932
440
|
};
|
|
933
|
-
|
|
934
|
-
// src/domains/constants/errorName.constant.ts
|
|
935
|
-
var CErrorName = {
|
|
936
|
-
evalError: "EvalError",
|
|
937
|
-
syntaxError: "SyntaxError",
|
|
938
|
-
rangeError: "RangeError",
|
|
939
|
-
referenceError: "ReferenceError",
|
|
940
|
-
typeError: "TypeError",
|
|
941
|
-
uriError: "URIError",
|
|
942
|
-
systemError: "SystemError",
|
|
943
|
-
assertionError: "AssertionError",
|
|
944
|
-
openSSLError: "OpenSSLError",
|
|
945
|
-
generalError: "GeneralError"
|
|
946
|
-
};
|
|
947
|
-
|
|
948
|
-
// src/domains/constants/event.constant.ts
|
|
949
|
-
var CEvent = {
|
|
950
|
-
beforeExit: "beforeExit",
|
|
951
|
-
disconnect: "disconnect",
|
|
952
|
-
exit: "exit",
|
|
953
|
-
rejectionHandled: "rejectionHandled",
|
|
954
|
-
uncaughtException: "uncaughtException",
|
|
955
|
-
uncaughtExceptionMonitor: "uncaughtExceptionMonitor",
|
|
956
|
-
unhandledRejection: "unhandledRejection",
|
|
957
|
-
warning: "warning",
|
|
958
|
-
message: "message",
|
|
959
|
-
multipleResolves: "multipleResolves",
|
|
960
|
-
worker: "worker",
|
|
961
|
-
sigint: "SIGINT",
|
|
962
|
-
sigterm: "SIGTERM"
|
|
963
|
-
};
|
|
964
441
|
// Annotate the CommonJS export names for ESM import in node:
|
|
965
442
|
0 && (module.exports = {
|
|
966
|
-
|
|
967
|
-
WebServer,
|
|
968
|
-
errorName,
|
|
969
|
-
event,
|
|
970
|
-
eventName,
|
|
971
|
-
getEnvVariable
|
|
443
|
+
WebServer
|
|
972
444
|
});
|