opticore-webapp 1.0.8 → 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.
Files changed (39) hide show
  1. package/dist/index.cjs +139 -599
  2. package/dist/index.d.cts +5 -63
  3. package/dist/index.d.ts +5 -63
  4. package/dist/index.js +146 -594
  5. package/package.json +7 -6
  6. package/src/application/service/core.service.ts +11 -8
  7. package/src/core/handlers/eventProcess.handler.ts +8 -5
  8. package/src/core/utils/logMessage.utils.ts +2 -2
  9. package/src/core/utils/modulesLoaded.utils.ts +5 -4
  10. package/src/core/webServer.core.ts +25 -21
  11. package/src/domains/interfaces/routeDefinition.interface.ts +2 -2
  12. package/src/domains/types/kernelModule.type.ts +1 -1
  13. package/src/index.ts +1 -8
  14. package/tsup.config.ts +1 -1
  15. package/src/core/events/errors/serverListen.event.error.ts +0 -335
  16. package/src/core/events/requestCalls.event.ts +0 -83
  17. package/src/core/handlers/errors/base/stackTraceError.ts +0 -23
  18. package/src/core/handlers/errors/stackTraceAssertionError.ts +0 -13
  19. package/src/core/handlers/errors/stackTraceEvalError.ts +0 -12
  20. package/src/core/handlers/errors/stackTraceGeneralError.ts +0 -13
  21. package/src/core/handlers/errors/stackTraceOpenSSLError.ts +0 -12
  22. package/src/core/handlers/errors/stackTraceRangeError.ts +0 -12
  23. package/src/core/handlers/errors/stackTraceReferenceError.ts +0 -13
  24. package/src/core/handlers/errors/stackTraceSyntaxError.ts +0 -12
  25. package/src/core/handlers/errors/stackTraceSystemError.ts +0 -14
  26. package/src/core/handlers/errors/stackTraceTypeError.ts +0 -13
  27. package/src/core/handlers/errors/stackTraceURIError.ts +0 -13
  28. package/src/domains/constants/errorName.constant.ts +0 -12
  29. package/src/domains/constants/event.constant.ts +0 -15
  30. package/src/domains/constants/eventNameError.constant.ts +0 -8
  31. package/src/domains/constants/httpStatusCodes.constant.ts +0 -375
  32. package/src/domains/constants/logLevel.constant.ts +0 -6
  33. package/src/domains/env/access.env.ts +0 -23
  34. package/src/domains/interfaces/envVariables.interface.ts +0 -16
  35. package/src/domains/interfaces/kernelModule.interface.ts +0 -6
  36. package/src/infrastructure/events/.gitkeep +0 -0
  37. package/src/infrastructure/handlers/.gitkeep +0 -0
  38. package/src/presentation/middleware/.gitkeep +0 -0
  39. /package/src/core/{errors → events}/.gitkeep +0 -0
package/dist/index.cjs CHANGED
@@ -30,66 +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
- WebServer: () => WebServerCore,
34
- errorName: () => CErrorName,
35
- event: () => CEvent,
36
- eventName: () => CEventNameError,
37
- getEnvVariable: () => getEnvVariable
33
+ WebServer: () => WebServerCore
38
34
  });
39
35
  module.exports = __toCommonJS(index_exports);
40
36
 
41
37
  // src/core/webServer.core.ts
42
- var import_express2 = __toESM(require("express"), 1);
43
38
  var import_cors = __toESM(require("cors"), 1);
