opticore-webapp 1.0.0 → 1.0.2

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.js CHANGED
@@ -103,183 +103,19 @@ var StackTraceError = class extends Error {
103
103
 
104
104
  // src/core/handlers/eventProcess.handler.ts
105
105
  import express from "express";
106
- import process from "node:process";
106
+ import process2 from "node:process";
107
107
  import EventEmitter from "node:events";
108
- import { ServerListenEventError } from "@/errors/serverListen.event.error";
109
- function eventProcessHandler() {
110
- const errorEmitter = new EventEmitter();
111
- const app = express();
112
- errorEmitter.on(CEventNameError.error, (error) => {
113
- ServerListenEventError.listenerError(error);
114
- });
115
- process.on(CEvent.beforeExit, (code) => {
116
- setTimeout(() => {
117
- ServerListenEventError.processBeforeExit(code);
118
- }, 100);
119
- });
120
- process.on(CEvent.disconnect, () => {
121
- ServerListenEventError.processDisconnected();
122
- });
123
- process.on(CEvent.exit, (code) => {
124
- ServerListenEventError.exited(code);
125
- });
126
- process.on(CEvent.rejectionHandled, (promise) => {
127
- ServerListenEventError.promiseRejectionHandled(promise);
128
- });
129
- process.on(CEvent.uncaughtException, (error) => {
130
- ServerListenEventError.uncaughtException(error);
131
- });
132
- process.on(CEvent.uncaughtExceptionMonitor, (error) => {
133
- ServerListenEventError.uncaughtExceptionMonitor(error);
134
- });
135
- process.on(CEvent.unhandledRejection, (reason, promise) => {
136
- ServerListenEventError.unhandledRejection(reason, promise);
137
- });
138
- process.on(CEvent.warning, (warning) => {
139
- ServerListenEventError.warning(warning);
140
- });
141
- process.on(CEvent.message, (message) => {
142
- ServerListenEventError.message(message);
143
- });
144
- process.on(CEvent.multipleResolves, (type, promise, reason) => {
145
- ServerListenEventError.multipleResolves(type, promise, reason);
146
- });
147
- process.on(CEvent.sigint, () => {
148
- ServerListenEventError.processInterrupted();
149
- });
150
- process.on(CEvent.sigterm, (signal) => {
151
- ServerListenEventError.sigtermSignalReceived(signal);
152
- });
153
- app.use((err, req, res, next) => {
154
- ServerListenEventError.expressErrorHandlingMiddleware(errorEmitter, err, req, res, next);
155
- });
156
- }
157
-
158
- // src/core/events/requestCalls.event.ts
159
- import colors from "ansi-colors";
160
- import { LoggerCore } from "opticore-logger";
161
- function requestCallsEvent(req, res, host, port, loadingTime) {
162
- const logger = new LoggerCore();
163
- const currentDatePath = `Request called`;
164
- if (req.originalUrl === "undefined") {
165
- console.log(`[ ${colors.red(`${currentDatePath}`)} ] ${loadingTime} | ${colors.bgRed(`${colors.white(` Not found `)}`)} [ Host ] http://${host}:${port} - [ Route ] The route do not exist. - [ Status ] ${colors.red(`${colors.white(` 404 `)}`)}`);
166
- logger.error("The route do not exist.");
167
- } else {
168
- switch (res.statusCode) {
169
- case 200:
170
- switch (req.method) {
171
- case "POST":
172
- console.log(`[ ${colors.cyan(`${currentDatePath}`)} ] ${loadingTime} | ${colors.bgGreen(`${colors.white(` Success `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ Status ] ${colors.bgCyan(`${colors.white(` 200 `)}`)}`);
173
- logger.info(`[ ${colors.cyan(`${currentDatePath}`)} ] ${loadingTime} | ${colors.bgGreen(`${colors.white(` Success `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ Status ] ${colors.bgCyan(`${colors.white(` 200 `)}`)}`);
174
- break;
175
- case "GET":
176
- case "PUT":
177
- console.log(`[ ${colors.cyan(`${currentDatePath}`)} ] ${loadingTime} | ${colors.bgGreen(`${colors.white(` Success `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${colors.bgCyan(`${colors.white(` 200 `)}`)}`);
178
- logger.info(`[ ${colors.cyan(`${currentDatePath}`)} ] ${loadingTime} | ${colors.bgGreen(`${colors.white(` Success `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${colors.bgCyan(`${colors.white(` 200 `)}`)}`);
179
- break;
180
- case "DELETE":
181
- console.log(`[ ${colors.cyan(`${currentDatePath}`)} ] ${loadingTime} | ${colors.bgGreen(`${colors.white(` Success `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${colors.bgCyan(`${colors.white(` 200 `)}`)}`);
182
- logger.info(`[ ${colors.cyan(`${currentDatePath}`)} ] ${loadingTime} | ${colors.bgGreen(`${colors.white(` Success `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${colors.bgCyan(`${colors.white(` 200 `)}`)}`);
183
- break;
184
- }
185
- break;
186
- case 404:
187
- switch (req.method) {
188
- case "POST":
189
- console.log(`[ ${colors.red(`${currentDatePath}`)} ] ${loadingTime} | ${colors.bgRed(`${colors.white(` Not found `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ Status ] ${colors.red(`${colors.white(` 404 `)}`)}`);
190
- break;
191
- case "GET":
192
- console.log(`[ ${colors.red(`${currentDatePath}`)} ] ${loadingTime} | ${colors.bgRed(`${colors.white(` Not found `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${colors.red(`${colors.bold(` 404 `)}`)}`);
193
- break;
194
- case "PUT":
195
- console.log(`[ ${colors.red(`${currentDatePath}`)} ] ${loadingTime} | ${colors.bgRed(`${colors.white(` Not found `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${colors.red(`${colors.bold(` 404 `)}`)}`);
196
- break;
197
- case "DELETE":
198
- console.log(`[ ${colors.red(`${currentDatePath}`)} ] ${loadingTime} | ${colors.bgRed(`${colors.white(` Not found `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${colors.red(`${colors.bold(` 404 `)}`)}`);
199
- break;
200
- }
201
- break;
202
- case 401:
203
- switch (req.method) {
204
- case "POST":
205
- console.log(`[ ${colors.yellowBright(`${currentDatePath}`)} ] ${loadingTime} | ${colors.bgYellowBright(`${colors.white(` Unauthorized `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ Status ] ${colors.bgYellow(`${colors.bold(` 401 `)}`)}`);
206
- break;
207
- case "GET":
208
- console.log(`[ ${colors.yellowBright(`${currentDatePath}`)} ] ${loadingTime} | ${colors.bgYellowBright(`${colors.white(` Unauthorized `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ Status ] ${colors.bgYellow(`${colors.bold(` 401 `)}`)}`);
209
- break;
210
- case "PUT":
211
- console.log(`[ ${colors.yellowBright(`${currentDatePath}`)} ] ${loadingTime} | ${colors.bgYellowBright(`${colors.white(` Unauthorized `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ Status ] ${colors.bgYellow(`${colors.bold(` 401 `)}`)}`);
212
- break;
213
- case "DELETE":
214
- console.log(`[ ${colors.yellowBright(`${currentDatePath}`)} ] ${loadingTime} | ${colors.bgYellowBright(`${colors.white(` Unauthorized `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ Status ] ${colors.bgYellow(`${colors.bold(` 401 `)}`)}`);
215
- break;
216
- }
217
- break;
218
- case 500:
219
- switch (req.method) {
220
- case "POST":
221
- console.log(`[ ${colors.red(`${currentDatePath}`)} ] ${loadingTime} | ${colors.bgRed(`${colors.white(` Server error `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ Status ] ${colors.red(`${colors.bold(` 500 `)}`)}`);
222
- break;
223
- case "GET":
224
- console.log(`[ ${colors.red(`${currentDatePath}`)} ] ${loadingTime} | ${colors.bgRed(`${colors.white(` Server error `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${colors.red(`${colors.bold(` 500 `)}`)}`);
225
- break;
226
- case "PUT":
227
- console.log(`[ ${colors.red(`${currentDatePath}`)} ] ${loadingTime} | ${colors.bgRed(`${colors.white(` Server error `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${colors.red(`${colors.bold(` 500 `)}`)}`);
228
- break;
229
- case "DELETE":
230
- console.log(`[ ${colors.red(`${currentDatePath}`)} ] ${loadingTime} | ${colors.bgRed(`${colors.white(` Server error `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${colors.red(`${colors.bold(` 500 `)}`)}`);
231
- break;
232
- }
233
- break;
234
- default:
235
- console.log(`[ ${colors.blueBright(`${currentDatePath}`)} ] ${loadingTime} | ${colors.blueBright(` ${res.statusMessage} `)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ Status ] ${colors.blueBright(` ${res.req.socket._httpMessage.statusCode} `)}`);
236
- break;
237
- }
238
- }
239
- }
240
-
241
- // src/domains/constants/eventNameError.constant.ts
242
- var CEventNameError = {
243
- error: "error",
244
- listening: "listening",
245
- close: "close",
246
- connection: "connection",
247
- drop: "drop",
248
- request: "request"
249
- };
250
108
 
251
109
  // src/core/events/errors/serverListen.event.error.ts
252
- import process2 from "process";
253
- import colors4 from "ansi-colors";
254
- import chalk from "chalk";
255
-
256
- // src/core/utils/logMessage.utils.ts
110
+ import process from "process";
257
111
  import colors2 from "ansi-colors";
112
+ import chalk from "chalk";
258
113
 
259
114
  // src/core/utils/dateTimeFormatted.utils.ts
260
115
  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()}`;
261
116
 
262
- // src/core/utils/logMessage.utils.ts
263
- var LogMessageUtils = class {
264
- static success(title, action, contentAction) {
265
- console.log(`${colors2.green(`\u2714`)} ${colors2.bgGreen(` ${colors2.bold(`${colors2.white(`${title}`)}`)} `)} ${dateTimeFormattedUtils} | ${colors2.bgGreen(`${colors2.white(` Success `)}`)} [ ${action} ] ${contentAction} - [ Status ] ${colors2.bgGreen(`${colors2.white(` 200 `)}`)}`);
266
- }
267
- static warning(title, action, contentAction) {
268
- console.warn(`${colors2.yellow(`\u26A0\uFE0F`)} ${colors2.bgYellow(` ${colors2.bold(`${colors2.white(`${title}`)}`)} `)} ${dateTimeFormattedUtils} | ${colors2.bgYellow(`${colors2.white(` Warning `)}`)} ${contentAction}`);
269
- }
270
- static info(title, action, contentAction) {
271
- console.info(`${colors2.cyan(`\u24D8`)} ${colors2.bgCyan(` ${colors2.bold(`${colors2.white(`${title}`)}`)} `)} ${dateTimeFormattedUtils} | ${colors2.bgCyan(`${colors2.white(` Info `)}`)} ${contentAction}`);
272
- }
273
- static error(title, errorType, stackTrace, messageContent, httpCodeValue) {
274
- console.error(`${colors2.red(`\u2718`)} ${colors2.bgRed(` ${colors2.bold(`${colors2.white(`${title}`)}`)} `)} | ${dateTimeFormattedUtils} | [ ${colors2.red(`${colors2.bold(` ${errorType} `)}`)} ] | [ ${colors2.bold(`stack trace`)} ] ${colors2.red(`${stackTrace}`)} - ${colors2.red(`${messageContent}`)} - [ ${colors2.red(`${colors2.bold(` HttpCode `)}`)} ] ${colors2.red(`${colors2.bold(` ${httpCodeValue} `)}`)} `);
275
- }
276
- static requestError(title, errorName, errorMessage, errorCode) {
277
- console.error(`[ ${colors2.red(`${title}`)} ] ${dateTimeFormattedUtils} | ${colors2.bgRed(`${colors2.white(` ERROR `)}`)} ${colors2.red(`[ ${errorName} ]`)} ${colors2.red(`${errorMessage}`)} - [ Status ] ${colors2.bgRed(`${colors2.white(` ${errorCode} `)}`)}`);
278
- }
279
- };
280
-
281
117
  // src/application/exceptions/messages.exception.ts
282
- import colors3 from "ansi-colors";
118
+ import colors from "ansi-colors";
283
119
  var messageException = {
284
120
  dbConnection: "DataBase connection",
285
121
  dbConnectionClosed: "MySQL connection is closed",
@@ -343,388 +179,297 @@ var messageException = {
343
179
  errorHost: "The host can't be empty or blank. Please define a string host in .env",
344
180
  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`,
345
181
  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`,
346
- errorDBHost: (host) => `A database host ${host} does not allow connection. Please either set the host like this: ${colors3.bgRed(`${colors3.white(`localhost`)}`)} in your .env file`
182
+ errorDBHost: (host) => `A database host ${host} does not allow connection. Please either set the host like this: ${colors.bgRed(`${colors.white(`localhost`)}`)} in your .env file`
183
+ };
184
+
185
+ // src/domains/constants/eventNameError.constant.ts
186
+ var CEventNameError = {
187
+ error: "error",
188
+ listening: "listening",
189
+ close: "close",
190
+ connection: "connection",
191
+ drop: "drop",
192
+ request: "request"
347
193
  };
348
194
 
349
195
  // src/core/events/errors/serverListen.event.error.ts
350
- var ServerListenEventError2 = class {
196
+ import { LoggerCore } from "opticore-logger";
197
+ var ServerListenEventError = class {
198
+ /**
199
+ *
200
+ */
351
201
  static hostPortUndefined() {
352
- const stackTrace = this.traceError(messageException.errorHostUrl, messageException.listening, 400 /* BAD_REQUEST */);
353
- LogMessageUtils.error(
354
- messageException.webServer,
355
- messageException.badHost,
356
- stackTrace.stack,
357
- messageException.errorHostUrl,
358
- 400 /* BAD_REQUEST */
359
- );
360
- process2.exit();
202
+ this.stackTrace = this.traceError(messageException.errorHostUrl, messageException.listening, 400 /* BAD_REQUEST */);
203
+ this.logger.error(this.stackTrace.message, messageException.webServer, messageException.badHost, this.stackTrace.stack, 400 /* BAD_REQUEST */);
204
+ process.exit();
361
205
  }
206
+ /**
207
+ *
208
+ */
362
209
  static hostUndefined() {
363
- const stackTrace = this.traceError(messageException.badHost, messageException.listening, 400 /* BAD_REQUEST */);
364
- LogMessageUtils.error(
365
- messageException.webServer,
366
- messageException.badHost,
367
- stackTrace.stack,
368
- messageException.errorHost,
369
- 400 /* BAD_REQUEST */
370
- );
371
- process2.exit();
210
+ this.stackTrace = this.traceError(messageException.badHost, messageException.listening, 400 /* BAD_REQUEST */);
211
+ this.logger.error(this.stackTrace.message, messageException.webServer, messageException.badHost, this.stackTrace.stack, 400 /* BAD_REQUEST */);
212
+ process.exit();
372
213
  }
214
+ /**
215
+ *
216
+ */
373
217
  static portUndefined() {
374
- const stackTrace = this.traceError(messageException.badPort, messageException.listening, 400 /* BAD_REQUEST */);
375
- LogMessageUtils.error(
376
- messageException.webServer,
377
- messageException.badPort,
378
- stackTrace.stack,
379
- messageException.errorPort,
380
- 400 /* BAD_REQUEST */
381
- );
382
- process2.exit();
218
+ this.stackTrace = this.traceError(messageException.badPort, messageException.listening, 400 /* BAD_REQUEST */);
219
+ this.logger.error(this.stackTrace.message, messageException.webServer, messageException.badHost, this.stackTrace.stack, 400 /* BAD_REQUEST */);
220
+ process.exit();
383
221
  }
222
+ /**
223
+ *
224
+ * @param err
225
+ */
384
226
  static onEventError(err) {
385
- LogMessageUtils.error(
386
- "Server start error",
387
- "Error",
388
- err.stack,
389
- err.message,
390
- 503 /* SERVICE_UNAVAILABLE */
391
- );
227
+ this.logger.error(err.message, "Server start error", "Error", err.stack, 503 /* SERVICE_UNAVAILABLE */);
392
228
  }
229
+ /**
230
+ *
231
+ * @param error
232
+ */
393
233
  static listenerError(error) {
394
- const stackTrace = this.traceError(
395
- error.message,
396
- error.name,
397
- 400 /* BAD_REQUEST */
398
- );
399
- LogMessageUtils.error(
400
- "Event error",
401
- "Error",
402
- error.stack,
403
- stackTrace.message,
404
- 503 /* SERVICE_UNAVAILABLE */
405
- );
234
+ this.stackTrace = this.traceError(error.message, error.name, 400 /* BAD_REQUEST */);
235
+ this.logger.error(this.stackTrace.message, "Event error", "Error", error.stack, 400 /* BAD_REQUEST */);
406
236
  }
237
+ /**
238
+ *
239
+ * @param code
240
+ */
407
241
  static processBeforeExit(code) {
408
- const stackTrace = this.traceError(
409
- `Process will exit with code: ${code}`,
410
- "BeforeExit",
411
- 503 /* SERVICE_UNAVAILABLE */
412
- );
413
- LogMessageUtils.error(
414
- "BeforeExit",
415
- "process before exit",
416
- stackTrace.stack,
417
- `Process will exit with code: ${code}`,
418
- 503 /* SERVICE_UNAVAILABLE */
419
- );
420
- process2.exit(code);
242
+ this.stackTrace = this.traceError(`Process will exit with code: ${code}`, "BeforeExit", 503 /* SERVICE_UNAVAILABLE */);
243
+ this.logger.error(this.stackTrace.message, "BeforeExit", "process before exit", this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
244
+ process.exit(code);
421
245
  }
246
+ /**
247
+ *
248
+ */
422
249
  static processDisconnected() {
423
- const stackTrace = this.traceError(
424
- "Child process disconnected",
425
- "process disconnected",
426
- 503 /* SERVICE_UNAVAILABLE */
427
- );
428
- LogMessageUtils.error(
429
- "Disconnected",
430
- "process disconnected",
431
- stackTrace.stack,
432
- "Child process disconnected",
433
- 503 /* SERVICE_UNAVAILABLE */
434
- );
435
- process2.exit();
250
+ this.stackTrace = this.traceError("Child process disconnected", "process disconnected", 503 /* SERVICE_UNAVAILABLE */);
251
+ this.logger.error(this.stackTrace.message, "Disconnected", "process disconnected", this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
252
+ process.exit();
436
253
  }
254
+ /**
255
+ *
256
+ * @param code
257
+ */
437
258
  static exited(code) {
438
259
  switch (code) {
439
260
  case 0:
440
- LogMessageUtils.success(
441
- "Exited",
442
- "completed",
443
- "The process finished as expected and everything is ok"
444
- );
261
+ this.logger.success("completed", "The process finished as expected and everything is ok");
445
262
  console.log("");
446
263
  const paddingLength = 35;
447
264
  const msg0 = " ".padEnd(paddingLength, " ");
448
265
  console.log(chalk.bgGreen.white(msg0.padEnd(paddingLength, " ")));
449
- console.log(`${colors4.bgGreen(` [OK] The server shutting down `)}`);
266
+ console.log(`${colors2.bgGreen(` [OK] The server shutting down `)}`);
450
267
  console.log(chalk.bgGreen.white(msg0.padEnd(paddingLength, " ")));
451
268
  break;
452
269
  case 1:
453
- const gnleStackTrace = this.traceError(
454
- "Something went wrong",
455
- "General Errors",
456
- 503 /* SERVICE_UNAVAILABLE */
457
- );
458
- LogMessageUtils.error(
459
- "Exited",
460
- "General Errors",
461
- gnleStackTrace.stack,
462
- "Something went wrong",
463
- 503 /* SERVICE_UNAVAILABLE */
464
- );
270
+ this.stackTrace = this.traceError("Something went wrong", "General Errors", 503 /* SERVICE_UNAVAILABLE */);
271
+ this.logger.error(this.stackTrace.message, "Exited", "General Errors", this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
465
272
  break;
466
273
  case 2:
467
- const incrCmdStackTrace = this.traceError(
468
- "Incorrect using of shell commands",
469
- "Misuse of shell builtins",
470
- 503 /* SERVICE_UNAVAILABLE */
471
- );
472
- LogMessageUtils.error(
473
- "Exited",
474
- incrCmdStackTrace.name,
475
- incrCmdStackTrace.stack,
476
- "Incorrect using of shell commands",
477
- 503 /* SERVICE_UNAVAILABLE */
478
- );
274
+ this.stackTrace = this.traceError("Incorrect using of shell commands", "Misuse of shell builtins", 503 /* SERVICE_UNAVAILABLE */);
275
+ this.logger.error(this.stackTrace.message, "Exited", "Incorrect using of shell commands", this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
479
276
  break;
480
277
  case 126:
481
- const notExeCmdStackTrace = this.traceError(
278
+ this.stackTrace = this.traceError(
482
279
  "Incorrect using of shell commands",
483
- "Misuse of shell builtins",
484
- 503 /* SERVICE_UNAVAILABLE */
485
- );
486
- LogMessageUtils.error(
487
- "Exited",
488
- `command invoked`,
489
- notExeCmdStackTrace.stack,
490
280
  "The command is found but is not executable (e.g., trying to execute a directory)",
491
281
  503 /* SERVICE_UNAVAILABLE */
492
282
  );
283
+ this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
493
284
  break;
494
285
  case 127:
495
- const cmdNotFoundStackTrace = this.traceError(
496
- "The command was not found in the system's PATH or is misspelled",
497
- "Exited",
498
- 503 /* SERVICE_UNAVAILABLE */
499
- );
500
- LogMessageUtils.error(
501
- "Exited",
286
+ this.stackTrace = this.traceError(
502
287
  "Command not found",
503
- cmdNotFoundStackTrace.stack,
504
288
  "The command was not found in the system's PATH or is misspelled",
505
289
  503 /* SERVICE_UNAVAILABLE */
506
290
  );
291
+ this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
507
292
  break;
508
293
  case 128:
509
- const cmdSysNotFoundStackTrace = this.traceError(
294
+ this.stackTrace = this.traceError(
510
295
  "The command was not found in the system's PATH or is misspelled",
511
- "Exited",
512
- 503 /* SERVICE_UNAVAILABLE */
513
- );
514
- LogMessageUtils.error(
515
- "Exited",
516
296
  "Invalid argument",
517
- cmdSysNotFoundStackTrace.stack,
518
- "The command was not found in the system's PATH or is misspelled",
519
297
  503 /* SERVICE_UNAVAILABLE */
520
298
  );
299
+ this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
521
300
  break;
522
301
  case 130:
523
- const endScriptStackTrace = this.traceError(
302
+ this.stackTrace = this.traceError(
524
303
  "Indicates that the script was manually terminated by the user using the Control-C (SIGINT) signal",
525
- "Exited",
526
- 503 /* SERVICE_UNAVAILABLE */
527
- );
528
- LogMessageUtils.error(
529
- "Exited",
530
304
  "Script terminated",
531
- endScriptStackTrace.stack,
532
- "Indicates that the script was manually terminated by the user using the Control-C (SIGINT) signal",
533
305
  503 /* SERVICE_UNAVAILABLE */
534
306
  );
307
+ this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
535
308
  break;
536
309
  case 137:
537
- const prcKillStackTrace = this.traceError(
310
+ this.stackTrace = this.traceError(
538
311
  "Indicates that the process was terminated by a SIGKILL signal, possibly due to an out-of-memory situation",
539
- "Exited",
540
- 503 /* SERVICE_UNAVAILABLE */
541
- );
542
- LogMessageUtils.error(
543
- "Exited",
544
312
  "SIGKILL",
545
- prcKillStackTrace.stack,
546
- "Indicates that the process was terminated by a SIGKILL signal, possibly due to an out-of-memory situation",
547
313
  503 /* SERVICE_UNAVAILABLE */
548
314
  );
315
+ this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
549
316
  break;
550
317
  case 139:
551
- const illegalAccessStackTrace = this.traceError(
318
+ this.stackTrace = this.traceError(
552
319
  "Indicates that the process accessed an illegal memory address (segfault)",
553
- "Exited",
554
- 503 /* SERVICE_UNAVAILABLE */
555
- );
556
- LogMessageUtils.error(
557
- "Exited",
558
320
  "Segmentation fault",
559
- illegalAccessStackTrace.stack,
560
- "Indicates that the process accessed an illegal memory address (segfault)",
561
321
  503 /* SERVICE_UNAVAILABLE */
562
322
  );
323
+ this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
563
324
  break;
564
325
  case 143:
565
- const sigtermStackTrace = this.traceError(
326
+ this.stackTrace = this.traceError(
566
327
  "Indicates that the process received a SIGTERM signal to terminate",
567
- "Exited",
568
- 503 /* SERVICE_UNAVAILABLE */
569
- );
570
- LogMessageUtils.error(
571
- "Exited",
572
328
  "process received a SIGTERM",
573
- sigtermStackTrace.stack,
574
- "Indicates that the process received a SIGTERM signal to terminate",
575
329
  503 /* SERVICE_UNAVAILABLE */
576
330
  );
331
+ this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
577
332
  break;
578
333
  case 255:
579
- const outsideStackTrace = this.traceError(
334
+ this.stackTrace = this.traceError(
580
335
  "An exit code that is outside the allowable range (0-255 for Unix-like systems)",
581
- "Exited",
582
- 503 /* SERVICE_UNAVAILABLE */
583
- );
584
- LogMessageUtils.error(
585
- "Exited",
586
336
  "out of range",
587
- outsideStackTrace.stack,
588
- "An exit code that is outside the allowable range (0-255 for Unix-like systems)",
589
337
  503 /* SERVICE_UNAVAILABLE */
590
338
  );
339
+ this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
591
340
  break;
592
341
  default:
593
- const globalStackTrace = this.traceError(
342
+ this.stackTrace = this.traceError(
594
343
  "Error is occurring",
595
- "Exited",
596
- 503 /* SERVICE_UNAVAILABLE */
597
- );
598
- LogMessageUtils.error(
599
- "Exited",
600
344
  "errors",
601
- globalStackTrace.stack,
602
- "Error is occurring",
603
345
  503 /* SERVICE_UNAVAILABLE */
604
346
  );
347
+ this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
605
348
  break;
606
349
  }
607
350
  }
351
+ /**
352
+ *
353
+ * @param promise
354
+ */
608
355
  static promiseRejectionHandled(promise) {
609
- const globalStackTrace = this.traceError(
356
+ this.stackTrace = this.traceError(
610
357
  `Promise rejection is handled at : ${promise}`,
611
358
  "rejection promise",
612
359
  503 /* SERVICE_UNAVAILABLE */
613
360
  );
614
- LogMessageUtils.error(
615
- "PromiseRejectionHandled",
616
- "rejection promise",
617
- globalStackTrace.stack,
618
- `Promise rejection is handled at : ${promise}`,
619
- 503 /* SERVICE_UNAVAILABLE */
620
- );
361
+ this.logger.error(this.stackTrace.message, "PromiseRejectionHandled", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
621
362
  }
363
+ /**
364
+ *
365
+ * @param error
366
+ */
622
367
  static uncaughtException(error) {
623
368
  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.") {
624
369
  console.log("");
625
370
  } else {
626
- const tackTrace = this.traceError(
627
- error.message,
628
- "uncaught exception handled",
629
- 503 /* SERVICE_UNAVAILABLE */
630
- );
631
- LogMessageUtils.error(
632
- "UncaughtException",
633
- "uncaught exception handled",
634
- tackTrace.stack,
635
- error.message,
636
- 503 /* SERVICE_UNAVAILABLE */
637
- );
371
+ this.stackTrace = this.traceError(error.message, "uncaught exception handled", 503 /* SERVICE_UNAVAILABLE */);
372
+ this.logger.error(this.stackTrace.message, "UncaughtException", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
638
373
  }
639
374
  }
375
+ /**
376
+ *
377
+ * @param error
378
+ */
640
379
  static uncaughtExceptionMonitor(error) {
641
380
  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.") {
642
381
  console.log("");
643
382
  }
644
383
  }
384
+ /**
385
+ *
386
+ * @param reason
387
+ * @param promise
388
+ */
645
389
  static unhandledRejection(reason, promise) {
646
- const stackTrace = this.traceError(
390
+ this.stackTrace = this.traceError(
647
391
  `Unhandled Rejection at: Promise ${promise} -- reason ${reason}`,
648
392
  "Unhandled rejection",
649
393
  503 /* SERVICE_UNAVAILABLE */
650
394
  );
651
- LogMessageUtils.error(
652
- "UnhandledRejection",
653
- "Unhandled rejection",
654
- stackTrace.stack,
655
- `Unhandled Rejection at: Promise ${promise} -- reason ${reason}`,
656
- 503 /* SERVICE_UNAVAILABLE */
657
- );
395
+ this.logger.error(this.stackTrace.message, "UnhandledRejection", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
658
396
  }
397
+ /**
398
+ *
399
+ * @param warning
400
+ */
659
401
  static warning(warning) {
660
- const stackTrace = this.traceError(warning.message, "warning", 503 /* SERVICE_UNAVAILABLE */);
661
- LogMessageUtils.error(
662
- "Warning",
663
- "warning",
664
- stackTrace.stack,
665
- warning.message,
666
- 503 /* SERVICE_UNAVAILABLE */
667
- );
402
+ this.stackTrace = this.traceError(warning.message, "warning", 503 /* SERVICE_UNAVAILABLE */);
403
+ this.logger.error(this.stackTrace.message, "Warning", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
668
404
  }
405
+ /**
406
+ *
407
+ * @param message
408
+ */
669
409
  static message(message) {
670
- const stackTrace = this.traceError(
410
+ this.stackTrace = this.traceError(
671
411
  `process got message ${message}`,
672
412
  "message exception",
673
413
  503 /* SERVICE_UNAVAILABLE */
674
414
  );
675
- LogMessageUtils.error(
676
- "Message",
677
- "message exception",
678
- stackTrace.stack,
679
- `process got message ${message}`,
680
- 503 /* SERVICE_UNAVAILABLE */
681
- );
415
+ this.logger.error(this.stackTrace.message, "Message", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
682
416
  }
417
+ /**
418
+ *
419
+ * @param type
420
+ * @param promise
421
+ * @param reason
422
+ */
683
423
  static multipleResolves(type, promise, reason) {
684
- const stackTrace = this.traceError(
424
+ this.stackTrace = this.traceError(
685
425
  `${promise} -- ${reason}`,
686
- "multipleResolves",
687
- 503 /* SERVICE_UNAVAILABLE */
688
- );
689
- LogMessageUtils.error(
690
- "multipleResolves",
691
426
  `Multiple resolves detected : ${type}`,
692
- stackTrace.stack,
693
- `${promise} -- ${reason}`,
694
427
  503 /* SERVICE_UNAVAILABLE */
695
428
  );
429
+ this.logger.error(this.stackTrace.message, "multipleResolves", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
696
430
  }
431
+ /**
432
+ *
433
+ */
697
434
  static processInterrupted() {
698
- LogMessageUtils.success(
699
- "[ OK ] Success",
700
- `Process ${process2.pid} has been interrupted`,
701
- "The Web server has been stopped !"
702
- );
703
- process2.exit(0);
435
+ this.logger.success("[ OK ] Success", "The Web server has been stopped !");
436
+ process.exit(0);
704
437
  }
438
+ /**
439
+ *
440
+ * @param signal
441
+ */
705
442
  static sigtermSignalReceived(signal) {
706
- const stackTrace = this.traceError(
707
- `Process ${process2.pid} received a SIGTERM signal`,
708
- "SIGTERM",
709
- 406 /* NOT_ACCEPTABLE */
710
- );
711
- LogMessageUtils.error(
712
- "SIGTERM",
443
+ this.stackTrace = this.traceError(
444
+ `Process ${process.pid} received a SIGTERM signal : ${signal.toString()}`,
713
445
  "SIGTERM",
714
- stackTrace.stack,
715
- `Process ${process2.pid} received a SIGTERM signal : ${signal.toString()}`,
716
446
  406 /* NOT_ACCEPTABLE */
717
447
  );
718
- process2.exit(0);
448
+ this.logger.error(this.stackTrace.message, "SIGTERM", this.stackTrace.name, this.stackTrace.stack, 406 /* NOT_ACCEPTABLE */);
449
+ process.exit(0);
719
450
  }
451
+ /**
452
+ *
453
+ */
720
454
  static serverClosing() {
721
- console.log(`${colors4.bgCyanBright(` ${colors4.bold(`${colors4.white(` INFO `)}`)}`)} All processes are stopped`);
455
+ console.log(`${colors2.bgCyanBright(` ${colors2.bold(`${colors2.white(` INFO `)}`)}`)} All processes are stopped`);
722
456
  console.log(" Server is closed");
723
- process2.exit();
457
+ process.exit();
724
458
  }
459
+ /**
460
+ *
461
+ */
725
462
  static dropNewConnection() {
726
- console.log(`${colors4.cyan(`\u24D8`)} ${colors4.bgCyan(` ${colors4.bold(`${colors4.white(` Server maxConnection `)}`)} `)} ${dateTimeFormattedUtils} | ${colors4.bgCyan(`${colors4.white(` Info `)}`)} The server dropped new connections`);
463
+ console.log(`${colors2.cyan(`\u24D8`)} ${colors2.bgCyan(` ${colors2.bold(`${colors2.white(` Server maxConnection `)}`)} `)} ${dateTimeFormattedUtils} | ${colors2.bgCyan(`${colors2.white(` Info `)}`)} The server dropped new connections`);
727
464
  }
465
+ /**
466
+ *
467
+ * @param errorEmitter
468
+ * @param err
469
+ * @param req
470
+ * @param res
471
+ * @param next
472
+ */
728
473
  static expressErrorHandlingMiddleware(errorEmitter, err, req, res, next) {
729
474
  if (err) {
730
475
  errorEmitter.emit(CEventNameError.error, err);
@@ -733,14 +478,8 @@ var ServerListenEventError2 = class {
733
478
  } else {
734
479
  console.error("res.status is not a function");
735
480
  }
736
- const stackTrace = this.traceError(err.message, "Express error", 406 /* NOT_ACCEPTABLE */);
737
- LogMessageUtils.error(
738
- "Express error-handling middleware",
739
- "Express error",
740
- stackTrace.stack,
741
- err.message,
742
- 503 /* SERVICE_UNAVAILABLE */
743
- );
481
+ this.stackTrace = this.traceError(err.message, "Express error", 406 /* NOT_ACCEPTABLE */);
482
+ this.logger.error(this.stackTrace.message, "Express error-handling middleware", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
744
483
  } else {
745
484
  next();
746
485
  }
@@ -749,6 +488,137 @@ var ServerListenEventError2 = class {
749
488
  return new StackTraceError(props, name, status, true);
750
489
  }
751
490
  };
491
+ ServerListenEventError.logger = new LoggerCore();
492
+
493
+ // src/core/handlers/eventProcess.handler.ts
494
+ function eventProcessHandler() {
495
+ const errorEmitter = new EventEmitter();
496
+ const app = express();
497
+ errorEmitter.on(CEventNameError.error, (error) => {
498
+ ServerListenEventError.listenerError(error);
499
+ });
500
+ process2.on(CEvent.beforeExit, (code) => {
501
+ setTimeout(() => {
502
+ ServerListenEventError.processBeforeExit(code);
503
+ }, 100);
504
+ });
505
+ process2.on(CEvent.disconnect, () => {
506
+ ServerListenEventError.processDisconnected();
507
+ });
508
+ process2.on(CEvent.exit, (code) => {
509
+ ServerListenEventError.exited(code);
510
+ });
511
+ process2.on(CEvent.rejectionHandled, (promise) => {
512
+ ServerListenEventError.promiseRejectionHandled(promise);
513
+ });
514
+ process2.on(CEvent.uncaughtException, (error) => {
515
+ ServerListenEventError.uncaughtException(error);
516
+ });
517
+ process2.on(CEvent.uncaughtExceptionMonitor, (error) => {
518
+ ServerListenEventError.uncaughtExceptionMonitor(error);
519
+ });
520
+ process2.on(CEvent.unhandledRejection, (reason, promise) => {
521
+ ServerListenEventError.unhandledRejection(reason, promise);
522
+ });
523
+ process2.on(CEvent.warning, (warning) => {
524
+ ServerListenEventError.warning(warning);
525
+ });
526
+ process2.on(CEvent.message, (message) => {
527
+ ServerListenEventError.message(message);
528
+ });
529
+ process2.on(CEvent.multipleResolves, (type, promise, reason) => {
530
+ ServerListenEventError.multipleResolves(type, promise, reason);
531
+ });
532
+ process2.on(CEvent.sigint, () => {
533
+ ServerListenEventError.processInterrupted();
534
+ });
535
+ process2.on(CEvent.sigterm, (signal) => {
536
+ ServerListenEventError.sigtermSignalReceived(signal);
537
+ });
538
+ app.use((err, req, res, next) => {
539
+ ServerListenEventError.expressErrorHandlingMiddleware(errorEmitter, err, req, res, next);
540
+ });
541
+ }
542
+
543
+ // src/core/events/requestCalls.event.ts
544
+ import colors3 from "ansi-colors";
545
+ import { LoggerCore as LoggerCore2 } from "opticore-logger";
546
+ function requestCallsEvent(req, res, host, port, loadingTime) {
547
+ const logger = new LoggerCore2();
548
+ const currentDatePath = `Request called`;
549
+ if (req.originalUrl === "undefined") {
550
+ console.log(`[ ${colors3.red(`${currentDatePath}`)} ] ${loadingTime} | ${colors3.bgRed(`${colors3.white(` Not found `)}`)} [ Host ] http://${host}:${port} - [ Route ] The route do not exist. - [ Status ] ${colors3.red(`${colors3.white(` 404 `)}`)}`);
551
+ logger.error("The route do not exist.");
552
+ } else {
553
+ switch (res.statusCode) {
554
+ case 200:
555
+ switch (req.method) {
556
+ case "POST":
557
+ logger.info(`[ ${colors3.cyan(`${currentDatePath}`)} ] ${loadingTime} | ${colors3.bgGreen(`${colors3.white(` Success `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ Status ] ${colors3.bgCyan(`${colors3.white(` 200 `)}`)}`);
558
+ break;
559
+ case "GET":
560
+ case "PUT":
561
+ logger.info(`[ ${colors3.cyan(`${currentDatePath}`)} ] ${loadingTime} | ${colors3.bgGreen(`${colors3.white(` Success `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${colors3.bgCyan(`${colors3.white(` 200 `)}`)}`);
562
+ break;
563
+ case "DELETE":
564
+ logger.info(`[ ${colors3.cyan(`${currentDatePath}`)} ] ${loadingTime} | ${colors3.bgGreen(`${colors3.white(` Success `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${colors3.bgCyan(`${colors3.white(` 200 `)}`)}`);
565
+ break;
566
+ }
567
+ break;
568
+ case 404:
569
+ switch (req.method) {
570
+ case "POST":
571
+ console.log(`[ ${colors3.red(`${currentDatePath}`)} ] ${loadingTime} | ${colors3.bgRed(`${colors3.white(` Not found `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ Status ] ${colors3.red(`${colors3.white(` 404 `)}`)}`);
572
+ break;
573
+ case "GET":
574
+ console.log(`[ ${colors3.red(`${currentDatePath}`)} ] ${loadingTime} | ${colors3.bgRed(`${colors3.white(` Not found `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${colors3.red(`${colors3.bold(` 404 `)}`)}`);
575
+ break;
576
+ case "PUT":
577
+ console.log(`[ ${colors3.red(`${currentDatePath}`)} ] ${loadingTime} | ${colors3.bgRed(`${colors3.white(` Not found `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${colors3.red(`${colors3.bold(` 404 `)}`)}`);
578
+ break;
579
+ case "DELETE":
580
+ console.log(`[ ${colors3.red(`${currentDatePath}`)} ] ${loadingTime} | ${colors3.bgRed(`${colors3.white(` Not found `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${colors3.red(`${colors3.bold(` 404 `)}`)}`);
581
+ break;
582
+ }
583
+ break;
584
+ case 401:
585
+ switch (req.method) {
586
+ case "POST":
587
+ console.log(`[ ${colors3.yellowBright(`${currentDatePath}`)} ] ${loadingTime} | ${colors3.bgYellowBright(`${colors3.white(` Unauthorized `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ Status ] ${colors3.bgYellow(`${colors3.bold(` 401 `)}`)}`);
588
+ break;
589
+ case "GET":
590
+ console.log(`[ ${colors3.yellowBright(`${currentDatePath}`)} ] ${loadingTime} | ${colors3.bgYellowBright(`${colors3.white(` Unauthorized `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ Status ] ${colors3.bgYellow(`${colors3.bold(` 401 `)}`)}`);
591
+ break;
592
+ case "PUT":
593
+ console.log(`[ ${colors3.yellowBright(`${currentDatePath}`)} ] ${loadingTime} | ${colors3.bgYellowBright(`${colors3.white(` Unauthorized `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ Status ] ${colors3.bgYellow(`${colors3.bold(` 401 `)}`)}`);
594
+ break;
595
+ case "DELETE":
596
+ console.log(`[ ${colors3.yellowBright(`${currentDatePath}`)} ] ${loadingTime} | ${colors3.bgYellowBright(`${colors3.white(` Unauthorized `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ Status ] ${colors3.bgYellow(`${colors3.bold(` 401 `)}`)}`);
597
+ break;
598
+ }
599
+ break;
600
+ case 500:
601
+ switch (req.method) {
602
+ case "POST":
603
+ console.log(`[ ${colors3.red(`${currentDatePath}`)} ] ${loadingTime} | ${colors3.bgRed(`${colors3.white(` Server error `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ Status ] ${colors3.red(`${colors3.bold(` 500 `)}`)}`);
604
+ break;
605
+ case "GET":
606
+ console.log(`[ ${colors3.red(`${currentDatePath}`)} ] ${loadingTime} | ${colors3.bgRed(`${colors3.white(` Server error `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${colors3.red(`${colors3.bold(` 500 `)}`)}`);
607
+ break;
608
+ case "PUT":
609
+ console.log(`[ ${colors3.red(`${currentDatePath}`)} ] ${loadingTime} | ${colors3.bgRed(`${colors3.white(` Server error `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${colors3.red(`${colors3.bold(` 500 `)}`)}`);
610
+ break;
611
+ case "DELETE":
612
+ console.log(`[ ${colors3.red(`${currentDatePath}`)} ] ${loadingTime} | ${colors3.bgRed(`${colors3.white(` Server error `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${colors3.red(`${colors3.bold(` 500 `)}`)}`);
613
+ break;
614
+ }
615
+ break;
616
+ default:
617
+ console.log(`[ ${colors3.blueBright(`${currentDatePath}`)} ] ${loadingTime} | ${colors3.blueBright(` ${res.statusMessage} `)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ Status ] ${colors3.blueBright(` ${res.req.socket._httpMessage.statusCode} `)}`);
618
+ break;
619
+ }
620
+ }
621
+ }
752
622
 
753
623
  // src/application/service/core.service.ts
754
624
  import process3 from "node:process";
@@ -759,6 +629,28 @@ import colors6 from "ansi-colors";
759
629
 
760
630
  // src/core/utils/modulesLoaded.utils.ts
761
631
  import colors5 from "ansi-colors";
632
+
633
+ // src/core/utils/logMessage.utils.ts
634
+ import colors4 from "ansi-colors";
635
+ var LogMessageUtils = class {
636
+ static success(title, action, contentAction) {
637
+ console.log(`${colors4.green(`\u2714`)} ${colors4.bgGreen(` ${colors4.bold(`${colors4.white(`${title}`)}`)} `)} ${dateTimeFormattedUtils} | ${colors4.bgGreen(`${colors4.white(` Success `)}`)} [ ${action} ] ${contentAction} - [ Status ] ${colors4.bgGreen(`${colors4.white(` 200 `)}`)}`);
638
+ }
639
+ static warning(title, action, contentAction) {
640
+ console.warn(`${colors4.yellow(`\u26A0\uFE0F`)} ${colors4.bgYellow(` ${colors4.bold(`${colors4.white(`${title}`)}`)} `)} ${dateTimeFormattedUtils} | ${colors4.bgYellow(`${colors4.white(` Warning `)}`)} ${contentAction}`);
641
+ }
642
+ static info(title, action, contentAction) {
643
+ console.info(`${colors4.cyan(`\u24D8`)} ${colors4.bgCyan(` ${colors4.bold(`${colors4.white(`${title}`)}`)} `)} ${dateTimeFormattedUtils} | ${colors4.bgCyan(`${colors4.white(` Info `)}`)} ${contentAction}`);
644
+ }
645
+ static error(title, errorType, stackTrace, messageContent, httpCodeValue) {
646
+ console.error(`${colors4.red(`\u2718`)} ${colors4.bgRed(` ${colors4.bold(`${colors4.white(`${title}`)}`)} `)} | ${dateTimeFormattedUtils} | [ ${colors4.red(`${colors4.bold(` ${errorType} `)}`)} ] | [ ${colors4.bold(`stack trace`)} ] ${colors4.red(`${stackTrace}`)} - ${colors4.red(`${messageContent}`)} - [ ${colors4.red(`${colors4.bold(` HttpCode `)}`)} ] ${colors4.red(`${colors4.bold(` ${httpCodeValue} `)}`)} `);
647
+ }
648
+ static requestError(title, errorName, errorMessage, errorCode) {
649
+ console.error(`[ ${colors4.red(`${title}`)} ] ${dateTimeFormattedUtils} | ${colors4.bgRed(`${colors4.white(` ERROR `)}`)} ${colors4.red(`[ ${errorName} ]`)} ${colors4.red(`${errorMessage}`)} - [ Status ] ${colors4.bgRed(`${colors4.white(` ${errorCode} `)}`)}`);
650
+ }
651
+ };
652
+
653
+ // src/core/utils/modulesLoaded.utils.ts
762
654
  function modulesLoadedUtils(allAppRoutes, dbConChecker) {
763
655
  LogMessageUtils.success("Kernel", "load kernel", "Modules app have been successfully loaded");
764
656
  console.log(`${colors5.whiteBright(` content`)} ${colors5.green("Kernel :")} ${colors5.cyan(`${colors5.bold(`server side`)}`)} has been loaded successfully ${colors5.green(`\u2714`)}`);
@@ -937,11 +829,11 @@ var WebServerCore = class {
937
829
  () => {
938
830
  try {
939
831
  if (this.host === "" && this.port === 0) {
940
- ServerListenEventError2.hostPortUndefined();
832
+ ServerListenEventError.hostPortUndefined();
941
833
  } else if (this.host === "") {
942
- ServerListenEventError2.hostUndefined();
834
+ ServerListenEventError.hostUndefined();
943
835
  } else if (this.port === 0) {
944
- ServerListenEventError2.portUndefined();
836
+ ServerListenEventError.portUndefined();
945
837
  } else {
946
838
  this.registerRoutes(routers);
947
839
  }
@@ -953,11 +845,11 @@ var WebServerCore = class {
953
845
  }
954
846
  onListeningOnServerEvent(serverWeb, kernelModule) {
955
847
  serverWeb.on(CEventNameError.error, (err) => {
956
- ServerListenEventError2.onEventError(err);
848
+ ServerListenEventError.onEventError(err);
957
849
  }).on(CEventNameError.close, () => {
958
- ServerListenEventError2.serverClosing();
850
+ ServerListenEventError.serverClosing();
959
851
  }).on(CEventNameError.drop, () => {
960
- ServerListenEventError2.dropNewConnection();
852
+ ServerListenEventError.dropNewConnection();
961
853
  }).on(CEventNameError.listening, () => {
962
854
  this.infoWebApp();
963
855
  this.serverUtility.coreListenerEventLoaderModuleService(kernelModule);