opticore-webapp-core 1.0.7 → 1.0.8
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 +232 -187
- package/dist/index.d.cts +38 -22
- package/dist/index.d.ts +38 -22
- package/dist/index.js +242 -197
- package/dist/utils/translations/message.translation.en.json +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -8,8 +8,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
8
8
|
// src/application/services/asymmetricCryptionDataWithPrivateRSAKey.service.ts
|
|
9
9
|
import crypto3 from "crypto";
|
|
10
10
|
import { HttpStatusCode as status } from "opticore-http-response";
|
|
11
|
-
import {
|
|
12
|
-
import { CLocal, TranslationLoader } from "opticore-translator";
|
|
11
|
+
import { TranslationLoader } from "opticore-translator";
|
|
13
12
|
import { StackTraceError as ErrorHandler } from "opticore-catch-exception-error";
|
|
14
13
|
|
|
15
14
|
// src/utils/cryptography/encryption/rsaKey.encryption.ts
|
|
@@ -138,6 +137,9 @@ var RSAKeyDecryption = class {
|
|
|
138
137
|
}
|
|
139
138
|
};
|
|
140
139
|
|
|
140
|
+
// src/application/services/loggerFileConfiguration.service.ts
|
|
141
|
+
import { LoggerCore } from "opticore-logger";
|
|
142
|
+
|
|
141
143
|
// src/core/config/logger/logger.config.ts
|
|
142
144
|
import { getEnvVariable } from "opticore-env-access";
|
|
143
145
|
var loggerConfig = {
|
|
@@ -164,28 +166,34 @@ var loggerConfig = {
|
|
|
164
166
|
}
|
|
165
167
|
};
|
|
166
168
|
|
|
169
|
+
// src/application/services/loggerFileConfiguration.service.ts
|
|
170
|
+
var SLoggerFileConfiguration = () => {
|
|
171
|
+
return new LoggerCore(loggerConfig);
|
|
172
|
+
};
|
|
173
|
+
|
|
167
174
|
// src/application/services/asymmetricCryptionDataWithPrivateRSAKey.service.ts
|
|
168
175
|
var SAsymmetricCryptionDataWithPrivateRSAKey = class {
|
|
169
|
-
static log =
|
|
176
|
+
static log = SLoggerFileConfiguration();
|
|
170
177
|
/**
|
|
171
|
-
*
|
|
178
|
+
*
|
|
172
179
|
* @param rsaKey
|
|
173
180
|
* @param keyType
|
|
181
|
+
* @param localeLanguage
|
|
174
182
|
* @protected
|
|
175
|
-
*
|
|
183
|
+
*
|
|
176
184
|
* Return ErrorHandler | string
|
|
177
185
|
*/
|
|
178
|
-
static verifyExistingKey(rsaKey, keyType) {
|
|
186
|
+
static verifyExistingKey(rsaKey, keyType, localeLanguage) {
|
|
179
187
|
if (!rsaKey) {
|
|
180
188
|
const stackTrace = this.traceError(
|
|
181
|
-
keyType + " " + TranslationLoader.t("rsaKeyNotFound",
|
|
182
|
-
TranslationLoader.t("erBadDbError",
|
|
189
|
+
keyType + " " + TranslationLoader.t("rsaKeyNotFound", localeLanguage, this.log),
|
|
190
|
+
TranslationLoader.t("erBadDbError", localeLanguage, this.log),
|
|
183
191
|
status.NOT_FOUND
|
|
184
192
|
);
|
|
185
193
|
this.log.error(
|
|
186
|
-
TranslationLoader.t("rsaKeyNotFound",
|
|
187
|
-
TranslationLoader.t("verifyExistingKey",
|
|
188
|
-
TranslationLoader.t("erBadDbError",
|
|
194
|
+
TranslationLoader.t("rsaKeyNotFound", localeLanguage, this.log),
|
|
195
|
+
TranslationLoader.t("verifyExistingKey", localeLanguage, this.log),
|
|
196
|
+
TranslationLoader.t("erBadDbError", localeLanguage, this.log),
|
|
189
197
|
stackTrace.stack,
|
|
190
198
|
status.NOT_FOUND
|
|
191
199
|
);
|
|
@@ -197,25 +205,26 @@ var SAsymmetricCryptionDataWithPrivateRSAKey = class {
|
|
|
197
205
|
*
|
|
198
206
|
* @param privateKey
|
|
199
207
|
* @param payload
|
|
208
|
+
* @param localeLanguage
|
|
200
209
|
* @private
|
|
201
210
|
*
|
|
202
211
|
* Return Buffer
|
|
203
212
|
*/
|
|
204
|
-
static encryptionWithPrivateKey(privateKey, payload) {
|
|
205
|
-
this.verifyExistingKey(privateKey, CSignRSAKeyComponent.keyType.private);
|
|
213
|
+
static encryptionWithPrivateKey(privateKey, payload, localeLanguage) {
|
|
214
|
+
this.verifyExistingKey(privateKey, CSignRSAKeyComponent.keyType.private, localeLanguage);
|
|
206
215
|
try {
|
|
207
216
|
const bufferedData = Buffer.from(payload, Number(CSignRSAKeyComponent.encodingFormat));
|
|
208
217
|
return RSAKeyEncryption.privateEncrypt(privateKey, bufferedData);
|
|
209
218
|
} catch (err) {
|
|
210
219
|
const stackTrace = this.traceError(
|
|
211
|
-
TranslationLoader.t("encryptionWithPrivateKeyFailed",
|
|
212
|
-
TranslationLoader.t("encryptionFailed",
|
|
220
|
+
TranslationLoader.t("encryptionWithPrivateKeyFailed", localeLanguage, this.log),
|
|
221
|
+
TranslationLoader.t("encryptionFailed", localeLanguage, this.log),
|
|
213
222
|
status.NOT_FOUND
|
|
214
223
|
);
|
|
215
224
|
this.log.error(
|
|
216
225
|
err.message,
|
|
217
|
-
TranslationLoader.t("encryptionFailed",
|
|
218
|
-
TranslationLoader.t("encryptionWithPrivateKeyFailed",
|
|
226
|
+
TranslationLoader.t("encryptionFailed", localeLanguage, this.log),
|
|
227
|
+
TranslationLoader.t("encryptionWithPrivateKeyFailed", localeLanguage, this.log),
|
|
219
228
|
stackTrace.stack,
|
|
220
229
|
status.NOT_FOUND
|
|
221
230
|
);
|
|
@@ -227,24 +236,25 @@ var SAsymmetricCryptionDataWithPrivateRSAKey = class {
|
|
|
227
236
|
* @param privateKey
|
|
228
237
|
* @param publicKey
|
|
229
238
|
* @param payload
|
|
239
|
+
* @param localeLanguage
|
|
230
240
|
* @private
|
|
231
241
|
*/
|
|
232
|
-
static decryptionWithPublicKey(privateKey, publicKey, payload) {
|
|
233
|
-
this.verifyExistingKey(publicKey, CSignRSAKeyComponent.keyType.public);
|
|
242
|
+
static decryptionWithPublicKey(privateKey, publicKey, payload, localeLanguage) {
|
|
243
|
+
this.verifyExistingKey(publicKey, CSignRSAKeyComponent.keyType.public, localeLanguage);
|
|
234
244
|
try {
|
|
235
|
-
const encryptedPayload = this.encryptionWithPrivateKey(privateKey, payload);
|
|
245
|
+
const encryptedPayload = this.encryptionWithPrivateKey(privateKey, payload, localeLanguage);
|
|
236
246
|
return RSAKeyDecryption.publicDecrypt(publicKey, encryptedPayload);
|
|
237
247
|
} catch (error) {
|
|
238
248
|
const stackTrace = this.traceError(
|
|
239
|
-
TranslationLoader.t("errorDecryption",
|
|
240
|
-
TranslationLoader.t("decryptionFailed",
|
|
249
|
+
TranslationLoader.t("errorDecryption", localeLanguage, this.log),
|
|
250
|
+
TranslationLoader.t("decryptionFailed", localeLanguage, this.log),
|
|
241
251
|
status.NOT_ACCEPTABLE
|
|
242
252
|
);
|
|
243
253
|
this.log.error(
|
|
244
|
-
TranslationLoader.t("decryptionWithPublicKeyFailed",
|
|
245
|
-
TranslationLoader.t("decryptionFailed",
|
|
254
|
+
TranslationLoader.t("decryptionWithPublicKeyFailed", localeLanguage, this.log),
|
|
255
|
+
TranslationLoader.t("decryptionFailed", localeLanguage, this.log),
|
|
246
256
|
stackTrace.stack,
|
|
247
|
-
TranslationLoader.t("errorDecryption",
|
|
257
|
+
TranslationLoader.t("errorDecryption", localeLanguage, this.log),
|
|
248
258
|
status.NOT_ACCEPTABLE
|
|
249
259
|
);
|
|
250
260
|
throw new Error();
|
|
@@ -254,10 +264,11 @@ var SAsymmetricCryptionDataWithPrivateRSAKey = class {
|
|
|
254
264
|
*
|
|
255
265
|
* @param privateKey
|
|
256
266
|
* @param payload
|
|
267
|
+
* @param localeLanguage
|
|
257
268
|
* @private
|
|
258
269
|
*/
|
|
259
|
-
static signWithRSAKey(privateKey, payload) {
|
|
260
|
-
this.verifyExistingKey(privateKey, CSignRSAKeyComponent.keyType.private);
|
|
270
|
+
static signWithRSAKey(privateKey, payload, localeLanguage) {
|
|
271
|
+
this.verifyExistingKey(privateKey, CSignRSAKeyComponent.keyType.private, localeLanguage);
|
|
261
272
|
const sign = crypto3.createSign(CSignRSAKeyComponent.algorithm.sha256);
|
|
262
273
|
sign.update(payload);
|
|
263
274
|
return sign.sign(privateKey, CSignRSAKeyComponent.outputFormat.base64);
|
|
@@ -267,27 +278,28 @@ var SAsymmetricCryptionDataWithPrivateRSAKey = class {
|
|
|
267
278
|
* @param privateKey
|
|
268
279
|
* @param publicKey
|
|
269
280
|
* @param payload
|
|
281
|
+
* @param localeLanguage
|
|
270
282
|
*/
|
|
271
|
-
static verifyRSAKey(privateKey, publicKey, payload) {
|
|
283
|
+
static verifyRSAKey(privateKey, publicKey, payload, localeLanguage) {
|
|
272
284
|
try {
|
|
273
285
|
const verify = crypto3.createVerify(CSignRSAKeyComponent.algorithm.sha256);
|
|
274
286
|
verify.update(payload);
|
|
275
|
-
const signature = this.signWithRSAKey(privateKey, payload);
|
|
287
|
+
const signature = this.signWithRSAKey(privateKey, payload, localeLanguage);
|
|
276
288
|
const isVerified = verify.verify(publicKey, signature, CSignRSAKeyComponent.outputFormat.base64);
|
|
277
289
|
if (isVerified) {
|
|
278
|
-
const decryptedData = this.decryptionWithPublicKey(privateKey, publicKey, payload);
|
|
290
|
+
const decryptedData = this.decryptionWithPublicKey(privateKey, publicKey, payload, localeLanguage);
|
|
279
291
|
return decryptedData.toString(CSignRSAKeyComponent.encodingFormat.utf_8);
|
|
280
292
|
} else {
|
|
281
293
|
const stackTrace = this.traceError(
|
|
282
|
-
TranslationLoader.t("signatureRSAKeyFailed",
|
|
283
|
-
TranslationLoader.t("verifyRSAKeyFailed",
|
|
294
|
+
TranslationLoader.t("signatureRSAKeyFailed", localeLanguage, this.log),
|
|
295
|
+
TranslationLoader.t("verifyRSAKeyFailed", localeLanguage, this.log),
|
|
284
296
|
status.NOT_ACCEPTABLE
|
|
285
297
|
);
|
|
286
298
|
this.log.error(
|
|
287
|
-
TranslationLoader.t("verifyRSAKey",
|
|
288
|
-
TranslationLoader.t("verifyRSAKeyFailed",
|
|
299
|
+
TranslationLoader.t("verifyRSAKey", localeLanguage, this.log),
|
|
300
|
+
TranslationLoader.t("verifyRSAKeyFailed", localeLanguage, this.log),
|
|
289
301
|
stackTrace.stack,
|
|
290
|
-
TranslationLoader.t("signatureRSAKeyFailed",
|
|
302
|
+
TranslationLoader.t("signatureRSAKeyFailed", localeLanguage, this.log),
|
|
291
303
|
status.NOT_FOUND
|
|
292
304
|
);
|
|
293
305
|
return new Error();
|
|
@@ -295,12 +307,12 @@ var SAsymmetricCryptionDataWithPrivateRSAKey = class {
|
|
|
295
307
|
} catch (err) {
|
|
296
308
|
const stackTrace = this.traceError(
|
|
297
309
|
err.name,
|
|
298
|
-
TranslationLoader.t("signatureRSAKeysError",
|
|
310
|
+
TranslationLoader.t("signatureRSAKeysError", localeLanguage, this.log),
|
|
299
311
|
status.NOT_ACCEPTABLE
|
|
300
312
|
);
|
|
301
313
|
this.log.error(
|
|
302
|
-
TranslationLoader.t("signatureRSAKeysError",
|
|
303
|
-
TranslationLoader.t("errorNameNotVerifyingRSAKey",
|
|
314
|
+
TranslationLoader.t("signatureRSAKeysError", localeLanguage, this.log),
|
|
315
|
+
TranslationLoader.t("errorNameNotVerifyingRSAKey", localeLanguage, this.log),
|
|
304
316
|
stackTrace.stack,
|
|
305
317
|
err.message,
|
|
306
318
|
status.NOT_FOUND
|
|
@@ -322,30 +334,30 @@ var SAsymmetricCryptionDataWithPrivateRSAKey = class {
|
|
|
322
334
|
|
|
323
335
|
// src/application/services/asymmetricCryptionDataWithPublicRSAKey.service.ts
|
|
324
336
|
import crypto4 from "crypto";
|
|
325
|
-
import {
|
|
326
|
-
import { CLocal as CLocal2, TranslationLoader as TranslationLoader2 } from "opticore-translator";
|
|
337
|
+
import { TranslationLoader as TranslationLoader2 } from "opticore-translator";
|
|
327
338
|
import { HttpStatusCode as status2 } from "opticore-http-response";
|
|
328
339
|
import { StackTraceError } from "opticore-catch-exception-error";
|
|
329
340
|
var SAsymmetricCryptionDataWithPublicRSAKey = class {
|
|
330
|
-
static
|
|
341
|
+
static logger = SLoggerFileConfiguration();
|
|
331
342
|
/**
|
|
332
343
|
*
|
|
333
344
|
* @param rsaKey
|
|
334
345
|
* @param keyType
|
|
346
|
+
* @param localeLanguage
|
|
335
347
|
* @protected
|
|
336
348
|
*/
|
|
337
|
-
static verifyExistingKey(rsaKey, keyType) {
|
|
349
|
+
static verifyExistingKey(rsaKey, keyType, localeLanguage) {
|
|
338
350
|
if (!rsaKey) {
|
|
339
351
|
const stackTrace = this.traceError(
|
|
340
|
-
keyType + TranslationLoader2.t("verifyExistingKey",
|
|
341
|
-
TranslationLoader2.t("verifyExistingKey",
|
|
352
|
+
keyType + TranslationLoader2.t("verifyExistingKey", localeLanguage, this.logger),
|
|
353
|
+
TranslationLoader2.t("verifyExistingKey", localeLanguage, this.logger),
|
|
342
354
|
status2.NOT_FOUND
|
|
343
355
|
);
|
|
344
|
-
this.
|
|
345
|
-
TranslationLoader2.t("verifyExistingKey",
|
|
356
|
+
this.logger.error(
|
|
357
|
+
TranslationLoader2.t("verifyExistingKey", localeLanguage, this.logger),
|
|
346
358
|
"key verification",
|
|
347
359
|
stackTrace.stack,
|
|
348
|
-
TranslationLoader2.t("verifyExistingKeyError",
|
|
360
|
+
TranslationLoader2.t("verifyExistingKeyError", localeLanguage, this.logger),
|
|
349
361
|
status2.NOT_FOUND
|
|
350
362
|
);
|
|
351
363
|
return new Error();
|
|
@@ -356,22 +368,23 @@ var SAsymmetricCryptionDataWithPublicRSAKey = class {
|
|
|
356
368
|
*
|
|
357
369
|
* @param publicKey
|
|
358
370
|
* @param payload
|
|
371
|
+
* @param localeLanguage
|
|
359
372
|
* @private
|
|
360
373
|
*/
|
|
361
|
-
static encryptionWithPublicKey(publicKey, payload) {
|
|
362
|
-
this.verifyExistingKey(publicKey, CSignRSAKeyComponent.keyType.public);
|
|
374
|
+
static encryptionWithPublicKey(publicKey, payload, localeLanguage) {
|
|
375
|
+
this.verifyExistingKey(publicKey, CSignRSAKeyComponent.keyType.public, localeLanguage);
|
|
363
376
|
try {
|
|
364
377
|
const bufferedData = Buffer.from(payload, Number(CSignRSAKeyComponent.encodingFormat));
|
|
365
378
|
return RSAKeyEncryption.publicEncrypt(publicKey, bufferedData);
|
|
366
379
|
} catch (err) {
|
|
367
380
|
const stackTrace = this.traceError(
|
|
368
381
|
err.message,
|
|
369
|
-
TranslationLoader2.t("encryptionWithPublicKey",
|
|
382
|
+
TranslationLoader2.t("encryptionWithPublicKey", localeLanguage, this.logger),
|
|
370
383
|
status2.NOT_ACCEPTABLE
|
|
371
384
|
);
|
|
372
|
-
this.
|
|
373
|
-
TranslationLoader2.t("errorEncryptionPublicKey",
|
|
374
|
-
TranslationLoader2.t("encryptionWithPublicKey",
|
|
385
|
+
this.logger.error(
|
|
386
|
+
TranslationLoader2.t("errorEncryptionPublicKey", localeLanguage, this.logger),
|
|
387
|
+
TranslationLoader2.t("encryptionWithPublicKey", localeLanguage, this.logger),
|
|
375
388
|
stackTrace.stack,
|
|
376
389
|
err.message,
|
|
377
390
|
status2.NOT_ACCEPTABLE
|
|
@@ -384,22 +397,23 @@ var SAsymmetricCryptionDataWithPublicRSAKey = class {
|
|
|
384
397
|
* @param privateKey
|
|
385
398
|
* @param publicKey
|
|
386
399
|
* @param payload
|
|
400
|
+
* @param localeLanguage
|
|
387
401
|
* @private
|
|
388
402
|
*/
|
|
389
|
-
static decryptionWithPrivateKey(privateKey, publicKey, payload) {
|
|
390
|
-
this.verifyExistingKey(publicKey, CSignRSAKeyComponent.keyType.public);
|
|
403
|
+
static decryptionWithPrivateKey(privateKey, publicKey, payload, localeLanguage) {
|
|
404
|
+
this.verifyExistingKey(publicKey, CSignRSAKeyComponent.keyType.public, localeLanguage);
|
|
391
405
|
try {
|
|
392
|
-
const encryptedPayload = this.encryptionWithPublicKey(publicKey, payload);
|
|
406
|
+
const encryptedPayload = this.encryptionWithPublicKey(publicKey, payload, localeLanguage);
|
|
393
407
|
return RSAKeyDecryption.privateDecrypt(privateKey, encryptedPayload);
|
|
394
408
|
} catch (err) {
|
|
395
409
|
const stackTrace = this.traceError(
|
|
396
410
|
err.code,
|
|
397
|
-
TranslationLoader2.t("errorDecryption",
|
|
411
|
+
TranslationLoader2.t("errorDecryption", localeLanguage, this.logger),
|
|
398
412
|
status2.NOT_ACCEPTABLE
|
|
399
413
|
);
|
|
400
|
-
this.
|
|
401
|
-
TranslationLoader2.t("errorDecryptionWithPrivateKey",
|
|
402
|
-
TranslationLoader2.t("errorDecryption",
|
|
414
|
+
this.logger.error(
|
|
415
|
+
TranslationLoader2.t("errorDecryptionWithPrivateKey", localeLanguage, this.logger),
|
|
416
|
+
TranslationLoader2.t("errorDecryption", localeLanguage, this.logger),
|
|
403
417
|
stackTrace.stack,
|
|
404
418
|
err.message,
|
|
405
419
|
status2.NOT_ACCEPTABLE
|
|
@@ -411,10 +425,11 @@ var SAsymmetricCryptionDataWithPublicRSAKey = class {
|
|
|
411
425
|
*
|
|
412
426
|
* @param publicKey
|
|
413
427
|
* @param payload
|
|
428
|
+
* @param localeLanguage
|
|
414
429
|
* @private
|
|
415
430
|
*/
|
|
416
|
-
static signWithPublicRSAKey(publicKey, payload) {
|
|
417
|
-
this.verifyExistingKey(publicKey, CSignRSAKeyComponent.keyType.private);
|
|
431
|
+
static signWithPublicRSAKey(publicKey, payload, localeLanguage) {
|
|
432
|
+
this.verifyExistingKey(publicKey, CSignRSAKeyComponent.keyType.private, localeLanguage);
|
|
418
433
|
const sign = crypto4.createSign(CSignRSAKeyComponent.algorithm.sha256);
|
|
419
434
|
sign.update(payload);
|
|
420
435
|
return sign.sign(publicKey, CSignRSAKeyComponent.outputFormat.base64);
|
|
@@ -424,27 +439,28 @@ var SAsymmetricCryptionDataWithPublicRSAKey = class {
|
|
|
424
439
|
* @param privateKey
|
|
425
440
|
* @param publicKey
|
|
426
441
|
* @param payload
|
|
442
|
+
* @param localeLanguage
|
|
427
443
|
*/
|
|
428
|
-
static verifyPublicRSAKey(privateKey, publicKey, payload) {
|
|
444
|
+
static verifyPublicRSAKey(privateKey, publicKey, payload, localeLanguage) {
|
|
429
445
|
try {
|
|
430
446
|
const verify = crypto4.createVerify(CSignRSAKeyComponent.algorithm.sha256);
|
|
431
447
|
verify.update(payload);
|
|
432
|
-
const signature = this.signWithPublicRSAKey(publicKey, payload);
|
|
448
|
+
const signature = this.signWithPublicRSAKey(publicKey, payload, localeLanguage);
|
|
433
449
|
const isVerified = verify.verify(publicKey, signature, CSignRSAKeyComponent.outputFormat.base64);
|
|
434
450
|
if (isVerified) {
|
|
435
|
-
const decryptedData = this.decryptionWithPrivateKey(privateKey, publicKey, payload);
|
|
451
|
+
const decryptedData = this.decryptionWithPrivateKey(privateKey, publicKey, payload, localeLanguage);
|
|
436
452
|
return decryptedData.toString(CSignRSAKeyComponent.encodingFormat.utf_8);
|
|
437
453
|
} else {
|
|
438
454
|
const stackTrace = this.traceError(
|
|
439
|
-
TranslationLoader2.t("verifyPublicRSAKeyError",
|
|
440
|
-
TranslationLoader2.t("signatureRSAKeyFailed",
|
|
455
|
+
TranslationLoader2.t("verifyPublicRSAKeyError", localeLanguage, this.logger),
|
|
456
|
+
TranslationLoader2.t("signatureRSAKeyFailed", localeLanguage, this.logger),
|
|
441
457
|
status2.NOT_FOUND
|
|
442
458
|
);
|
|
443
|
-
this.
|
|
444
|
-
TranslationLoader2.t("verifyPublicRSAKey",
|
|
445
|
-
TranslationLoader2.t("signatureRSAKeyFailed",
|
|
459
|
+
this.logger.error(
|
|
460
|
+
TranslationLoader2.t("verifyPublicRSAKey", localeLanguage, this.logger),
|
|
461
|
+
TranslationLoader2.t("signatureRSAKeyFailed", localeLanguage, this.logger),
|
|
446
462
|
stackTrace.stack,
|
|
447
|
-
TranslationLoader2.t("verifyPublicRSAKeyError",
|
|
463
|
+
TranslationLoader2.t("verifyPublicRSAKeyError", localeLanguage, this.logger),
|
|
448
464
|
status2.NOT_FOUND
|
|
449
465
|
);
|
|
450
466
|
return stackTrace;
|
|
@@ -452,12 +468,12 @@ var SAsymmetricCryptionDataWithPublicRSAKey = class {
|
|
|
452
468
|
} catch (err) {
|
|
453
469
|
const stackTrace = this.traceError(
|
|
454
470
|
err.code,
|
|
455
|
-
TranslationLoader2.t("verifyPublicRSAKey",
|
|
471
|
+
TranslationLoader2.t("verifyPublicRSAKey", localeLanguage, this.logger),
|
|
456
472
|
status2.NOT_ACCEPTABLE
|
|
457
473
|
);
|
|
458
|
-
this.
|
|
459
|
-
TranslationLoader2.t("verifyPublicRSAKey",
|
|
460
|
-
TranslationLoader2.t("errorDecryption",
|
|
474
|
+
this.logger.error(
|
|
475
|
+
TranslationLoader2.t("verifyPublicRSAKey", localeLanguage, this.logger),
|
|
476
|
+
TranslationLoader2.t("errorDecryption", localeLanguage, this.logger),
|
|
461
477
|
stackTrace.stack,
|
|
462
478
|
err.message,
|
|
463
479
|
status2.NOT_ACCEPTABLE
|
|
@@ -483,44 +499,44 @@ async function SCheckerMongoDatabaseConnection(url, user, password, dbName) {
|
|
|
483
499
|
}
|
|
484
500
|
|
|
485
501
|
// src/core/handlers/errors/database/mySqlError.handler.database.ts
|
|
486
|
-
import { LoggerCore as
|
|
502
|
+
import { LoggerCore as LoggerCore2 } from "opticore-logger";
|
|
487
503
|
import { HttpStatusCode as status3 } from "opticore-http-response";
|
|
488
|
-
import {
|
|
489
|
-
function mySqlErrorHandlerDatabase(err, dbHost, database, user, password) {
|
|
490
|
-
const logger = new
|
|
504
|
+
import { TranslationLoader as TranslationLoader3 } from "opticore-translator";
|
|
505
|
+
function mySqlErrorHandlerDatabase(localLanguage, err, dbHost, database, user, password) {
|
|
506
|
+
const logger = new LoggerCore2(loggerConfig);
|
|
491
507
|
switch (err.code) {
|
|
492
508
|
case "EAI_AGAIN":
|
|
493
509
|
logger.error(
|
|
494
|
-
TranslationLoader3.t("errorDBHost",
|
|
495
|
-
TranslationLoader3.t("mySQLError",
|
|
496
|
-
TranslationLoader3.t("eAiAgain",
|
|
510
|
+
TranslationLoader3.t("errorDBHost", localLanguage, { dbHost }),
|
|
511
|
+
TranslationLoader3.t("mySQLError", localLanguage),
|
|
512
|
+
TranslationLoader3.t("eAiAgain", localLanguage),
|
|
497
513
|
err.stack,
|
|
498
514
|
status3.NOT_ACCEPTABLE
|
|
499
515
|
);
|
|
500
516
|
break;
|
|
501
517
|
case "ER_NOT_SUPPORTED_AUTH_MODE":
|
|
502
518
|
logger.error(
|
|
503
|
-
TranslationLoader3.t("erNotSupportedAuthModeError",
|
|
504
|
-
TranslationLoader3.t("dbConnection",
|
|
505
|
-
TranslationLoader3.t("erNotSupportedAuthMode",
|
|
519
|
+
TranslationLoader3.t("erNotSupportedAuthModeError", localLanguage),
|
|
520
|
+
TranslationLoader3.t("dbConnection", localLanguage),
|
|
521
|
+
TranslationLoader3.t("erNotSupportedAuthMode", localLanguage),
|
|
506
522
|
err.stack,
|
|
507
523
|
status3.NOT_ACCEPTABLE
|
|
508
524
|
);
|
|
509
525
|
break;
|
|
510
526
|
case "ER_ACCESS_DENIED_ERROR":
|
|
511
527
|
logger.error(
|
|
512
|
-
TranslationLoader3.t("accessDeniedToDBCon",
|
|
513
|
-
TranslationLoader3.t("dbConnection",
|
|
514
|
-
TranslationLoader3.t("erAccessDeniedError",
|
|
528
|
+
TranslationLoader3.t("accessDeniedToDBCon", localLanguage, { user, password }),
|
|
529
|
+
TranslationLoader3.t("dbConnection", localLanguage),
|
|
530
|
+
TranslationLoader3.t("erAccessDeniedError", localLanguage),
|
|
515
531
|
err.stack,
|
|
516
532
|
status3.NOT_ACCEPTABLE
|
|
517
533
|
);
|
|
518
534
|
break;
|
|
519
535
|
case "ER_BAD_DB_ERROR":
|
|
520
536
|
logger.error(
|
|
521
|
-
TranslationLoader3.t("unknownDB",
|
|
522
|
-
TranslationLoader3.t("dbConnection",
|
|
523
|
-
TranslationLoader3.t("erBadDbError",
|
|
537
|
+
TranslationLoader3.t("unknownDB", localLanguage, { database }),
|
|
538
|
+
TranslationLoader3.t("dbConnection", localLanguage),
|
|
539
|
+
TranslationLoader3.t("erBadDbError", localLanguage),
|
|
524
540
|
err.stack,
|
|
525
541
|
status3.NOT_ACCEPTABLE
|
|
526
542
|
);
|
|
@@ -528,8 +544,8 @@ function mySqlErrorHandlerDatabase(err, dbHost, database, user, password) {
|
|
|
528
544
|
default:
|
|
529
545
|
logger.error(
|
|
530
546
|
err.message,
|
|
531
|
-
TranslationLoader3.t("dbConnection",
|
|
532
|
-
TranslationLoader3.t("mysqlErrorCon",
|
|
547
|
+
TranslationLoader3.t("dbConnection", localLanguage),
|
|
548
|
+
TranslationLoader3.t("mysqlErrorCon", localLanguage),
|
|
533
549
|
err.stack,
|
|
534
550
|
status3.NOT_ACCEPTABLE
|
|
535
551
|
);
|
|
@@ -538,25 +554,24 @@ function mySqlErrorHandlerDatabase(err, dbHost, database, user, password) {
|
|
|
538
554
|
}
|
|
539
555
|
|
|
540
556
|
// src/application/services/checkerMySqlDatabaseConnection.service.ts
|
|
541
|
-
import {
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
const log = new LoggerCore4(loggerConfig);
|
|
557
|
+
import { TranslationLoader as TranslationLoader4 } from "opticore-translator";
|
|
558
|
+
function SCheckerMySqlDatabaseConnection(localeLanguage, dbConnection, user, database, dbHost, password) {
|
|
559
|
+
const logger = SLoggerFileConfiguration();
|
|
545
560
|
dbConnection.connect((err) => {
|
|
546
561
|
if (err) {
|
|
547
|
-
return mySqlErrorHandlerDatabase(err, dbHost, database, user, password);
|
|
562
|
+
return mySqlErrorHandlerDatabase(localeLanguage, err, dbHost, database, user, password);
|
|
548
563
|
} else {
|
|
549
|
-
|
|
550
|
-
TranslationLoader4.t("dbConnection",
|
|
551
|
-
TranslationLoader4.t("dbConnexionSuccess",
|
|
564
|
+
logger.success(
|
|
565
|
+
TranslationLoader4.t("dbConnection", localeLanguage, logger),
|
|
566
|
+
TranslationLoader4.t("dbConnexionSuccess", localeLanguage, logger)
|
|
552
567
|
);
|
|
553
568
|
return dbConnection.end((endConErr) => {
|
|
554
569
|
if (endConErr) {
|
|
555
|
-
return mySqlErrorHandlerDatabase(err, dbHost, database, user, password);
|
|
570
|
+
return mySqlErrorHandlerDatabase(localeLanguage, err, dbHost, database, user, password);
|
|
556
571
|
} else {
|
|
557
|
-
|
|
558
|
-
TranslationLoader4.t("dbConnection",
|
|
559
|
-
TranslationLoader4.t("dbConnectionClosed",
|
|
572
|
+
logger.success(
|
|
573
|
+
TranslationLoader4.t("dbConnection", localeLanguage, logger),
|
|
574
|
+
TranslationLoader4.t("dbConnectionClosed", localeLanguage, logger)
|
|
560
575
|
);
|
|
561
576
|
console.log("");
|
|
562
577
|
}
|
|
@@ -567,11 +582,10 @@ function SCheckerMySqlDatabaseConnection(dbConnection, user, database, dbHost, p
|
|
|
567
582
|
|
|
568
583
|
// src/application/services/checkerPostgresDatabaseConnection.service.ts
|
|
569
584
|
import { HttpStatusCode as status4 } from "opticore-http-response";
|
|
570
|
-
import
|
|
571
|
-
import {
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
const logger = new LoggerCore5(loggerConfig);
|
|
585
|
+
import pg from "pg";
|
|
586
|
+
import { TranslationLoader as TranslationLoader5 } from "opticore-translator";
|
|
587
|
+
async function SCheckerPostgresDatabaseConnection(localeLanguage, connectionString, keepAlive, stream, statement_timeout, ssl, query_timeout, keepAliveInitialDelayMillis, idle_in_transaction_session_timeout, application_name, connectionTimeoutMillis, types, options) {
|
|
588
|
+
const logger = SLoggerFileConfiguration();
|
|
575
589
|
const configOptions = {
|
|
576
590
|
connectionString,
|
|
577
591
|
keepAlive,
|
|
@@ -586,20 +600,20 @@ async function SCheckerPostgresDatabaseConnection(connectionString, keepAlive, s
|
|
|
586
600
|
types,
|
|
587
601
|
options
|
|
588
602
|
};
|
|
589
|
-
const client = new Client(configOptions);
|
|
603
|
+
const client = new pg.Client(configOptions);
|
|
590
604
|
await client.connect();
|
|
591
605
|
await client.end().then(
|
|
592
606
|
() => {
|
|
593
607
|
logger.success(
|
|
594
|
-
TranslationLoader5.t("postgresSuccessConn",
|
|
595
|
-
TranslationLoader5.t("postgresClosingConnSuccess",
|
|
608
|
+
TranslationLoader5.t("postgresSuccessConn", localeLanguage, logger),
|
|
609
|
+
TranslationLoader5.t("postgresClosingConnSuccess", localeLanguage, logger)
|
|
596
610
|
);
|
|
597
611
|
},
|
|
598
612
|
(onRejected) => {
|
|
599
613
|
logger.error(
|
|
600
|
-
TranslationLoader5.t("postgresEndClientRejection",
|
|
601
|
-
TranslationLoader5.t("postgresClientError",
|
|
602
|
-
TranslationLoader5.t("postgresEndRejection",
|
|
614
|
+
TranslationLoader5.t("postgresEndClientRejection", localeLanguage, logger),
|
|
615
|
+
TranslationLoader5.t("postgresClientError", localeLanguage, logger),
|
|
616
|
+
TranslationLoader5.t("postgresEndRejection", localeLanguage, logger),
|
|
603
617
|
onRejected,
|
|
604
618
|
status4.BAD_REQUEST
|
|
605
619
|
);
|
|
@@ -607,8 +621,8 @@ async function SCheckerPostgresDatabaseConnection(connectionString, keepAlive, s
|
|
|
607
621
|
).catch((onError) => {
|
|
608
622
|
logger.error(
|
|
609
623
|
onError.message,
|
|
610
|
-
TranslationLoader5.t("postgresConnError",
|
|
611
|
-
TranslationLoader5.t("postgresException",
|
|
624
|
+
TranslationLoader5.t("postgresConnError", localeLanguage, logger),
|
|
625
|
+
TranslationLoader5.t("postgresException", localeLanguage, logger),
|
|
612
626
|
onError.stack,
|
|
613
627
|
status4.BAD_REQUEST
|
|
614
628
|
);
|
|
@@ -630,51 +644,50 @@ var optionalArgumentConnectionUtil = getEnvVariable2.argumentsDatabaseConnection
|
|
|
630
644
|
// src/utils/parsing/parsingYaml.utils.ts
|
|
631
645
|
import { readFile } from "fs/promises";
|
|
632
646
|
import { HttpStatusCode } from "opticore-http-response";
|
|
633
|
-
import { LoggerCore as
|
|
634
|
-
import {
|
|
647
|
+
import { LoggerCore as LoggerCore3 } from "opticore-logger";
|
|
648
|
+
import { TranslationLoader as TranslationLoader7 } from "opticore-translator";
|
|
635
649
|
|
|
636
650
|
// src/core/config/loaders/translateLanguage.loader.ts
|
|
637
651
|
import path from "path";
|
|
638
652
|
import { createRequire } from "module";
|
|
639
653
|
import { TranslationLoader as TranslationLoader6 } from "opticore-translator";
|
|
640
|
-
var translateWebAppCoreLanguageLoader = (
|
|
654
|
+
var translateWebAppCoreLanguageLoader = () => {
|
|
641
655
|
const require2 = createRequire(import.meta.url);
|
|
642
656
|
const packagePath = path.dirname(require2.resolve("opticore-webapp-core"));
|
|
643
657
|
const translateMsgJsonFilePath = path.join(packagePath, "utils", "translations");
|
|
644
|
-
TranslationLoader6.loadTranslations(translateMsgJsonFilePath
|
|
658
|
+
TranslationLoader6.loadTranslations(translateMsgJsonFilePath);
|
|
645
659
|
};
|
|
646
660
|
|
|
647
661
|
// src/utils/parsing/parsingYaml.utils.ts
|
|
648
662
|
var YamlParsing = class {
|
|
649
|
-
static logger = new
|
|
650
|
-
static
|
|
663
|
+
static logger = new LoggerCore3(loggerConfig);
|
|
664
|
+
static localeLanguage;
|
|
665
|
+
static __init(localeLanguage) {
|
|
666
|
+
translateWebAppCoreLanguageLoader();
|
|
667
|
+
this.localeLanguage = localeLanguage;
|
|
668
|
+
return this;
|
|
669
|
+
}
|
|
670
|
+
static async readFile(filePath, localeLanguage) {
|
|
651
671
|
try {
|
|
652
672
|
const yamlContent = await readFile(filePath, "utf-8");
|
|
653
|
-
await this.parsing(yamlContent);
|
|
673
|
+
await this.parsing(yamlContent, localeLanguage);
|
|
654
674
|
} catch (error) {
|
|
655
675
|
this.logger.error(
|
|
656
676
|
error.message,
|
|
657
|
-
TranslationLoader7.t("parsingFailed",
|
|
658
|
-
TranslationLoader7.t("readingError",
|
|
677
|
+
TranslationLoader7.t("parsingFailed", localeLanguage, this.logger),
|
|
678
|
+
TranslationLoader7.t("readingError", localeLanguage, this.logger),
|
|
659
679
|
error.stack,
|
|
660
680
|
HttpStatusCode.NOT_ACCEPTABLE
|
|
661
681
|
);
|
|
662
682
|
}
|
|
663
683
|
}
|
|
664
|
-
/**
|
|
665
|
-
*
|
|
666
|
-
* @param defaultLocalLang
|
|
667
|
-
*/
|
|
668
|
-
static __init(defaultLocalLang) {
|
|
669
|
-
translateWebAppCoreLanguageLoader(defaultLocalLang);
|
|
670
|
-
return this;
|
|
671
|
-
}
|
|
672
684
|
/**
|
|
673
685
|
*
|
|
674
686
|
* @param content
|
|
687
|
+
* @param localeLanguage
|
|
675
688
|
* @private
|
|
676
689
|
*/
|
|
677
|
-
static async parsing(content) {
|
|
690
|
+
static async parsing(content, localeLanguage) {
|
|
678
691
|
const result = {};
|
|
679
692
|
const lines = content.split("\n");
|
|
680
693
|
let currentKey = null;
|
|
@@ -694,9 +707,9 @@ var YamlParsing = class {
|
|
|
694
707
|
}
|
|
695
708
|
} else {
|
|
696
709
|
this.logger.error(
|
|
697
|
-
TranslationLoader7.t("badFormat",
|
|
698
|
-
TranslationLoader7.t("parsingFailed",
|
|
699
|
-
TranslationLoader7.t("unsupportedFormat",
|
|
710
|
+
TranslationLoader7.t("badFormat", localeLanguage, { line }),
|
|
711
|
+
TranslationLoader7.t("parsingFailed", localeLanguage, this.logger),
|
|
712
|
+
TranslationLoader7.t("unsupportedFormat", localeLanguage, this.logger),
|
|
700
713
|
content,
|
|
701
714
|
HttpStatusCode.NOT_ACCEPTABLE
|
|
702
715
|
);
|
|
@@ -724,86 +737,90 @@ var Environment = class {
|
|
|
724
737
|
import mySQL from "mysql";
|
|
725
738
|
import { HttpStatusCode as status6 } from "opticore-http-response";
|
|
726
739
|
import { getEnvVariable as getEnvVariable3 } from "opticore-env-access";
|
|
727
|
-
import { LoggerCore as
|
|
728
|
-
import {
|
|
740
|
+
import { LoggerCore as LoggerCore5 } from "opticore-logger";
|
|
741
|
+
import { TranslationLoader as TranslationLoader9 } from "opticore-translator";
|
|
729
742
|
|
|
730
743
|
// src/core/errors/databaseConnexion.error.ts
|
|
731
744
|
import { HttpStatusCode as status5 } from "opticore-http-response";
|
|
732
|
-
import { LoggerCore as
|
|
745
|
+
import { LoggerCore as LoggerCore4 } from "opticore-logger";
|
|
733
746
|
import { StackTraceError as StackTraceError2 } from "opticore-catch-exception-error";
|
|
734
|
-
import {
|
|
747
|
+
import { TranslationLoader as TranslationLoader8 } from "opticore-translator";
|
|
735
748
|
var DbConnexionConfigError = class {
|
|
736
|
-
static logger = new
|
|
749
|
+
static logger = new LoggerCore4(loggerConfig);
|
|
737
750
|
/**
|
|
738
751
|
*
|
|
752
|
+
* @param localLanguage
|
|
739
753
|
* @param e
|
|
740
754
|
*/
|
|
741
|
-
static mongoDBAuthenticationFailed(e) {
|
|
755
|
+
static mongoDBAuthenticationFailed(localLanguage, e) {
|
|
742
756
|
const stackTrace = this.traceError(
|
|
743
|
-
TranslationLoader8.t("mongoDBConnection",
|
|
744
|
-
TranslationLoader8.t("mongoDBAuthentication",
|
|
757
|
+
TranslationLoader8.t("mongoDBConnection", localLanguage, { e }),
|
|
758
|
+
TranslationLoader8.t("mongoDBAuthentication", localLanguage),
|
|
745
759
|
status5.UNAUTHORIZED
|
|
746
760
|
);
|
|
747
761
|
this.logger.error(
|
|
748
|
-
TranslationLoader8.t("mongoDBAuthenticationError",
|
|
749
|
-
TranslationLoader8.t("mongoDBConnection",
|
|
750
|
-
TranslationLoader8.t("mongoDBAuthenticationFailed",
|
|
762
|
+
TranslationLoader8.t("mongoDBAuthenticationError", localLanguage),
|
|
763
|
+
TranslationLoader8.t("mongoDBConnection", localLanguage),
|
|
764
|
+
TranslationLoader8.t("mongoDBAuthenticationFailed", localLanguage),
|
|
751
765
|
stackTrace.stack,
|
|
752
766
|
status5.UNAUTHORIZED
|
|
753
767
|
);
|
|
754
768
|
}
|
|
755
769
|
/**
|
|
756
770
|
*
|
|
771
|
+
* @param localLanguage
|
|
757
772
|
* @param err
|
|
758
773
|
* @param dbHost
|
|
759
774
|
* @param dbPort
|
|
760
775
|
*/
|
|
761
|
-
static mongoDBInvalidUrl(err, dbHost, dbPort) {
|
|
776
|
+
static mongoDBInvalidUrl(localLanguage, err, dbHost, dbPort) {
|
|
762
777
|
const stackTrace = this.traceError(
|
|
763
|
-
TranslationLoader8.t("mongoDBConnection",
|
|
764
|
-
TranslationLoader8.t("mongoDBUnableParsingUrl",
|
|
778
|
+
TranslationLoader8.t("mongoDBConnection", localLanguage, { err }),
|
|
779
|
+
TranslationLoader8.t("mongoDBUnableParsingUrl", localLanguage),
|
|
765
780
|
status5.BAD_REQUEST
|
|
766
781
|
);
|
|
767
782
|
this.logger.error(
|
|
768
|
-
TranslationLoader8.t("dbUrlParsingError",
|
|
769
|
-
TranslationLoader8.t("mongoDBConnection",
|
|
770
|
-
TranslationLoader8.t("mongoDBUnableParsingUrl",
|
|
783
|
+
TranslationLoader8.t("dbUrlParsingError", localLanguage, { dbHost, dbPort }),
|
|
784
|
+
TranslationLoader8.t("mongoDBConnection", localLanguage),
|
|
785
|
+
TranslationLoader8.t("mongoDBUnableParsingUrl", localLanguage),
|
|
771
786
|
stackTrace.stack,
|
|
772
787
|
status5.BAD_REQUEST
|
|
773
788
|
);
|
|
774
789
|
}
|
|
775
790
|
/**
|
|
776
791
|
*
|
|
792
|
+
* @param localLanguage
|
|
777
793
|
* @param err
|
|
778
794
|
* @param dbHost
|
|
779
795
|
*/
|
|
780
|
-
static mongoDBEaiAgain(err, dbHost) {
|
|
796
|
+
static mongoDBEaiAgain(localLanguage, err, dbHost) {
|
|
781
797
|
const stackTrace = this.traceError(
|
|
782
|
-
TranslationLoader8.t("mongoDBConnection",
|
|
783
|
-
TranslationLoader8.t("mongoDBServerSelection",
|
|
798
|
+
TranslationLoader8.t("mongoDBConnection", localLanguage, { err }),
|
|
799
|
+
TranslationLoader8.t("mongoDBServerSelection", localLanguage),
|
|
784
800
|
status5.BAD_REQUEST
|
|
785
801
|
);
|
|
786
802
|
this.logger.error(
|
|
787
|
-
TranslationLoader8.t("mongoServerError",
|
|
788
|
-
TranslationLoader8.t("mongoDBConnection",
|
|
789
|
-
TranslationLoader8.t("mongoDBServerSelection",
|
|
803
|
+
TranslationLoader8.t("mongoServerError", localLanguage, { dbHost }),
|
|
804
|
+
TranslationLoader8.t("mongoDBConnection", localLanguage),
|
|
805
|
+
TranslationLoader8.t("mongoDBServerSelection", localLanguage),
|
|
790
806
|
stackTrace.stack,
|
|
791
807
|
status5.BAD_REQUEST
|
|
792
808
|
);
|
|
793
809
|
}
|
|
794
810
|
/**
|
|
795
811
|
*
|
|
812
|
+
* @param localLanguage
|
|
796
813
|
* @param err
|
|
797
814
|
*/
|
|
798
|
-
static mongoDbGlobalError(err) {
|
|
815
|
+
static mongoDbGlobalError(localLanguage, err) {
|
|
799
816
|
const stackTrace = this.traceError(
|
|
800
|
-
|
|
801
|
-
TranslationLoader8.t("mongoDBConnection",
|
|
817
|
+
TranslationLoader8.t("mongoDBConnection", localLanguage, { err }),
|
|
818
|
+
TranslationLoader8.t("mongoDBConnection", localLanguage),
|
|
802
819
|
status5.NOT_ACCEPTABLE
|
|
803
820
|
);
|
|
804
821
|
this.logger.error(
|
|
805
|
-
TranslationLoader8.t("mongoDBConnection",
|
|
806
|
-
TranslationLoader8.t("mongoDBConnectionError",
|
|
822
|
+
TranslationLoader8.t("mongoDBConnection", localLanguage),
|
|
823
|
+
TranslationLoader8.t("mongoDBConnectionError", localLanguage),
|
|
807
824
|
stackTrace.stack,
|
|
808
825
|
err.message,
|
|
809
826
|
status5.NOT_ACCEPTABLE
|
|
@@ -825,34 +842,39 @@ var DbConnexionConfigError = class {
|
|
|
825
842
|
import { StackTraceError as ErrorHandler2 } from "opticore-catch-exception-error";
|
|
826
843
|
var DatabaseConnectionConfig = class {
|
|
827
844
|
env = new Environment(getEnvVariable3);
|
|
828
|
-
logger = new
|
|
845
|
+
logger = new LoggerCore5(loggerConfig);
|
|
829
846
|
/**
|
|
847
|
+
*
|
|
848
|
+
* @param optionalArgumentConnection
|
|
849
|
+
* @param localeLanguage
|
|
850
|
+
*
|
|
830
851
|
* MySQL database connection with an optional arguments
|
|
831
852
|
* Establish the connection between app and Database Management System.
|
|
832
853
|
* Inside this class, a checker verifies if database credentials are right,
|
|
833
854
|
* and it's show off in the log that the connection has been created successfully.
|
|
834
855
|
* But if any error is occurring during trying connection, it'd specify that error by stack traces.
|
|
835
856
|
*/
|
|
836
|
-
databaseMySQLConnexionChecker(optionalArgumentConnection) {
|
|
857
|
+
databaseMySQLConnexionChecker(optionalArgumentConnection, localeLanguage) {
|
|
837
858
|
const dbURL = `${this.env.get("dataBaseUser")}:${this.env.get("dataBasePassword")}@${this.env.get("dataBaseHost")}:${this.env.get("dataBasePort")}/${this.env.get("dataBaseName")}`;
|
|
838
859
|
let url = `mysql://${dbURL}?${optionalArgumentConnection}`;
|
|
839
860
|
const dbConnection = mySQL.createConnection(url);
|
|
840
|
-
return SCheckerMySqlDatabaseConnection(dbConnection, this.env.get("dataBaseUser"), this.env.get("dataBaseName"), this.env.get("dataBaseHost"), this.env.get("dataBasePassword"));
|
|
861
|
+
return SCheckerMySqlDatabaseConnection(localeLanguage, dbConnection, this.env.get("dataBaseUser"), this.env.get("dataBaseName"), this.env.get("dataBaseHost"), this.env.get("dataBasePassword"));
|
|
841
862
|
}
|
|
842
863
|
/**
|
|
843
864
|
*
|
|
844
865
|
* @param optionalArgumentConnection
|
|
866
|
+
* @param localeLanguage
|
|
845
867
|
*
|
|
846
868
|
* Mongo database connection with optional connection arguments
|
|
847
869
|
*/
|
|
848
|
-
async databaseMongoDBConnectionChecker(optionalArgumentConnection) {
|
|
870
|
+
async databaseMongoDBConnectionChecker(optionalArgumentConnection, localeLanguage) {
|
|
849
871
|
const dbUrl = `${this.env.get("dataBaseUser")}:${this.env.get("dataBasePassword")}@${this.env.get("dataBaseHost")}:${this.env.get("dataBasePort")}/${this.env.get("dataBaseName")}`;
|
|
850
872
|
const url = `mongodb://${dbUrl}${optionalArgumentConnection}`;
|
|
851
873
|
try {
|
|
852
874
|
await SCheckerMongoDatabaseConnection(url, this.env.get("dataBaseUser"), this.env.get("dataBasePassword"), this.env.get("dataBaseName"));
|
|
853
875
|
this.logger.success(
|
|
854
|
-
TranslationLoader9.t("mongoDBConnectionChecker",
|
|
855
|
-
TranslationLoader9.t("mongoConnectionSuccess",
|
|
876
|
+
TranslationLoader9.t("mongoDBConnectionChecker", localeLanguage, loggerConfig),
|
|
877
|
+
TranslationLoader9.t("mongoConnectionSuccess", localeLanguage, loggerConfig)
|
|
856
878
|
);
|
|
857
879
|
console.log("");
|
|
858
880
|
} catch (e) {
|
|
@@ -871,6 +893,7 @@ var DatabaseConnectionConfig = class {
|
|
|
871
893
|
}
|
|
872
894
|
/**
|
|
873
895
|
*
|
|
896
|
+
* @param localeLanguage
|
|
874
897
|
* @param keepAlive
|
|
875
898
|
* @param stream
|
|
876
899
|
* @param statement_timeout
|
|
@@ -885,10 +908,11 @@ var DatabaseConnectionConfig = class {
|
|
|
885
908
|
*
|
|
886
909
|
* Postgres database connection with optional connection arguments
|
|
887
910
|
*/
|
|
888
|
-
async databasePostgresDBConnectionChecker(keepAlive, stream, statement_timeout, ssl, query_timeout, keepAliveInitialDelayMillis, idle_in_transaction_session_timeout, application_name, connectionTimeoutMillis, types, options) {
|
|
911
|
+
async databasePostgresDBConnectionChecker(localeLanguage, keepAlive, stream, statement_timeout, ssl, query_timeout, keepAliveInitialDelayMillis, idle_in_transaction_session_timeout, application_name, connectionTimeoutMillis, types, options) {
|
|
889
912
|
const url = `postgresql:/${this.env.get("dataBaseUser")}:${this.env.get("dataBasePassword")}@${this.env.get("dataBaseHost")}:${this.env.get("dataBasePort")}/${this.env.get("dataBaseName")}`;
|
|
890
913
|
try {
|
|
891
914
|
await SCheckerPostgresDatabaseConnection(
|
|
915
|
+
localeLanguage,
|
|
892
916
|
url,
|
|
893
917
|
keepAlive,
|
|
894
918
|
stream,
|
|
@@ -902,11 +926,14 @@ var DatabaseConnectionConfig = class {
|
|
|
902
926
|
types,
|
|
903
927
|
options
|
|
904
928
|
);
|
|
905
|
-
this.logger.success(
|
|
929
|
+
this.logger.success(
|
|
930
|
+
TranslationLoader9.t("postgresDBConnectionChecker", localeLanguage, loggerConfig),
|
|
931
|
+
TranslationLoader9.t("postgresConnectionSuccess", localeLanguage, loggerConfig)
|
|
932
|
+
);
|
|
906
933
|
console.log("");
|
|
907
934
|
} catch (err) {
|
|
908
935
|
const stackTrace = this.traceError(
|
|
909
|
-
TranslationLoader9.t(`${err.message}`,
|
|
936
|
+
TranslationLoader9.t(`${err.message}`, localeLanguage, loggerConfig),
|
|
910
937
|
"PostgresConnectionError",
|
|
911
938
|
status6.NOT_ACCEPTABLE
|
|
912
939
|
);
|
|
@@ -925,21 +952,34 @@ var DatabaseConnectionConfig = class {
|
|
|
925
952
|
};
|
|
926
953
|
|
|
927
954
|
// src/core/config/database/middleware/mongoChecker.database.ts
|
|
928
|
-
var MMongoCheckerDatabase = (optionalArgumentConnection) => {
|
|
955
|
+
var MMongoCheckerDatabase = (optionalArgumentConnection, localLanguage) => {
|
|
929
956
|
const DbConnexion = new DatabaseConnectionConfig();
|
|
930
|
-
return DbConnexion.databaseMongoDBConnectionChecker(optionalArgumentConnection);
|
|
957
|
+
return DbConnexion.databaseMongoDBConnectionChecker(optionalArgumentConnection, localLanguage);
|
|
931
958
|
};
|
|
932
959
|
|
|
933
960
|
// src/core/config/database/middleware/mySqlChecker.database.ts
|
|
934
|
-
var MMySqlCheckerDatabase = (optionalArgumentConnection) => {
|
|
961
|
+
var MMySqlCheckerDatabase = (optionalArgumentConnection, localLanguage) => {
|
|
935
962
|
const DbConnexion = new DatabaseConnectionConfig();
|
|
936
|
-
return DbConnexion.databaseMySQLConnexionChecker(optionalArgumentConnection);
|
|
963
|
+
return DbConnexion.databaseMySQLConnexionChecker(optionalArgumentConnection, localLanguage);
|
|
937
964
|
};
|
|
938
965
|
|
|
939
966
|
// src/core/config/database/middleware/postgresChecker.database.ts
|
|
940
|
-
var MPostgresCheckerDatabase = (
|
|
967
|
+
var MPostgresCheckerDatabase = (localLanguage, keepAlive, stream, statement_timeout, ssl, query_timeout, keepAliveInitialDelayMillis, idle_in_transaction_session_timeout, application_name, connectionTimeoutMillis, types, options) => {
|
|
941
968
|
const DbConnexion = new DatabaseConnectionConfig();
|
|
942
|
-
return DbConnexion.databasePostgresDBConnectionChecker(
|
|
969
|
+
return DbConnexion.databasePostgresDBConnectionChecker(
|
|
970
|
+
localLanguage,
|
|
971
|
+
keepAlive,
|
|
972
|
+
stream,
|
|
973
|
+
statement_timeout,
|
|
974
|
+
ssl,
|
|
975
|
+
query_timeout,
|
|
976
|
+
keepAliveInitialDelayMillis,
|
|
977
|
+
idle_in_transaction_session_timeout,
|
|
978
|
+
application_name,
|
|
979
|
+
connectionTimeoutMillis,
|
|
980
|
+
types,
|
|
981
|
+
options
|
|
982
|
+
);
|
|
943
983
|
};
|
|
944
984
|
|
|
945
985
|
// src/utils/utility.utils.ts
|
|
@@ -948,8 +988,12 @@ import chalk from "chalk";
|
|
|
948
988
|
import colors from "ansi-colors";
|
|
949
989
|
import path2 from "path";
|
|
950
990
|
import fs from "fs";
|
|
951
|
-
import {
|
|
991
|
+
import { TranslationLoader as TranslationLoader10 } from "opticore-translator";
|
|
952
992
|
var Utility = class {
|
|
993
|
+
localLang;
|
|
994
|
+
constructor(localLanguage) {
|
|
995
|
+
this.localLang = localLanguage;
|
|
996
|
+
}
|
|
953
997
|
/**
|
|
954
998
|
*
|
|
955
999
|
* @param data
|
|
@@ -1041,19 +1085,19 @@ var Utility = class {
|
|
|
1041
1085
|
this.getEnvFileLoading(".env");
|
|
1042
1086
|
const isDevelopment = process.env.NODE_ENV === "development";
|
|
1043
1087
|
if (isDevelopment) {
|
|
1044
|
-
return `${TranslationLoader10.t("serverRunning",
|
|
1088
|
+
return `${TranslationLoader10.t("serverRunning", this.localLang)} ${colors.bgBlue(`${colors.bold(`${development}`)}`)} mode`;
|
|
1045
1089
|
} else {
|
|
1046
|
-
return `${TranslationLoader10.t("serverRunning",
|
|
1090
|
+
return `${TranslationLoader10.t("serverRunning", this.localLang)} ${colors.bgBlue(`${colors.bold(`${production}`)}`)} mode`;
|
|
1047
1091
|
}
|
|
1048
1092
|
}
|
|
1049
1093
|
infoServer(nodeVersion, startingTime, host, port, rss, heapUsed, user, system) {
|
|
1050
1094
|
const paddingLength = 52;
|
|
1051
1095
|
const msg0 = " ".padEnd(paddingLength, " ");
|
|
1052
|
-
const msg1 = ` ${TranslationLoader10.t("okServerListening",
|
|
1096
|
+
const msg1 = ` ${TranslationLoader10.t("okServerListening", this.localLang)}`;
|
|
1053
1097
|
const msg2Value = `${colors.bgBlue(`${colors.bold(`${nodeVersion}`)}`)}`;
|
|
1054
|
-
const msg2 = ` ${TranslationLoader10.t("webServerUseNodeVersion",
|
|
1098
|
+
const msg2 = ` ${TranslationLoader10.t("webServerUseNodeVersion", this.localLang)}`;
|
|
1055
1099
|
const msg3Value = `${colors.bgBlue(`${colors.bold(`${startingTime}`)}`)}`;
|
|
1056
|
-
const msg3 = ` ${TranslationLoader10.t("startupTime",
|
|
1100
|
+
const msg3 = ` ${TranslationLoader10.t("startupTime", this.localLang)}`;
|
|
1057
1101
|
const msg4 = ` ${this.getServerRunningMode("development", "production")}`;
|
|
1058
1102
|
const msg5 = ` ${colors.underline(`http://${host}:${port}`)}`;
|
|
1059
1103
|
console.log(chalk.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
@@ -1064,27 +1108,28 @@ var Utility = class {
|
|
|
1064
1108
|
console.log(chalk.bgGreen.white(msg5.padEnd(61, " ")));
|
|
1065
1109
|
console.log(chalk.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
1066
1110
|
console.log(``);
|
|
1067
|
-
console.log(`${`${TranslationLoader10.t("totalMemory",
|
|
1068
|
-
console.log(`${`${TranslationLoader10.t("memoryUsedDuringExecution",
|
|
1069
|
-
console.log(`${`${TranslationLoader10.t("memoryUsedByUser",
|
|
1070
|
-
console.log(`${`${TranslationLoader10.t("memoryUsedBySystem",
|
|
1111
|
+
console.log(`${`${TranslationLoader10.t("totalMemory", this.localLang)}`} ${colors.cyan(`${colors.bold(`${rss}`)}`)}`);
|
|
1112
|
+
console.log(`${`${TranslationLoader10.t("memoryUsedDuringExecution", this.localLang)}`} ${colors.cyan(`${colors.bold(`${heapUsed}`)}`)}`);
|
|
1113
|
+
console.log(`${`${TranslationLoader10.t("memoryUsedByUser", this.localLang)}`} ${colors.cyan(`${colors.bold(`${user}`)}`)}`);
|
|
1114
|
+
console.log(`${`${TranslationLoader10.t("memoryUsedBySystem", this.localLang)}`} ${colors.cyan(`${colors.bold(`${system}`)}`)}`);
|
|
1071
1115
|
console.log(``);
|
|
1072
1116
|
}
|
|
1073
1117
|
};
|
|
1074
1118
|
|
|
1075
1119
|
// src/core/events/pathModuleVerifier.event.ts
|
|
1076
1120
|
import { resolve } from "path";
|
|
1077
|
-
import { LoggerCore as
|
|
1121
|
+
import { LoggerCore as LoggerCore6 } from "opticore-logger";
|
|
1078
1122
|
import { HttpStatusCode as HttpStatusCode2 } from "opticore-http-response";
|
|
1079
|
-
import {
|
|
1123
|
+
import { TranslationLoader as TranslationLoader11 } from "opticore-translator";
|
|
1080
1124
|
var PathModuleVerifier = class {
|
|
1081
|
-
static log = new
|
|
1125
|
+
static log = new LoggerCore6(loggerConfig);
|
|
1082
1126
|
/**
|
|
1083
1127
|
* Verifies if modules at specific paths are loaded.
|
|
1084
1128
|
* If any module is not loaded, it throws an error.
|
|
1129
|
+
* @param localLanguage
|
|
1085
1130
|
* @param modulePaths - An array of paths to the modules to verify.
|
|
1086
1131
|
*/
|
|
1087
|
-
static verifyModulePaths(modulePaths) {
|
|
1132
|
+
static verifyModulePaths(localLanguage, modulePaths) {
|
|
1088
1133
|
const notLoadedPaths = [];
|
|
1089
1134
|
for (const modulePath of modulePaths) {
|
|
1090
1135
|
if (!this.isModulePathLoaded(modulePath)) {
|
|
@@ -1093,7 +1138,7 @@ var PathModuleVerifier = class {
|
|
|
1093
1138
|
}
|
|
1094
1139
|
if (notLoadedPaths.length > 0) {
|
|
1095
1140
|
this.log.error(
|
|
1096
|
-
TranslationLoader11.t("moduleNotLoaded",
|
|
1141
|
+
TranslationLoader11.t("moduleNotLoaded", localLanguage, { notLoadedPaths: notLoadedPaths.join(", ") }),
|
|
1097
1142
|
"",
|
|
1098
1143
|
"",
|
|
1099
1144
|
modulePaths,
|