44
-
45
- // src/domains/env/access.env.ts
46
- var import_dotenv = __toESM(require("dotenv"), 1);
47
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B;
48
- var getEnvVariable = {
49
- appHost: String((_b = (_a = import_dotenv.default.config()) == null ? void 0 : _a.parsed) == null ? void 0 : _b.APP_HOST),
50
- appPort: String((_d = (_c = import_dotenv.default.config()) == null ? void 0 : _c.parsed) == null ? void 0 : _d.APP_PORT),
51
- prodEnv: String((_f = (_e = import_dotenv.default.config()) == null ? void 0 : _e.parsed) == null ? void 0 : _f.ENV_PROD),
52
- devEnv: String((_h = (_g = import_dotenv.default.config()) == null ? void 0 : _g.parsed) == null ? void 0 : _h.ENV_DEV),
53
- dataBaseHost: String((_j = (_i = import_dotenv.default.config()) == null ? void 0 : _i.parsed) == null ? void 0 : _j.DATA_BASE_HOST),
54
- dataBasePort: String((_l = (_k = import_dotenv.default.config()) == null ? void 0 : _k.parsed) == null ? void 0 : _l.DATA_BASE_PORT),
55
- dataBaseUser: String((_n = (_m = import_dotenv.default.config()) == null ? void 0 : _m.parsed) == null ? void 0 : _n.DATA_BASE_USER),
56
- dataBasePassword: String((_p = (_o = import_dotenv.default.config()) == null ? void 0 : _o.parsed) == null ? void 0 : _p.DATA_BASE_PASSWORD),
57
- dataBaseName: String((_r = (_q = import_dotenv.default.config()) == null ? void 0 : _q.parsed) == null ? void 0 : _r.DATA_BASE_NAME),
58
- apiVersion: String((_t = (_s = import_dotenv.default.config()) == null ? void 0 : _s.parsed) == null ? void 0 : _t.API_VERSION),
59
- usernameField: String((_v = (_u = import_dotenv.default.config()) == null ? void 0 : _u.parsed) == null ? void 0 : _v.USERNAME_FIELD),
60
- passwordField: String((_x = (_w = import_dotenv.default.config()) == null ? void 0 : _w.parsed) == null ? void 0 : _x.PASSWORD_FIELD),
61
- argumentsDatabaseConnection: String((_z = (_y = import_dotenv.default.config()) == null ? void 0 : _y.parsed) == null ? void 0 : _z.ARGUMENTS_DATABASE_CONNECTION),
62
- logEnv: String((_B = (_A = import_dotenv.default.config()) == null ? void 0 : _A.parsed) == null ? void 0 : _B.LOG_ENVIRONMENT)
63
- };
64
-
65
- // src/core/handlers/errors/base/stackTraceError.ts
66
- var StackTraceError = class extends Error {
67
- // Centralized error objet that derives from Node's Error.
68
- constructor(props, name, httpCode, isOperational) {
69
- super(props);
70
- Object.setPrototypeOf(this, new.target.prototype);
71
- this.name = name;
72
- this.httpCode = httpCode;
73
- this.isOperational = isOperational;
74
- Error.captureStackTrace(this);
75
- }
76
- };
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");
77
44
 
78
45
  // src/core/handlers/eventProcess.handler.ts
79
- var import_express = __toESM(require("express"), 1);
80
46
  var import_node_process = __toESM(require("process"), 1);
81
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
+ }
82
98
 
83
- // src/core/events/errors/serverListen.event.error.ts
84
- var import_process = __toESM(require("process"), 1);
85
- 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);
86
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);
87
110
 
88
111
  // src/core/utils/dateTimeFormatted.utils.ts
