opticore-webapp-core 1.0.18 → 1.0.19

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
@@ -197,14 +197,13 @@ var SAsymmetricCryptionDataWithPrivateRSAKey = class {
197
197
  TranslationLoader.t("erBadDbError", this.localeLanguage, this.log),
198
198
  status.NOT_FOUND
199
199
  );
200
- this.log.error(
201
- TranslationLoader.t("rsaKeyNotFound", this.localeLanguage, this.log),
202
- TranslationLoader.t("verifyExistingKey", this.localeLanguage, this.log),
203
- TranslationLoader.t("erBadDbError", this.localeLanguage, this.log),
204
- stackTrace.stack,
205
- status.NOT_FOUND
206
- );
207
- throw new Error();
200
+ this.log.error({
201
+ message: TranslationLoader.t("rsaKeyNotFound", this.localeLanguage, this.log),
202
+ title: TranslationLoader.t("verifyExistingKey", this.localeLanguage, this.log),
203
+ errorType: TranslationLoader.t("erBadDbError", this.localeLanguage, this.log),
204
+ stackTrace: stackTrace.stack,
205
+ httpCodeValue: status.NOT_FOUND
206
+ });
208
207
  }
209
208
  return rsaKey;
210
209
  }
@@ -227,14 +226,14 @@ var SAsymmetricCryptionDataWithPrivateRSAKey = class {
227
226
  TranslationLoader.t("encryptionFailed", this.localeLanguage, this.log),
228
227
  status.NOT_FOUND
229
228
  );
230
- this.log.error(
231
- err.message,
232
- TranslationLoader.t("encryptionFailed", this.localeLanguage, this.log),
233
- TranslationLoader.t("encryptionWithPrivateKeyFailed", this.localeLanguage, this.log),
234
- stackTrace.stack,
235
- status.NOT_FOUND
236
- );
237
- throw new Error();
229
+ this.log.error({
230
+ message: err.message,
231
+ title: TranslationLoader.t("encryptionFailed", this.localeLanguage, this.log),
232
+ errorType: TranslationLoader.t("encryptionWithPrivateKeyFailed", this.localeLanguage, this.log),
233
+ stackTrace: stackTrace.stack,
234
+ httpCodeValue: status.NOT_FOUND
235
+ });
236
+ process.exit();
238
237
  }
239
238
  }
240
239
  /**
@@ -255,14 +254,14 @@ var SAsymmetricCryptionDataWithPrivateRSAKey = class {
255
254
  TranslationLoader.t("decryptionFailed", this.localeLanguage, this.log),
256
255
  status.NOT_ACCEPTABLE
257
256
  );
258
- this.log.error(
259
- TranslationLoader.t("decryptionWithPublicKeyFailed", this.localeLanguage, this.log),
260
- TranslationLoader.t("decryptionFailed", this.localeLanguage, this.log),
261
- stackTrace.stack,
262
- TranslationLoader.t("errorDecryption", this.localeLanguage, this.log),
263
- status.NOT_ACCEPTABLE
264
- );
265
- throw new Error();
257
+ this.log.error({
258
+ message: TranslationLoader.t("decryptionWithPublicKeyFailed", this.localeLanguage, this.log),
259
+ title: TranslationLoader.t("decryptionFailed", this.localeLanguage, this.log),
260
+ errorType: TranslationLoader.t("errorDecryption", this.localeLanguage, this.log),
261
+ stackTrace: stackTrace.stack,
262
+ httpCodeValue: status.NOT_ACCEPTABLE
263
+ });
264
+ process.exit();
266
265
  }
267
266
  }
268
267
  /**
@@ -298,14 +297,14 @@ var SAsymmetricCryptionDataWithPrivateRSAKey = class {
298
297
  TranslationLoader.t("verifyRSAKeyFailed", this.localeLanguage, this.log),
299
298
  status.NOT_ACCEPTABLE
300
299
  );
301
- this.log.error(
302
- TranslationLoader.t("verifyRSAKey", this.localeLanguage, this.log),
303
- TranslationLoader.t("verifyRSAKeyFailed", this.localeLanguage, this.log),
304
- stackTrace.stack,
305
- TranslationLoader.t("signatureRSAKeyFailed", this.localeLanguage, this.log),
306
- status.NOT_FOUND
307
- );
308
- return new Error();
300
+ this.log.error({
301
+ message: TranslationLoader.t("verifyRSAKey", this.localeLanguage, this.log),
302
+ title: TranslationLoader.t("verifyRSAKeyFailed", this.localeLanguage, this.log),
303
+ errorType: TranslationLoader.t("signatureRSAKeyFailed", this.localeLanguage, this.log),
304
+ stackTrace: stackTrace.stack,
305
+ httpCodeValue: status.NOT_FOUND
306
+ });
307
+ process.exit();
309
308
  }
310
309
  } catch (err) {
311
310
  const stackTrace = this.traceError(
@@ -313,14 +312,14 @@ var SAsymmetricCryptionDataWithPrivateRSAKey = class {
313
312
  TranslationLoader.t("signatureRSAKeysError", this.localeLanguage, this.log),
314
313
  status.NOT_ACCEPTABLE
315
314
  );
316
- this.log.error(
317
- TranslationLoader.t("signatureRSAKeysError", this.localeLanguage, this.log),
318
- TranslationLoader.t("errorNameNotVerifyingRSAKey", this.localeLanguage, this.log),
319
- stackTrace.stack,
320
- err.message,
321
- status.NOT_FOUND
322
- );
323
- throw new Error();
315
+ this.log.error({
316
+ message: TranslationLoader.t("signatureRSAKeysError", this.localeLanguage, this.log),
317
+ title: TranslationLoader.t("errorNameNotVerifyingRSAKey", this.localeLanguage, this.log),
318
+ errorType: err.name,
319
+ stackTrace: stackTrace.stack,
320
+ httpCodeValue: status.NOT_FOUND
321
+ });
322
+ process.exit();
324
323
  }
325
324
  }
326
325
  /**
@@ -330,15 +329,15 @@ var SAsymmetricCryptionDataWithPrivateRSAKey = class {
330
329
  * @param status
331
330
  * @private
332
331
  */
