opticore-webapp 1.0.1 → 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.cjs +184 -293
- package/dist/index.js +184 -293
- package/package.json +2 -2
- package/src/core/events/errors/serverListen.event.error.ts +157 -243
- package/src/core/events/requestCalls.event.ts +0 -3
- package/tsup.config.ts +1 -1
package/dist/index.cjs
CHANGED
|
@@ -149,36 +149,14 @@ var import_node_events = __toESM(require("events"), 1);
|
|
|
149
149
|
|
|
150
150
|
// src/core/events/errors/serverListen.event.error.ts
|
|
151
151
|
var import_process = __toESM(require("process"), 1);
|
|
152
|
-
var
|
|
152
|
+
var import_ansi_colors2 = __toESM(require("ansi-colors"), 1);
|
|
153
153
|
var import_chalk = __toESM(require("chalk"), 1);
|
|
154
154
|
|
|
155
|
-
// src/core/utils/logMessage.utils.ts
|
|
156
|
-
var import_ansi_colors = __toESM(require("ansi-colors"), 1);
|
|
157
|
-
|
|
158
155
|
// src/core/utils/dateTimeFormatted.utils.ts
|
|
159
156
|
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()}`;
|
|
160
157
|
|
|
161
|
-
// src/core/utils/logMessage.utils.ts
|
|
162
|
-
var LogMessageUtils = class {
|
|
163
|
-
static success(title, action, contentAction) {
|
|
164
|
-
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 `)}`)}`);
|
|
165
|
-
}
|
|
166
|
-
static warning(title, action, contentAction) {
|
|
167
|
-
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}`);
|
|
168
|
-
}
|
|
169
|
-
static info(title, action, contentAction) {
|
|
170
|
-
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}`);
|
|
171
|
-
}
|
|
172
|
-
static error(title, errorType, stackTrace, messageContent, httpCodeValue) {
|
|
173
|
-
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} `)}`)} `);
|
|
174
|
-
}
|
|
175
|
-
static requestError(title, errorName, errorMessage, errorCode) {
|
|
176
|
-
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} `)}`)}`);
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
|
|
180
158
|
// src/application/exceptions/messages.exception.ts
|
|
181
|
-
var
|
|
159
|
+
var import_ansi_colors = __toESM(require("ansi-colors"), 1);
|
|
182
160
|
var messageException = {
|
|
183
161
|
dbConnection: "DataBase connection",
|
|
184
162
|
dbConnectionClosed: "MySQL connection is closed",
|
|
@@ -242,7 +220,7 @@ var messageException = {
|
|
|
242
220
|
errorHost: "The host can't be empty or blank. Please define a string host in .env",
|
|
243
221
|
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`,
|
|
244
222
|
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`,
|
|
245
|
-
errorDBHost: (host) => `A database host ${host} does not allow connection. Please either set the host like this: ${
|
|
223
|
+
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`
|
|
246
224
|
};
|
|
247
225
|
|
|
248
226
|
// src/domains/constants/eventNameError.constant.ts
|
|
@@ -256,384 +234,283 @@ var CEventNameError = {
|
|
|
256
234
|
};
|
|
257
235
|
|
|
258
236
|
// src/core/events/errors/serverListen.event.error.ts
|
|
237
|
+
var import_opticore_logger = require("opticore-logger");
|
|
259
238
|
var ServerListenEventError = class {
|
|
239
|
+
/**
|
|
240
|
+
*
|
|
241
|
+
*/
|
|
260
242
|
static hostPortUndefined() {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
messageException.webServer,
|
|
264
|
-
messageException.badHost,
|
|
265
|
-
stackTrace.stack,
|
|
266
|
-
messageException.errorHostUrl,
|
|
267
|
-
400 /* BAD_REQUEST */
|
|
268
|
-
);
|
|
243
|
+
this.stackTrace = this.traceError(messageException.errorHostUrl, messageException.listening, 400 /* BAD_REQUEST */);
|
|
244
|
+
this.logger.error(this.stackTrace.message, messageException.webServer, messageException.badHost, this.stackTrace.stack, 400 /* BAD_REQUEST */);
|
|
269
245
|
import_process.default.exit();
|
|
270
246
|
}
|
|
247
|
+
/**
|
|
248
|
+
*
|
|
249
|
+
*/
|
|
271
250
|
static hostUndefined() {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
messageException.webServer,
|
|
275
|
-
messageException.badHost,
|
|
276
|
-
stackTrace.stack,
|
|
277
|
-
messageException.errorHost,
|
|
278
|
-
400 /* BAD_REQUEST */
|
|
279
|
-
);
|
|
251
|
+
this.stackTrace = this.traceError(messageException.badHost, messageException.listening, 400 /* BAD_REQUEST */);
|
|
252
|
+
this.logger.error(this.stackTrace.message, messageException.webServer, messageException.badHost, this.stackTrace.stack, 400 /* BAD_REQUEST */);
|
|
280
253
|
import_process.default.exit();
|
|
281
254
|
}
|
|
255
|
+
/**
|
|
256
|
+
*
|
|
257
|
+
*/
|
|
282
258
|
static portUndefined() {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
messageException.webServer,
|
|
286
|
-
messageException.badPort,
|
|
287
|
-
stackTrace.stack,
|
|
288
|
-
messageException.errorPort,
|
|
289
|
-
400 /* BAD_REQUEST */
|
|
290
|
-
);
|
|
259
|
+
this.stackTrace = this.traceError(messageException.badPort, messageException.listening, 400 /* BAD_REQUEST */);
|
|
260
|
+
this.logger.error(this.stackTrace.message, messageException.webServer, messageException.badHost, this.stackTrace.stack, 400 /* BAD_REQUEST */);
|
|
291
261
|
import_process.default.exit();
|
|
292
262
|
}
|
|
263
|
+
/**
|
|
264
|
+
*
|
|
265
|
+
* @param err
|
|
266
|
+
*/
|
|
293
267
|
static onEventError(err) {
|
|
294
|
-
|
|
295
|
-
"Server start error",
|
|
296
|
-
"Error",
|
|
297
|
-
err.stack,
|
|
298
|
-
err.message,
|
|
299
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
300
|
-
);
|
|
268
|
+
this.logger.error(err.message, "Server start error", "Error", err.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
301
269
|
}
|
|
270
|
+
/**
|
|
271
|
+
*
|
|
272
|
+
* @param error
|
|
273
|
+
*/
|
|
302
274
|
static listenerError(error) {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
error.name,
|
|
306
|
-
400 /* BAD_REQUEST */
|
|
307
|
-
);
|
|
308
|
-
LogMessageUtils.error(
|
|
309
|
-
"Event error",
|
|
310
|
-
"Error",
|
|
311
|
-
error.stack,
|
|
312
|
-
stackTrace.message,
|
|
313
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
314
|
-
);
|
|
275
|
+
this.stackTrace = this.traceError(error.message, error.name, 400 /* BAD_REQUEST */);
|
|
276
|
+
this.logger.error(this.stackTrace.message, "Event error", "Error", error.stack, 400 /* BAD_REQUEST */);
|
|
315
277
|
}
|
|
278
|
+
/**
|
|
279
|
+
*
|
|
280
|
+
* @param code
|
|
281
|
+
*/
|
|
316
282
|
static processBeforeExit(code) {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
"BeforeExit",
|
|
320
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
321
|
-
);
|
|
322
|
-
LogMessageUtils.error(
|
|
323
|
-
"BeforeExit",
|
|
324
|
-
"process before exit",
|
|
325
|
-
stackTrace.stack,
|
|
326
|
-
`Process will exit with code: ${code}`,
|
|
327
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
328
|
-
);
|
|
283
|
+
this.stackTrace = this.traceError(`Process will exit with code: ${code}`, "BeforeExit", 503 /* SERVICE_UNAVAILABLE */);
|
|
284
|
+
this.logger.error(this.stackTrace.message, "BeforeExit", "process before exit", this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
329
285
|
import_process.default.exit(code);
|
|
330
286
|
}
|
|
287
|
+
/**
|
|
288
|
+
*
|
|
289
|
+
*/
|
|
331
290
|
static processDisconnected() {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
"process disconnected",
|
|
335
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
336
|
-
);
|
|
337
|
-
LogMessageUtils.error(
|
|
338
|
-
"Disconnected",
|
|
339
|
-
"process disconnected",
|
|
340
|
-
stackTrace.stack,
|
|
341
|
-
"Child process disconnected",
|
|
342
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
343
|
-
);
|
|
291
|
+
this.stackTrace = this.traceError("Child process disconnected", "process disconnected", 503 /* SERVICE_UNAVAILABLE */);
|
|
292
|
+
this.logger.error(this.stackTrace.message, "Disconnected", "process disconnected", this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
344
293
|
import_process.default.exit();
|
|
345
294
|
}
|
|
295
|
+
/**
|
|
296
|
+
*
|
|
297
|
+
* @param code
|
|
298
|
+
*/
|
|
346
299
|
static exited(code) {
|
|
347
300
|
switch (code) {
|
|
348
301
|
case 0:
|
|
349
|
-
|
|
350
|
-
"Exited",
|
|
351
|
-
"completed",
|
|
352
|
-
"The process finished as expected and everything is ok"
|
|
353
|
-
);
|
|
302
|
+
this.logger.success("completed", "The process finished as expected and everything is ok");
|
|
354
303
|
console.log("");
|
|
355
304
|
const paddingLength = 35;
|
|
356
305
|
const msg0 = " ".padEnd(paddingLength, " ");
|
|
357
306
|
console.log(import_chalk.default.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
358
|
-
console.log(`${
|
|
307
|
+
console.log(`${import_ansi_colors2.default.bgGreen(` [OK] The server shutting down `)}`);
|
|
359
308
|
console.log(import_chalk.default.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
360
309
|
break;
|
|
361
310
|
case 1:
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
"General Errors",
|
|
365
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
366
|
-
);
|
|
367
|
-
LogMessageUtils.error(
|
|
368
|
-
"Exited",
|
|
369
|
-
"General Errors",
|
|
370
|
-
gnleStackTrace.stack,
|
|
371
|
-
"Something went wrong",
|
|
372
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
373
|
-
);
|
|
311
|
+
this.stackTrace = this.traceError("Something went wrong", "General Errors", 503 /* SERVICE_UNAVAILABLE */);
|
|
312
|
+
this.logger.error(this.stackTrace.message, "Exited", "General Errors", this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
374
313
|
break;
|
|
375
314
|
case 2:
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
"Misuse of shell builtins",
|
|
379
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
380
|
-
);
|
|
381
|
-
LogMessageUtils.error(
|
|
382
|
-
"Exited",
|
|
383
|
-
incrCmdStackTrace.name,
|
|
384
|
-
incrCmdStackTrace.stack,
|
|
385
|
-
"Incorrect using of shell commands",
|
|
386
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
387
|
-
);
|
|
315
|
+
this.stackTrace = this.traceError("Incorrect using of shell commands", "Misuse of shell builtins", 503 /* SERVICE_UNAVAILABLE */);
|
|
316
|
+
this.logger.error(this.stackTrace.message, "Exited", "Incorrect using of shell commands", this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
388
317
|
break;
|
|
389
318
|
case 126:
|
|
390
|
-
|
|
319
|
+
this.stackTrace = this.traceError(
|
|
391
320
|
"Incorrect using of shell commands",
|
|
392
|
-
"Misuse of shell builtins",
|
|
393
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
394
|
-
);
|
|
395
|
-
LogMessageUtils.error(
|
|
396
|
-
"Exited",
|
|
397
|
-
`command invoked`,
|
|
398
|
-
notExeCmdStackTrace.stack,
|
|
399
321
|
"The command is found but is not executable (e.g., trying to execute a directory)",
|
|
400
322
|
503 /* SERVICE_UNAVAILABLE */
|
|
401
323
|
);
|
|
324
|
+
this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
402
325
|
break;
|
|
403
326
|
case 127:
|
|
404
|
-
|
|
405
|
-
"The command was not found in the system's PATH or is misspelled",
|
|
406
|
-
"Exited",
|
|
407
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
408
|
-
);
|
|
409
|
-
LogMessageUtils.error(
|
|
410
|
-
"Exited",
|
|
327
|
+
this.stackTrace = this.traceError(
|
|
411
328
|
"Command not found",
|
|
412
|
-
cmdNotFoundStackTrace.stack,
|
|
413
329
|
"The command was not found in the system's PATH or is misspelled",
|
|
414
330
|
503 /* SERVICE_UNAVAILABLE */
|
|
415
331
|
);
|
|
332
|
+
this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
416
333
|
break;
|
|
417
334
|
case 128:
|
|
418
|
-
|
|
335
|
+
this.stackTrace = this.traceError(
|
|
419
336
|
"The command was not found in the system's PATH or is misspelled",
|
|
420
|
-
"Exited",
|
|
421
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
422
|
-
);
|
|
423
|
-
LogMessageUtils.error(
|
|
424
|
-
"Exited",
|
|
425
337
|
"Invalid argument",
|
|
426
|
-
cmdSysNotFoundStackTrace.stack,
|
|
427
|
-
"The command was not found in the system's PATH or is misspelled",
|
|
428
338
|
503 /* SERVICE_UNAVAILABLE */
|
|
429
339
|
);
|
|
340
|
+
this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
430
341
|
break;
|
|
431
342
|
case 130:
|
|
432
|
-
|
|
343
|
+
this.stackTrace = this.traceError(
|
|
433
344
|
"Indicates that the script was manually terminated by the user using the Control-C (SIGINT) signal",
|
|
434
|
-
"Exited",
|
|
435
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
436
|
-
);
|
|
437
|
-
LogMessageUtils.error(
|
|
438
|
-
"Exited",
|
|
439
345
|
"Script terminated",
|
|
440
|
-
endScriptStackTrace.stack,
|
|
441
|
-
"Indicates that the script was manually terminated by the user using the Control-C (SIGINT) signal",
|
|
442
346
|
503 /* SERVICE_UNAVAILABLE */
|
|
443
347
|
);
|
|
348
|
+
this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
444
349
|
break;
|
|
445
350
|
case 137:
|
|
446
|
-
|
|
351
|
+
this.stackTrace = this.traceError(
|
|
447
352
|
"Indicates that the process was terminated by a SIGKILL signal, possibly due to an out-of-memory situation",
|
|
448
|
-
"Exited",
|
|
449
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
450
|
-
);
|
|
451
|
-
LogMessageUtils.error(
|
|
452
|
-
"Exited",
|
|
453
353
|
"SIGKILL",
|
|
454
|
-
prcKillStackTrace.stack,
|
|
455
|
-
"Indicates that the process was terminated by a SIGKILL signal, possibly due to an out-of-memory situation",
|
|
456
354
|
503 /* SERVICE_UNAVAILABLE */
|
|
457
355
|
);
|
|
356
|
+
this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
458
357
|
break;
|
|
459
358
|
case 139:
|
|
460
|
-
|
|
359
|
+
this.stackTrace = this.traceError(
|
|
461
360
|
"Indicates that the process accessed an illegal memory address (segfault)",
|
|
462
|
-
"Exited",
|
|
463
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
464
|
-
);
|
|
465
|
-
LogMessageUtils.error(
|
|
466
|
-
"Exited",
|
|
467
361
|
"Segmentation fault",
|
|
468
|
-
illegalAccessStackTrace.stack,
|
|
469
|
-
"Indicates that the process accessed an illegal memory address (segfault)",
|
|
470
362
|
503 /* SERVICE_UNAVAILABLE */
|
|
471
363
|
);
|
|
364
|
+
this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
472
365
|
break;
|
|
473
366
|
case 143:
|
|
474
|
-
|
|
367
|
+
this.stackTrace = this.traceError(
|
|
475
368
|
"Indicates that the process received a SIGTERM signal to terminate",
|
|
476
|
-
"Exited",
|
|
477
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
478
|
-
);
|
|
479
|
-
LogMessageUtils.error(
|
|
480
|
-
"Exited",
|
|
481
369
|
"process received a SIGTERM",
|
|
482
|
-
sigtermStackTrace.stack,
|
|
483
|
-
"Indicates that the process received a SIGTERM signal to terminate",
|
|
484
370
|
503 /* SERVICE_UNAVAILABLE */
|
|
485
371
|
);
|
|
372
|
+
this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
486
373
|
break;
|
|
487
374
|
case 255:
|
|
488
|
-
|
|
375
|
+
this.stackTrace = this.traceError(
|
|
489
376
|
"An exit code that is outside the allowable range (0-255 for Unix-like systems)",
|
|
490
|
-
"Exited",
|
|
491
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
492
|
-
);
|
|
493
|
-
LogMessageUtils.error(
|
|
494
|
-
"Exited",
|
|
495
377
|
"out of range",
|
|
496
|
-
outsideStackTrace.stack,
|
|
497
|
-
"An exit code that is outside the allowable range (0-255 for Unix-like systems)",
|
|
498
378
|
503 /* SERVICE_UNAVAILABLE */
|
|
499
379
|
);
|
|
380
|
+
this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
500
381
|
break;
|
|
501
382
|
default:
|
|
502
|
-
|
|
383
|
+
this.stackTrace = this.traceError(
|
|
503
384
|
"Error is occurring",
|
|
504
|
-
"Exited",
|
|
505
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
506
|
-
);
|
|
507
|
-
LogMessageUtils.error(
|
|
508
|
-
"Exited",
|
|
509
385
|
"errors",
|
|
510
|
-
globalStackTrace.stack,
|
|
511
|
-
"Error is occurring",
|
|
512
386
|
503 /* SERVICE_UNAVAILABLE */
|
|
513
387
|
);
|
|
388
|
+
this.logger.error(this.stackTrace.message, "Exited", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
514
389
|
break;
|
|
515
390
|
}
|
|
516
391
|
}
|
|
392
|
+
/**
|
|
393
|
+
*
|
|
394
|
+
* @param promise
|
|
395
|
+
*/
|
|
517
396
|
static promiseRejectionHandled(promise) {
|
|
518
|
-
|
|
397
|
+
this.stackTrace = this.traceError(
|
|
519
398
|
`Promise rejection is handled at : ${promise}`,
|
|
520
399
|
"rejection promise",
|
|
521
400
|
503 /* SERVICE_UNAVAILABLE */
|
|
522
401
|
);
|
|
523
|
-
|
|
524
|
-
"PromiseRejectionHandled",
|
|
525
|
-
"rejection promise",
|
|
526
|
-
globalStackTrace.stack,
|
|
527
|
-
`Promise rejection is handled at : ${promise}`,
|
|
528
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
529
|
-
);
|
|
402
|
+
this.logger.error(this.stackTrace.message, "PromiseRejectionHandled", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
530
403
|
}
|
|
404
|
+
/**
|
|
405
|
+
*
|
|
406
|
+
* @param error
|
|
407
|
+
*/
|
|
531
408
|
static uncaughtException(error) {
|
|
532
409
|
if (error.message === "'app.router' is deprecated!\nPlease see the 3.x to 4.x migration guide for details on how to update your app.") {
|
|
533
410
|
console.log("");
|
|
534
411
|
} else {
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
"uncaught exception handled",
|
|
538
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
539
|
-
);
|
|
540
|
-
LogMessageUtils.error(
|
|
541
|
-
"UncaughtException",
|
|
542
|
-
"uncaught exception handled",
|
|
543
|
-
tackTrace.stack,
|
|
544
|
-
error.message,
|
|
545
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
546
|
-
);
|
|
412
|
+
this.stackTrace = this.traceError(error.message, "uncaught exception handled", 503 /* SERVICE_UNAVAILABLE */);
|
|
413
|
+
this.logger.error(this.stackTrace.message, "UncaughtException", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
547
414
|
}
|
|
548
415
|
}
|
|
416
|
+
/**
|
|
417
|
+
*
|
|
418
|
+
* @param error
|
|
419
|
+
*/
|
|
549
420
|
static uncaughtExceptionMonitor(error) {
|
|
550
421
|
if (error.message === "'app.router' is deprecated!\nPlease see the 3.x to 4.x migration guide for details on how to update your app.") {
|
|
551
422
|
console.log("");
|
|
552
423
|
}
|
|
553
424
|
}
|
|
425
|
+
/**
|
|
426
|
+
*
|
|
427
|
+
* @param reason
|
|
428
|
+
* @param promise
|
|
429
|
+
*/
|
|
554
430
|
static unhandledRejection(reason, promise) {
|
|
555
|
-
|
|
431
|
+
this.stackTrace = this.traceError(
|
|
556
432
|
`Unhandled Rejection at: Promise ${promise} -- reason ${reason}`,
|
|
557
433
|
"Unhandled rejection",
|
|
558
434
|
503 /* SERVICE_UNAVAILABLE */
|
|
559
435
|
);
|
|
560
|
-
|
|
561
|
-
"UnhandledRejection",
|
|
562
|
-
"Unhandled rejection",
|
|
563
|
-
stackTrace.stack,
|
|
564
|
-
`Unhandled Rejection at: Promise ${promise} -- reason ${reason}`,
|
|
565
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
566
|
-
);
|
|
436
|
+
this.logger.error(this.stackTrace.message, "UnhandledRejection", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
567
437
|
}
|
|
438
|
+
/**
|
|
439
|
+
*
|
|
440
|
+
* @param warning
|
|
441
|
+
*/
|
|
568
442
|
static warning(warning) {
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
"Warning",
|
|
572
|
-
"warning",
|
|
573
|
-
stackTrace.stack,
|
|
574
|
-
warning.message,
|
|
575
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
576
|
-
);
|
|
443
|
+
this.stackTrace = this.traceError(warning.message, "warning", 503 /* SERVICE_UNAVAILABLE */);
|
|
444
|
+
this.logger.error(this.stackTrace.message, "Warning", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
577
445
|
}
|
|
446
|
+
/**
|
|
447
|
+
*
|
|
448
|
+
* @param message
|
|
449
|
+
*/
|
|
578
450
|
static message(message) {
|
|
579
|
-
|
|
451
|
+
this.stackTrace = this.traceError(
|
|
580
452
|
`process got message ${message}`,
|
|
581
453
|
"message exception",
|
|
582
454
|
503 /* SERVICE_UNAVAILABLE */
|
|
583
455
|
);
|
|
584
|
-
|
|
585
|
-
"Message",
|
|
586
|
-
"message exception",
|
|
587
|
-
stackTrace.stack,
|
|
588
|
-
`process got message ${message}`,
|
|
589
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
590
|
-
);
|
|
456
|
+
this.logger.error(this.stackTrace.message, "Message", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
591
457
|
}
|
|
458
|
+
/**
|
|
459
|
+
*
|
|
460
|
+
* @param type
|
|
461
|
+
* @param promise
|
|
462
|
+
* @param reason
|
|
463
|
+
*/
|
|
592
464
|
static multipleResolves(type, promise, reason) {
|
|
593
|
-
|
|
465
|
+
this.stackTrace = this.traceError(
|
|
594
466
|
`${promise} -- ${reason}`,
|
|
595
|
-
"multipleResolves",
|
|
596
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
597
|
-
);
|
|
598
|
-
LogMessageUtils.error(
|
|
599
|
-
"multipleResolves",
|
|
600
467
|
`Multiple resolves detected : ${type}`,
|
|
601
|
-
stackTrace.stack,
|
|
602
|
-
`${promise} -- ${reason}`,
|
|
603
468
|
503 /* SERVICE_UNAVAILABLE */
|
|
604
469
|
);
|
|
470
|
+
this.logger.error(this.stackTrace.message, "multipleResolves", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
605
471
|
}
|
|
472
|
+
/**
|
|
473
|
+
*
|
|
474
|
+
*/
|
|
606
475
|
static processInterrupted() {
|
|
607
|
-
|
|
608
|
-
"[ OK ] Success",
|
|
609
|
-
`Process ${import_process.default.pid} has been interrupted`,
|
|
610
|
-
"The Web server has been stopped !"
|
|
611
|
-
);
|
|
476
|
+
this.logger.success("[ OK ] Success", "The Web server has been stopped !");
|
|
612
477
|
import_process.default.exit(0);
|
|
613
478
|
}
|
|
479
|
+
/**
|
|
480
|
+
*
|
|
481
|
+
* @param signal
|
|
482
|
+
*/
|
|
614
483
|
static sigtermSignalReceived(signal) {
|
|
615
|
-
|
|
616
|
-
`Process ${import_process.default.pid} received a SIGTERM signal`,
|
|
617
|
-
"SIGTERM",
|
|
618
|
-
406 /* NOT_ACCEPTABLE */
|
|
619
|
-
);
|
|
620
|
-
LogMessageUtils.error(
|
|
621
|
-
"SIGTERM",
|
|
622
|
-
"SIGTERM",
|
|
623
|
-
stackTrace.stack,
|
|
484
|
+
this.stackTrace = this.traceError(
|
|
624
485
|
`Process ${import_process.default.pid} received a SIGTERM signal : ${signal.toString()}`,
|
|
486
|
+
"SIGTERM",
|
|
625
487
|
406 /* NOT_ACCEPTABLE */
|
|
626
488
|
);
|
|
489
|
+
this.logger.error(this.stackTrace.message, "SIGTERM", this.stackTrace.name, this.stackTrace.stack, 406 /* NOT_ACCEPTABLE */);
|
|
627
490
|
import_process.default.exit(0);
|
|
628
491
|
}
|
|
492
|
+
/**
|
|
493
|
+
*
|
|
494
|
+
*/
|
|
629
495
|
static serverClosing() {
|
|
630
|
-
console.log(`${
|
|
496
|
+
console.log(`${import_ansi_colors2.default.bgCyanBright(` ${import_ansi_colors2.default.bold(`${import_ansi_colors2.default.white(` INFO `)}`)}`)} All processes are stopped`);
|
|
631
497
|
console.log(" Server is closed");
|
|
632
498
|
import_process.default.exit();
|
|
633
499
|
}
|
|
500
|
+
/**
|
|
501
|
+
*
|
|
502
|
+
*/
|
|
634
503
|
static dropNewConnection() {
|
|
635
|
-
console.log(`${
|
|
504
|
+
console.log(`${import_ansi_colors2.default.cyan(`\u24D8`)} ${import_ansi_colors2.default.bgCyan(` ${import_ansi_colors2.default.bold(`${import_ansi_colors2.default.white(` Server maxConnection `)}`)} `)} ${dateTimeFormattedUtils} | ${import_ansi_colors2.default.bgCyan(`${import_ansi_colors2.default.white(` Info `)}`)} The server dropped new connections`);
|
|
636
505
|
}
|
|
506
|
+
/**
|
|
507
|
+
*
|
|
508
|
+
* @param errorEmitter
|
|
509
|
+
* @param err
|
|
510
|
+
* @param req
|
|
511
|
+
* @param res
|
|
512
|
+
* @param next
|
|
513
|
+
*/
|
|
637
514
|
static expressErrorHandlingMiddleware(errorEmitter, err, req, res, next) {
|
|
638
515
|
if (err) {
|
|
639
516
|
errorEmitter.emit(CEventNameError.error, err);
|
|
@@ -642,14 +519,8 @@ var ServerListenEventError = class {
|
|
|
642
519
|
} else {
|
|
643
520
|
console.error("res.status is not a function");
|
|
644
521
|
}
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
"Express error-handling middleware",
|
|
648
|
-
"Express error",
|
|
649
|
-
stackTrace.stack,
|
|
650
|
-
err.message,
|
|
651
|
-
503 /* SERVICE_UNAVAILABLE */
|
|
652
|
-
);
|
|
522
|
+
this.stackTrace = this.traceError(err.message, "Express error", 406 /* NOT_ACCEPTABLE */);
|
|
523
|
+
this.logger.error(this.stackTrace.message, "Express error-handling middleware", this.stackTrace.name, this.stackTrace.stack, 503 /* SERVICE_UNAVAILABLE */);
|
|
653
524
|
} else {
|
|
654
525
|
next();
|
|
655
526
|
}
|
|
@@ -658,6 +529,7 @@ var ServerListenEventError = class {
|
|
|
658
529
|
return new StackTraceError(props, name, status, true);
|
|
659
530
|
}
|
|
660
531
|
};
|
|
532
|
+
ServerListenEventError.logger = new import_opticore_logger.LoggerCore();
|
|
661
533
|
|
|
662
534
|
// src/core/handlers/eventProcess.handler.ts
|
|
663
535
|
function eventProcessHandler() {
|
|
@@ -710,83 +582,80 @@ function eventProcessHandler() {
|
|
|
710
582
|
}
|
|
711
583
|
|
|
712
584
|
// src/core/events/requestCalls.event.ts
|
|
713
|
-
var
|
|
714
|
-
var
|
|
585
|
+
var import_ansi_colors3 = __toESM(require("ansi-colors"), 1);
|
|
586
|
+
var import_opticore_logger2 = require("opticore-logger");
|
|
715
587
|
function requestCallsEvent(req, res, host, port, loadingTime) {
|
|
716
|
-
const logger = new
|
|
588
|
+
const logger = new import_opticore_logger2.LoggerCore();
|
|
717
589
|
const currentDatePath = `Request called`;
|
|
718
590
|
if (req.originalUrl === "undefined") {
|
|
719
|
-
console.log(`[ ${
|
|
591
|
+
console.log(`[ ${import_ansi_colors3.default.red(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors3.default.bgRed(`${import_ansi_colors3.default.white(` Not found `)}`)} [ Host ] http://${host}:${port} - [ Route ] The route do not exist. - [ Status ] ${import_ansi_colors3.default.red(`${import_ansi_colors3.default.white(` 404 `)}`)}`);
|
|
720
592
|
logger.error("The route do not exist.");
|
|
721
593
|
} else {
|
|
722
594
|
switch (res.statusCode) {
|
|
723
595
|
case 200:
|
|
724
596
|
switch (req.method) {
|
|
725
597
|
case "POST":
|
|
726
|
-
|
|
727
|
-
logger.info(`[ ${import_ansi_colors4.default.cyan(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors4.default.bgGreen(`${import_ansi_colors4.default.white(` Success `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ Status ] ${import_ansi_colors4.default.bgCyan(`${import_ansi_colors4.default.white(` 200 `)}`)}`);
|
|
598
|
+
logger.info(`[ ${import_ansi_colors3.default.cyan(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors3.default.bgGreen(`${import_ansi_colors3.default.white(` Success `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ Status ] ${import_ansi_colors3.default.bgCyan(`${import_ansi_colors3.default.white(` 200 `)}`)}`);
|
|
728
599
|
break;
|
|
729
600
|
case "GET":
|
|
730
601
|
case "PUT":
|
|
731
|
-
|
|
732
|
-
logger.info(`[ ${import_ansi_colors4.default.cyan(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors4.default.bgGreen(`${import_ansi_colors4.default.white(` Success `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${import_ansi_colors4.default.bgCyan(`${import_ansi_colors4.default.white(` 200 `)}`)}`);
|
|
602
|
+
logger.info(`[ ${import_ansi_colors3.default.cyan(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors3.default.bgGreen(`${import_ansi_colors3.default.white(` Success `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${import_ansi_colors3.default.bgCyan(`${import_ansi_colors3.default.white(` 200 `)}`)}`);
|
|
733
603
|
break;
|
|
734
604
|
case "DELETE":
|
|
735
|
-
|
|
736
|
-
logger.info(`[ ${import_ansi_colors4.default.cyan(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors4.default.bgGreen(`${import_ansi_colors4.default.white(` Success `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${import_ansi_colors4.default.bgCyan(`${import_ansi_colors4.default.white(` 200 `)}`)}`);
|
|
605
|
+
logger.info(`[ ${import_ansi_colors3.default.cyan(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors3.default.bgGreen(`${import_ansi_colors3.default.white(` Success `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${import_ansi_colors3.default.bgCyan(`${import_ansi_colors3.default.white(` 200 `)}`)}`);
|
|
737
606
|
break;
|
|
738
607
|
}
|
|
739
608
|
break;
|
|
740
609
|
case 404:
|
|
741
610
|
switch (req.method) {
|
|
742
611
|
case "POST":
|
|
743
|
-
console.log(`[ ${
|
|
612
|
+
console.log(`[ ${import_ansi_colors3.default.red(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors3.default.bgRed(`${import_ansi_colors3.default.white(` Not found `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ Status ] ${import_ansi_colors3.default.red(`${import_ansi_colors3.default.white(` 404 `)}`)}`);
|
|
744
613
|
break;
|
|
745
614
|
case "GET":
|
|
746
|
-
console.log(`[ ${
|
|
615
|
+
console.log(`[ ${import_ansi_colors3.default.red(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors3.default.bgRed(`${import_ansi_colors3.default.white(` Not found `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${import_ansi_colors3.default.red(`${import_ansi_colors3.default.bold(` 404 `)}`)}`);
|
|
747
616
|
break;
|
|
748
617
|
case "PUT":
|
|
749
|
-
console.log(`[ ${
|
|
618
|
+
console.log(`[ ${import_ansi_colors3.default.red(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors3.default.bgRed(`${import_ansi_colors3.default.white(` Not found `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${import_ansi_colors3.default.red(`${import_ansi_colors3.default.bold(` 404 `)}`)}`);
|
|
750
619
|
break;
|
|
751
620
|
case "DELETE":
|
|
752
|
-
console.log(`[ ${
|
|
621
|
+
console.log(`[ ${import_ansi_colors3.default.red(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors3.default.bgRed(`${import_ansi_colors3.default.white(` Not found `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${import_ansi_colors3.default.red(`${import_ansi_colors3.default.bold(` 404 `)}`)}`);
|
|
753
622
|
break;
|
|
754
623
|
}
|
|
755
624
|
break;
|
|
756
625
|
case 401:
|
|
757
626
|
switch (req.method) {
|
|
758
627
|
case "POST":
|
|
759
|
-
console.log(`[ ${
|
|
628
|
+
console.log(`[ ${import_ansi_colors3.default.yellowBright(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors3.default.bgYellowBright(`${import_ansi_colors3.default.white(` Unauthorized `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ Status ] ${import_ansi_colors3.default.bgYellow(`${import_ansi_colors3.default.bold(` 401 `)}`)}`);
|
|
760
629
|
break;
|
|
761
630
|
case "GET":
|
|
762
|
-
console.log(`[ ${
|
|
631
|
+
console.log(`[ ${import_ansi_colors3.default.yellowBright(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors3.default.bgYellowBright(`${import_ansi_colors3.default.white(` Unauthorized `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ Status ] ${import_ansi_colors3.default.bgYellow(`${import_ansi_colors3.default.bold(` 401 `)}`)}`);
|
|
763
632
|
break;
|
|
764
633
|
case "PUT":
|
|
765
|
-
console.log(`[ ${
|
|
634
|
+
console.log(`[ ${import_ansi_colors3.default.yellowBright(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors3.default.bgYellowBright(`${import_ansi_colors3.default.white(` Unauthorized `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ Status ] ${import_ansi_colors3.default.bgYellow(`${import_ansi_colors3.default.bold(` 401 `)}`)}`);
|
|
766
635
|
break;
|
|
767
636
|
case "DELETE":
|
|
768
|
-
console.log(`[ ${
|
|
637
|
+
console.log(`[ ${import_ansi_colors3.default.yellowBright(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors3.default.bgYellowBright(`${import_ansi_colors3.default.white(` Unauthorized `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ Status ] ${import_ansi_colors3.default.bgYellow(`${import_ansi_colors3.default.bold(` 401 `)}`)}`);
|
|
769
638
|
break;
|
|
770
639
|
}
|
|
771
640
|
break;
|
|
772
641
|
case 500:
|
|
773
642
|
switch (req.method) {
|
|
774
643
|
case "POST":
|
|
775
|
-
console.log(`[ ${
|
|
644
|
+
console.log(`[ ${import_ansi_colors3.default.red(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors3.default.bgRed(`${import_ansi_colors3.default.white(` Server error `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ Status ] ${import_ansi_colors3.default.red(`${import_ansi_colors3.default.bold(` 500 `)}`)}`);
|
|
776
645
|
break;
|
|
777
646
|
case "GET":
|
|
778
|
-
console.log(`[ ${
|
|
647
|
+
console.log(`[ ${import_ansi_colors3.default.red(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors3.default.bgRed(`${import_ansi_colors3.default.white(` Server error `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${import_ansi_colors3.default.red(`${import_ansi_colors3.default.bold(` 500 `)}`)}`);
|
|
779
648
|
break;
|
|
780
649
|
case "PUT":
|
|
781
|
-
console.log(`[ ${
|
|
650
|
+
console.log(`[ ${import_ansi_colors3.default.red(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors3.default.bgRed(`${import_ansi_colors3.default.white(` Server error `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${import_ansi_colors3.default.red(`${import_ansi_colors3.default.bold(` 500 `)}`)}`);
|
|
782
651
|
break;
|
|
783
652
|
case "DELETE":
|
|
784
|
-
console.log(`[ ${
|
|
653
|
+
console.log(`[ ${import_ansi_colors3.default.red(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors3.default.bgRed(`${import_ansi_colors3.default.white(` Server error `)}`)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ query ] ${JSON.stringify(req.query)} - [ params ] ${JSON.stringify(req.params)} - [ Status ] ${import_ansi_colors3.default.red(`${import_ansi_colors3.default.bold(` 500 `)}`)}`);
|
|
785
654
|
break;
|
|
786
655
|
}
|
|
787
656
|
break;
|
|
788
657
|
default:
|
|
789
|
-
console.log(`[ ${
|
|
658
|
+
console.log(`[ ${import_ansi_colors3.default.blueBright(`${currentDatePath}`)} ] ${loadingTime} | ${import_ansi_colors3.default.blueBright(` ${res.statusMessage} `)} [ Host ] http://${host}:${port} - [ Route ] ${req.originalUrl} - [ Status ] ${import_ansi_colors3.default.blueBright(` ${res.req.socket._httpMessage.statusCode} `)}`);
|
|
790
659
|
break;
|
|
791
660
|
}
|
|
792
661
|
}
|
|
@@ -801,6 +670,28 @@ var import_ansi_colors6 = __toESM(require("ansi-colors"), 1);
|
|
|
801
670
|
|
|
802
671
|
// src/core/utils/modulesLoaded.utils.ts
|
|
803
672
|
var import_ansi_colors5 = __toESM(require("ansi-colors"), 1);
|
|
673
|
+
|
|
674
|
+
// src/core/utils/logMessage.utils.ts
|
|
675
|
+
var import_ansi_colors4 = __toESM(require("ansi-colors"), 1);
|
|
676
|
+
var LogMessageUtils = class {
|
|
677
|
+
static success(title, action, contentAction) {
|
|
678
|
+
console.log(`${import_ansi_colors4.default.green(`\u2714`)} ${import_ansi_colors4.default.bgGreen(` ${import_ansi_colors4.default.bold(`${import_ansi_colors4.default.white(`${title}`)}`)} `)} ${dateTimeFormattedUtils} | ${import_ansi_colors4.default.bgGreen(`${import_ansi_colors4.default.white(` Success `)}`)} [ ${action} ] ${contentAction} - [ Status ] ${import_ansi_colors4.default.bgGreen(`${import_ansi_colors4.default.white(` 200 `)}`)}`);
|
|
679
|
+
}
|
|
680
|
+
static warning(title, action, contentAction) {
|
|
681
|
+
console.warn(`${import_ansi_colors4.default.yellow(`\u26A0\uFE0F`)} ${import_ansi_colors4.default.bgYellow(` ${import_ansi_colors4.default.bold(`${import_ansi_colors4.default.white(`${title}`)}`)} `)} ${dateTimeFormattedUtils} | ${import_ansi_colors4.default.bgYellow(`${import_ansi_colors4.default.white(` Warning `)}`)} ${contentAction}`);
|
|
682
|
+
}
|
|
683
|
+
static info(title, action, contentAction) {
|
|
684
|
+
console.info(`${import_ansi_colors4.default.cyan(`\u24D8`)} ${import_ansi_colors4.default.bgCyan(` ${import_ansi_colors4.default.bold(`${import_ansi_colors4.default.white(`${title}`)}`)} `)} ${dateTimeFormattedUtils} | ${import_ansi_colors4.default.bgCyan(`${import_ansi_colors4.default.white(` Info `)}`)} ${contentAction}`);
|
|
685
|
+
}
|
|
686
|
+
static error(title, errorType, stackTrace, messageContent, httpCodeValue) {
|
|
687
|
+
console.error(`${import_ansi_colors4.default.red(`\u2718`)} ${import_ansi_colors4.default.bgRed(` ${import_ansi_colors4.default.bold(`${import_ansi_colors4.default.white(`${title}`)}`)} `)} | ${dateTimeFormattedUtils} | [ ${import_ansi_colors4.default.red(`${import_ansi_colors4.default.bold(` ${errorType} `)}`)} ] | [ ${import_ansi_colors4.default.bold(`stack trace`)} ] ${import_ansi_colors4.default.red(`${stackTrace}`)} - ${import_ansi_colors4.default.red(`${messageContent}`)} - [ ${import_ansi_colors4.default.red(`${import_ansi_colors4.default.bold(` HttpCode `)}`)} ] ${import_ansi_colors4.default.red(`${import_ansi_colors4.default.bold(` ${httpCodeValue} `)}`)} `);
|
|
688
|
+
}
|
|
689
|
+
static requestError(title, errorName, errorMessage, errorCode) {
|
|
690
|
+
console.error(`[ ${import_ansi_colors4.default.red(`${title}`)} ] ${dateTimeFormattedUtils} | ${import_ansi_colors4.default.bgRed(`${import_ansi_colors4.default.white(` ERROR `)}`)} ${import_ansi_colors4.default.red(`[ ${errorName} ]`)} ${import_ansi_colors4.default.red(`${errorMessage}`)} - [ Status ] ${import_ansi_colors4.default.bgRed(`${import_ansi_colors4.default.white(` ${errorCode} `)}`)}`);
|
|
691
|
+
}
|
|
692
|
+
};
|
|
693
|
+
|
|
694
|
+
// src/core/utils/modulesLoaded.utils.ts
|
|
804
695
|
function modulesLoadedUtils(allAppRoutes, dbConChecker) {
|
|
805
696
|
LogMessageUtils.success("Kernel", "load kernel", "Modules app have been successfully loaded");
|
|
806
697
|
console.log(`${import_ansi_colors5.default.whiteBright(` content`)} ${import_ansi_colors5.default.green("Kernel :")} ${import_ansi_colors5.default.cyan(`${import_ansi_colors5.default.bold(`server side`)}`)} has been loaded successfully ${import_ansi_colors5.default.green(`\u2714`)}`);
|