89
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()}`;
90
113
 
91
- // src/application/exceptions/messages.exception.ts
114
+ // src/core/utils/logMessage.utils.ts
92
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);
93
144
  var messageException = {
94
145
  dbConnection: "DataBase connection",
95
146
  dbConnectionClosed: "MySQL connection is closed",
@@ -153,485 +204,9 @@ var messageException = {
153
204
  errorHost: "The host can't be empty or blank. Please define a string host in .env",
154
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`,
155
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`,
156
- errorDBHost: (host) => `A database host ${host} does not allow connection. Please either set the host like this: ${import_ansi_colors.default.bgRed(`${import_ansi_colors.default.white(`localhost`)}`)} in your .env file`
157
- };
158
-
159
- // src/domains/constants/eventNameError.constant.ts
160
- var CEventNameError = {
161
- error: "error",
162
- listening: "listening",
163
- close: "close",
164
- connection: "connection",
165
- drop: "drop",
166
- request: "request"
167
- };
168
-
169
- // src/core/events/errors/serverListen.event.error.ts
170
- var import_opticore_logger = require("opticore-logger");
171
- var ServerListenEventError = class {
172
- /**
173
- *
174
- */
175
- static hostPortUndefined() {
176
- this.stackTrace = this.traceError(messageException.errorHostUrl, messageException.listening, 400 /* BAD_REQUEST */);
177
- this.logger.error(this.stackTrace.message, messageException.webServer, messageException.badHost, this.stackTrace.stack, 400 /* BAD_REQUEST */);
178
- import_process.default.exit();
179
- }
180
- /**
181
- *
182
- */
183
- static hostUndefined() {
184
- this.stackTrace = this.traceError(messageException.badHost, messageException.listening, 400 /* BAD_REQUEST */);
185
- this.logger.error(this.stackTrace.message, messageException.webServer, messageException.badHost, this.stackTrace.stack, 400 /* BAD_REQUEST */);
186
- import_process.default.exit();
187
- }
188
- /**
189
- *
190
- */
191
- static portUndefined() {
192
- this.stackTrace = this.traceError(messageException.badPort, messageException.listening, 400 /* BAD_REQUEST */);
193
- this.logger.error(this.stackTrace.message, messageException.webServer, messageException.badHost, this.stackTrace.stack, 400 /* BAD_REQUEST */);
194
- import_process.default.exit();
195
- }
196
- /**
197
- *
198
- * @param err
199
- */
200
- static onEventError(err) {
201
- this.logger.error(err.message, "Server start error", "Error", err.stack, 503 /* SERVICE_UNAVAILABLE */);
202
- }
203
- /**
204
- *
205
- * @param error
206
- */
207
- static listenerError(error) {
208
- this.stackTrace = this.traceError(error.message, error.name, 400 /* BAD_REQUEST */);
209
- this.logger.error(this.stackTrace.message, "Event error", "Error", error.stack, 400 /* BAD_REQUEST */);
210
- }
211
- /**
212
- *
213
- * @param code
214
- */
215
- static processBeforeExit(code) {
216
- this.stackTrace = this.traceError(`Process will exit with code: ${code}`, "BeforeExit", 503 /* SERVICE_UNAVAILABLE */);
217
- this.logger.error(this.stackTrace.message, "BeforeExit", "process before exit", this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
218
- import_process.default.exit(code);
219
- }
220
- /**
221
- *
222
- */
223
- static processDisconnected() {
224
- this.stackTrace = this.traceError("Child process disconnected", "process disconnected", 503 /* SERVICE_UNAVAILABLE */);
225
- this.logger.error(this.stackTrace.message, "Disconnected", "process disconnected", this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
226
- import_process.default.exit();
227
- }
228
- /**
229
- *
230
- * @param code
231
- */
232
- static exited(code) {
233
- switch (code) {
234
- case 0:
235
- this.logger.success("completed", "The process finished as expected and everything is ok");
236
- console.log("");
237
- const paddingLength = 35;
238
- const msg0 = " ".padEnd(paddingLength, " ");
239
- console.log(import_chalk.default.bgGreen.white(msg0.padEnd(paddingLength, " ")));
240
- console.log(`${import_ansi_colors2.default.bgGreen(` [OK] The server shutting down `)}`);
241
- console.log(import_chalk.default.bgGreen.white(msg0.padEnd(paddingLength, " ")));
242
- break;
243
- case 1:
244
- this.stackTrace = this.traceError("Something went wrong", "General Errors", 503 /* SERVICE_UNAVAILABLE */);
245
- this.logger.error(this.stackTrace.message, "Exited", "General Errors", this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
246
- break;
247
- case 2:
248
- this.stackTrace = this.traceError("Incorrect using of shell commands", "Misuse of shell builtins", 503 /* SERVICE_UNAVAILABLE */);
249
- this.logger.error(this.stackTrace.message, "Exited", "Incorrect using of shell commands", this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
250
- break;
251
- case 126:
252
- this.stackTrace = this.traceError(
253
- "Incorrect using of shell commands",
254
- "The command is found but is not executable (e.g., trying to execute a directory)",
255
- 503 /* SERVICE_UNAVAILABLE */
256
- );
257
- this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
258
- break;
259
- case 127:
260
- this.stackTrace = this.traceError(
261
- "Command not found",
262
- "The command was not found in the system's PATH or is misspelled",
263
- 503 /* SERVICE_UNAVAILABLE */
264
- );
265
- this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
266
- break;
267
- case 128:
268
- this.stackTrace = this.traceError(
269
- "The command was not found in the system's PATH or is misspelled",
270
- "Invalid argument",
271
- 503 /* SERVICE_UNAVAILABLE */
272
- );
273
- this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
274
- break;
275
- case 130:
276
- this.stackTrace = this.traceError(
277
- "Indicates that the script was manually terminated by the user using the Control-C (SIGINT) signal",
278
- "Script terminated",
279
- 503 /* SERVICE_UNAVAILABLE */
280
- );
281
- this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
282
- break;
283
- case 137:
284
- this.stackTrace = this.traceError(
285
- "Indicates that the process was terminated by a SIGKILL signal, possibly due to an out-of-memory situation",
286
- "SIGKILL",
287
- 503 /* SERVICE_UNAVAILABLE */
288
- );
289
- this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
290
- break;
291
- case 139:
292
- this.stackTrace = this.traceError(
293
- "Indicates that the process accessed an illegal memory address (segfault)",
294
- "Segmentation fault",
295
- 503 /* SERVICE_UNAVAILABLE */
296
- );
297
- this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
298
- break;
299
- case 143:
300
- this.stackTrace = this.traceError(
301
- "Indicates that the process received a SIGTERM signal to terminate",
302
- "process received a SIGTERM",
303
- 503 /* SERVICE_UNAVAILABLE */
304
- );
305
- this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
306
- break;
307
- case 255:
308
- this.stackTrace = this.traceError(
309
- "An exit code that is outside the allowable range (0-255 for Unix-like systems)",
310
- "out of range",
311
- 503 /* SERVICE_UNAVAILABLE */
312
- );
313
- this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
314
- break;
315
- default:
316
- this.stackTrace = this.traceError(
317
- "Error is occurring",
318
- "errors",
319
- 503 /* SERVICE_UNAVAILABLE */
320
- );
321
- this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
322
- break;
323
- }
324
- }
325
- /**
326
- *
327
- * @param promise
328
- */
329
- static promiseRejectionHandled(promise) {
330
- this.stackTrace = this.traceError(
331
- `Promise rejection is handled at : ${promise}`,
332
- "rejection promise",
333
- 503 /* SERVICE_UNAVAILABLE */
334
- );
335
- this.logger.error(this.stackTrace.message, "PromiseRejectionHandled", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
336
- }
337
- /**
338
- *
339
- * @param error
340
- */
341
- static uncaughtException(error) {
342
- 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.") {
343
- console.log("");
344
- } else {
345
- this.stackTrace = this.traceError(error.message, "uncaught exception handled", 503 /* SERVICE_UNAVAILABLE */);
346
- this.logger.error(this.stackTrace.message, "UncaughtException", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
347
- }
348
- }
349
- /**
350
- *
351
- * @param error
352
- */
353
- static uncaughtExceptionMonitor(error) {
354
- 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.") {
355
- console.log("");
356
- }
357
- }
358
- /**
359
- *
360
- * @param reason
361
- * @param promise
362
- */
363
- static unhandledRejection(reason, promise) {
364
- this.stackTrace = this.traceError(
365
- `Unhandled Rejection at: Promise ${promise} -- reason ${reason}`,
366
- "Unhandled rejection",
367
- 503 /* SERVICE_UNAVAILABLE */
368
- );
369
- this.logger.error(this.stackTrace.message, "UnhandledRejection", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
370
- }
371
- /**
372
- *
373
- * @param warning
374
- */
375
- static warning(warning) {
376
- this.stackTrace = this.traceError(warning.message, "warning", 503 /* SERVICE_UNAVAILABLE */);
377
- this.logger.error(this.stackTrace.message, "Warning", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
378
- }
379
- /**
380
- *
381
- * @param message
382
- */
383
- static message(message) {
384
- this.stackTrace = this.traceError(
385
- `process got message ${message}`,
386
- "message exception",
387
- 503 /* SERVICE_UNAVAILABLE */
388
- );
389
- this.logger.error(this.stackTrace.message, "Message", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
390
- }
391
- /**
392
- *
393
- * @param type
394
- * @param promise
395
- * @param reason
396
- */
397
- static multipleResolves(type, promise, reason) {
398
- this.stackTrace = this.traceError(
399
- `${promise} -- ${reason}`,
400
- `Multiple resolves detected : ${type}`,
401
- 503 /* SERVICE_UNAVAILABLE */
402
- );
403
- this.logger.error(this.stackTrace.message, "multipleResolves", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
404
- }
405
- /**
406
- *
407
- */
408
- static processInterrupted() {
409
- this.logger.success("[ OK ] Success", "The Web server has been stopped !");
410
- import_process.default.exit(0);
411
- }
412
- /**
413
- *
414
- * @param signal
415
- */
416
- static sigtermSignalReceived(signal) {
417
- this.stackTrace = this.traceError(
418
- `Process ${import_process.default.pid} received a SIGTERM signal : ${signal.toString()}`,
419
- "SIGTERM",
420
- 406 /* NOT_ACCEPTABLE */
421
- );
422
- this.logger.error(this.stackTrace.message, "SIGTERM", this.stackTrace.name, this.stackTrace.stack, 406 /* NOT_ACCEPTABLE */);
423
- import_process.default.exit(0);
424
- }
425
- /**
426
- *
427
- */
428
- static serverClosing() {
429
- console.log(`${import_ansi_colors2.default.bgCyanBright(` ${import_ansi_colors2.default.bold(`${import_ansi_colors2.default.white(` INFO `)}`)}`)} All processes are stopped`);
430
- console.log(" Server is closed");
431
- import_process.default.exit();
432
- }
433
- /**
434
- *
435
- */
436
- static dropNewConnection() {
437
- 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`);
438
- }
439
- /**
440
- *
441
- * @param errorEmitter
442
- * @param err
443
- * @param req
444
- * @param res
445
- * @param next
446
- */
447
- static expressErrorHandlingMiddleware(errorEmitter, err, req, res, next) {
448
- if (err) {
449
- errorEmitter.emit(CEventNameError.error, err);
450
- if (typeof res.status === "function") {
451
- res.status(500).send("Internal Server Error");
452
- } else {
453
- console.error("res.status is not a function");
454
- }
455
- this.stackTrace = this.traceError(err.message, "Express error", 406 /* NOT_ACCEPTABLE */);
456
- this.logger.error(this.stackTrace.message, "Express error-handling middleware", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
457
- } else {
458
- next();
459
- }
460
- }
461
- static traceError(props, name, status) {
462
- return new StackTraceError(props, name, status, true);
463
- }
464
- };
465
- ServerListenEventError.logger = new import_opticore_logger.LoggerCore();
466
-
467
- // src/core/handlers/eventProcess.handler.ts
468
- function eventProcessHandler() {
469
- const errorEmitter = new import_node_events.default();
470
- const app = (0, import_express.default)();
471
- errorEmitter.on(CEventNameError.error, (error) => {
472
- ServerListenEventError.listenerError(error);
473
- });
474
- import_node_process.default.on(CEvent.beforeExit, (code) => {
475
- setTimeout(() => {
476
- ServerListenEventError.processBeforeExit(code);
477
- }, 100);
478
- });
479
- import_node_process.default.on(CEvent.disconnect, () => {
480
- ServerListenEventError.processDisconnected();
481
- });
482
- import_node_process.default.on(CEvent.exit, (code) => {
483
- ServerListenEventError.exited(code);
484
- });
485
- import_node_process.default.on(CEvent.rejectionHandled, (promise) => {
486
- ServerListenEventError.promiseRejectionHandled(promise);
487
- });
488
- import_node_process.default.on(CEvent.uncaughtException, (error) => {
489
- ServerListenEventError.uncaughtException(error);
490
- });
491
- import_node_process.default.on(CEvent.uncaughtExceptionMonitor, (error) => {
492
- ServerListenEventError.uncaughtExceptionMonitor(error);
493
- });
494
- import_node_process.default.on(CEvent.unhandledRejection, (reason, promise) => {
495
- ServerListenEventError.unhandledRejection(reason, promise);
496
- });
497
- import_node_process.default.on(CEvent.warning, (warning) => {
498
- ServerListenEventError.warning(warning);
499
- });
500
- import_node_process.default.on(CEvent.message, (message) => {
501
- ServerListenEventError.message(message);
502
- });
503
- import_node_process.default.on(CEvent.multipleResolves, (type, promise, reason) => {
504
- ServerListenEventError.multipleResolves(type, promise, reason);
505
- });
506
- import_node_process.default.on(CEvent.sigint, () => {
507
- ServerListenEventError.processInterrupted();
508
- });
509
- import_node_process.default.on(CEvent.sigterm, (signal) => {
510
- ServerListenEventError.sigtermSignalReceived(signal);
511
- });
512
- app.use((err, req, res, next) => {
513
- ServerListenEventError.expressErrorHandlingMiddleware(errorEmitter, err, req, res, next);
514
- });
515
- }
516
-
517
- // src/core/events/requestCalls.event.ts
518
- var import_ansi_colors3 = __toESM(require("ansi-colors"), 1);
519
- var import_opticore_logger2 = require("opticore-logger");
520
- function requestCallsEvent(req, res, host, port, loadingTime) {
521
- const logger = new import_opticore_logger2.LoggerCore();
522
- const currentDatePath = `Request called`;
523
- if (req.originalUrl === "undefined") {
524
- 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 `)}`)}`);
525
- logger.error("The route do not exist.");
526
- } else {
527
- switch (res.statusCode) {
528
- case 200:
529
- switch (req.method) {
530
- case "POST":
531
- 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 `)}`)}`);
532
- break;
533
- case "GET":
534
- case "PUT":
535
- 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 `)}`)}`);
536
- break;
537
- case "DELETE":
538
- 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 `)}`)}`);
539
- break;
540
- }
541
- break;
542
- case 404:
543
- switch (req.method) {
544
- case "POST":
545
- 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 `)}`)}`);
546
- break;
547
- case "GET":
548
- 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 `)}`)}`);
549
- break;
550
- case "PUT":
551
- 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 `)}`)}`);
552
- break;
553
- case "DELETE":
554
- 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 `)}`)}`);
555
- break;
556
- }
557
- break;
558
- case 401:
559
- switch (req.method) {
560
- case "POST":
561
- 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 `)}`)}`);
562
- break;
563
- case "GET":
564
- 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 `)}`)}`);
565
- break;
566
- case "PUT":
567
- 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 `)}`)}`);
568
- break;
569
- case "DELETE":
570
- 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 `)}`)}`);
571
- break;
572
- }
573
- break;
574
- case 500:
575
- switch (req.method) {
576
- case "POST":
577
- 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 `)}`)}`);
578
- break;
579
- case "GET":
580
- 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 `)}`)}`);
581
- break;
582
- case "PUT":
583
- 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 `)}`)}`);
584
- break;
585
- case "DELETE":
586
- 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 `)}`)}`);
587
- break;
588
- }
589
- break;
590
- default:
591
- 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} `)}`);
592
- break;
593
- }
594
- }
595
- }
596
-
597
- // src/application/service/core.service.ts
598
- var import_node_process2 = __toESM(require("process"), 1);
599
- var import_chalk2 = __toESM(require("chalk"), 1);
600
- var path = __toESM(require("path"), 1);
601
- var fs = __toESM(require("fs"), 1);
602
- var import_ansi_colors6 = __toESM(require("ansi-colors"), 1);
603
-
604
- // src/core/utils/modulesLoaded.utils.ts
605
- var import_ansi_colors5 = __toESM(require("ansi-colors"), 1);
606
-
607
- // src/core/utils/logMessage.utils.ts
608
- var import_ansi_colors4 = __toESM(require("ansi-colors"), 1);
609
- var LogMessageUtils = class {
610
- static success(title, action, contentAction) {
611
- 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 `)}`)}`);
612
- }
613
- static warning(title, action, contentAction) {
614
- 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}`);
615
- }
616
- static info(title, action, contentAction) {
617
- 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}`);
618
- }
619
- static error(title, errorType, stackTrace, messageContent, httpCodeValue) {
620
- 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} `)}`)} `);
621
- }
622
- static requestError(title, errorName, errorMessage, errorCode) {
623
- 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} `)}`)}`);
624
- }
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`
625
208
  };
