opticore-webapp-core 1.0.7 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +231 -180
- package/dist/index.d.cts +50 -35
- package/dist/index.d.ts +50 -35
- package/dist/index.js +241 -190
- package/dist/utils/translations/message.translation.en.json +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -59,7 +59,6 @@ var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
|
59
59
|
// src/application/services/asymmetricCryptionDataWithPrivateRSAKey.service.ts
|
|
60
60
|
var import_crypto3 = __toESM(require("crypto"), 1);
|
|
61
61
|
var import_opticore_http_response = require("opticore-http-response");
|
|
62
|
-
var import_opticore_logger = require("opticore-logger");
|
|
63
62
|
var import_opticore_translator = require("opticore-translator");
|
|
64
63
|
var import_opticore_catch_exception_error = require("opticore-catch-exception-error");
|
|
65
64
|
|
|
@@ -189,6 +188,9 @@ var RSAKeyDecryption = class {
|
|
|
189
188
|
}
|
|
190
189
|
};
|
|
191
190
|
|
|
191
|
+
// src/application/services/loggerFileConfiguration.service.ts
|
|
192
|
+
var import_opticore_logger = require("opticore-logger");
|
|
193
|
+
|
|
192
194
|
// src/core/config/logger/logger.config.ts
|
|
193
195
|
var import_opticore_env_access = require("opticore-env-access");
|
|
194
196
|
var loggerConfig = {
|
|
@@ -215,28 +217,37 @@ var loggerConfig = {
|
|
|
215
217
|
}
|
|
216
218
|
};
|
|
217
219
|
|
|
220
|
+
// src/application/services/loggerFileConfiguration.service.ts
|
|
221
|
+
var SLoggerFileConfiguration = () => {
|
|
222
|
+
return new import_opticore_logger.LoggerCore(loggerConfig);
|
|
223
|
+
};
|
|
224
|
+
|
|
218
225
|
// src/application/services/asymmetricCryptionDataWithPrivateRSAKey.service.ts
|
|
219
226
|
var SAsymmetricCryptionDataWithPrivateRSAKey = class {
|
|
220
|
-
|
|
227
|
+
log = SLoggerFileConfiguration();
|
|
228
|
+
localeLanguage;
|
|
229
|
+
constructor(localeLanguage) {
|
|
230
|
+
this.localeLanguage = localeLanguage;
|
|
231
|
+
}
|
|
221
232
|
/**
|
|
222
|
-
*
|
|
233
|
+
*
|
|
223
234
|
* @param rsaKey
|
|
224
235
|
* @param keyType
|
|
225
236
|
* @protected
|
|
226
|
-
*
|
|
237
|
+
*
|
|
227
238
|
* Return ErrorHandler | string
|
|
228
239
|
*/
|
|
229
|
-
|
|
240
|
+
verifyExistingKey(rsaKey, keyType) {
|
|
230
241
|
if (!rsaKey) {
|
|
231
242
|
const stackTrace = this.traceError(
|
|
232
|
-
keyType + " " + import_opticore_translator.TranslationLoader.t("rsaKeyNotFound",
|
|
233
|
-
import_opticore_translator.TranslationLoader.t("erBadDbError",
|
|
243
|
+
keyType + " " + import_opticore_translator.TranslationLoader.t("rsaKeyNotFound", this.localeLanguage, this.log),
|
|
244
|
+
import_opticore_translator.TranslationLoader.t("erBadDbError", this.localeLanguage, this.log),
|
|
234
245
|
import_opticore_http_response.HttpStatusCode.NOT_FOUND
|
|
235
246
|
);
|
|
236
247
|
this.log.error(
|
|
237
|
-
import_opticore_translator.TranslationLoader.t("rsaKeyNotFound",
|
|
238
|
-
import_opticore_translator.TranslationLoader.t("verifyExistingKey",
|
|
239
|
-
import_opticore_translator.TranslationLoader.t("erBadDbError",
|
|
248
|
+
import_opticore_translator.TranslationLoader.t("rsaKeyNotFound", this.localeLanguage, this.log),
|
|
249
|
+
import_opticore_translator.TranslationLoader.t("verifyExistingKey", this.localeLanguage, this.log),
|
|
250
|
+
import_opticore_translator.TranslationLoader.t("erBadDbError", this.localeLanguage, this.log),
|
|
240
251
|
stackTrace.stack,
|
|
241
252
|
import_opticore_http_response.HttpStatusCode.NOT_FOUND
|
|
242
253
|
);
|
|
@@ -252,21 +263,21 @@ var SAsymmetricCryptionDataWithPrivateRSAKey = class {
|
|
|
252
263
|
*
|
|
253
264
|
* Return Buffer
|
|
254
265
|
*/
|
|
255
|
-
|
|
266
|
+
encryptionWithPrivateKey(privateKey, payload) {
|
|
256
267
|
this.verifyExistingKey(privateKey, CSignRSAKeyComponent.keyType.private);
|
|
257
268
|
try {
|
|
258
269
|
const bufferedData = Buffer.from(payload, Number(CSignRSAKeyComponent.encodingFormat));
|
|
259
270
|
return RSAKeyEncryption.privateEncrypt(privateKey, bufferedData);
|
|
260
271
|
} catch (err) {
|
|
261
272
|
const stackTrace = this.traceError(
|
|
262
|
-
import_opticore_translator.TranslationLoader.t("encryptionWithPrivateKeyFailed",
|
|
263
|
-
import_opticore_translator.TranslationLoader.t("encryptionFailed",
|
|
273
|
+
import_opticore_translator.TranslationLoader.t("encryptionWithPrivateKeyFailed", this.localeLanguage, this.log),
|
|
274
|
+
import_opticore_translator.TranslationLoader.t("encryptionFailed", this.localeLanguage, this.log),
|
|
264
275
|
import_opticore_http_response.HttpStatusCode.NOT_FOUND
|
|
265
276
|
);
|
|
266
277
|
this.log.error(
|
|
267
278
|
err.message,
|
|
268
|
-
import_opticore_translator.TranslationLoader.t("encryptionFailed",
|
|
269
|
-
import_opticore_translator.TranslationLoader.t("encryptionWithPrivateKeyFailed",
|
|
279
|
+
import_opticore_translator.TranslationLoader.t("encryptionFailed", this.localeLanguage, this.log),
|
|
280
|
+
import_opticore_translator.TranslationLoader.t("encryptionWithPrivateKeyFailed", this.localeLanguage, this.log),
|
|
270
281
|
stackTrace.stack,
|
|
271
282
|
import_opticore_http_response.HttpStatusCode.NOT_FOUND
|
|
272
283
|
);
|
|
@@ -280,22 +291,22 @@ var SAsymmetricCryptionDataWithPrivateRSAKey = class {
|
|
|
280
291
|
* @param payload
|
|
281
292
|
* @private
|
|
282
293
|
*/
|
|
283
|
-
|
|
294
|
+
decryptionWithPublicKey(privateKey, publicKey, payload) {
|
|
284
295
|
this.verifyExistingKey(publicKey, CSignRSAKeyComponent.keyType.public);
|
|
285
296
|
try {
|
|
286
297
|
const encryptedPayload = this.encryptionWithPrivateKey(privateKey, payload);
|
|
287
298
|
return RSAKeyDecryption.publicDecrypt(publicKey, encryptedPayload);
|
|
288
299
|
} catch (error) {
|
|
289
300
|
const stackTrace = this.traceError(
|
|
290
|
-
import_opticore_translator.TranslationLoader.t("errorDecryption",
|
|
291
|
-
import_opticore_translator.TranslationLoader.t("decryptionFailed",
|
|
301
|
+
import_opticore_translator.TranslationLoader.t("errorDecryption", this.localeLanguage, this.log),
|
|
302
|
+
import_opticore_translator.TranslationLoader.t("decryptionFailed", this.localeLanguage, this.log),
|
|
292
303
|
import_opticore_http_response.HttpStatusCode.NOT_ACCEPTABLE
|
|
293
304
|
);
|
|
294
305
|
this.log.error(
|
|
295
|
-
import_opticore_translator.TranslationLoader.t("decryptionWithPublicKeyFailed",
|
|
296
|
-
import_opticore_translator.TranslationLoader.t("decryptionFailed",
|
|
306
|
+
import_opticore_translator.TranslationLoader.t("decryptionWithPublicKeyFailed", this.localeLanguage, this.log),
|
|
307
|
+
import_opticore_translator.TranslationLoader.t("decryptionFailed", this.localeLanguage, this.log),
|
|
297
308
|
stackTrace.stack,
|
|
298
|
-
import_opticore_translator.TranslationLoader.t("errorDecryption",
|
|
309
|
+
import_opticore_translator.TranslationLoader.t("errorDecryption", this.localeLanguage, this.log),
|
|
299
310
|
import_opticore_http_response.HttpStatusCode.NOT_ACCEPTABLE
|
|
300
311
|
);
|
|
301
312
|
throw new Error();
|
|
@@ -307,7 +318,7 @@ var SAsymmetricCryptionDataWithPrivateRSAKey = class {
|
|
|
307
318
|
* @param payload
|
|
308
319
|
* @private
|
|
309
320
|
*/
|
|
310
|
-
|
|
321
|
+
signWithRSAKey(privateKey, payload) {
|
|
311
322
|
this.verifyExistingKey(privateKey, CSignRSAKeyComponent.keyType.private);
|
|
312
323
|
const sign = import_crypto3.default.createSign(CSignRSAKeyComponent.algorithm.sha256);
|
|
313
324
|
sign.update(payload);
|
|
@@ -319,7 +330,7 @@ var SAsymmetricCryptionDataWithPrivateRSAKey = class {
|
|
|
319
330
|
* @param publicKey
|
|
320
331
|
* @param payload
|
|
321
332
|
*/
|
|
322
|
-
|
|
333
|
+
verifyRSAKey(privateKey, publicKey, payload) {
|
|
323
334
|
try {
|
|
324
335
|
const verify = import_crypto3.default.createVerify(CSignRSAKeyComponent.algorithm.sha256);
|
|
325
336
|
verify.update(payload);
|
|
@@ -330,15 +341,15 @@ var SAsymmetricCryptionDataWithPrivateRSAKey = class {
|
|
|
330
341
|
return decryptedData.toString(CSignRSAKeyComponent.encodingFormat.utf_8);
|
|
331
342
|
} else {
|
|
332
343
|
const stackTrace = this.traceError(
|
|
333
|
-
import_opticore_translator.TranslationLoader.t("signatureRSAKeyFailed",
|
|
334
|
-
import_opticore_translator.TranslationLoader.t("verifyRSAKeyFailed",
|
|
344
|
+
import_opticore_translator.TranslationLoader.t("signatureRSAKeyFailed", this.localeLanguage, this.log),
|
|
345
|
+
import_opticore_translator.TranslationLoader.t("verifyRSAKeyFailed", this.localeLanguage, this.log),
|
|
335
346
|
import_opticore_http_response.HttpStatusCode.NOT_ACCEPTABLE
|
|
336
347
|
);
|
|
337
348
|
this.log.error(
|
|
338
|
-
import_opticore_translator.TranslationLoader.t("verifyRSAKey",
|
|
339
|
-
import_opticore_translator.TranslationLoader.t("verifyRSAKeyFailed",
|
|
349
|
+
import_opticore_translator.TranslationLoader.t("verifyRSAKey", this.localeLanguage, this.log),
|
|
350
|
+
import_opticore_translator.TranslationLoader.t("verifyRSAKeyFailed", this.localeLanguage, this.log),
|
|
340
351
|
stackTrace.stack,
|
|
341
|
-
import_opticore_translator.TranslationLoader.t("signatureRSAKeyFailed",
|
|
352
|
+
import_opticore_translator.TranslationLoader.t("signatureRSAKeyFailed", this.localeLanguage, this.log),
|
|
342
353
|
import_opticore_http_response.HttpStatusCode.NOT_FOUND
|
|
343
354
|
);
|
|
344
355
|
return new Error();
|
|
@@ -346,12 +357,12 @@ var SAsymmetricCryptionDataWithPrivateRSAKey = class {
|
|
|
346
357
|
} catch (err) {
|
|
347
358
|
const stackTrace = this.traceError(
|
|
348
359
|
err.name,
|
|
349
|
-
import_opticore_translator.TranslationLoader.t("signatureRSAKeysError",
|
|
360
|
+
import_opticore_translator.TranslationLoader.t("signatureRSAKeysError", this.localeLanguage, this.log),
|
|
350
361
|
import_opticore_http_response.HttpStatusCode.NOT_ACCEPTABLE
|
|
351
362
|
);
|
|
352
363
|
this.log.error(
|
|
353
|
-
import_opticore_translator.TranslationLoader.t("signatureRSAKeysError",
|
|
354
|
-
import_opticore_translator.TranslationLoader.t("errorNameNotVerifyingRSAKey",
|
|
364
|
+
import_opticore_translator.TranslationLoader.t("signatureRSAKeysError", this.localeLanguage, this.log),
|
|
365
|
+
import_opticore_translator.TranslationLoader.t("errorNameNotVerifyingRSAKey", this.localeLanguage, this.log),
|
|
355
366
|
stackTrace.stack,
|
|
356
367
|
err.message,
|
|
357
368
|
import_opticore_http_response.HttpStatusCode.NOT_FOUND
|
|
@@ -366,37 +377,41 @@ var SAsymmetricCryptionDataWithPrivateRSAKey = class {
|
|
|
366
377
|
* @param status
|
|
367
378
|
* @private
|
|
368
379
|
*/
|
|
369
|
-
|
|
380
|
+
traceError(props, name, status7) {
|
|
370
381
|
return new import_opticore_catch_exception_error.StackTraceError(props, name, status7, true);
|
|
371
382
|
}
|
|
372
383
|
};
|
|
373
384
|
|
|
374
385
|
// src/application/services/asymmetricCryptionDataWithPublicRSAKey.service.ts
|
|
375
386
|
var import_crypto4 = __toESM(require("crypto"), 1);
|
|
376
|
-
var import_opticore_logger2 = require("opticore-logger");
|
|
377
387
|
var import_opticore_translator2 = require("opticore-translator");
|
|
378
388
|
var import_opticore_http_response2 = require("opticore-http-response");
|
|
379
389
|
var import_opticore_catch_exception_error2 = require("opticore-catch-exception-error");
|
|
380
390
|
var SAsymmetricCryptionDataWithPublicRSAKey = class {
|
|
381
|
-
|
|
391
|
+
logger = SLoggerFileConfiguration();
|
|
392
|
+
localeLanguage;
|
|
393
|
+
constructor(localeLanguage) {
|
|
394
|
+
this.localeLanguage = localeLanguage;
|
|
395
|
+
}
|
|
382
396
|
/**
|
|
383
397
|
*
|
|
384
398
|
* @param rsaKey
|
|
385
399
|
* @param keyType
|
|
400
|
+
*
|
|
386
401
|
* @protected
|
|
387
402
|
*/
|
|
388
|
-
|
|
403
|
+
verifyExistingKey(rsaKey, keyType) {
|
|
389
404
|
if (!rsaKey) {
|
|
390
405
|
const stackTrace = this.traceError(
|
|
391
|
-
keyType + import_opticore_translator2.TranslationLoader.t("verifyExistingKey",
|
|
392
|
-
import_opticore_translator2.TranslationLoader.t("verifyExistingKey",
|
|
406
|
+
keyType + import_opticore_translator2.TranslationLoader.t("verifyExistingKey", this.localeLanguage, this.logger),
|
|
407
|
+
import_opticore_translator2.TranslationLoader.t("verifyExistingKey", this.localeLanguage, this.logger),
|
|
393
408
|
import_opticore_http_response2.HttpStatusCode.NOT_FOUND
|
|
394
409
|
);
|
|
395
|
-
this.
|
|
396
|
-
import_opticore_translator2.TranslationLoader.t("verifyExistingKey",
|
|
410
|
+
this.logger.error(
|
|
411
|
+
import_opticore_translator2.TranslationLoader.t("verifyExistingKey", this.localeLanguage, this.logger),
|
|
397
412
|
"key verification",
|
|
398
413
|
stackTrace.stack,
|
|
399
|
-
import_opticore_translator2.TranslationLoader.t("verifyExistingKeyError",
|
|
414
|
+
import_opticore_translator2.TranslationLoader.t("verifyExistingKeyError", this.localeLanguage, this.logger),
|
|
400
415
|
import_opticore_http_response2.HttpStatusCode.NOT_FOUND
|
|
401
416
|
);
|
|
402
417
|
return new Error();
|
|
@@ -407,9 +422,10 @@ var SAsymmetricCryptionDataWithPublicRSAKey = class {
|
|
|
407
422
|
*
|
|
408
423
|
* @param publicKey
|
|
409
424
|
* @param payload
|
|
425
|
+
*
|
|
410
426
|
* @private
|
|
411
427
|
*/
|
|
412
|
-
|
|
428
|
+
encryptionWithPublicKey(publicKey, payload) {
|
|
413
429
|
this.verifyExistingKey(publicKey, CSignRSAKeyComponent.keyType.public);
|
|
414
430
|
try {
|
|
415
431
|
const bufferedData = Buffer.from(payload, Number(CSignRSAKeyComponent.encodingFormat));
|
|
@@ -417,12 +433,12 @@ var SAsymmetricCryptionDataWithPublicRSAKey = class {
|
|
|
417
433
|
} catch (err) {
|
|
418
434
|
const stackTrace = this.traceError(
|
|
419
435
|
err.message,
|
|
420
|
-
import_opticore_translator2.TranslationLoader.t("encryptionWithPublicKey",
|
|
436
|
+
import_opticore_translator2.TranslationLoader.t("encryptionWithPublicKey", this.localeLanguage, this.logger),
|
|
421
437
|
import_opticore_http_response2.HttpStatusCode.NOT_ACCEPTABLE
|
|
422
438
|
);
|
|
423
|
-
this.
|
|
424
|
-
import_opticore_translator2.TranslationLoader.t("errorEncryptionPublicKey",
|
|
425
|
-
import_opticore_translator2.TranslationLoader.t("encryptionWithPublicKey",
|
|
439
|
+
this.logger.error(
|
|
440
|
+
import_opticore_translator2.TranslationLoader.t("errorEncryptionPublicKey", this.localeLanguage, this.logger),
|
|
441
|
+
import_opticore_translator2.TranslationLoader.t("encryptionWithPublicKey", this.localeLanguage, this.logger),
|
|
426
442
|
stackTrace.stack,
|
|
427
443
|
err.message,
|
|
428
444
|
import_opticore_http_response2.HttpStatusCode.NOT_ACCEPTABLE
|
|
@@ -435,9 +451,10 @@ var SAsymmetricCryptionDataWithPublicRSAKey = class {
|
|
|
435
451
|
* @param privateKey
|
|
436
452
|
* @param publicKey
|
|
437
453
|
* @param payload
|
|
454
|
+
*
|
|
438
455
|
* @private
|
|
439
456
|
*/
|
|
440
|
-
|
|
457
|
+
decryptionWithPrivateKey(privateKey, publicKey, payload) {
|
|
441
458
|
this.verifyExistingKey(publicKey, CSignRSAKeyComponent.keyType.public);
|
|
442
459
|
try {
|
|
443
460
|
const encryptedPayload = this.encryptionWithPublicKey(publicKey, payload);
|
|
@@ -445,12 +462,12 @@ var SAsymmetricCryptionDataWithPublicRSAKey = class {
|
|
|
445
462
|
} catch (err) {
|
|
446
463
|
const stackTrace = this.traceError(
|
|
447
464
|
err.code,
|
|
448
|
-
import_opticore_translator2.TranslationLoader.t("errorDecryption",
|
|
465
|
+
import_opticore_translator2.TranslationLoader.t("errorDecryption", this.localeLanguage, this.logger),
|
|
449
466
|
import_opticore_http_response2.HttpStatusCode.NOT_ACCEPTABLE
|
|
450
467
|
);
|
|
451
|
-
this.
|
|
452
|
-
import_opticore_translator2.TranslationLoader.t("errorDecryptionWithPrivateKey",
|
|
453
|
-
import_opticore_translator2.TranslationLoader.t("errorDecryption",
|
|
468
|
+
this.logger.error(
|
|
469
|
+
import_opticore_translator2.TranslationLoader.t("errorDecryptionWithPrivateKey", this.localeLanguage, this.logger),
|
|
470
|
+
import_opticore_translator2.TranslationLoader.t("errorDecryption", this.localeLanguage, this.logger),
|
|
454
471
|
stackTrace.stack,
|
|
455
472
|
err.message,
|
|
456
473
|
import_opticore_http_response2.HttpStatusCode.NOT_ACCEPTABLE
|
|
@@ -462,9 +479,10 @@ var SAsymmetricCryptionDataWithPublicRSAKey = class {
|
|
|
462
479
|
*
|
|
463
480
|
* @param publicKey
|
|
464
481
|
* @param payload
|
|
482
|
+
*
|
|
465
483
|
* @private
|
|
466
484
|
*/
|
|
467
|
-
|
|
485
|
+
signWithPublicRSAKey(publicKey, payload) {
|
|
468
486
|
this.verifyExistingKey(publicKey, CSignRSAKeyComponent.keyType.private);
|
|
469
487
|
const sign = import_crypto4.default.createSign(CSignRSAKeyComponent.algorithm.sha256);
|
|
470
488
|
sign.update(payload);
|
|
@@ -475,8 +493,9 @@ var SAsymmetricCryptionDataWithPublicRSAKey = class {
|
|
|
475
493
|
* @param privateKey
|
|
476
494
|
* @param publicKey
|
|
477
495
|
* @param payload
|
|
496
|
+
*
|
|
478
497
|
*/
|
|
479
|
-
|
|
498
|
+
verifyPublicRSAKey(privateKey, publicKey, payload) {
|
|
480
499
|
try {
|
|
481
500
|
const verify = import_crypto4.default.createVerify(CSignRSAKeyComponent.algorithm.sha256);
|
|
482
501
|
verify.update(payload);
|
|
@@ -487,15 +506,15 @@ var SAsymmetricCryptionDataWithPublicRSAKey = class {
|
|
|
487
506
|
return decryptedData.toString(CSignRSAKeyComponent.encodingFormat.utf_8);
|
|
488
507
|
} else {
|
|
489
508
|
const stackTrace = this.traceError(
|
|
490
|
-
import_opticore_translator2.TranslationLoader.t("verifyPublicRSAKeyError",
|
|
491
|
-
import_opticore_translator2.TranslationLoader.t("signatureRSAKeyFailed",
|
|
509
|
+
import_opticore_translator2.TranslationLoader.t("verifyPublicRSAKeyError", this.localeLanguage, this.logger),
|
|
510
|
+
import_opticore_translator2.TranslationLoader.t("signatureRSAKeyFailed", this.localeLanguage, this.logger),
|
|
492
511
|
import_opticore_http_response2.HttpStatusCode.NOT_FOUND
|
|
493
512
|
);
|
|
494
|
-
this.
|
|
495
|
-
import_opticore_translator2.TranslationLoader.t("verifyPublicRSAKey",
|
|
496
|
-
import_opticore_translator2.TranslationLoader.t("signatureRSAKeyFailed",
|
|
513
|
+
this.logger.error(
|
|
514
|
+
import_opticore_translator2.TranslationLoader.t("verifyPublicRSAKey", this.localeLanguage, this.logger),
|
|
515
|
+
import_opticore_translator2.TranslationLoader.t("signatureRSAKeyFailed", this.localeLanguage, this.logger),
|
|
497
516
|
stackTrace.stack,
|
|
498
|
-
import_opticore_translator2.TranslationLoader.t("verifyPublicRSAKeyError",
|
|
517
|
+
import_opticore_translator2.TranslationLoader.t("verifyPublicRSAKeyError", this.localeLanguage, this.logger),
|
|
499
518
|
import_opticore_http_response2.HttpStatusCode.NOT_FOUND
|
|
500
519
|
);
|
|
501
520
|
return stackTrace;
|
|
@@ -503,12 +522,12 @@ var SAsymmetricCryptionDataWithPublicRSAKey = class {
|
|
|
503
522
|
} catch (err) {
|
|
504
523
|
const stackTrace = this.traceError(
|
|
505
524
|
err.code,
|
|
506
|
-
import_opticore_translator2.TranslationLoader.t("verifyPublicRSAKey",
|
|
525
|
+
import_opticore_translator2.TranslationLoader.t("verifyPublicRSAKey", this.localeLanguage, this.logger),
|
|
507
526
|
import_opticore_http_response2.HttpStatusCode.NOT_ACCEPTABLE
|
|
508
527
|
);
|
|
509
|
-
this.
|
|
510
|
-
import_opticore_translator2.TranslationLoader.t("verifyPublicRSAKey",
|
|
511
|
-
import_opticore_translator2.TranslationLoader.t("errorDecryption",
|
|
528
|
+
this.logger.error(
|
|
529
|
+
import_opticore_translator2.TranslationLoader.t("verifyPublicRSAKey", this.localeLanguage, this.logger),
|
|
530
|
+
import_opticore_translator2.TranslationLoader.t("errorDecryption", this.localeLanguage, this.logger),
|
|
512
531
|
stackTrace.stack,
|
|
513
532
|
err.message,
|
|
514
533
|
import_opticore_http_response2.HttpStatusCode.NOT_ACCEPTABLE
|
|
@@ -516,7 +535,7 @@ var SAsymmetricCryptionDataWithPublicRSAKey = class {
|
|
|
516
535
|
throw new Error();
|
|
517
536
|
}
|
|
518
537
|
}
|
|
519
|
-
|
|
538
|
+
traceError(props, name, status7) {
|
|
520
539
|
return new import_opticore_catch_exception_error2.StackTraceError(props, name, status7, true);
|
|
521
540
|
}
|
|
522
541
|
};
|
|
@@ -534,44 +553,44 @@ async function SCheckerMongoDatabaseConnection(url, user, password, dbName) {
|
|
|
534
553
|
}
|
|
535
554
|
|
|
536
555
|
// src/core/handlers/errors/database/mySqlError.handler.database.ts
|
|
537
|
-
var
|
|
556
|
+
var import_opticore_logger2 = require("opticore-logger");
|
|
538
557
|
var import_opticore_http_response3 = require("opticore-http-response");
|
|
539
558
|
var import_opticore_translator3 = require("opticore-translator");
|
|
540
|
-
function mySqlErrorHandlerDatabase(err, dbHost, database, user, password) {
|
|
541
|
-
const logger = new
|
|
559
|
+
function mySqlErrorHandlerDatabase(localLanguage, err, dbHost, database, user, password) {
|
|
560
|
+
const logger = new import_opticore_logger2.LoggerCore(loggerConfig);
|
|
542
561
|
switch (err.code) {
|
|
543
562
|
case "EAI_AGAIN":
|
|
544
563
|
logger.error(
|
|
545
|
-
import_opticore_translator3.TranslationLoader.t("errorDBHost",
|
|
546
|
-
import_opticore_translator3.TranslationLoader.t("mySQLError",
|
|
547
|
-
import_opticore_translator3.TranslationLoader.t("eAiAgain",
|
|
564
|
+
import_opticore_translator3.TranslationLoader.t("errorDBHost", localLanguage, { dbHost }),
|
|
565
|
+
import_opticore_translator3.TranslationLoader.t("mySQLError", localLanguage),
|
|
566
|
+
import_opticore_translator3.TranslationLoader.t("eAiAgain", localLanguage),
|
|
548
567
|
err.stack,
|
|
549
568
|
import_opticore_http_response3.HttpStatusCode.NOT_ACCEPTABLE
|
|
550
569
|
);
|
|
551
570
|
break;
|
|
552
571
|
case "ER_NOT_SUPPORTED_AUTH_MODE":
|
|
553
572
|
logger.error(
|
|
554
|
-
import_opticore_translator3.TranslationLoader.t("erNotSupportedAuthModeError",
|
|
555
|
-
import_opticore_translator3.TranslationLoader.t("dbConnection",
|
|
556
|
-
import_opticore_translator3.TranslationLoader.t("erNotSupportedAuthMode",
|
|
573
|
+
import_opticore_translator3.TranslationLoader.t("erNotSupportedAuthModeError", localLanguage),
|
|
574
|
+
import_opticore_translator3.TranslationLoader.t("dbConnection", localLanguage),
|
|
575
|
+
import_opticore_translator3.TranslationLoader.t("erNotSupportedAuthMode", localLanguage),
|
|
557
576
|
err.stack,
|
|
558
577
|
import_opticore_http_response3.HttpStatusCode.NOT_ACCEPTABLE
|
|
559
578
|
);
|
|
560
579
|
break;
|
|
561
580
|
case "ER_ACCESS_DENIED_ERROR":
|
|
562
581
|
logger.error(
|
|
563
|
-
import_opticore_translator3.TranslationLoader.t("accessDeniedToDBCon",
|
|
564
|
-
import_opticore_translator3.TranslationLoader.t("dbConnection",
|
|
565
|
-
import_opticore_translator3.TranslationLoader.t("erAccessDeniedError",
|
|
582
|
+
import_opticore_translator3.TranslationLoader.t("accessDeniedToDBCon", localLanguage, { user, password }),
|
|
583
|
+
import_opticore_translator3.TranslationLoader.t("dbConnection", localLanguage),
|
|
584
|
+
import_opticore_translator3.TranslationLoader.t("erAccessDeniedError", localLanguage),
|
|
566
585
|
err.stack,
|
|
567
586
|
import_opticore_http_response3.HttpStatusCode.NOT_ACCEPTABLE
|
|
568
587
|
);
|
|
569
588
|
break;
|
|
570
589
|
case "ER_BAD_DB_ERROR":
|
|
571
590
|
logger.error(
|
|
572
|
-
import_opticore_translator3.TranslationLoader.t("unknownDB",
|
|
573
|
-
import_opticore_translator3.TranslationLoader.t("dbConnection",
|
|
574
|
-
import_opticore_translator3.TranslationLoader.t("erBadDbError",
|
|
591
|
+
import_opticore_translator3.TranslationLoader.t("unknownDB", localLanguage, { database }),
|
|
592
|
+
import_opticore_translator3.TranslationLoader.t("dbConnection", localLanguage),
|
|
593
|
+
import_opticore_translator3.TranslationLoader.t("erBadDbError", localLanguage),
|
|
575
594
|
err.stack,
|
|
576
595
|
import_opticore_http_response3.HttpStatusCode.NOT_ACCEPTABLE
|
|
577
596
|
);
|
|
@@ -579,8 +598,8 @@ function mySqlErrorHandlerDatabase(err, dbHost, database, user, password) {
|
|
|
579
598
|
default:
|
|
580
599
|
logger.error(
|
|
581
600
|
err.message,
|
|
582
|
-
import_opticore_translator3.TranslationLoader.t("dbConnection",
|
|
583
|
-
import_opticore_translator3.TranslationLoader.t("mysqlErrorCon",
|
|
601
|
+
import_opticore_translator3.TranslationLoader.t("dbConnection", localLanguage),
|
|
602
|
+
import_opticore_translator3.TranslationLoader.t("mysqlErrorCon", localLanguage),
|
|
584
603
|
err.stack,
|
|
585
604
|
import_opticore_http_response3.HttpStatusCode.NOT_ACCEPTABLE
|
|
586
605
|
);
|
|
@@ -589,25 +608,24 @@ function mySqlErrorHandlerDatabase(err, dbHost, database, user, password) {
|
|
|
589
608
|
}
|
|
590
609
|
|
|
591
610
|
// src/application/services/checkerMySqlDatabaseConnection.service.ts
|
|
592
|
-
var import_opticore_logger4 = require("opticore-logger");
|
|
593
611
|
var import_opticore_translator4 = require("opticore-translator");
|
|
594
|
-
function SCheckerMySqlDatabaseConnection(dbConnection, user, database, dbHost, password) {
|
|
595
|
-
const
|
|
612
|
+
function SCheckerMySqlDatabaseConnection(localeLanguage, dbConnection, user, database, dbHost, password) {
|
|
613
|
+
const logger = SLoggerFileConfiguration();
|
|
596
614
|
dbConnection.connect((err) => {
|
|
597
615
|
if (err) {
|
|
598
|
-
return mySqlErrorHandlerDatabase(err, dbHost, database, user, password);
|
|
616
|
+
return mySqlErrorHandlerDatabase(localeLanguage, err, dbHost, database, user, password);
|
|
599
617
|
} else {
|
|
600
|
-
|
|
601
|
-
import_opticore_translator4.TranslationLoader.t("dbConnection",
|
|
602
|
-
import_opticore_translator4.TranslationLoader.t("dbConnexionSuccess",
|
|
618
|
+
logger.success(
|
|
619
|
+
import_opticore_translator4.TranslationLoader.t("dbConnection", localeLanguage, logger),
|
|
620
|
+
import_opticore_translator4.TranslationLoader.t("dbConnexionSuccess", localeLanguage, logger)
|
|
603
621
|
);
|
|
604
622
|
return dbConnection.end((endConErr) => {
|
|
605
623
|
if (endConErr) {
|
|
606
|
-
return mySqlErrorHandlerDatabase(err, dbHost, database, user, password);
|
|
624
|
+
return mySqlErrorHandlerDatabase(localeLanguage, err, dbHost, database, user, password);
|
|
607
625
|
} else {
|
|
608
|
-
|
|
609
|
-
import_opticore_translator4.TranslationLoader.t("dbConnection",
|
|
610
|
-
import_opticore_translator4.TranslationLoader.t("dbConnectionClosed",
|
|
626
|
+
logger.success(
|
|
627
|
+
import_opticore_translator4.TranslationLoader.t("dbConnection", localeLanguage, logger),
|
|
628
|
+
import_opticore_translator4.TranslationLoader.t("dbConnectionClosed", localeLanguage, logger)
|
|
611
629
|
);
|
|
612
630
|
console.log("");
|
|
613
631
|
}
|
|
@@ -618,11 +636,10 @@ function SCheckerMySqlDatabaseConnection(dbConnection, user, database, dbHost, p
|
|
|
618
636
|
|
|
619
637
|
// src/application/services/checkerPostgresDatabaseConnection.service.ts
|
|
620
638
|
var import_opticore_http_response4 = require("opticore-http-response");
|
|
621
|
-
var import_pg = require("pg");
|
|
622
|
-
var import_opticore_logger5 = require("opticore-logger");
|
|
639
|
+
var import_pg = __toESM(require("pg"), 1);
|
|
623
640
|
var import_opticore_translator5 = require("opticore-translator");
|
|
624
|
-
async function SCheckerPostgresDatabaseConnection(connectionString, keepAlive, stream, statement_timeout, ssl, query_timeout, keepAliveInitialDelayMillis, idle_in_transaction_session_timeout, application_name, connectionTimeoutMillis, types, options) {
|
|
625
|
-
const logger =
|
|
641
|
+
async function SCheckerPostgresDatabaseConnection(localeLanguage, connectionString, keepAlive, stream, statement_timeout, ssl, query_timeout, keepAliveInitialDelayMillis, idle_in_transaction_session_timeout, application_name, connectionTimeoutMillis, types, options) {
|
|
642
|
+
const logger = SLoggerFileConfiguration();
|
|
626
643
|
const configOptions = {
|
|
627
644
|
connectionString,
|
|
628
645
|
keepAlive,
|
|
@@ -637,20 +654,20 @@ async function SCheckerPostgresDatabaseConnection(connectionString, keepAlive, s
|
|
|
637
654
|
types,
|
|
638
655
|
options
|
|
639
656
|
};
|
|
640
|
-
const client = new import_pg.Client(configOptions);
|
|
657
|
+
const client = new import_pg.default.Client(configOptions);
|
|
641
658
|
await client.connect();
|
|
642
659
|
await client.end().then(
|
|
643
660
|
() => {
|
|
644
661
|
logger.success(
|
|
645
|
-
import_opticore_translator5.TranslationLoader.t("postgresSuccessConn",
|
|
646
|
-
import_opticore_translator5.TranslationLoader.t("postgresClosingConnSuccess",
|
|
662
|
+
import_opticore_translator5.TranslationLoader.t("postgresSuccessConn", localeLanguage, logger),
|
|
663
|
+
import_opticore_translator5.TranslationLoader.t("postgresClosingConnSuccess", localeLanguage, logger)
|
|
647
664
|
);
|
|
648
665
|
},
|
|
649
666
|
(onRejected) => {
|
|
650
667
|
logger.error(
|
|
651
|
-
import_opticore_translator5.TranslationLoader.t("postgresEndClientRejection",
|
|
652
|
-
import_opticore_translator5.TranslationLoader.t("postgresClientError",
|
|
653
|
-
import_opticore_translator5.TranslationLoader.t("postgresEndRejection",
|
|
668
|
+
import_opticore_translator5.TranslationLoader.t("postgresEndClientRejection", localeLanguage, logger),
|
|
669
|
+
import_opticore_translator5.TranslationLoader.t("postgresClientError", localeLanguage, logger),
|
|
670
|
+
import_opticore_translator5.TranslationLoader.t("postgresEndRejection", localeLanguage, logger),
|
|
654
671
|
onRejected,
|
|
655
672
|
import_opticore_http_response4.HttpStatusCode.BAD_REQUEST
|
|
656
673
|
);
|
|
@@ -658,8 +675,8 @@ async function SCheckerPostgresDatabaseConnection(connectionString, keepAlive, s
|
|
|
658
675
|
).catch((onError) => {
|
|
659
676
|
logger.error(
|
|
660
677
|
onError.message,
|
|
661
|
-
import_opticore_translator5.TranslationLoader.t("postgresConnError",
|
|
662
|
-
import_opticore_translator5.TranslationLoader.t("postgresException",
|
|
678
|
+
import_opticore_translator5.TranslationLoader.t("postgresConnError", localeLanguage, logger),
|
|
679
|
+
import_opticore_translator5.TranslationLoader.t("postgresException", localeLanguage, logger),
|
|
663
680
|
onError.stack,
|
|
664
681
|
import_opticore_http_response4.HttpStatusCode.BAD_REQUEST
|
|
665
682
|
);
|
|
@@ -681,51 +698,48 @@ var optionalArgumentConnectionUtil = import_opticore_env_access2.getEnvVariable.
|
|
|
681
698
|
// src/utils/parsing/parsingYaml.utils.ts
|
|
682
699
|
var import_promises = require("fs/promises");
|
|
683
700
|
var import_opticore_http_response5 = require("opticore-http-response");
|
|
684
|
-
var
|
|
701
|
+
var import_opticore_logger3 = require("opticore-logger");
|
|
685
702
|
var import_opticore_translator7 = require("opticore-translator");
|
|
686
703
|
|
|
687
704
|
// src/core/config/loaders/translateLanguage.loader.ts
|
|
688
705
|
var import_path = __toESM(require("path"), 1);
|
|
689
706
|
var import_module = require("module");
|
|
690
707
|
var import_opticore_translator6 = require("opticore-translator");
|
|
691
|
-
var translateWebAppCoreLanguageLoader = (
|
|
708
|
+
var translateWebAppCoreLanguageLoader = () => {
|
|
692
709
|
const require2 = (0, import_module.createRequire)(importMetaUrl);
|
|
693
710
|
const packagePath = import_path.default.dirname(require2.resolve("opticore-webapp-core"));
|
|
694
711
|
const translateMsgJsonFilePath = import_path.default.join(packagePath, "utils", "translations");
|
|
695
|
-
import_opticore_translator6.TranslationLoader.loadTranslations(translateMsgJsonFilePath
|
|
712
|
+
import_opticore_translator6.TranslationLoader.loadTranslations(translateMsgJsonFilePath);
|
|
696
713
|
};
|
|
697
714
|
|
|
698
715
|
// src/utils/parsing/parsingYaml.utils.ts
|
|
699
716
|
var YamlParsing = class {
|
|
700
|
-
|
|
701
|
-
|
|
717
|
+
logger = new import_opticore_logger3.LoggerCore(loggerConfig);
|
|
718
|
+
localeLanguage;
|
|
719
|
+
constructor(localeLanguage) {
|
|
720
|
+
this.localeLanguage = localeLanguage;
|
|
721
|
+
translateWebAppCoreLanguageLoader();
|
|
722
|
+
}
|
|
723
|
+
async readFile(filePath) {
|
|
702
724
|
try {
|
|
703
725
|
const yamlContent = await (0, import_promises.readFile)(filePath, "utf-8");
|
|
704
726
|
await this.parsing(yamlContent);
|
|
705
727
|
} catch (error) {
|
|
706
728
|
this.logger.error(
|
|
707
729
|
error.message,
|
|
708
|
-
import_opticore_translator7.TranslationLoader.t("parsingFailed",
|
|
709
|
-
import_opticore_translator7.TranslationLoader.t("readingError",
|
|
730
|
+
import_opticore_translator7.TranslationLoader.t("parsingFailed", this.localeLanguage, this.logger),
|
|
731
|
+
import_opticore_translator7.TranslationLoader.t("readingError", this.localeLanguage, this.logger),
|
|
710
732
|
error.stack,
|
|
711
733
|
import_opticore_http_response5.HttpStatusCode.NOT_ACCEPTABLE
|
|
712
734
|
);
|
|
713
735
|
}
|
|
714
736
|
}
|
|
715
|
-
/**
|
|
716
|
-
*
|
|
717
|
-
* @param defaultLocalLang
|
|
718
|
-
*/
|
|
719
|
-
static __init(defaultLocalLang) {
|
|
720
|
-
translateWebAppCoreLanguageLoader(defaultLocalLang);
|
|
721
|
-
return this;
|
|
722
|
-
}
|
|
723
737
|
/**
|
|
724
738
|
*
|
|
725
739
|
* @param content
|
|
726
740
|
* @private
|
|
727
741
|
*/
|
|
728
|
-
|
|
742
|
+
async parsing(content) {
|
|
729
743
|
const result = {};
|
|
730
744
|
const lines = content.split("\n");
|
|
731
745
|
let currentKey = null;
|
|
@@ -745,9 +759,9 @@ var YamlParsing = class {
|
|
|
745
759
|
}
|
|
746
760
|
} else {
|
|
747
761
|
this.logger.error(
|
|
748
|
-
import_opticore_translator7.TranslationLoader.t("badFormat",
|
|
749
|
-
import_opticore_translator7.TranslationLoader.t("parsingFailed",
|
|
750
|
-
import_opticore_translator7.TranslationLoader.t("unsupportedFormat",
|
|
762
|
+
import_opticore_translator7.TranslationLoader.t("badFormat", this.localeLanguage, { line }),
|
|
763
|
+
import_opticore_translator7.TranslationLoader.t("parsingFailed", this.localeLanguage, this.logger),
|
|
764
|
+
import_opticore_translator7.TranslationLoader.t("unsupportedFormat", this.localeLanguage, this.logger),
|
|
751
765
|
content,
|
|
752
766
|
import_opticore_http_response5.HttpStatusCode.NOT_ACCEPTABLE
|
|
753
767
|
);
|
|
@@ -775,30 +789,34 @@ var Environment = class {
|
|
|
775
789
|
var import_mysql = __toESM(require("mysql"), 1);
|
|
776
790
|
var import_opticore_http_response7 = require("opticore-http-response");
|
|
777
791
|
var import_opticore_env_access3 = require("opticore-env-access");
|
|
778
|
-
var
|
|
792
|
+
var import_opticore_logger5 = require("opticore-logger");
|
|
779
793
|
var import_opticore_translator9 = require("opticore-translator");
|
|
780
794
|
|
|
781
795
|
// src/core/errors/databaseConnexion.error.ts
|
|
782
796
|
var import_opticore_http_response6 = require("opticore-http-response");
|
|
783
|
-
var
|
|
797
|
+
var import_opticore_logger4 = require("opticore-logger");
|
|
784
798
|
var import_opticore_catch_exception_error3 = require("opticore-catch-exception-error");
|
|
785
799
|
var import_opticore_translator8 = require("opticore-translator");
|
|
786
800
|
var DbConnexionConfigError = class {
|
|
787
|
-
|
|
801
|
+
logger = new import_opticore_logger4.LoggerCore(loggerConfig);
|
|
802
|
+
localeLanguage;
|
|
803
|
+
constructor(localeLanguage) {
|
|
804
|
+
this.localeLanguage = localeLanguage;
|
|
805
|
+
}
|
|
788
806
|
/**
|
|
789
807
|
*
|
|
790
808
|
* @param e
|
|
791
809
|
*/
|
|
792
|
-
|
|
810
|
+
mongoDBAuthenticationFailed(e) {
|
|
793
811
|
const stackTrace = this.traceError(
|
|
794
|
-
import_opticore_translator8.TranslationLoader.t("mongoDBConnection",
|
|
795
|
-
import_opticore_translator8.TranslationLoader.t("mongoDBAuthentication",
|
|
812
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", this.localeLanguage, { e }),
|
|
813
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBAuthentication", this.localeLanguage),
|
|
796
814
|
import_opticore_http_response6.HttpStatusCode.UNAUTHORIZED
|
|
797
815
|
);
|
|
798
816
|
this.logger.error(
|
|
799
|
-
import_opticore_translator8.TranslationLoader.t("mongoDBAuthenticationError",
|
|
800
|
-
import_opticore_translator8.TranslationLoader.t("mongoDBConnection",
|
|
801
|
-
import_opticore_translator8.TranslationLoader.t("mongoDBAuthenticationFailed",
|
|
817
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBAuthenticationError", this.localeLanguage),
|
|
818
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", this.localeLanguage),
|
|
819
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBAuthenticationFailed", this.localeLanguage),
|
|
802
820
|
stackTrace.stack,
|
|
803
821
|
import_opticore_http_response6.HttpStatusCode.UNAUTHORIZED
|
|
804
822
|
);
|
|
@@ -809,16 +827,16 @@ var DbConnexionConfigError = class {
|
|
|
809
827
|
* @param dbHost
|
|
810
828
|
* @param dbPort
|
|
811
829
|
*/
|
|
812
|
-
|
|
830
|
+
mongoDBInvalidUrl(err, dbHost, dbPort) {
|
|
813
831
|
const stackTrace = this.traceError(
|
|
814
|
-
import_opticore_translator8.TranslationLoader.t("mongoDBConnection",
|
|
815
|
-
import_opticore_translator8.TranslationLoader.t("mongoDBUnableParsingUrl",
|
|
832
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", this.localeLanguage, { err }),
|
|
833
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBUnableParsingUrl", this.localeLanguage),
|
|
816
834
|
import_opticore_http_response6.HttpStatusCode.BAD_REQUEST
|
|
817
835
|
);
|
|
818
836
|
this.logger.error(
|
|
819
|
-
import_opticore_translator8.TranslationLoader.t("dbUrlParsingError",
|
|
820
|
-
import_opticore_translator8.TranslationLoader.t("mongoDBConnection",
|
|
821
|
-
import_opticore_translator8.TranslationLoader.t("mongoDBUnableParsingUrl",
|
|
837
|
+
import_opticore_translator8.TranslationLoader.t("dbUrlParsingError", this.localeLanguage, { dbHost, dbPort }),
|
|
838
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", this.localeLanguage),
|
|
839
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBUnableParsingUrl", this.localeLanguage),
|
|
822
840
|
stackTrace.stack,
|
|
823
841
|
import_opticore_http_response6.HttpStatusCode.BAD_REQUEST
|
|
824
842
|
);
|
|
@@ -828,16 +846,16 @@ var DbConnexionConfigError = class {
|
|
|
828
846
|
* @param err
|
|
829
847
|
* @param dbHost
|
|
830
848
|
*/
|
|
831
|
-
|
|
849
|
+
mongoDBEaiAgain(err, dbHost) {
|
|
832
850
|
const stackTrace = this.traceError(
|
|
833
|
-
import_opticore_translator8.TranslationLoader.t("mongoDBConnection",
|
|
834
|
-
import_opticore_translator8.TranslationLoader.t("mongoDBServerSelection",
|
|
851
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", this.localeLanguage, { err }),
|
|
852
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBServerSelection", this.localeLanguage),
|
|
835
853
|
import_opticore_http_response6.HttpStatusCode.BAD_REQUEST
|
|
836
854
|
);
|
|
837
855
|
this.logger.error(
|
|
838
|
-
import_opticore_translator8.TranslationLoader.t("mongoServerError",
|
|
839
|
-
import_opticore_translator8.TranslationLoader.t("mongoDBConnection",
|
|
840
|
-
import_opticore_translator8.TranslationLoader.t("mongoDBServerSelection",
|
|
856
|
+
import_opticore_translator8.TranslationLoader.t("mongoServerError", this.localeLanguage, { dbHost }),
|
|
857
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", this.localeLanguage),
|
|
858
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBServerSelection", this.localeLanguage),
|
|
841
859
|
stackTrace.stack,
|
|
842
860
|
import_opticore_http_response6.HttpStatusCode.BAD_REQUEST
|
|
843
861
|
);
|
|
@@ -846,15 +864,15 @@ var DbConnexionConfigError = class {
|
|
|
846
864
|
*
|
|
847
865
|
* @param err
|
|
848
866
|
*/
|
|
849
|
-
|
|
867
|
+
mongoDbGlobalError(err) {
|
|
850
868
|
const stackTrace = this.traceError(
|
|
851
|
-
|
|
852
|
-
import_opticore_translator8.TranslationLoader.t("mongoDBConnection",
|
|
869
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", this.localeLanguage, { err }),
|
|
870
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", this.localeLanguage),
|
|
853
871
|
import_opticore_http_response6.HttpStatusCode.NOT_ACCEPTABLE
|
|
854
872
|
);
|
|
855
873
|
this.logger.error(
|
|
856
|
-
import_opticore_translator8.TranslationLoader.t("mongoDBConnection",
|
|
857
|
-
import_opticore_translator8.TranslationLoader.t("mongoDBConnectionError",
|
|
874
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", this.localeLanguage),
|
|
875
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnectionError", this.localeLanguage),
|
|
858
876
|
stackTrace.stack,
|
|
859
877
|
err.message,
|
|
860
878
|
import_opticore_http_response6.HttpStatusCode.NOT_ACCEPTABLE
|
|
@@ -867,7 +885,7 @@ var DbConnexionConfigError = class {
|
|
|
867
885
|
* @param status
|
|
868
886
|
* @private
|
|
869
887
|
*/
|
|
870
|
-
|
|
888
|
+
traceError(props, name, status7) {
|
|
871
889
|
return new import_opticore_catch_exception_error3.StackTraceError(props, name, status7, true);
|
|
872
890
|
}
|
|
873
891
|
};
|
|
@@ -876,8 +894,17 @@ var DbConnexionConfigError = class {
|
|
|
876
894
|
var import_opticore_catch_exception_error4 = require("opticore-catch-exception-error");
|
|
877
895
|
var DatabaseConnectionConfig = class {
|
|
878
896
|
env = new Environment(import_opticore_env_access3.getEnvVariable);
|
|
879
|
-
logger = new
|
|
897
|
+
logger = new import_opticore_logger5.LoggerCore(loggerConfig);
|
|
898
|
+
localeLanguage;
|
|
899
|
+
DbConnexionConfigError;
|
|
900
|
+
constructor(localeLanguage) {
|
|
901
|
+
this.localeLanguage = localeLanguage;
|
|
902
|
+
this.DbConnexionConfigError = new DbConnexionConfigError(localeLanguage);
|
|
903
|
+
}
|
|
880
904
|
/**
|
|
905
|
+
*
|
|
906
|
+
* @param optionalArgumentConnection
|
|
907
|
+
*
|
|
881
908
|
* MySQL database connection with an optional arguments
|
|
882
909
|
* Establish the connection between app and Database Management System.
|
|
883
910
|
* Inside this class, a checker verifies if database credentials are right,
|
|
@@ -888,7 +915,7 @@ var DatabaseConnectionConfig = class {
|
|
|
888
915
|
const dbURL = `${this.env.get("dataBaseUser")}:${this.env.get("dataBasePassword")}@${this.env.get("dataBaseHost")}:${this.env.get("dataBasePort")}/${this.env.get("dataBaseName")}`;
|
|
889
916
|
let url = `mysql://${dbURL}?${optionalArgumentConnection}`;
|
|
890
917
|
const dbConnection = import_mysql.default.createConnection(url);
|
|
891
|
-
return SCheckerMySqlDatabaseConnection(dbConnection, this.env.get("dataBaseUser"), this.env.get("dataBaseName"), this.env.get("dataBaseHost"), this.env.get("dataBasePassword"));
|
|
918
|
+
return SCheckerMySqlDatabaseConnection(this.localeLanguage, dbConnection, this.env.get("dataBaseUser"), this.env.get("dataBaseName"), this.env.get("dataBaseHost"), this.env.get("dataBasePassword"));
|
|
892
919
|
}
|
|
893
920
|
/**
|
|
894
921
|
*
|
|
@@ -902,21 +929,21 @@ var DatabaseConnectionConfig = class {
|
|
|
902
929
|
try {
|
|
903
930
|
await SCheckerMongoDatabaseConnection(url, this.env.get("dataBaseUser"), this.env.get("dataBasePassword"), this.env.get("dataBaseName"));
|
|
904
931
|
this.logger.success(
|
|
905
|
-
import_opticore_translator9.TranslationLoader.t("mongoDBConnectionChecker",
|
|
906
|
-
import_opticore_translator9.TranslationLoader.t("mongoConnectionSuccess",
|
|
932
|
+
import_opticore_translator9.TranslationLoader.t("mongoDBConnectionChecker", this.localeLanguage, loggerConfig),
|
|
933
|
+
import_opticore_translator9.TranslationLoader.t("mongoConnectionSuccess", this.localeLanguage, loggerConfig)
|
|
907
934
|
);
|
|
908
935
|
console.log("");
|
|
909
936
|
} catch (e) {
|
|
910
937
|
if (e.code === 18) {
|
|
911
|
-
DbConnexionConfigError.mongoDBAuthenticationFailed(e);
|
|
938
|
+
this.DbConnexionConfigError.mongoDBAuthenticationFailed(e);
|
|
912
939
|
}
|
|
913
940
|
if (e.cause.code === "ERR_INVALID_URL") {
|
|
914
|
-
DbConnexionConfigError.mongoDBInvalidUrl(e, this.env.get("dataBaseHost"), this.env.get("dataBasePort"));
|
|
941
|
+
this.DbConnexionConfigError.mongoDBInvalidUrl(e, this.env.get("dataBaseHost"), this.env.get("dataBasePort"));
|
|
915
942
|
}
|
|
916
943
|
if (e.code === void 0) {
|
|
917
|
-
DbConnexionConfigError.mongoDBEaiAgain(e, this.env.get("dataBaseHost"));
|
|
944
|
+
this.DbConnexionConfigError.mongoDBEaiAgain(e, this.env.get("dataBaseHost"));
|
|
918
945
|
} else {
|
|
919
|
-
DbConnexionConfigError.mongoDbGlobalError(e);
|
|
946
|
+
this.DbConnexionConfigError.mongoDbGlobalError(e);
|
|
920
947
|
}
|
|
921
948
|
}
|
|
922
949
|
}
|
|
@@ -940,6 +967,7 @@ var DatabaseConnectionConfig = class {
|
|
|
940
967
|
const url = `postgresql:/${this.env.get("dataBaseUser")}:${this.env.get("dataBasePassword")}@${this.env.get("dataBaseHost")}:${this.env.get("dataBasePort")}/${this.env.get("dataBaseName")}`;
|
|
941
968
|
try {
|
|
942
969
|
await SCheckerPostgresDatabaseConnection(
|
|
970
|
+
this.localeLanguage,
|
|
943
971
|
url,
|
|
944
972
|
keepAlive,
|
|
945
973
|
stream,
|
|
@@ -953,11 +981,14 @@ var DatabaseConnectionConfig = class {
|
|
|
953
981
|
types,
|
|
954
982
|
options
|
|
955
983
|
);
|
|
956
|
-
this.logger.success(
|
|
984
|
+
this.logger.success(
|
|
985
|
+
import_opticore_translator9.TranslationLoader.t("postgresDBConnectionChecker", this.localeLanguage, loggerConfig),
|
|
986
|
+
import_opticore_translator9.TranslationLoader.t("postgresConnectionSuccess", this.localeLanguage, loggerConfig)
|
|
987
|
+
);
|
|
957
988
|
console.log("");
|
|
958
989
|
} catch (err) {
|
|
959
990
|
const stackTrace = this.traceError(
|
|
960
|
-
import_opticore_translator9.TranslationLoader.t(`${err.message}`,
|
|
991
|
+
import_opticore_translator9.TranslationLoader.t(`${err.message}`, this.localeLanguage, loggerConfig),
|
|
961
992
|
"PostgresConnectionError",
|
|
962
993
|
import_opticore_http_response7.HttpStatusCode.NOT_ACCEPTABLE
|
|
963
994
|
);
|
|
@@ -976,21 +1007,33 @@ var DatabaseConnectionConfig = class {
|
|
|
976
1007
|
};
|
|
977
1008
|
|
|
978
1009
|
// src/core/config/database/middleware/mongoChecker.database.ts
|
|
979
|
-
var MMongoCheckerDatabase = (optionalArgumentConnection) => {
|
|
980
|
-
const DbConnexion = new DatabaseConnectionConfig();
|
|
1010
|
+
var MMongoCheckerDatabase = (optionalArgumentConnection, localLanguage) => {
|
|
1011
|
+
const DbConnexion = new DatabaseConnectionConfig(localLanguage);
|
|
981
1012
|
return DbConnexion.databaseMongoDBConnectionChecker(optionalArgumentConnection);
|
|
982
1013
|
};
|
|
983
1014
|
|
|
984
1015
|
// src/core/config/database/middleware/mySqlChecker.database.ts
|
|
985
|
-
var MMySqlCheckerDatabase = (optionalArgumentConnection) => {
|
|
986
|
-
const DbConnexion = new DatabaseConnectionConfig();
|
|
1016
|
+
var MMySqlCheckerDatabase = (optionalArgumentConnection, localLanguage) => {
|
|
1017
|
+
const DbConnexion = new DatabaseConnectionConfig(localLanguage);
|
|
987
1018
|
return DbConnexion.databaseMySQLConnexionChecker(optionalArgumentConnection);
|
|
988
1019
|
};
|
|
989
1020
|
|
|
990
1021
|
// src/core/config/database/middleware/postgresChecker.database.ts
|
|
991
|
-
var MPostgresCheckerDatabase = (
|
|
992
|
-
const DbConnexion = new DatabaseConnectionConfig();
|
|
993
|
-
return DbConnexion.databasePostgresDBConnectionChecker(
|
|
1022
|
+
var MPostgresCheckerDatabase = (localLanguage, keepAlive, stream, statement_timeout, ssl, query_timeout, keepAliveInitialDelayMillis, idle_in_transaction_session_timeout, application_name, connectionTimeoutMillis, types, options) => {
|
|
1023
|
+
const DbConnexion = new DatabaseConnectionConfig(localLanguage);
|
|
1024
|
+
return DbConnexion.databasePostgresDBConnectionChecker(
|
|
1025
|
+
keepAlive,
|
|
1026
|
+
stream,
|
|
1027
|
+
statement_timeout,
|
|
1028
|
+
ssl,
|
|
1029
|
+
query_timeout,
|
|
1030
|
+
keepAliveInitialDelayMillis,
|
|
1031
|
+
idle_in_transaction_session_timeout,
|
|
1032
|
+
application_name,
|
|
1033
|
+
connectionTimeoutMillis,
|
|
1034
|
+
types,
|
|
1035
|
+
options
|
|
1036
|
+
);
|
|
994
1037
|
};
|
|
995
1038
|
|
|
996
1039
|
// src/utils/utility.utils.ts
|
|
@@ -1001,6 +1044,10 @@ var import_path2 = __toESM(require("path"), 1);
|
|
|
1001
1044
|
var import_fs = __toESM(require("fs"), 1);
|
|
1002
1045
|
var import_opticore_translator10 = require("opticore-translator");
|
|
1003
1046
|
var Utility = class {
|
|
1047
|
+
localLang;
|
|
1048
|
+
constructor(localLanguage) {
|
|
1049
|
+
this.localLang = localLanguage;
|
|
1050
|
+
}
|
|
1004
1051
|
/**
|
|
1005
1052
|
*
|
|
1006
1053
|
* @param data
|
|
@@ -1092,19 +1139,19 @@ var Utility = class {
|
|
|
1092
1139
|
this.getEnvFileLoading(".env");
|
|
1093
1140
|
const isDevelopment = import_node_process.default.env.NODE_ENV === "development";
|
|
1094
1141
|
if (isDevelopment) {
|
|
1095
|
-
return `${import_opticore_translator10.TranslationLoader.t("serverRunning",
|
|
1142
|
+
return `${import_opticore_translator10.TranslationLoader.t("serverRunning", this.localLang)} ${import_ansi_colors.default.bgBlue(`${import_ansi_colors.default.bold(`${development}`)}`)} mode`;
|
|
1096
1143
|
} else {
|
|
1097
|
-
return `${import_opticore_translator10.TranslationLoader.t("serverRunning",
|
|
1144
|
+
return `${import_opticore_translator10.TranslationLoader.t("serverRunning", this.localLang)} ${import_ansi_colors.default.bgBlue(`${import_ansi_colors.default.bold(`${production}`)}`)} mode`;
|
|
1098
1145
|
}
|
|
1099
1146
|
}
|
|
1100
1147
|
infoServer(nodeVersion, startingTime, host, port, rss, heapUsed, user, system) {
|
|
1101
1148
|
const paddingLength = 52;
|
|
1102
1149
|
const msg0 = " ".padEnd(paddingLength, " ");
|
|
1103
|
-
const msg1 = ` ${import_opticore_translator10.TranslationLoader.t("okServerListening",
|
|
1150
|
+
const msg1 = ` ${import_opticore_translator10.TranslationLoader.t("okServerListening", this.localLang)}`;
|
|
1104
1151
|
const msg2Value = `${import_ansi_colors.default.bgBlue(`${import_ansi_colors.default.bold(`${nodeVersion}`)}`)}`;
|
|
1105
|
-
const msg2 = ` ${import_opticore_translator10.TranslationLoader.t("webServerUseNodeVersion",
|
|
1152
|
+
const msg2 = ` ${import_opticore_translator10.TranslationLoader.t("webServerUseNodeVersion", this.localLang)}`;
|
|
1106
1153
|
const msg3Value = `${import_ansi_colors.default.bgBlue(`${import_ansi_colors.default.bold(`${startingTime}`)}`)}`;
|
|
1107
|
-
const msg3 = ` ${import_opticore_translator10.TranslationLoader.t("startupTime",
|
|
1154
|
+
const msg3 = ` ${import_opticore_translator10.TranslationLoader.t("startupTime", this.localLang)}`;
|
|
1108
1155
|
const msg4 = ` ${this.getServerRunningMode("development", "production")}`;
|
|
1109
1156
|
const msg5 = ` ${import_ansi_colors.default.underline(`http://${host}:${port}`)}`;
|
|
1110
1157
|
console.log(import_chalk.default.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
@@ -1115,27 +1162,31 @@ var Utility = class {
|
|
|
1115
1162
|
console.log(import_chalk.default.bgGreen.white(msg5.padEnd(61, " ")));
|
|
1116
1163
|
console.log(import_chalk.default.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
1117
1164
|
console.log(``);
|
|
1118
|
-
console.log(`${`${import_opticore_translator10.TranslationLoader.t("totalMemory",
|
|
1119
|
-
console.log(`${`${import_opticore_translator10.TranslationLoader.t("memoryUsedDuringExecution",
|
|
1120
|
-
console.log(`${`${import_opticore_translator10.TranslationLoader.t("memoryUsedByUser",
|
|
1121
|
-
console.log(`${`${import_opticore_translator10.TranslationLoader.t("memoryUsedBySystem",
|
|
1165
|
+
console.log(`${`${import_opticore_translator10.TranslationLoader.t("totalMemory", this.localLang)}`} ${import_ansi_colors.default.cyan(`${import_ansi_colors.default.bold(`${rss}`)}`)}`);
|
|
1166
|
+
console.log(`${`${import_opticore_translator10.TranslationLoader.t("memoryUsedDuringExecution", this.localLang)}`} ${import_ansi_colors.default.cyan(`${import_ansi_colors.default.bold(`${heapUsed}`)}`)}`);
|
|
1167
|
+
console.log(`${`${import_opticore_translator10.TranslationLoader.t("memoryUsedByUser", this.localLang)}`} ${import_ansi_colors.default.cyan(`${import_ansi_colors.default.bold(`${user}`)}`)}`);
|
|
1168
|
+
console.log(`${`${import_opticore_translator10.TranslationLoader.t("memoryUsedBySystem", this.localLang)}`} ${import_ansi_colors.default.cyan(`${import_ansi_colors.default.bold(`${system}`)}`)}`);
|
|
1122
1169
|
console.log(``);
|
|
1123
1170
|
}
|
|
1124
1171
|
};
|
|
1125
1172
|
|
|
1126
1173
|
// src/core/events/pathModuleVerifier.event.ts
|
|
1127
1174
|
var import_path3 = require("path");
|
|
1128
|
-
var
|
|
1175
|
+
var import_opticore_logger6 = require("opticore-logger");
|
|
1129
1176
|
var import_opticore_http_response8 = require("opticore-http-response");
|
|
1130
1177
|
var import_opticore_translator11 = require("opticore-translator");
|
|
1131
1178
|
var PathModuleVerifier = class {
|
|
1132
|
-
|
|
1179
|
+
log = new import_opticore_logger6.LoggerCore(loggerConfig);
|
|
1180
|
+
localeLanguage;
|
|
1181
|
+
constructor(localeLanguage) {
|
|
1182
|
+
this.localeLanguage = localeLanguage;
|
|
1183
|
+
}
|
|
1133
1184
|
/**
|
|
1134
1185
|
* Verifies if modules at specific paths are loaded.
|
|
1135
1186
|
* If any module is not loaded, it throws an error.
|
|
1136
1187
|
* @param modulePaths - An array of paths to the modules to verify.
|
|
1137
1188
|
*/
|
|
1138
|
-
|
|
1189
|
+
verifyModulePaths(modulePaths) {
|
|
1139
1190
|
const notLoadedPaths = [];
|
|
1140
1191
|
for (const modulePath of modulePaths) {
|
|
1141
1192
|
if (!this.isModulePathLoaded(modulePath)) {
|
|
@@ -1144,7 +1195,7 @@ var PathModuleVerifier = class {
|
|
|
1144
1195
|
}
|
|
1145
1196
|
if (notLoadedPaths.length > 0) {
|
|
1146
1197
|
this.log.error(
|
|
1147
|
-
import_opticore_translator11.TranslationLoader.t("moduleNotLoaded",
|
|
1198
|
+
import_opticore_translator11.TranslationLoader.t("moduleNotLoaded", this.localeLanguage, { notLoadedPaths: notLoadedPaths.join(", ") }),
|
|
1148
1199
|
"",
|
|
1149
1200
|
"",
|
|
1150
1201
|
modulePaths,
|
|
@@ -1158,7 +1209,7 @@ var PathModuleVerifier = class {
|
|
|
1158
1209
|
* @param modulePath - The path to the module.
|
|
1159
1210
|
* @returns True if the module is loaded, false otherwise.
|
|
1160
1211
|
*/
|
|
1161
|
-
|
|
1212
|
+
isModulePathLoaded(modulePath) {
|
|
1162
1213
|
try {
|
|
1163
1214
|
const resolvedPath = (0, import_path3.resolve)(modulePath);
|
|
1164
1215
|
return require.cache[resolvedPath] !== void 0;
|