333
- traceError(props, name, status7) {
334
- return new ErrorHandler(props, name, status7, true);
332
+ traceError(props, name, status2) {
333
+ return new ErrorHandler(props, name, status2, true);
335
334
  }
336
335
  };
337
336
 
338
337
  // src/application/services/asymmetricCryptionDataWithPublicRSAKey.service.ts
339
338
  import crypto4 from "crypto";
340
339
  import { TranslationLoader as TranslationLoader2 } from "opticore-translator";
341
- import { HttpStatusCode as status2 } from "opticore-http-response";
340
+ import { HttpStatusCode } from "opticore-http-response";
342
341
  import { StackTraceError } from "opticore-catch-exception-error";
343
342
  var SAsymmetricCryptionDataWithPublicRSAKey = class {
344
343
  logger;
@@ -357,18 +356,17 @@ var SAsymmetricCryptionDataWithPublicRSAKey = class {
357
356
  verifyExistingKey(rsaKey, keyType) {
358
357
  if (!rsaKey) {
359
358
  const stackTrace = this.traceError(
360
- keyType + TranslationLoader2.t("verifyExistingKey", this.localeLanguage, this.logger),
361
- TranslationLoader2.t("verifyExistingKey", this.localeLanguage, this.logger),
362
- status2.NOT_FOUND
359
+ keyType + TranslationLoader2.t("verifyExistingKey", this.localeLanguage),
360
+ TranslationLoader2.t("verifyExistingKey", this.localeLanguage),
361
+ HttpStatusCode.NOT_FOUND
363
362
  );
364
- this.logger.error(
365
- TranslationLoader2.t("verifyExistingKey", this.localeLanguage, this.logger),
366
- "key verification",
367
- stackTrace.stack,
368
- TranslationLoader2.t("verifyExistingKeyError", this.localeLanguage, this.logger),
369
- status2.NOT_FOUND
370
- );
371
- return new Error();
363
+ this.logger.error({
364
+ message: TranslationLoader2.t("verifyExistingKey", this.localeLanguage),
365
+ title: "key verification",
366
+ errorType: TranslationLoader2.t("verifyExistingKeyError", this.localeLanguage),
367
+ stackTrace: stackTrace.stack,
368
+ httpCodeValue: HttpStatusCode.NOT_FOUND
369
+ });
372
370
  }
373
371
  return rsaKey;
374
372
  }
@@ -387,17 +385,17 @@ var SAsymmetricCryptionDataWithPublicRSAKey = class {
387
385
  } catch (err) {
388
386
  const stackTrace = this.traceError(
389
387
  err.message,
390
- TranslationLoader2.t("encryptionWithPublicKey", this.localeLanguage, this.logger),
391
- status2.NOT_ACCEPTABLE
388
+ TranslationLoader2.t("encryptionWithPublicKey", this.localeLanguage),
389
+ HttpStatusCode.NOT_ACCEPTABLE
392
390
  );
393
- this.logger.error(
394
- TranslationLoader2.t("errorEncryptionPublicKey", this.localeLanguage, this.logger),
395
- TranslationLoader2.t("encryptionWithPublicKey", this.localeLanguage, this.logger),
396
- stackTrace.stack,
397
- err.message,
398
- status2.NOT_ACCEPTABLE
399
- );
400
- throw new Error();
391
+ this.logger.error({
392
+ message: TranslationLoader2.t("errorEncryptionPublicKey", this.localeLanguage),
393
+ title: TranslationLoader2.t("encryptionWithPublicKey", this.localeLanguage),
394
+ errorType: err.code,
395
+ stackTrace: stackTrace.stack,
396
+ httpCodeValue: HttpStatusCode.NOT_ACCEPTABLE
397
+ });
398
+ process.exit();
401
399
  }
402
400
  }
403
401
  /**
@@ -416,17 +414,17 @@ var SAsymmetricCryptionDataWithPublicRSAKey = class {
416
414
  } catch (err) {
417
415
  const stackTrace = this.traceError(
418
416
  err.code,
419
- TranslationLoader2.t("errorDecryption", this.localeLanguage, this.logger),
420
- status2.NOT_ACCEPTABLE
421
- );
422
- this.logger.error(
423
- TranslationLoader2.t("errorDecryptionWithPrivateKey", this.localeLanguage, this.logger),
424
- TranslationLoader2.t("errorDecryption", this.localeLanguage, this.logger),
425
- stackTrace.stack,
426
- err.message,
427
- status2.NOT_ACCEPTABLE
417
+ TranslationLoader2.t("errorDecryption", this.localeLanguage),
418
+ HttpStatusCode.NOT_ACCEPTABLE
428
419
  );
429
- throw new Error();
420
+ this.logger.error({
421
+ message: TranslationLoader2.t("errorDecryptionWithPrivateKey", this.localeLanguage),
422
+ title: TranslationLoader2.t("errorDecryption", this.localeLanguage),
423
+ errorType: err.message,
424
+ stackTrace: stackTrace.stack,
425
+ httpCodeValue: HttpStatusCode.NOT_ACCEPTABLE
426
+ });
427
+ process.exit();
430
428
  }
431
429
  }
432
430
  /**
@@ -460,183 +458,40 @@ var SAsymmetricCryptionDataWithPublicRSAKey = class {
460
458
  return decryptedData.toString(CSignRSAKeyComponent.encodingFormat.utf_8);
461
459
  } else {
462
460
  const stackTrace = this.traceError(
463
- TranslationLoader2.t("verifyPublicRSAKeyError", this.localeLanguage, this.logger),
464
- TranslationLoader2.t("signatureRSAKeyFailed", this.localeLanguage, this.logger),
465
- status2.NOT_FOUND
466
- );
467
- this.logger.error(
468
- TranslationLoader2.t("verifyPublicRSAKey", this.localeLanguage, this.logger),
469
- TranslationLoader2.t("signatureRSAKeyFailed", this.localeLanguage, this.logger),
470
- stackTrace.stack,
471
- TranslationLoader2.t("verifyPublicRSAKeyError", this.localeLanguage, this.logger),
472
- status2.NOT_FOUND
461
+ TranslationLoader2.t("verifyPublicRSAKeyError", this.localeLanguage),
462
+ TranslationLoader2.t("signatureRSAKeyFailed", this.localeLanguage),
463
+ HttpStatusCode.NOT_FOUND
473
464
  );
465
+ this.logger.error({
466
+ message: TranslationLoader2.t("verifyPublicRSAKey", this.localeLanguage),
467
+ title: TranslationLoader2.t("signatureRSAKeyFailed", this.localeLanguage),
468
+ errorType: TranslationLoader2.t("verifyPublicRSAKeyError", this.localeLanguage),
469
+ stackTrace: stackTrace.stack,
470
+ httpCodeValue: HttpStatusCode.NOT_FOUND
471
+ });
474
472
  return stackTrace;
475
473
  }
476
474
  } catch (err) {
477
475
  const stackTrace = this.traceError(
478
476
  err.code,
479
- TranslationLoader2.t("verifyPublicRSAKey", this.localeLanguage, this.logger),
480
- status2.NOT_ACCEPTABLE
477
+ TranslationLoader2.t("verifyPublicRSAKey", this.localeLanguage),
478
+ HttpStatusCode.NOT_ACCEPTABLE
481
479
  );
482
- this.logger.error(
483
- TranslationLoader2.t("verifyPublicRSAKey", this.localeLanguage, this.logger),
484
- TranslationLoader2.t("errorDecryption", this.localeLanguage, this.logger),
485
- stackTrace.stack,
486
- err.message,
487
- status2.NOT_ACCEPTABLE
488
- );
489
- throw new Error();
480
+ this.logger.error({
481
+ message: TranslationLoader2.t("verifyPublicRSAKey", this.localeLanguage),
482
+ title: TranslationLoader2.t("errorDecryption", this.localeLanguage),
483
+ errorType: err.message,
484
+ stackTrace: stackTrace.stack,
485
+ httpCodeValue: HttpStatusCode.NOT_ACCEPTABLE
486
+ });
487
+ process.exit();
490
488
  }
491
489
  }
492
- traceError(props, name, status7) {
493
- return new StackTraceError(props, name, status7, true);
490
+ traceError(props, name, HttpStatusCode6) {
491
+ return new StackTraceError(props, name, HttpStatusCode6, true);
494
492
  }
495
493
  };
496
494
 
497
- // src/application/services/checkerMongoDatabaseConnection.service.ts
498
- import { MongoClient } from "mongodb";
499
- async function SCheckerMongoDatabaseConnection(url, user, password, dbName) {
500
- const client = new MongoClient(
501
- url,
502
- {
503
- auth: { username: user, password }
504
- }
505
- );
506
- await client.connect();
507
- }
508
-
509
- // src/core/handlers/errors/database/mySqlError.handler.database.ts
510
- import { LoggerCore as LoggerCore2 } from "opticore-logger";
511
- import { HttpStatusCode as status3 } from "opticore-http-response";
512
- import { TranslationLoader as TranslationLoader3 } from "opticore-translator";
513
- function mySqlErrorHandlerDatabase(localLanguage, environnementPath, err, dbHost, database, user, password) {
514
- const logger = new LoggerCore2(loggerConfig(environnementPath));
515
- switch (err.code) {
516
- case "EAI_AGAIN":
517
- logger.error(
518
- TranslationLoader3.t("errorDBHost", localLanguage, { dbHost }),
519
- TranslationLoader3.t("mySQLError", localLanguage),
520
- TranslationLoader3.t("eAiAgain", localLanguage),
521
- err.stack,
522
- status3.NOT_ACCEPTABLE
523
- );
524
- break;
525
- case "ER_NOT_SUPPORTED_AUTH_MODE":
526
- logger.error(
527
- TranslationLoader3.t("erNotSupportedAuthModeError", localLanguage),
528
- TranslationLoader3.t("dbConnection", localLanguage),
529
- TranslationLoader3.t("erNotSupportedAuthMode", localLanguage),
530
- err.stack,
531
- status3.NOT_ACCEPTABLE
532
- );
533
- break;
534
- case "ER_ACCESS_DENIED_ERROR":
535
- logger.error(
536
- TranslationLoader3.t("accessDeniedToDBCon", localLanguage, { user, password }),
537
- TranslationLoader3.t("dbConnection", localLanguage),
538
- TranslationLoader3.t("erAccessDeniedError", localLanguage),
539
- err.stack,
540
- status3.NOT_ACCEPTABLE
541
- );
542
- break;
543
- case "ER_BAD_DB_ERROR":
544
- logger.error(
545
- TranslationLoader3.t("unknownDB", localLanguage, { database }),
546
- TranslationLoader3.t("dbConnection", localLanguage),
547
- TranslationLoader3.t("erBadDbError", localLanguage),
548
- err.stack,
549
- status3.NOT_ACCEPTABLE
550
- );
551
- break;
552
- default:
553
- logger.error(
554
- err.message,
555
- TranslationLoader3.t("dbConnection", localLanguage),
556
- TranslationLoader3.t("mysqlErrorCon", localLanguage),
557
- err.stack,
558
- status3.NOT_ACCEPTABLE
559
- );
560
- break;
561
- }
562
- }
563
-
564
- // src/application/services/checkerMySqlDatabaseConnection.service.ts
565
- import { TranslationLoader as TranslationLoader4 } from "opticore-translator";
566
- function SCheckerMySqlDatabaseConnection(localeLanguage, environnementPath, dbConnection, user, database, dbHost, password) {
567
- const logger = SLoggerFileConfiguration(environnementPath);
568
- dbConnection.connect((err) => {
569
- if (err) {
570
- return mySqlErrorHandlerDatabase(localeLanguage, environnementPath, err, dbHost, database, user, password);
571
- } else {
572
- logger.success(
573
- TranslationLoader4.t("dbConnection", localeLanguage, logger),
574
- TranslationLoader4.t("dbConnexionSuccess", localeLanguage, logger)
575
- );
576
- return dbConnection.end((endConErr) => {
577
- if (endConErr) {
578
- return mySqlErrorHandlerDatabase(localeLanguage, environnementPath, err, dbHost, database, user, password);
579
- } else {
580
- logger.success(
581
- TranslationLoader4.t("dbConnection", localeLanguage, logger),
582
- TranslationLoader4.t("dbConnectionClosed", localeLanguage, logger)
583
- );
584
- console.log("");
585
- }
586
- });
587
- }
588
- });
589
- }
590
-
591
- // src/application/services/checkerPostgresDatabaseConnection.service.ts
592
- import { HttpStatusCode as status4 } from "opticore-http-response";
593
- import pg from "pg";
594
- import { TranslationLoader as TranslationLoader5 } from "opticore-translator";
595
- async function SCheckerPostgresDatabaseConnection(localeLanguage, environnementPath, connectionString, keepAlive, stream, statement_timeout, ssl, query_timeout, keepAliveInitialDelayMillis, idle_in_transaction_session_timeout, application_name, connectionTimeoutMillis, types, options) {
596
- const logger = SLoggerFileConfiguration(environnementPath);
597
- const configOptions = {
598
- connectionString,
599
- keepAlive,
600
- stream,
601
- statement_timeout,
602
- ssl,
603
- query_timeout,
604
- keepAliveInitialDelayMillis,
605
- idle_in_transaction_session_timeout,
606
- application_name,
607
- connectionTimeoutMillis,
608
- types,
609
- options
610
- };
611
- const client = new pg.Client(configOptions);
612
- await client.connect();
613
- await client.end().then(
614
- () => {
615
- logger.success(
616
- TranslationLoader5.t("postgresSuccessConn", localeLanguage, logger),
617
- TranslationLoader5.t("postgresClosingConnSuccess", localeLanguage, logger)
618
- );
619
- },
620
- (onRejected) => {
621
- logger.error(
622
- TranslationLoader5.t("postgresEndClientRejection", localeLanguage, logger),
623
- TranslationLoader5.t("postgresClientError", localeLanguage, logger),
624
- TranslationLoader5.t("postgresEndRejection", localeLanguage, logger),
625
- onRejected,
626
- status4.BAD_REQUEST
627
- );
628
- }
629
- ).catch((onError) => {
630
- logger.error(
631
- onError.message,
632
- TranslationLoader5.t("postgresConnError", localeLanguage, logger),
633
- TranslationLoader5.t("postgresException", localeLanguage, logger),
634
- onError.stack,
635
- status4.BAD_REQUEST
636
- );
637
- });
638
- }
639
-
640
495
  // src/domains/constants/logLevel.constant.ts
641
496
  var CLogLevel = {
642
497
  debug: "DEBUG",
@@ -645,38 +500,31 @@ var CLogLevel = {
645
500
  error: "ERROR"
646
501
  };
647
502
 
648
- // src/utils/connection/optionalArgumentConnection.util.ts
649
- import { getEnvironnementValue as getEnvironnementValue2 } from "opticore-env-access";
650
- var UOptionalArgumentConnection = (environnementPath) => {
651
- const envPath = getEnvironnementValue2(environnementPath);
652
- return envPath.argumentsDatabaseConnection;
653
- };
654
-
655
503
  // src/utils/parsing/parsingYaml.utils.ts
656
504
  import { readFile } from "fs/promises";
657
- import { HttpStatusCode as HttpStatusCode2 } from "opticore-http-response";
658
- import { LoggerCore as LoggerCore3 } from "opticore-logger";
659
- import { TranslationLoader as TranslationLoader7 } from "opticore-translator";
505
+ import { HttpStatusCode as HttpStatusCode3 } from "opticore-http-response";
506
+ import { LoggerCore as LoggerCore2 } from "opticore-logger";
507
+ import { TranslationLoader as TranslationLoader4 } from "opticore-translator";
660
508
 
661
509
  // src/core/config/loaders/translateLanguage.loader.ts
662
510
  import path from "path";
663
511
  import { createRequire } from "module";
664
- import { TranslationLoader as TranslationLoader6 } from "opticore-translator";
665
- import { HttpStatusCode } from "opticore-http-response";
512
+ import { TranslationLoader as TranslationLoader3 } from "opticore-translator";
513
+ import { HttpStatusCode as HttpStatusCode2 } from "opticore-http-response";
666
514
  var translateWebAppCoreLanguageLoader = (environnementPath, localLang) => {
667
515
  try {
668
516
  const require2 = createRequire(import.meta.url);
669
517
  const packagePath = path.dirname(require2.resolve("opticore-webapp-core"));
670
518
  const translateMsgJsonFilePath = path.join(packagePath, "utils", "translations");
671
- TranslationLoader6.loadTranslations(translateMsgJsonFilePath);
519
+ TranslationLoader3.loadTranslations(translateMsgJsonFilePath);
672
520
  } catch (err) {
673
- SLoggerFileConfiguration(environnementPath).error(
674
- TranslationLoader6.t(err.message, localLang),
675
- err.code,
676
- err.code,
677
- err.stackTrace,
678
- HttpStatusCode.INTERNAL_SERVER_ERROR
679
- );
521
+ SLoggerFileConfiguration(environnementPath).error({
522
+ message: TranslationLoader3.t(err.message, localLang),
523
+ title: err.code,
524
+ errorType: err.code,
525
+ stackTrace: err.stackTrace,
526
+ httpCodeValue: HttpStatusCode2.INTERNAL_SERVER_ERROR
527
+ });
680
528
  }
681
529
  };
682
530
 
@@ -685,10 +533,10 @@ import path2 from "path";
685
533
  var YamlParsing = class {
686
534
  logger;
687
535
  localeLanguage;
688
- constructor(localeLanguage, environnementPath) {
689
- translateWebAppCoreLanguageLoader(environnementPath, localeLanguage);
536
+ constructor(localeLanguage, environmentPath) {
537
+ translateWebAppCoreLanguageLoader(environmentPath, localeLanguage);
690
538
  this.localeLanguage = localeLanguage;
691
- this.logger = new LoggerCore3(loggerConfig(environnementPath));
539
+ this.logger = new LoggerCore2(loggerConfig(environmentPath));
692
540
  }
693
541
  absolutPath() {
694
542
  return path2.join(process.cwd(), "src", "utils", "translations");
@@ -698,13 +546,13 @@ var YamlParsing = class {
698
546
  const yamlContent = await readFile(filePath, "utf-8");
699
547
  await this.parsing(yamlContent);
700
548
  } catch (error) {
701
- this.logger.error(
702
- error.message,
703
- TranslationLoader7.t("parsingFailed", this.localeLanguage, this.logger),
704
- TranslationLoader7.t("readingError", this.localeLanguage, this.logger),
705
- error.stack,
706
- HttpStatusCode2.NOT_ACCEPTABLE
707
- );
549
+ this.logger.error({
550
+ message: error.message,
551
+ title: TranslationLoader4.t("parsingFailed", this.localeLanguage, this.logger),
552
+ errorType: TranslationLoader4.t("readingError", this.localeLanguage, this.logger),
553
+ stackTrace: error.stack,
554
+ httpCodeValue: HttpStatusCode3.NOT_ACCEPTABLE
555
+ });
708
556
  }
709
557
  }
710
558
  /**
@@ -731,13 +579,13 @@ var YamlParsing = class {
731
579
  result[key] = value?.trim() || null;
732
580
  }
733
581
  } else {
734
- this.logger.error(
735
- TranslationLoader7.t("badFormat", this.localeLanguage, { line }),
736
- TranslationLoader7.t("parsingFailed", this.localeLanguage, this.logger),
737
- TranslationLoader7.t("unsupportedFormat", this.localeLanguage, this.logger),
738
- content,
739
- HttpStatusCode2.NOT_ACCEPTABLE
740
- );
582
+ this.logger.error({
583
+ message: TranslationLoader4.t("badFormat", this.localeLanguage, { line }),
584
+ title: TranslationLoader4.t("parsingFailed", this.localeLanguage, this.logger),
585
+ errorType: TranslationLoader4.t("unsupportedFormat", this.localeLanguage, this.logger),
586
+ stackTrace: content,
587
+ httpCodeValue: HttpStatusCode3.NOT_ACCEPTABLE
588
+ });
741
589
  }
742
590
  }
743
591
  return result;
@@ -758,258 +606,13 @@ var Environment = class {
758
606
  }
759
607
  };
760
608
 
761
- // src/core/config/database/connexion.config.database.ts
762
- import mySQL from "mysql";
763
- import { HttpStatusCode as status6 } from "opticore-http-response";
764
- import { LoggerCore as LoggerCore4 } from "opticore-logger";
765
- import { TranslationLoader as TranslationLoader9 } from "opticore-translator";
766
-
767
- // src/core/errors/databaseConnexion.error.ts
768
- import { HttpStatusCode as status5 } from "opticore-http-response";
769
- import { StackTraceError as StackTraceError2 } from "opticore-catch-exception-error";
770
- import { TranslationLoader as TranslationLoader8 } from "opticore-translator";
771
- var DbConnexionConfigError = class {
772
- logger;
773
- localeLanguage;
774
- constructor(localeLanguage, environnementPath) {
775
- this.localeLanguage = localeLanguage;
776
- this.logger = SLoggerFileConfiguration(environnementPath);
777
- }
778
- /**
779
- *
780
- * @param e
781
- */
782
- mongoDBAuthenticationFailed(e) {
783
- const stackTrace = this.traceError(
784
- TranslationLoader8.t("mongoDBConnection", this.localeLanguage, { e }),
785
- TranslationLoader8.t("mongoDBAuthentication", this.localeLanguage),
786
- status5.UNAUTHORIZED
787
- );
788
- this.logger.error(
789
- TranslationLoader8.t("mongoDBAuthenticationError", this.localeLanguage),
790
- TranslationLoader8.t("mongoDBConnection", this.localeLanguage),
791
- TranslationLoader8.t("mongoDBAuthenticationFailed", this.localeLanguage),
792
- stackTrace.stack,
793
- status5.UNAUTHORIZED
794
- );
795
- }
796
- /**
797
- *
798
- * @param err
799
- * @param dbHost
800
- * @param dbPort
801
- */
802
- mongoDBInvalidUrl(err, dbHost, dbPort) {
803
- const stackTrace = this.traceError(
804
- TranslationLoader8.t("mongoDBConnection", this.localeLanguage, { err }),
805
- TranslationLoader8.t("mongoDBUnableParsingUrl", this.localeLanguage),
806
- status5.BAD_REQUEST
807
- );
808
- this.logger.error(
809
- TranslationLoader8.t("dbUrlParsingError", this.localeLanguage, { dbHost, dbPort }),
810
- TranslationLoader8.t("mongoDBConnection", this.localeLanguage),
811
- TranslationLoader8.t("mongoDBUnableParsingUrl", this.localeLanguage),
812
- stackTrace.stack,
813
- status5.BAD_REQUEST
814
- );
815
- }
816
- /**
817
- *
818
- * @param err
819
- * @param dbHost
820
- */
821
- mongoDBEaiAgain(err, dbHost) {
822
- const stackTrace = this.traceError(
823
- TranslationLoader8.t("mongoDBConnection", this.localeLanguage, { err }),
824
- TranslationLoader8.t("mongoDBServerSelection", this.localeLanguage),
825
- status5.BAD_REQUEST
826
- );
827
- this.logger.error(
828
- TranslationLoader8.t("mongoServerError", this.localeLanguage, { dbHost }),
829
- TranslationLoader8.t("mongoDBConnection", this.localeLanguage),
830
- TranslationLoader8.t("mongoDBServerSelection", this.localeLanguage),
831
- stackTrace.stack,
832
- status5.BAD_REQUEST
833
- );
834
- }
835
- /**
836
- *
837
- * @param err
838
- */
839
- mongoDbGlobalError(err) {
840
- const stackTrace = this.traceError(
841
- TranslationLoader8.t("mongoDBConnection", this.localeLanguage, { err }),
842
- TranslationLoader8.t("mongoDBConnection", this.localeLanguage),
843
- status5.NOT_ACCEPTABLE
844
- );
845
- this.logger.error(
846
- TranslationLoader8.t("mongoDBConnection", this.localeLanguage),
847
- TranslationLoader8.t("mongoDBConnectionError", this.localeLanguage),
848
- stackTrace.stack,
849
- err.message,
850
- status5.NOT_ACCEPTABLE
851
- );
852
- }
853
- /**
854
- *
855
- * @param props
856
- * @param name
857
- * @param status
858
- * @private
859
- */
860
- traceError(props, name, status7) {
861
- return new StackTraceError2(props, name, status7, true);
862
- }
863
- };
864
-
865
- // src/core/config/database/connexion.config.database.ts
866
- import { StackTraceError as ErrorHandler2 } from "opticore-catch-exception-error";
867
- var DatabaseConnectionConfig = class {
868
- env;
869
- logger;
870
- localeLanguage;
871
- environnementPath;
872
- DbConnexionConfigError;
873
- constructor(localeLanguage, environnementPath) {
874
- this.localeLanguage = localeLanguage;
875
- this.environnementPath = environnementPath;
876
- this.DbConnexionConfigError = new DbConnexionConfigError(localeLanguage, environnementPath);
877
- this.env = new Environment(environnementPath);
878
- this.logger = new LoggerCore4(loggerConfig(environnementPath));
879
- }
880
- /**
881
- *
882
- * @param optionalArgumentConnection
883
- *
884
- * MySQL database connection with an optional arguments
885
- * Establish the connection between app and Database Management System.
886
- * Inside this class, a checker verifies if database credentials are right,
887
- * and it's show off in the log that the connection has been created successfully.
888
- * But if any error is occurring during trying connection, it'd specify that error by stack traces.
889
- */
890
- databaseMySQLConnexionChecker(optionalArgumentConnection) {
891
- const dbURL = `${this.env.get("dataBaseUser")}:${this.env.get("dataBasePassword")}@${this.env.get("dataBaseHost")}:${this.env.get("dataBasePort")}/${this.env.get("dataBaseName")}`;
892
- let url = `mysql://${dbURL}?${optionalArgumentConnection}`;
893
- const dbConnection = mySQL.createConnection(url);
894
- return SCheckerMySqlDatabaseConnection(this.localeLanguage, this.environnementPath, dbConnection, this.env.get("dataBaseUser"), this.env.get("dataBaseName"), this.env.get("dataBaseHost"), this.env.get("dataBasePassword"));
895
- }
896
- /**
897
- *
898
- * @param optionalArgumentConnection
899
- *
900
- * Mongo database connection with optional connection arguments
901
- */
902
- async databaseMongoDBConnectionChecker(optionalArgumentConnection) {
903
- const dbUrl = `${this.env.get("dataBaseUser")}:${this.env.get("dataBasePassword")}@${this.env.get("dataBaseHost")}:${this.env.get("dataBasePort")}/${this.env.get("dataBaseName")}`;
904
- const url = `mongodb://${dbUrl}${optionalArgumentConnection}`;
905
- try {
906
- await SCheckerMongoDatabaseConnection(url, this.env.get("dataBaseUser"), this.env.get("dataBasePassword"), this.env.get("dataBaseName"));
907
- this.logger.success(
908
- TranslationLoader9.t("mongoDBConnectionChecker", this.localeLanguage, loggerConfig),
909
- TranslationLoader9.t("mongoConnectionSuccess", this.localeLanguage, loggerConfig)
910
- );
911
- console.log("");
912
- } catch (e) {
913
- if (e.code === 18) {
914
- this.DbConnexionConfigError.mongoDBAuthenticationFailed(e);
915
- }
916
- if (e.cause.code === "ERR_INVALID_URL") {
917
- this.DbConnexionConfigError.mongoDBInvalidUrl(e, this.env.get("dataBaseHost"), this.env.get("dataBasePort"));
918
- }
919
- if (e.code === void 0) {
920
- this.DbConnexionConfigError.mongoDBEaiAgain(e, this.env.get("dataBaseHost"));
921
- } else {
922
- this.DbConnexionConfigError.mongoDbGlobalError(e);
923
- }
924
- }
925
- }
926
- /**
927
- *
928
- * @param keepAlive
929
- * @param stream
930
- * @param statement_timeout
931
- * @param ssl
932
- * @param query_timeout
933
- * @param keepAliveInitialDelayMillis
934
- * @param idle_in_transaction_session_timeout
935
- * @param application_name
936
- * @param connectionTimeoutMillis
937
- * @param types
938
- * @param options
939
- *
940
- * Postgres database connection with optional connection arguments
941
- */
942
- async databasePostgresDBConnectionChecker(keepAlive, stream, statement_timeout, ssl, query_timeout, keepAliveInitialDelayMillis, idle_in_transaction_session_timeout, application_name, connectionTimeoutMillis, types, options) {
943
- const url = `postgresql:/${this.env.get("dataBaseUser")}:${this.env.get("dataBasePassword")}@${this.env.get("dataBaseHost")}:${this.env.get("dataBasePort")}/${this.env.get("dataBaseName")}`;
944
- try {
945
- await SCheckerPostgresDatabaseConnection(
946
- this.localeLanguage,
947
- this.environnementPath,
948
- url,
949
- keepAlive,
950
- stream,
951
- statement_timeout,
952
- ssl,
953
- query_timeout,
954
- keepAliveInitialDelayMillis,
955
- idle_in_transaction_session_timeout,
956
- application_name,
957
- connectionTimeoutMillis,
958
- types,
959
- options
960
- );
961
- this.logger.success(
962
- TranslationLoader9.t("postgresDBConnectionChecker", this.localeLanguage, loggerConfig),
963
- TranslationLoader9.t("postgresConnectionSuccess", this.localeLanguage, loggerConfig)
964
- );
965
- console.log("");
966
- } catch (err) {
967
- const stackTrace = this.traceError(TranslationLoader9.t(`${err.message}`, this.localeLanguage, loggerConfig), "PostgresConnectionError", status6.NOT_ACCEPTABLE);
968
- this.logger.error(err.message, "PostgresConnectionError", "Postgres connection error", stackTrace.stack, status6.NOT_ACCEPTABLE);
969
- }
970
- }
971
- traceError(props, name, status7) {
972
- return new ErrorHandler2(props, name, status7, true);
973
- }
974
- };
975
-
976
- // src/core/config/database/middleware/mongoChecker.database.ts
977
- var MMongoCheckerDatabase = (optionalArgumentConnection, localLanguage, environnementPath) => {
978
- const DbConnexion = new DatabaseConnectionConfig(localLanguage, environnementPath);
979
- return DbConnexion.databaseMongoDBConnectionChecker(optionalArgumentConnection);
980
- };
981
-
982
- // src/core/config/database/middleware/mySqlChecker.database.ts
983
- var MMySqlCheckerDatabase = (optionalArgumentConnection, localLanguage, environnementPath) => {
984
- const DbConnexion = new DatabaseConnectionConfig(localLanguage, environnementPath);
985
- return DbConnexion.databaseMySQLConnexionChecker(optionalArgumentConnection);
986
- };
987
-
988
- // src/core/config/database/middleware/postgresChecker.database.ts
989
- var MPostgresCheckerDatabase = (localLanguage, environnementPath, keepAlive, stream, statement_timeout, ssl, query_timeout, keepAliveInitialDelayMillis, idle_in_transaction_session_timeout, application_name, connectionTimeoutMillis, types, options) => {
990
- const DbConnexion = new DatabaseConnectionConfig(localLanguage, environnementPath);
991
- return DbConnexion.databasePostgresDBConnectionChecker(
992
- keepAlive,
993
- stream,
994
- statement_timeout,
995
- ssl,
996
- query_timeout,
997
- keepAliveInitialDelayMillis,
998
- idle_in_transaction_session_timeout,
999
- application_name,
1000
- connectionTimeoutMillis,
1001
- types,
1002
- options
1003
- );
1004
- };
1005
-
1006
609
  // src/utils/utility.utils.ts