626
209
 
627
- // src/core/utils/modulesLoaded.utils.ts
628
- function modulesLoadedUtils(allAppRoutes, dbConChecker) {
629
- LogMessageUtils.success("Kernel", "load kernel", "Modules app have been successfully loaded");
630
- 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`)}`);
631
- 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 `);
632
- 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`)}`) : "";
633
- }
634
-
635
210
  // src/application/service/core.service.ts
636
211
  var CoreService = class {
637
212
  /**
@@ -725,33 +300,33 @@ var CoreService = class {
725
300
  this.getEnvFileLoading(".env");
726
301
  const isDevelopment = import_node_process2.default.env.NODE_ENV === "development";
727
302
  if (isDevelopment) {
728
- return `The server is running in ${import_ansi_colors6.default.bgBlue(`${import_ansi_colors6.default.bold(`${development}`)}`)} mode`;
303
+ return `The server is running in ${import_ansi_colors4.default.bgBlue(`${import_ansi_colors4.default.bold(`${development}`)}`)} mode`;
729
304
  } else {
730
- return `The server is running in ${import_ansi_colors6.default.bgBlue(`${import_ansi_colors6.default.bold(`${production}`)}`)} mode`;
305
+ return `The server is running in ${import_ansi_colors4.default.bgBlue(`${import_ansi_colors4.default.bold(`${production}`)}`)} mode`;
731
306
  }
732
307
  }
733
308
  infoServer(nodeVersion, startingTime, host, port, rss, heapUsed, user, system) {
734
309
  const paddingLength = 52;
735
310
  const msg0 = " ".padEnd(paddingLength, " ");
736
311
  const msg1 = " [OK] Web server listening";
737
- const msg2Value = `${import_ansi_colors6.default.bgBlue(`${import_ansi_colors6.default.bold(`${nodeVersion}`)}`)}`;
312
+ const msg2Value = `${import_ansi_colors4.default.bgBlue(`${import_ansi_colors4.default.bold(`${nodeVersion}`)}`)}`;
738
313
  const msg2 = ` The Web server is using Node.js version`;
739
- const msg3Value = `${import_ansi_colors6.default.bgBlue(`${import_ansi_colors6.default.bold(`${startingTime}`)}`)}`;
314
+ const msg3Value = `${import_ansi_colors4.default.bgBlue(`${import_ansi_colors4.default.bold(`${startingTime}`)}`)}`;
740
315
  const msg3 = ` Startup time:`;
741
316
  const msg4 = ` ${this.getServerRunningMode("development", "production")}`;
742
- const msg5 = ` ${import_ansi_colors6.default.underline(`http://${host}:${port}`)}`;
743
- console.log(import_chalk2.default.bgGreen.white(msg0.padEnd(paddingLength, " ")));
744
- console.log(import_chalk2.default.bgGreen.white(msg1.padEnd(paddingLength, " ")));
745
- console.log(import_chalk2.default.bgGreen.white(msg2, msg2Value.padEnd(30.5, " ")));
746
- console.log(import_chalk2.default.bgGreen.white(msg3, msg3Value.padEnd(56, " ")));
747
- console.log(import_chalk2.default.bgGreen.white(msg4.padEnd(71, " ")));
748
- console.log(import_chalk2.default.bgGreen.white(msg5.padEnd(61, " ")));
749
- console.log(import_chalk2.default.bgGreen.white(msg0.padEnd(paddingLength, " ")));
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, " ")));
750
325
  console.log(``);
751
- console.log(`${`Resident Set Size - total memory allocated for the process execution :`} ${import_ansi_colors6.default.cyan(`${import_ansi_colors6.default.bold(`${rss}`)}`)}`);
752
- console.log(`${`Actual memory used during the execution :`} ${import_ansi_colors6.default.cyan(`${import_ansi_colors6.default.bold(`${heapUsed}`)}`)}`);
753
- console.log(`${`Memory usage by user :`} ${import_ansi_colors6.default.cyan(`${import_ansi_colors6.default.bold(`${user}`)}`)}`);
754
- console.log(`${`Memory usage by system :`} ${import_ansi_colors6.default.cyan(`${import_ansi_colors6.default.bold(`${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}`)}`)}`);
755
330
  console.log(``);
756
331
  }
757
332
  coreListenerEventLoaderModuleService(kernelModule) {
@@ -770,10 +345,10 @@ var CoreService = class {
770
345
  dbCon();
771
346
  })();
772
347
  } else {
773
- const stackTrace = new StackTraceError(
348
+ const stackTrace = new import_opticore_catch_exception_error2.StackTraceError(
774
349
  messageException.loadedModulesError,
775
350
  messageException.loadedModules,
776
- 406 /* NOT_ACCEPTABLE */,
351
+ import_opticore_http_response.HttpStatusCode.NOT_ACCEPTABLE,
777
352
  true
778
353
  );
779
354
  throw new Error(stackTrace.message);
@@ -785,14 +360,14 @@ var CoreService = class {
785
360
  var WebServerCore = class {
786
361
  constructor(app, corsOriginOptions) {
787
362
  this.serverUtility = new CoreService();
788
- this.expressApp = (0, import_express2.default)();
789
- this.port = Number(getEnvVariable.appPort);
790
- 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;
791
366
  this.routerExpressApp = app;
792
- this.expressApp.use(import_express2.default.json());
793
- this.expressApp.use(import_express2.default.raw());
794
- this.expressApp.use(import_express2.default.text());
795
- this.expressApp.use(import_express2.default.urlencoded({ extended: true }));
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 }));
796
371
  this.expressApp.use((0, import_cors.default)(corsOriginOptions));
797
372
  this.stackTraceErrorHandling();
798
373
  }
@@ -803,35 +378,35 @@ var WebServerCore = class {
803
378
  () => {
804
379
  try {
805
380
  if (this.host === "" && this.port === 0) {
806
- ServerListenEventError.hostPortUndefined();
381
+ import_opticore_catch_exception_error3.ServerListenEventError.hostPortUndefined();
807
382
  } else if (this.host === "") {
808
- ServerListenEventError.hostUndefined();
383
+ import_opticore_catch_exception_error3.ServerListenEventError.hostUndefined();
809
384
  } else if (this.port === 0) {
810
- ServerListenEventError.portUndefined();
385
+ import_opticore_catch_exception_error3.ServerListenEventError.portUndefined();
811
386
  } else {
812
387
  this.registerRoutes(routers);
813
388
  }
814
389
  } catch (err) {
815
- this.traceError(err.message, "Error", 406 /* NOT_ACCEPTABLE */);
390
+ this.traceError(err.message, "Error", import_opticore_http_response2.HttpStatusCode.NOT_ACCEPTABLE);
816
391
  }
817
392
  }
818
393
  );
819
394
  }
820
395
  onListeningOnServerEvent(serverWeb, kernelModule) {
821
- serverWeb.on(CEventNameError.error, (err) => {
822
- ServerListenEventError.onEventError(err);
823
- }).on(CEventNameError.close, () => {
824
- ServerListenEventError.serverClosing();
825
- }).on(CEventNameError.drop, () => {
826
- ServerListenEventError.dropNewConnection();
827
- }).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, () => {
828
403
  this.infoWebApp();
829
404
  this.serverUtility.coreListenerEventLoaderModuleService(kernelModule);
830
405
  });
831
406
  }
832
407
  onRequestOnServerEvent(serverWeb) {
833
- serverWeb.on(CEventNameError.request, (req, res) => {
834
- 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);
835
410
  });
836
411
  }
837
412
  kernelModules(registerRouter, dbConnection) {
@@ -851,54 +426,19 @@ var WebServerCore = class {
851
426
  this.serverUtility.infoServer(
852
427
  this.serverUtility.getVersions().nodeVersion,
853
428
  this.serverUtility.getProjectInfo().startingTime,
854
- getEnvVariable.appHost,
855
- Number(getEnvVariable.appPort),
429
+ import_opticore_env_access.getEnvVariable.appHost,
430
+ Number(import_opticore_env_access.getEnvVariable.appPort),
856
431
  this.serverUtility.getUsageMemory().rss,
857
432
  this.serverUtility.getUsageMemory().heapUsed,
858
433
  this.serverUtility.getUsageMemory().user,
859
434
  this.serverUtility.getUsageMemory().system
860
435
  );
861
436
  }
862
- traceError(props, name, status) {
863
- return new StackTraceError(props, name, status, true);
437
+ traceError(props, name, status2) {
438
+ return new import_opticore_catch_exception_error3.StackTraceError(props, name, status2, true);
864
439
  }
865
440
  };
866
-
867
- // src/domains/constants/errorName.constant.ts
868
- var CErrorName = {
869
- evalError: "EvalError",
870
- syntaxError: "SyntaxError",
871
- rangeError: "RangeError",
872
- referenceError: "ReferenceError",
873
- typeError: "TypeError",
874
- uriError: "URIError",
875
- systemError: "SystemError",
876
- assertionError: "AssertionError",
877
- openSSLError: "OpenSSLError",
878
- generalError: "GeneralError"
879
- };
880
-
881
- // src/domains/constants/event.constant.ts
882
- var CEvent = {
883
- beforeExit: "beforeExit",
884
- disconnect: "disconnect",
885
- exit: "exit",
886
- rejectionHandled: "rejectionHandled",
887
- uncaughtException: "uncaughtException",
888
- uncaughtExceptionMonitor: "uncaughtExceptionMonitor",
889
- unhandledRejection: "unhandledRejection",
890
- warning: "warning",
891
- message: "message",
892
- multipleResolves: "multipleResolves",
893
- worker: "worker",
894
- sigint: "SIGINT",
895
- sigterm: "SIGTERM"
896
- };
897
441
  // Annotate the CommonJS export names for ESM import in node:
898
442
  0 && (module.exports = {
899
- WebServer,
900
- errorName,
901
- event,
902
- eventName,
903
- getEnvVariable
443
+ WebServer
904
444
  });