opticore-webapp-core 1.0.17 → 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.cjs +158 -569
- package/dist/index.d.cts +4 -62
- package/dist/index.d.ts +4 -62
- package/dist/index.js +162 -566
- package/package.json +9 -9
- package/dist/utils/translations/message.translation.en.json +0 -130
- package/dist/utils/translations/message.translation.fr.json +0 -49
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
|
-
|
|
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
|
-
|
|
262
|
-
|
|
263
|
-
status.NOT_ACCEPTABLE
|
|
264
|
-
);
|
|
265
|
-
|
|
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
|
-
|
|
305
|
-
|
|
306
|
-
status.NOT_FOUND
|
|
307
|
-
);
|
|
308
|
-
|
|
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
|
-
|
|
320
|
-
|
|
321
|
-
status.NOT_FOUND
|
|
322
|
-
);
|
|
323
|
-
|
|
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,
|
|
334
|
-
return new ErrorHandler(props, name,
|
|
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
|
|
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
|
|
361
|
-
TranslationLoader2.t("verifyExistingKey", this.localeLanguage
|
|
362
|
-
|
|
363
|
-
);
|
|
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
|
|
359
|
+
keyType + TranslationLoader2.t("verifyExistingKey", this.localeLanguage),
|
|
360
|
+
TranslationLoader2.t("verifyExistingKey", this.localeLanguage),
|
|
361
|
+
HttpStatusCode.NOT_FOUND
|
|
370
362
|
);
|
|
371
|
-
|
|
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
|
|
391
|
-
|
|
392
|
-
);
|
|
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
|
|
388
|
+
TranslationLoader2.t("encryptionWithPublicKey", this.localeLanguage),
|
|
389
|
+
HttpStatusCode.NOT_ACCEPTABLE
|
|
399
390
|
);
|
|
400
|
-
|
|
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
|
|
420
|
-
|
|
417
|
+
TranslationLoader2.t("errorDecryption", this.localeLanguage),
|
|
418
|
+
HttpStatusCode.NOT_ACCEPTABLE
|
|
421
419
|
);
|
|
422
|
-
this.logger.error(
|
|
423
|
-
TranslationLoader2.t("errorDecryptionWithPrivateKey", this.localeLanguage
|
|
424
|
-
TranslationLoader2.t("errorDecryption", this.localeLanguage
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
);
|
|
429
|
-
|
|
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
|
|
464
|
-
TranslationLoader2.t("signatureRSAKeyFailed", this.localeLanguage
|
|
465
|
-
|
|
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
|
|
480
|
-
|
|
481
|
-
);
|
|
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
|
|
477
|
+
TranslationLoader2.t("verifyPublicRSAKey", this.localeLanguage),
|
|
478
|
+
HttpStatusCode.NOT_ACCEPTABLE
|
|
488
479
|
);
|
|
489
|
-
|
|
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,
|
|
493
|
-
return new StackTraceError(props, name,
|
|
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,62 +500,59 @@ 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
|
|
658
|
-
import { LoggerCore as
|
|
659
|
-
import { TranslationLoader as
|
|
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
|
|
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
|
-
|
|
519
|
+
TranslationLoader3.loadTranslations(translateMsgJsonFilePath);
|
|
672
520
|
} catch (err) {
|
|
673
|
-
SLoggerFileConfiguration(environnementPath).error(
|
|
674
|
-
|
|
675
|
-
err.code,
|
|
676
|
-
err.code,
|
|
677
|
-
err.stackTrace,
|
|
678
|
-
|
|
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
|
|
|
683
531
|
// src/utils/parsing/parsingYaml.utils.ts
|
|
532
|
+
import path2 from "path";
|
|
684
533
|
var YamlParsing = class {
|
|
685
534
|
logger;
|
|
686
535
|
localeLanguage;
|
|
687
|
-
constructor(localeLanguage,
|
|
688
|
-
translateWebAppCoreLanguageLoader(
|
|
536
|
+
constructor(localeLanguage, environmentPath) {
|
|
537
|
+
translateWebAppCoreLanguageLoader(environmentPath, localeLanguage);
|
|
689
538
|
this.localeLanguage = localeLanguage;
|
|
690
|
-
this.logger = new
|
|
539
|
+
this.logger = new LoggerCore2(loggerConfig(environmentPath));
|
|
540
|
+
}
|
|
541
|
+
absolutPath() {
|
|
542
|
+
return path2.join(process.cwd(), "src", "utils", "translations");
|
|
691
543
|
}
|
|
692
544
|
async readFile(filePath) {
|
|
693
545
|
try {
|
|
694
546
|
const yamlContent = await readFile(filePath, "utf-8");
|
|
695
547
|
await this.parsing(yamlContent);
|
|
696
548
|
} catch (error) {
|
|
697
|
-
this.logger.error(
|
|
698
|
-
error.message,
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
error.stack,
|
|
702
|
-
|
|
703
|
-
);
|
|
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
|
+
});
|
|
704
556
|
}
|
|
705
557
|
}
|
|
706
558
|
/**
|
|
@@ -727,13 +579,13 @@ var YamlParsing = class {
|
|
|
727
579
|
result[key] = value?.trim() || null;
|
|
728
580
|
}
|
|
729
581
|
} else {
|
|
730
|
-
this.logger.error(
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
content,
|
|
735
|
-
|
|
736
|
-
);
|
|
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
|
+
});
|
|
737
589
|
}
|
|
738
590
|
}
|
|
739
591
|
return result;
|
|
@@ -754,258 +606,13 @@ var Environment = class {
|
|
|
754
606
|
}
|
|
755
607
|
};
|
|
756
608
|
|
|
757
|
-
// src/core/config/database/connexion.config.database.ts
|
|
758
|
-
import mySQL from "mysql";
|
|
759
|
-
import { HttpStatusCode as status6 } from "opticore-http-response";
|
|
760
|
-
import { LoggerCore as LoggerCore4 } from "opticore-logger";
|
|
761
|
-
import { TranslationLoader as TranslationLoader9 } from "opticore-translator";
|
|
762
|
-
|
|
763
|
-
// src/core/errors/databaseConnexion.error.ts
|
|
764
|
-
import { HttpStatusCode as status5 } from "opticore-http-response";
|
|
765
|
-
import { StackTraceError as StackTraceError2 } from "opticore-catch-exception-error";
|
|
766
|
-
import { TranslationLoader as TranslationLoader8 } from "opticore-translator";
|
|
767
|
-
var DbConnexionConfigError = class {
|
|
768
|
-
logger;
|
|
769
|
-
localeLanguage;
|
|
770
|
-
constructor(localeLanguage, environnementPath) {
|
|
771
|
-
this.localeLanguage = localeLanguage;
|
|
772
|
-
this.logger = SLoggerFileConfiguration(environnementPath);
|
|
773
|
-
}
|
|
774
|
-
/**
|
|
775
|
-
*
|
|
776
|
-
* @param e
|
|
777
|
-
*/
|
|
778
|
-
mongoDBAuthenticationFailed(e) {
|
|
779
|
-
const stackTrace = this.traceError(
|
|
780
|
-
TranslationLoader8.t("mongoDBConnection", this.localeLanguage, { e }),
|
|
781
|
-
TranslationLoader8.t("mongoDBAuthentication", this.localeLanguage),
|
|
782
|
-
status5.UNAUTHORIZED
|
|
783
|
-
);
|
|
784
|
-
this.logger.error(
|
|
785
|
-
TranslationLoader8.t("mongoDBAuthenticationError", this.localeLanguage),
|
|
786
|
-
TranslationLoader8.t("mongoDBConnection", this.localeLanguage),
|
|
787
|
-
TranslationLoader8.t("mongoDBAuthenticationFailed", this.localeLanguage),
|
|
788
|
-
stackTrace.stack,
|
|
789
|
-
status5.UNAUTHORIZED
|
|
790
|
-
);
|
|
791
|
-
}
|
|
792
|
-
/**
|
|
793
|
-
*
|
|
794
|
-
* @param err
|
|
795
|
-
* @param dbHost
|
|
796
|
-
* @param dbPort
|
|
797
|
-
*/
|
|
798
|
-
mongoDBInvalidUrl(err, dbHost, dbPort) {
|
|
799
|
-
const stackTrace = this.traceError(
|
|
800
|
-
TranslationLoader8.t("mongoDBConnection", this.localeLanguage, { err }),
|
|
801
|
-
TranslationLoader8.t("mongoDBUnableParsingUrl", this.localeLanguage),
|
|
802
|
-
status5.BAD_REQUEST
|
|
803
|
-
);
|
|
804
|
-
this.logger.error(
|
|
805
|
-
TranslationLoader8.t("dbUrlParsingError", this.localeLanguage, { dbHost, dbPort }),
|
|
806
|
-
TranslationLoader8.t("mongoDBConnection", this.localeLanguage),
|
|
807
|
-
TranslationLoader8.t("mongoDBUnableParsingUrl", this.localeLanguage),
|
|
808
|
-
stackTrace.stack,
|
|
809
|
-
status5.BAD_REQUEST
|
|
810
|
-
);
|
|
811
|
-
}
|
|
812
|
-
/**
|
|
813
|
-
*
|
|
814
|
-
* @param err
|
|
815
|
-
* @param dbHost
|
|
816
|
-
*/
|
|
817
|
-
mongoDBEaiAgain(err, dbHost) {
|
|
818
|
-
const stackTrace = this.traceError(
|
|
819
|
-
TranslationLoader8.t("mongoDBConnection", this.localeLanguage, { err }),
|
|
820
|
-
TranslationLoader8.t("mongoDBServerSelection", this.localeLanguage),
|
|
821
|
-
status5.BAD_REQUEST
|
|
822
|
-
);
|
|
823
|
-
this.logger.error(
|
|
824
|
-
TranslationLoader8.t("mongoServerError", this.localeLanguage, { dbHost }),
|
|
825
|
-
TranslationLoader8.t("mongoDBConnection", this.localeLanguage),
|
|
826
|
-
TranslationLoader8.t("mongoDBServerSelection", this.localeLanguage),
|
|
827
|
-
stackTrace.stack,
|
|
828
|
-
status5.BAD_REQUEST
|
|
829
|
-
);
|
|
830
|
-
}
|
|
831
|
-
/**
|
|
832
|
-
*
|
|
833
|
-
* @param err
|
|
834
|
-
*/
|
|
835
|
-
mongoDbGlobalError(err) {
|
|
836
|
-
const stackTrace = this.traceError(
|
|
837
|
-
TranslationLoader8.t("mongoDBConnection", this.localeLanguage, { err }),
|
|
838
|
-
TranslationLoader8.t("mongoDBConnection", this.localeLanguage),
|
|
839
|
-
status5.NOT_ACCEPTABLE
|
|
840
|
-
);
|
|
841
|
-
this.logger.error(
|
|
842
|
-
TranslationLoader8.t("mongoDBConnection", this.localeLanguage),
|
|
843
|
-
TranslationLoader8.t("mongoDBConnectionError", this.localeLanguage),
|
|
844
|
-
stackTrace.stack,
|
|
845
|
-
err.message,
|
|
846
|
-
status5.NOT_ACCEPTABLE
|
|
847
|
-
);
|
|
848
|
-
}
|
|
849
|
-
/**
|
|
850
|
-
*
|
|
851
|
-
* @param props
|
|
852
|
-
* @param name
|
|
853
|
-
* @param status
|
|
854
|
-
* @private
|
|
855
|
-
*/
|
|
856
|
-
traceError(props, name, status7) {
|
|
857
|
-
return new StackTraceError2(props, name, status7, true);
|
|
858
|
-
}
|
|
859
|
-
};
|
|
860
|
-
|
|
861
|
-
// src/core/config/database/connexion.config.database.ts
|
|
862
|
-
import { StackTraceError as ErrorHandler2 } from "opticore-catch-exception-error";
|
|
863
|
-
var DatabaseConnectionConfig = class {
|
|
864
|
-
env;
|
|
865
|
-
logger;
|
|
866
|
-
localeLanguage;
|
|
867
|
-
environnementPath;
|
|
868
|
-
DbConnexionConfigError;
|
|
869
|
-
constructor(localeLanguage, environnementPath) {
|
|
870
|
-
this.localeLanguage = localeLanguage;
|
|
871
|
-
this.environnementPath = environnementPath;
|
|
872
|
-
this.DbConnexionConfigError = new DbConnexionConfigError(localeLanguage, environnementPath);
|
|
873
|
-
this.env = new Environment(environnementPath);
|
|
874
|
-
this.logger = new LoggerCore4(loggerConfig(environnementPath));
|
|
875
|
-
}
|
|
876
|
-
/**
|
|
877
|
-
*
|
|
878
|
-
* @param optionalArgumentConnection
|
|
879
|
-
*
|
|
880
|
-
* MySQL database connection with an optional arguments
|
|
881
|
-
* Establish the connection between app and Database Management System.
|
|
882
|
-
* Inside this class, a checker verifies if database credentials are right,
|
|
883
|
-
* and it's show off in the log that the connection has been created successfully.
|
|
884
|
-
* But if any error is occurring during trying connection, it'd specify that error by stack traces.
|
|
885
|
-
*/
|
|
886
|
-
databaseMySQLConnexionChecker(optionalArgumentConnection) {
|
|
887
|
-
const dbURL = `${this.env.get("dataBaseUser")}:${this.env.get("dataBasePassword")}@${this.env.get("dataBaseHost")}:${this.env.get("dataBasePort")}/${this.env.get("dataBaseName")}`;
|
|
888
|
-
let url = `mysql://${dbURL}?${optionalArgumentConnection}`;
|
|
889
|
-
const dbConnection = mySQL.createConnection(url);
|
|
890
|
-
return SCheckerMySqlDatabaseConnection(this.localeLanguage, this.environnementPath, dbConnection, this.env.get("dataBaseUser"), this.env.get("dataBaseName"), this.env.get("dataBaseHost"), this.env.get("dataBasePassword"));
|
|
891
|
-
}
|
|
892
|
-
/**
|
|
893
|
-
*
|
|
894
|
-
* @param optionalArgumentConnection
|
|
895
|
-
*
|
|
896
|
-
* Mongo database connection with optional connection arguments
|
|
897
|
-
*/
|
|
898
|
-
async databaseMongoDBConnectionChecker(optionalArgumentConnection) {
|
|
899
|
-
const dbUrl = `${this.env.get("dataBaseUser")}:${this.env.get("dataBasePassword")}@${this.env.get("dataBaseHost")}:${this.env.get("dataBasePort")}/${this.env.get("dataBaseName")}`;
|
|
900
|
-
const url = `mongodb://${dbUrl}${optionalArgumentConnection}`;
|
|
901
|
-
try {
|
|
902
|
-
await SCheckerMongoDatabaseConnection(url, this.env.get("dataBaseUser"), this.env.get("dataBasePassword"), this.env.get("dataBaseName"));
|
|
903
|
-
this.logger.success(
|
|
904
|
-
TranslationLoader9.t("mongoDBConnectionChecker", this.localeLanguage, loggerConfig),
|
|
905
|
-
TranslationLoader9.t("mongoConnectionSuccess", this.localeLanguage, loggerConfig)
|
|
906
|
-
);
|
|
907
|
-
console.log("");
|
|
908
|
-
} catch (e) {
|
|
909
|
-
if (e.code === 18) {
|
|
910
|
-
this.DbConnexionConfigError.mongoDBAuthenticationFailed(e);
|
|
911
|
-
}
|
|
912
|
-
if (e.cause.code === "ERR_INVALID_URL") {
|
|
913
|
-
this.DbConnexionConfigError.mongoDBInvalidUrl(e, this.env.get("dataBaseHost"), this.env.get("dataBasePort"));
|
|
914
|
-
}
|
|
915
|
-
if (e.code === void 0) {
|
|
916
|
-
this.DbConnexionConfigError.mongoDBEaiAgain(e, this.env.get("dataBaseHost"));
|
|
917
|
-
} else {
|
|
918
|
-
this.DbConnexionConfigError.mongoDbGlobalError(e);
|
|
919
|
-
}
|
|
920
|
-
}
|
|
921
|
-
}
|
|
922
|
-
/**
|
|
923
|
-
*
|
|
924
|
-
* @param keepAlive
|
|
925
|
-
* @param stream
|
|
926
|
-
* @param statement_timeout
|
|
927
|
-
* @param ssl
|
|
928
|
-
* @param query_timeout
|
|
929
|
-
* @param keepAliveInitialDelayMillis
|
|
930
|
-
* @param idle_in_transaction_session_timeout
|
|
931
|
-
* @param application_name
|
|
932
|
-
* @param connectionTimeoutMillis
|
|
933
|
-
* @param types
|
|
934
|
-
* @param options
|
|
935
|
-
*
|
|
936
|
-
* Postgres database connection with optional connection arguments
|
|
937
|
-
*/
|
|
938
|
-
async databasePostgresDBConnectionChecker(keepAlive, stream, statement_timeout, ssl, query_timeout, keepAliveInitialDelayMillis, idle_in_transaction_session_timeout, application_name, connectionTimeoutMillis, types, options) {
|
|
939
|
-
const url = `postgresql:/${this.env.get("dataBaseUser")}:${this.env.get("dataBasePassword")}@${this.env.get("dataBaseHost")}:${this.env.get("dataBasePort")}/${this.env.get("dataBaseName")}`;
|
|
940
|
-
try {
|
|
941
|
-
await SCheckerPostgresDatabaseConnection(
|
|
942
|
-
this.localeLanguage,
|
|
943
|
-
this.environnementPath,
|
|
944
|
-
url,
|
|
945
|
-
keepAlive,
|
|
946
|
-
stream,
|
|
947
|
-
statement_timeout,
|
|
948
|
-
ssl,
|
|
949
|
-
query_timeout,
|
|
950
|
-
keepAliveInitialDelayMillis,
|
|
951
|
-
idle_in_transaction_session_timeout,
|
|
952
|
-
application_name,
|
|
953
|
-
connectionTimeoutMillis,
|
|
954
|
-
types,
|
|
955
|
-
options
|
|
956
|
-
);
|
|
957
|
-
this.logger.success(
|
|
958
|
-
TranslationLoader9.t("postgresDBConnectionChecker", this.localeLanguage, loggerConfig),
|
|
959
|
-
TranslationLoader9.t("postgresConnectionSuccess", this.localeLanguage, loggerConfig)
|
|
960
|
-
);
|
|
961
|
-
console.log("");
|
|
962
|
-
} catch (err) {
|
|
963
|
-
const stackTrace = this.traceError(TranslationLoader9.t(`${err.message}`, this.localeLanguage, loggerConfig), "PostgresConnectionError", status6.NOT_ACCEPTABLE);
|
|
964
|
-
this.logger.error(err.message, "PostgresConnectionError", "Postgres connection error", stackTrace.stack, status6.NOT_ACCEPTABLE);
|
|
965
|
-
}
|
|
966
|
-
}
|
|
967
|
-
traceError(props, name, status7) {
|
|
968
|
-
return new ErrorHandler2(props, name, status7, true);
|
|
969
|
-
}
|
|
970
|
-
};
|
|
971
|
-
|
|
972
|
-
// src/core/config/database/middleware/mongoChecker.database.ts
|
|
973
|
-
var MMongoCheckerDatabase = (optionalArgumentConnection, localLanguage, environnementPath) => {
|
|
974
|
-
const DbConnexion = new DatabaseConnectionConfig(localLanguage, environnementPath);
|
|
975
|
-
return DbConnexion.databaseMongoDBConnectionChecker(optionalArgumentConnection);
|
|
976
|
-
};
|
|
977
|
-
|
|
978
|
-
// src/core/config/database/middleware/mySqlChecker.database.ts
|
|
979
|
-
var MMySqlCheckerDatabase = (optionalArgumentConnection, localLanguage, environnementPath) => {
|
|
980
|
-
const DbConnexion = new DatabaseConnectionConfig(localLanguage, environnementPath);
|
|
981
|
-
return DbConnexion.databaseMySQLConnexionChecker(optionalArgumentConnection);
|
|
982
|
-
};
|
|
983
|
-
|
|
984
|
-
// src/core/config/database/middleware/postgresChecker.database.ts
|
|
985
|
-
var MPostgresCheckerDatabase = (localLanguage, environnementPath, keepAlive, stream, statement_timeout, ssl, query_timeout, keepAliveInitialDelayMillis, idle_in_transaction_session_timeout, application_name, connectionTimeoutMillis, types, options) => {
|
|
986
|
-
const DbConnexion = new DatabaseConnectionConfig(localLanguage, environnementPath);
|
|
987
|
-
return DbConnexion.databasePostgresDBConnectionChecker(
|
|
988
|
-
keepAlive,
|
|
989
|
-
stream,
|
|
990
|
-
statement_timeout,
|
|
991
|
-
ssl,
|
|
992
|
-
query_timeout,
|
|
993
|
-
keepAliveInitialDelayMillis,
|
|
994
|
-
idle_in_transaction_session_timeout,
|
|
995
|
-
application_name,
|
|
996
|
-
connectionTimeoutMillis,
|
|
997
|
-
types,
|
|
998
|
-
options
|
|
999
|
-
);
|
|
1000
|
-
};
|
|
1001
|
-
|
|
1002
609
|
// src/utils/utility.utils.ts
|
|
1003
610
|
import process2 from "node:process";
|
|
1004
611
|
import chalk from "chalk";
|
|
1005
612
|
import colors from "ansi-colors";
|
|
1006
|
-
import
|
|
613
|
+
import path3 from "path";
|
|
1007
614
|
import fs from "fs";
|
|
1008
|
-
import { TranslationLoader as
|
|
615
|
+
import { TranslationLoader as TranslationLoader5 } from "opticore-translator";
|
|
1009
616
|
var Utility = class {
|
|
1010
617
|
localLang;
|
|
1011
618
|
constructor(localLanguage) {
|
|
@@ -1070,7 +677,7 @@ var Utility = class {
|
|
|
1070
677
|
const endTime = process2.hrtime(startTime);
|
|
1071
678
|
const executionTime = (endTime[0] * 1e9 + endTime[1]) / 1e6;
|
|
1072
679
|
return {
|
|
1073
|
-
"projectPath":
|
|
680
|
+
"projectPath": path3.join(process2.cwd()),
|
|
1074
681
|
"startingTime": `${executionTime.toFixed(5)} ms`
|
|
1075
682
|
};
|
|
1076
683
|
}
|
|
@@ -1080,7 +687,7 @@ var Utility = class {
|
|
|
1080
687
|
* @private
|
|
1081
688
|
*/
|
|
1082
689
|
getEnvFileLoading(filePath) {
|
|
1083
|
-
const fullPath =
|
|
690
|
+
const fullPath = path3.resolve(process2.cwd(), filePath);
|
|
1084
691
|
if (fs.existsSync(fullPath)) {
|
|
1085
692
|
const env = fs.readFileSync(fullPath, "utf-8");
|
|
1086
693
|
const lines = env.split("\n");
|
|
@@ -1102,19 +709,19 @@ var Utility = class {
|
|
|
1102
709
|
this.getEnvFileLoading(".env");
|
|
1103
710
|
const isDevelopment = process2.env.NODE_ENV === "development";
|
|
1104
711
|
if (isDevelopment) {
|
|
1105
|
-
return `${
|
|
712
|
+
return `${TranslationLoader5.t("serverRunning", this.localLang)} ${colors.bgBlue(`${colors.bold(`${development}`)}`)} mode`;
|
|
1106
713
|
} else {
|
|
1107
|
-
return `${
|
|
714
|
+
return `${TranslationLoader5.t("serverRunning", this.localLang)} ${colors.bgBlue(`${colors.bold(`${production}`)}`)} mode`;
|
|
1108
715
|
}
|
|
1109
716
|
}
|
|
1110
717
|
infoServer(nodeVersion, startingTime, host, port, rss, heapUsed, user, system) {
|
|
1111
718
|
const paddingLength = 52;
|
|
1112
719
|
const msg0 = " ".padEnd(paddingLength, " ");
|
|
1113
|
-
const msg1 = ` ${
|
|
720
|
+
const msg1 = ` ${TranslationLoader5.t("okServerListening", this.localLang)}`;
|
|
1114
721
|
const msg2Value = `${colors.bgBlue(`${colors.bold(`${nodeVersion}`)}`)}`;
|
|
1115
|
-
const msg2 = ` ${
|
|
722
|
+
const msg2 = ` ${TranslationLoader5.t("webServerUseNodeVersion", this.localLang)}`;
|
|
1116
723
|
const msg3Value = `${colors.bgBlue(`${colors.bold(`${startingTime}`)}`)}`;
|
|
1117
|
-
const msg3 = ` ${
|
|
724
|
+
const msg3 = ` ${TranslationLoader5.t("startupTime", this.localLang)}`;
|
|
1118
725
|
const msg4 = ` ${this.getServerRunningMode("development", "production")}`;
|
|
1119
726
|
const msg5 = ` ${colors.underline(`http://${host}:${port}`)}`;
|
|
1120
727
|
console.log(chalk.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
@@ -1125,18 +732,18 @@ var Utility = class {
|
|
|
1125
732
|
console.log(chalk.bgGreen.white(msg5.padEnd(61, " ")));
|
|
1126
733
|
console.log(chalk.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
1127
734
|
console.log(``);
|
|
1128
|
-
console.log(`${`${
|
|
1129
|
-
console.log(`${`${
|
|
1130
|
-
console.log(`${`${
|
|
1131
|
-
console.log(`${`${
|
|
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}`)}`)}`);
|
|
1132
739
|
console.log(``);
|
|
1133
740
|
}
|
|
1134
741
|
};
|
|
1135
742
|
|
|
1136
743
|
// src/core/events/pathModuleVerifier.event.ts
|
|
1137
744
|
import { resolve } from "path";
|
|
1138
|
-
import { HttpStatusCode as
|
|
1139
|
-
import { TranslationLoader as
|
|
745
|
+
import { HttpStatusCode as HttpStatusCode4 } from "opticore-http-response";
|
|
746
|
+
import { TranslationLoader as TranslationLoader6 } from "opticore-translator";
|
|
1140
747
|
var PathModuleVerifier = class {
|
|
1141
748
|
log;
|
|
1142
749
|
localeLanguage;
|
|
@@ -1157,13 +764,13 @@ var PathModuleVerifier = class {
|
|
|
1157
764
|
}
|
|
1158
765
|
}
|
|
1159
766
|
if (notLoadedPaths.length > 0) {
|
|
1160
|
-
this.log.error(
|
|
1161
|
-
|
|
1162
|
-
"",
|
|
1163
|
-
"",
|
|
1164
|
-
modulePaths,
|
|
1165
|
-
|
|
1166
|
-
);
|
|
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
|
+
});
|
|
1167
774
|
throw new Error();
|
|
1168
775
|
}
|
|
1169
776
|
}
|
|
@@ -1183,9 +790,9 @@ var PathModuleVerifier = class {
|
|
|
1183
790
|
};
|
|
1184
791
|
|
|
1185
792
|
// src/core/config/loaders/localLanguage.loader.ts
|
|
1186
|
-
import
|
|
1187
|
-
import { TranslationLoader as
|
|
1188
|
-
import { HttpStatusCode as
|
|
793
|
+
import path4 from "path";
|
|
794
|
+
import { TranslationLoader as TranslationLoader7 } from "opticore-translator";
|
|
795
|
+
import { HttpStatusCode as HttpStatusCode5 } from "opticore-http-response";
|
|
1189
796
|
var LocalLanguageLoader = class {
|
|
1190
797
|
localeLanguage;
|
|
1191
798
|
environnementPath;
|
|
@@ -1195,40 +802,29 @@ var LocalLanguageLoader = class {
|
|
|
1195
802
|
}
|
|
1196
803
|
load() {
|
|
1197
804
|
try {
|
|
1198
|
-
const translateMsgJsonFilePath =
|
|
1199
|
-
|
|
805
|
+
const translateMsgJsonFilePath = path4.join(process.cwd(), "src", "utils", "translations");
|
|
806
|
+
TranslationLoader7.loadTranslations(translateMsgJsonFilePath);
|
|
1200
807
|
} catch (err) {
|
|
1201
|
-
SLoggerFileConfiguration(this.environnementPath).error(
|
|
1202
|
-
|
|
1203
|
-
err.
|
|
1204
|
-
err.code,
|
|
1205
|
-
err.
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
);
|
|
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
|
+
});
|
|
1209
815
|
}
|
|
1210
816
|
}
|
|
1211
|
-
absolutPath() {
|
|
1212
|
-
return path3.join(process.cwd(), "src", "utils", "translations");
|
|
1213
|
-
}
|
|
1214
817
|
};
|
|
1215
818
|
export {
|
|
1216
819
|
CLogLevel,
|
|
1217
820
|
CSignRSAKeyComponent,
|
|
1218
821
|
Environment,
|
|
1219
822
|
LocalLanguageLoader,
|
|
1220
|
-
MMongoCheckerDatabase,
|
|
1221
|
-
MMySqlCheckerDatabase,
|
|
1222
|
-
MPostgresCheckerDatabase,
|
|
1223
823
|
PathModuleVerifier,
|
|
1224
824
|
RSAKeyDecryption,
|
|
1225
825
|
RSAKeyEncryption,
|
|
1226
826
|
SAsymmetricCryptionDataWithPrivateRSAKey,
|
|
1227
827
|
SAsymmetricCryptionDataWithPublicRSAKey,
|
|
1228
|
-
SCheckerMongoDatabaseConnection,
|
|
1229
|
-
SCheckerMySqlDatabaseConnection,
|
|
1230
|
-
SCheckerPostgresDatabaseConnection,
|
|
1231
|
-
UOptionalArgumentConnection,
|
|
1232
828
|
Utility,
|
|
1233
829
|
YamlParsing,
|
|
1234
830
|
dateTimeFormatted,
|