1007
610
  import process2 from "node:process";
1008
611
  import chalk from "chalk";
1009
612
  import colors from "ansi-colors";
1010
613
  import path3 from "path";
1011
614
  import fs from "fs";
1012
- import { TranslationLoader as TranslationLoader10 } from "opticore-translator";
615
+ import { TranslationLoader as TranslationLoader5 } from "opticore-translator";
1013
616
  var Utility = class {
1014
617
  localLang;
1015
618
  constructor(localLanguage) {
@@ -1106,19 +709,19 @@ var Utility = class {
1106
709
  this.getEnvFileLoading(".env");
1107
710
  const isDevelopment = process2.env.NODE_ENV === "development";
1108
711
  if (isDevelopment) {
1109
- return `${TranslationLoader10.t("serverRunning", this.localLang)} ${colors.bgBlue(`${colors.bold(`${development}`)}`)} mode`;
712
+ return `${TranslationLoader5.t("serverRunning", this.localLang)} ${colors.bgBlue(`${colors.bold(`${development}`)}`)} mode`;
1110
713
  } else {
1111
- return `${TranslationLoader10.t("serverRunning", this.localLang)} ${colors.bgBlue(`${colors.bold(`${production}`)}`)} mode`;
714
+ return `${TranslationLoader5.t("serverRunning", this.localLang)} ${colors.bgBlue(`${colors.bold(`${production}`)}`)} mode`;
1112
715
  }
1113
716
  }
1114
717
  infoServer(nodeVersion, startingTime, host, port, rss, heapUsed, user, system) {
1115
718
  const paddingLength = 52;
1116
719
  const msg0 = " ".padEnd(paddingLength, " ");
1117
- const msg1 = ` ${TranslationLoader10.t("okServerListening", this.localLang)}`;
720
+ const msg1 = ` ${TranslationLoader5.t("okServerListening", this.localLang)}`;
1118
721
  const msg2Value = `${colors.bgBlue(`${colors.bold(`${nodeVersion}`)}`)}`;
1119
- const msg2 = ` ${TranslationLoader10.t("webServerUseNodeVersion", this.localLang)}`;
722
+ const msg2 = ` ${TranslationLoader5.t("webServerUseNodeVersion", this.localLang)}`;
1120
723
  const msg3Value = `${colors.bgBlue(`${colors.bold(`${startingTime}`)}`)}`;
1121
- const msg3 = ` ${TranslationLoader10.t("startupTime", this.localLang)}`;
724
+ const msg3 = ` ${TranslationLoader5.t("startupTime", this.localLang)}`;
1122
725
  const msg4 = ` ${this.getServerRunningMode("development", "production")}`;
1123
726
  const msg5 = ` ${colors.underline(`http://${host}:${port}`)}`;
1124
727
  console.log(chalk.bgGreen.white(msg0.padEnd(paddingLength, " ")));
@@ -1129,18 +732,18 @@ var Utility = class {
1129
732
  console.log(chalk.bgGreen.white(msg5.padEnd(61, " ")));
1130
733
  console.log(chalk.bgGreen.white(msg0.padEnd(paddingLength, " ")));
1131
734
  console.log(``);
1132
- console.log(`${`${TranslationLoader10.t("totalMemory", this.localLang)}`} ${colors.cyan(`${colors.bold(`${rss}`)}`)}`);
1133
- console.log(`${`${TranslationLoader10.t("memoryUsedDuringExecution", this.localLang)}`} ${colors.cyan(`${colors.bold(`${heapUsed}`)}`)}`);
1134
- console.log(`${`${TranslationLoader10.t("memoryUsedByUser", this.localLang)}`} ${colors.cyan(`${colors.bold(`${user}`)}`)}`);
1135
- console.log(`${`${TranslationLoader10.t("memoryUsedBySystem", this.localLang)}`} ${colors.cyan(`${colors.bold(`${system}`)}`)}`);
735
+ console.log(`${`${TranslationLoader5.t("totalMemory", this.localLang)}`} ${colors.cyan(`${colors.bold(`${rss}`)}`)}`);
736
+ console.log(`${`${TranslationLoader5.t("memoryUsedDuringExecution", this.localLang)}`} ${colors.cyan(`${colors.bold(`${heapUsed}`)}`)}`);
737
+ console.log(`${`${TranslationLoader5.t("memoryUsedByUser", this.localLang)}`} ${colors.cyan(`${colors.bold(`${user}`)}`)}`);
738
+ console.log(`${`${TranslationLoader5.t("memoryUsedBySystem", this.localLang)}`} ${colors.cyan(`${colors.bold(`${system}`)}`)}`);
1136
739
  console.log(``);
1137
740
  }
1138
741
  };
1139
742
 
1140
743
  // src/core/events/pathModuleVerifier.event.ts
1141
744
  import { resolve } from "path";
1142
- import { HttpStatusCode as HttpStatusCode3 } from "opticore-http-response";
1143
- import { TranslationLoader as TranslationLoader11 } from "opticore-translator";
745
+ import { HttpStatusCode as HttpStatusCode4 } from "opticore-http-response";
746
+ import { TranslationLoader as TranslationLoader6 } from "opticore-translator";
1144
747
  var PathModuleVerifier = class {
1145
748
  log;
1146
749
  localeLanguage;
@@ -1161,13 +764,13 @@ var PathModuleVerifier = class {
1161
764
  }
1162
765
  }
1163
766
  if (notLoadedPaths.length > 0) {
1164
- this.log.error(
1165
- TranslationLoader11.t("moduleNotLoaded", this.localeLanguage, { notLoadedPaths: notLoadedPaths.join(", ") }),
1166
- "",
1167
- "",
1168
- modulePaths,
1169
- HttpStatusCode3.NOT_ACCEPTABLE
1170
- );
767
+ this.log.error({
768
+ message: TranslationLoader6.t("moduleNotLoaded", this.localeLanguage, { notLoadedPaths: notLoadedPaths.join(", ") }),
769
+ title: "",
770
+ errorType: "",
771
+ stackTrace: modulePaths,
772
+ httpCodeValue: HttpStatusCode4.NOT_ACCEPTABLE
773
+ });
1171
774
  throw new Error();
1172
775
  }
1173
776
  }
@@ -1188,8 +791,8 @@ var PathModuleVerifier = class {
1188
791
 
1189
792
  // src/core/config/loaders/localLanguage.loader.ts
1190
793
  import path4 from "path";
1191
- import { TranslationLoader as TranslationLoader12 } from "opticore-translator";
1192
- import { HttpStatusCode as HttpStatusCode4 } from "opticore-http-response";
794
+ import { TranslationLoader as TranslationLoader7 } from "opticore-translator";
795
+ import { HttpStatusCode as HttpStatusCode5 } from "opticore-http-response";
1193
796
  var LocalLanguageLoader = class {
1194
797
  localeLanguage;
1195
798
  environnementPath;
@@ -1200,16 +803,15 @@ var LocalLanguageLoader = class {
1200
803
  load() {
1201
804
  try {
1202
805
  const translateMsgJsonFilePath = path4.join(process.cwd(), "src", "utils", "translations");
1203
- TranslationLoader12.loadTranslations(translateMsgJsonFilePath);
806
+ TranslationLoader7.loadTranslations(translateMsgJsonFilePath);
1204
807
  } catch (err) {
1205
- SLoggerFileConfiguration(this.environnementPath).error(
1206
- //TranslationLoader.t(err.message, this.localeLanguage),
1207
- err.message,
1208
- err.code,
1209
- err.code,
1210
- err.stackTrace,
1211
- HttpStatusCode4.INTERNAL_SERVER_ERROR
1212
- );
808
+ SLoggerFileConfiguration(this.environnementPath).error({
809
+ message: err.message,
810
+ title: err.code,
811
+ errorType: err.code,
812
+ stackTrace: err.stackTrace,
813
+ httpCodeValue: HttpStatusCode5.INTERNAL_SERVER_ERROR
814
+ });
1213
815
  }
1214
816
  }
1215
817
  };
@@ -1218,18 +820,11 @@ export {
1218
820
  CSignRSAKeyComponent,
1219
821
  Environment,
1220
822
  LocalLanguageLoader,
1221
- MMongoCheckerDatabase,
1222
- MMySqlCheckerDatabase,
1223
- MPostgresCheckerDatabase,
1224
823
  PathModuleVerifier,
1225
824
  RSAKeyDecryption,
1226
825
  RSAKeyEncryption,
1227
826
  SAsymmetricCryptionDataWithPrivateRSAKey,
1228
827
  SAsymmetricCryptionDataWithPublicRSAKey,
1229
- SCheckerMongoDatabaseConnection,
1230
- SCheckerMySqlDatabaseConnection,
1231
- SCheckerPostgresDatabaseConnection,
1232
- UOptionalArgumentConnection,
1233
828
  Utility,
1234
829
  YamlParsing,
1235
830
  dateTimeFormatted,