opticore-webapp-core 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,1128 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
7
+
8
+ // src/application/services/asymmetricCryptionDataWithPrivateRSAKey.service.ts
9
+ import crypto3 from "crypto";
10
+ import { HttpStatusCode as status } from "opticore-http-response";
11
+ import { LoggerCore } from "opticore-logger";
12
+ import { CLocal, TranslationLoader } from "opticore-translator";
13
+ import { StackTraceError as ErrorHandler } from "opticore-catch-exception-error";
14
+
15
+ // src/utils/cryptography/encryption/rsaKey.encryption.ts
16
+ import crypto from "crypto";
17
+
18
+ // src/core/constants/signRSA/algorithm.constant.ts
19
+ var CAlgorithm = {
20
+ RSA_MD5: "RSA-MD5",
21
+ RSA_RIPEMD160: "RSA-RIPEMD160",
22
+ RSA_SHA1: "RSA-SHA1",
23
+ RSA_SHA1_2: "RSA-SHA1-2",
24
+ RSA_SHA224: "RSA-SHA224",
25
+ RSA_SHA256: "RSA-SHA256",
26
+ RSA_SHA3_224: "RSA-SHA3-224",
27
+ RSA_SHA3_256: "RSA-SHA3-256",
28
+ RSA_SHA3_384: "RSA-SHA3-384",
29
+ RSA_SHA3_512: "RSA-SHA3-512",
30
+ RSA_SHA384: "RSA-SHA384",
31
+ RSA_SHA512: "RSA-SHA512",
32
+ RSA_SHA512_224: "RSA-SHA512/224",
33
+ RSA_SHA512_256: "RSA-SHA512/256",
34
+ RSA_SM3: "RSA-SM3",
35
+ blake2b512: "blake2b512",
36
+ blake2s256: "blake2s256",
37
+ id_rsassa_pkcs1_v1_5_with_sha3_224: "id-rsassa-pkcs1-v1_5-with-sha3-224",
38
+ id_rsassa_pkcs1_v1_5_with_sha3_256: "id-rsassa-pkcs1-v1_5-with-sha3-256",
39
+ id_rsassa_pkcs1_v1_5_with_sha3_384: "id-rsassa-pkcs1-v1_5-with-sha3-384",
40
+ id_rsassa_pkcs1_v1_5_with_sha3_512: "id-rsassa-pkcs1-v1_5-with-sha3-512",
41
+ md5: "md5",
42
+ md5_sha1: "md5-sha1",
43
+ md5WithRSAEncryption: "md5WithRSAEncryption",
44
+ ripemd: "ripemd",
45
+ ripemd160: "ripemd160",
46
+ ripemd160WithRSA: "ripemd160WithRSA",
47
+ rmd160: "rmd160",
48
+ sha1: "sha1",
49
+ sha1WithRSAEncryption: "sha1WithRSAEncryption",
50
+ sha224: "sha224",
51
+ sha224WithRSAEncryption: "sha224WithRSAEncryption",
52
+ sha256: "SHA256",
53
+ sha256WithRSAEncryption: "sha256WithRSAEncryption",
54
+ sha3_224: "sha3-224",
55
+ sha3_256: "sha3-256",
56
+ sha3_384: "sha3-384",
57
+ sha3_512: "sha3-512",
58
+ sha384: "sha384",
59
+ sha384WithRSAEncryption: "sha384WithRSAEncryption",
60
+ sha512: "sha512",
61
+ sha512_224: "sha512-224",
62
+ sha512_224WithRSAEncryption: "sha512-224WithRSAEncryption",
63
+ sha512_256: "sha512-256",
64
+ sha512_256WithRSAEncryption: "sha512-256WithRSAEncryption",
65
+ sha512WithRSAEncryption: "sha512WithRSAEncryption",
66
+ shake128: "shake128",
67
+ shake256: "shake256",
68
+ sm3: "sm3",
69
+ sm3WithRSAEncryption: "sm3WithRSAEncryption",
70
+ ssl3_md5: "ssl3-md5",
71
+ ssl3_sha1: "ssl3-sha1"
72
+ };
73
+
74
+ // src/core/constants/signRSA/keyType.constant.ts
75
+ var CKeyType = {
76
+ private: "Private",
77
+ public: "Public"
78
+ };
79
+
80
+ // src/core/constants/signRSA/outputFormat.constant.ts
81
+ var COutputFormat = {
82
+ base64: "base64",
83
+ base64url: "base64url",
84
+ hex: "hex",
85
+ binary: "binary"
86
+ };
87
+
88
+ // src/core/constants/signRSA/encodingFormat.constant.ts
89
+ var CEncodingFormat = {
90
+ ascii: "ascii",
91
+ utf8: "utf8",
92
+ utf_8: "utf-8",
93
+ utf16le: "utf16le",
94
+ utf_16le: "utf-16le",
95
+ ucs2: "ucs2",
96
+ ucs_2: "ucs-2",
97
+ base64: "base64",
98
+ base64url: "base64url",
99
+ latin1: "latin1",
100
+ binary: "binary",
101
+ hex: "hex"
102
+ };
103
+
104
+ // src/core/constants/signRSAKeyComponent.constant.ts
105
+ var CSignRSAKeyComponent = {
106
+ algorithm: CAlgorithm,
107
+ keyType: CKeyType,
108
+ outputFormat: COutputFormat,
109
+ encodingFormat: CEncodingFormat
110
+ };
111
+
112
+ // src/utils/cryptography/encryption/rsaKey.encryption.ts
113
+ var RSAKeyEncryption = class {
114
+ static privateEncrypt(privateKey, encryptData) {
115
+ const rsaPrivateKey = {
116
+ key: privateKey
117
+ };
118
+ const bufferData = Buffer.from(encryptData, CSignRSAKeyComponent.encodingFormat.utf8);
119
+ return crypto.privateEncrypt(rsaPrivateKey, bufferData);
120
+ }
121
+ static publicEncrypt(publicKey, encryptData) {
122
+ const rsaPublicKey = { key: publicKey };
123
+ const bufferData = Buffer.from(encryptData, CSignRSAKeyComponent.encodingFormat.utf8);
124
+ return crypto.publicEncrypt(rsaPublicKey, bufferData);
125
+ }
126
+ };
127
+
128
+ // src/utils/cryptography/decryption/rsaKey.decryption.ts
129
+ import crypto2 from "crypto";
130
+ var RSAKeyDecryption = class {
131
+ static privateDecrypt(privateKey, decryptData) {
132
+ const rsaPrivateKey = { key: privateKey };
133
+ return crypto2.privateDecrypt(rsaPrivateKey, decryptData);
134
+ }
135
+ static publicDecrypt(publicKey, decryptData) {
136
+ const rsaPublicKey = { key: publicKey };
137
+ return crypto2.publicDecrypt(rsaPublicKey, decryptData);
138
+ }
139
+ };
140
+
141
+ // src/core/config/logger/logger.config.ts
142
+ import { getEnvVariable } from "opticore-env-access";
143
+ var loggerConfig = {
144
+ logLevels: [
145
+ getEnvVariable.logLevelInfo,
146
+ getEnvVariable.logLevelWarning,
147
+ getEnvVariable.logLevelSuccess,
148
+ getEnvVariable.logLevelError,
149
+ getEnvVariable.logLevelDebug
150
+ ],
151
+ transports: {
152
+ file: {
153
+ enabled: getEnvVariable.logFileEnabled,
154
+ maxSizeMB: getEnvVariable.logFileMaxSize,
155
+ rotate: getEnvVariable.logFileRotate
156
+ },
157
+ console: {
158
+ enabled: getEnvVariable.logConsoleEnabled
159
+ },
160
+ remote: {
161
+ enabled: getEnvVariable.logRemoteEnabled,
162
+ endpoint: getEnvVariable.logRemoteEndPoint
163
+ }
164
+ }
165
+ };
166
+
167
+ // src/application/services/asymmetricCryptionDataWithPrivateRSAKey.service.ts
168
+ var SAsymmetricCryptionDataWithPrivateRSAKey = class {
169
+ /**
170
+ *
171
+ * @param rsaKey
172
+ * @param keyType
173
+ * @protected
174
+ *
175
+ * Return ErrorHandler | string
176
+ */
177
+ static verifyExistingKey(rsaKey, keyType) {
178
+ if (!rsaKey) {
179
+ const stackTrace = this.traceError(
180
+ keyType + " " + TranslationLoader.t("rsaKeyNotFound", CLocal),
181
+ TranslationLoader.t("erBadDbError", CLocal),
182
+ status.NOT_FOUND
183
+ );
184
+ this.log.error(
185
+ TranslationLoader.t("rsaKeyNotFound", CLocal),
186
+ TranslationLoader.t("verifyExistingKey", CLocal),
187
+ TranslationLoader.t("erBadDbError", CLocal),
188
+ stackTrace.stack,
189
+ status.NOT_FOUND
190
+ );
191
+ throw new Error();
192
+ }
193
+ return rsaKey;
194
+ }
195
+ /**
196
+ *
197
+ * @param privateKey
198
+ * @param payload
199
+ * @private
200
+ *
201
+ * Return Buffer
202
+ */
203
+ static encryptionWithPrivateKey(privateKey, payload) {
204
+ this.verifyExistingKey(privateKey, CSignRSAKeyComponent.keyType.private);
205
+ try {
206
+ const bufferedData = Buffer.from(payload, Number(CSignRSAKeyComponent.encodingFormat));
207
+ return RSAKeyEncryption.privateEncrypt(privateKey, bufferedData);
208
+ } catch (err) {
209
+ const stackTrace = this.traceError(
210
+ TranslationLoader.t("encryptionWithPrivateKeyFailed", CLocal),
211
+ TranslationLoader.t("encryptionFailed", CLocal),
212
+ status.NOT_FOUND
213
+ );
214
+ this.log.error(
215
+ err.message,
216
+ TranslationLoader.t("encryptionFailed", CLocal),
217
+ TranslationLoader.t("encryptionWithPrivateKeyFailed", CLocal),
218
+ stackTrace.stack,
219
+ status.NOT_FOUND
220
+ );
221
+ throw new Error();
222
+ }
223
+ }
224
+ /**
225
+ *
226
+ * @param privateKey
227
+ * @param publicKey
228
+ * @param payload
229
+ * @private
230
+ */
231
+ static decryptionWithPublicKey(privateKey, publicKey, payload) {
232
+ this.verifyExistingKey(publicKey, CSignRSAKeyComponent.keyType.public);
233
+ try {
234
+ const encryptedPayload = this.encryptionWithPrivateKey(privateKey, payload);
235
+ return RSAKeyDecryption.publicDecrypt(publicKey, encryptedPayload);
236
+ } catch (error) {
237
+ const stackTrace = this.traceError(
238
+ TranslationLoader.t("errorDecryption", CLocal),
239
+ TranslationLoader.t("decryptionFailed", CLocal),
240
+ status.NOT_ACCEPTABLE
241
+ );
242
+ this.log.error(
243
+ TranslationLoader.t("decryptionWithPublicKeyFailed", CLocal),
244
+ TranslationLoader.t("decryptionFailed", CLocal),
245
+ stackTrace.stack,
246
+ TranslationLoader.t("errorDecryption", CLocal),
247
+ status.NOT_ACCEPTABLE
248
+ );
249
+ throw new Error();
250
+ }
251
+ }
252
+ /**
253
+ *
254
+ * @param privateKey
255
+ * @param payload
256
+ * @private
257
+ */
258
+ static signWithRSAKey(privateKey, payload) {
259
+ this.verifyExistingKey(privateKey, CSignRSAKeyComponent.keyType.private);
260
+ const sign = crypto3.createSign(CSignRSAKeyComponent.algorithm.sha256);
261
+ sign.update(payload);
262
+ return sign.sign(privateKey, CSignRSAKeyComponent.outputFormat.base64);
263
+ }
264
+ /**
265
+ *
266
+ * @param privateKey
267
+ * @param publicKey
268
+ * @param payload
269
+ */
270
+ static verifyRSAKey(privateKey, publicKey, payload) {
271
+ try {
272
+ const verify = crypto3.createVerify(CSignRSAKeyComponent.algorithm.sha256);
273
+ verify.update(payload);
274
+ const signature = this.signWithRSAKey(privateKey, payload);
275
+ const isVerified = verify.verify(publicKey, signature, CSignRSAKeyComponent.outputFormat.base64);
276
+ if (isVerified) {
277
+ const decryptedData = this.decryptionWithPublicKey(privateKey, publicKey, payload);
278
+ return decryptedData.toString(CSignRSAKeyComponent.encodingFormat.utf_8);
279
+ } else {
280
+ const stackTrace = this.traceError(
281
+ TranslationLoader.t("signatureRSAKeyFailed", CLocal),
282
+ TranslationLoader.t("verifyRSAKeyFailed", CLocal),
283
+ status.NOT_ACCEPTABLE
284
+ );
285
+ this.log.error(
286
+ TranslationLoader.t("verifyRSAKey", CLocal),
287
+ TranslationLoader.t("verifyRSAKeyFailed", CLocal),
288
+ stackTrace.stack,
289
+ TranslationLoader.t("signatureRSAKeyFailed", CLocal),
290
+ status.NOT_FOUND
291
+ );
292
+ return new Error();
293
+ }
294
+ } catch (err) {
295
+ const stackTrace = this.traceError(
296
+ err.name,
297
+ TranslationLoader.t("signatureRSAKeysError", CLocal),
298
+ status.NOT_ACCEPTABLE
299
+ );
300
+ this.log.error(
301
+ TranslationLoader.t("signatureRSAKeysError", CLocal),
302
+ TranslationLoader.t("errorNameNotVerifyingRSAKey", CLocal),
303
+ stackTrace.stack,
304
+ err.message,
305
+ status.NOT_FOUND
306
+ );
307
+ throw new Error();
308
+ }
309
+ }
310
+ /**
311
+ *
312
+ * @param props
313
+ * @param name
314
+ * @param status
315
+ * @private
316
+ */
317
+ static traceError(props, name, status7) {
318
+ return new ErrorHandler(props, name, status7, true);
319
+ }
320
+ };
321
+ SAsymmetricCryptionDataWithPrivateRSAKey.log = new LoggerCore(loggerConfig);
322
+
323
+ // src/application/services/asymmetricCryptionDataWithPublicRSAKey.service.ts
324
+ import crypto4 from "crypto";
325
+ import { LoggerCore as LoggerCore2 } from "opticore-logger";
326
+ import { CLocal as CLocal2, TranslationLoader as TranslationLoader2 } from "opticore-translator";
327
+ import { HttpStatusCode as status2 } from "opticore-http-response";
328
+ import { StackTraceError } from "opticore-catch-exception-error";
329
+ var SAsymmetricCryptionDataWithPublicRSAKey = class {
330
+ /**
331
+ *
332
+ * @param rsaKey
333
+ * @param keyType
334
+ * @protected
335
+ */
336
+ static verifyExistingKey(rsaKey, keyType) {
337
+ if (!rsaKey) {
338
+ const stackTrace = this.traceError(
339
+ keyType + TranslationLoader2.t("verifyExistingKey", CLocal2),
340
+ TranslationLoader2.t("verifyExistingKey", CLocal2),
341
+ status2.NOT_FOUND
342
+ );
343
+ this.log.error(
344
+ TranslationLoader2.t("verifyExistingKey", CLocal2),
345
+ "key verification",
346
+ stackTrace.stack,
347
+ TranslationLoader2.t("verifyExistingKeyError", CLocal2),
348
+ status2.NOT_FOUND
349
+ );
350
+ return new Error();
351
+ }
352
+ return rsaKey;
353
+ }
354
+ /**
355
+ *
356
+ * @param publicKey
357
+ * @param payload
358
+ * @private
359
+ */
360
+ static encryptionWithPublicKey(publicKey, payload) {
361
+ this.verifyExistingKey(publicKey, CSignRSAKeyComponent.keyType.public);
362
+ try {
363
+ const bufferedData = Buffer.from(payload, Number(CSignRSAKeyComponent.encodingFormat));
364
+ return RSAKeyEncryption.publicEncrypt(publicKey, bufferedData);
365
+ } catch (err) {
366
+ const stackTrace = this.traceError(
367
+ err.message,
368
+ TranslationLoader2.t("encryptionWithPublicKey", CLocal2),
369
+ status2.NOT_ACCEPTABLE
370
+ );
371
+ this.log.error(
372
+ TranslationLoader2.t("errorEncryptionPublicKey", CLocal2),
373
+ TranslationLoader2.t("encryptionWithPublicKey", CLocal2),
374
+ stackTrace.stack,
375
+ err.message,
376
+ status2.NOT_ACCEPTABLE
377
+ );
378
+ throw new Error();
379
+ }
380
+ }
381
+ /**
382
+ *
383
+ * @param privateKey
384
+ * @param publicKey
385
+ * @param payload
386
+ * @private
387
+ */
388
+ static decryptionWithPrivateKey(privateKey, publicKey, payload) {
389
+ this.verifyExistingKey(publicKey, CSignRSAKeyComponent.keyType.public);
390
+ try {
391
+ const encryptedPayload = this.encryptionWithPublicKey(publicKey, payload);
392
+ return RSAKeyDecryption.privateDecrypt(privateKey, encryptedPayload);
393
+ } catch (err) {
394
+ const stackTrace = this.traceError(
395
+ err.code,
396
+ TranslationLoader2.t("errorDecryption", CLocal2),
397
+ status2.NOT_ACCEPTABLE
398
+ );
399
+ this.log.error(
400
+ TranslationLoader2.t("errorDecryptionWithPrivateKey", CLocal2),
401
+ TranslationLoader2.t("errorDecryption", CLocal2),
402
+ stackTrace.stack,
403
+ err.message,
404
+ status2.NOT_ACCEPTABLE
405
+ );
406
+ throw new Error();
407
+ }
408
+ }
409
+ /**
410
+ *
411
+ * @param publicKey
412
+ * @param payload
413
+ * @private
414
+ */
415
+ static signWithPublicRSAKey(publicKey, payload) {
416
+ this.verifyExistingKey(publicKey, CSignRSAKeyComponent.keyType.private);
417
+ const sign = crypto4.createSign(CSignRSAKeyComponent.algorithm.sha256);
418
+ sign.update(payload);
419
+ return sign.sign(publicKey, CSignRSAKeyComponent.outputFormat.base64);
420
+ }
421
+ /**
422
+ *
423
+ * @param privateKey
424
+ * @param publicKey
425
+ * @param payload
426
+ */
427
+ static verifyPublicRSAKey(privateKey, publicKey, payload) {
428
+ try {
429
+ const verify = crypto4.createVerify(CSignRSAKeyComponent.algorithm.sha256);
430
+ verify.update(payload);
431
+ const signature = this.signWithPublicRSAKey(publicKey, payload);
432
+ const isVerified = verify.verify(publicKey, signature, CSignRSAKeyComponent.outputFormat.base64);
433
+ if (isVerified) {
434
+ const decryptedData = this.decryptionWithPrivateKey(privateKey, publicKey, payload);
435
+ return decryptedData.toString(CSignRSAKeyComponent.encodingFormat.utf_8);
436
+ } else {
437
+ const stackTrace = this.traceError(
438
+ TranslationLoader2.t("verifyPublicRSAKeyError", CLocal2),
439
+ TranslationLoader2.t("signatureRSAKeyFailed", CLocal2),
440
+ status2.NOT_FOUND
441
+ );
442
+ this.log.error(
443
+ TranslationLoader2.t("verifyPublicRSAKey", CLocal2),
444
+ TranslationLoader2.t("signatureRSAKeyFailed", CLocal2),
445
+ stackTrace.stack,
446
+ TranslationLoader2.t("verifyPublicRSAKeyError", CLocal2),
447
+ status2.NOT_FOUND
448
+ );
449
+ return stackTrace;
450
+ }
451
+ } catch (err) {
452
+ const stackTrace = this.traceError(
453
+ err.code,
454
+ TranslationLoader2.t("verifyPublicRSAKey", CLocal2),
455
+ status2.NOT_ACCEPTABLE
456
+ );
457
+ this.log.error(
458
+ TranslationLoader2.t("verifyPublicRSAKey", CLocal2),
459
+ TranslationLoader2.t("errorDecryption", CLocal2),
460
+ stackTrace.stack,
461
+ err.message,
462
+ status2.NOT_ACCEPTABLE
463
+ );
464
+ throw new Error();
465
+ }
466
+ }
467
+ static traceError(props, name, status7) {
468
+ return new StackTraceError(props, name, status7, true);
469
+ }
470
+ };
471
+ SAsymmetricCryptionDataWithPublicRSAKey.log = new LoggerCore2(loggerConfig);
472
+
473
+ // src/application/services/checkerMongoDatabaseConnection.service.ts
474
+ import { MongoClient } from "mongodb";
475
+ async function SCheckerMongoDatabaseConnection(url, user, password, dbName) {
476
+ const client = new MongoClient(
477
+ url,
478
+ {
479
+ auth: { username: user, password }
480
+ }
481
+ );
482
+ await client.connect();
483
+ }
484
+
485
+ // src/core/handlers/errors/database/mySqlError.handler.database.ts
486
+ import { LoggerCore as LoggerCore3 } from "opticore-logger";
487
+ import { HttpStatusCode as status3 } from "opticore-http-response";
488
+ import { CLocal as CLocal3, TranslationLoader as TranslationLoader3 } from "opticore-translator";
489
+ function mySqlErrorHandlerDatabase(err, dbHost, database, user, password) {
490
+ const logger = new LoggerCore3(loggerConfig);
491
+ switch (err.code) {
492
+ case "EAI_AGAIN":
493
+ logger.error(
494
+ TranslationLoader3.t("errorDBHost", CLocal3, { dbHost }),
495
+ TranslationLoader3.t("mySQLError", CLocal3),
496
+ TranslationLoader3.t("eAiAgain", CLocal3),
497
+ err.stack,
498
+ status3.NOT_ACCEPTABLE
499
+ );
500
+ break;
501
+ case "ER_NOT_SUPPORTED_AUTH_MODE":
502
+ logger.error(
503
+ TranslationLoader3.t("erNotSupportedAuthModeError", CLocal3),
504
+ TranslationLoader3.t("dbConnection", CLocal3),
505
+ TranslationLoader3.t("erNotSupportedAuthMode", CLocal3),
506
+ err.stack,
507
+ status3.NOT_ACCEPTABLE
508
+ );
509
+ break;
510
+ case "ER_ACCESS_DENIED_ERROR":
511
+ logger.error(
512
+ TranslationLoader3.t("accessDeniedToDBCon", CLocal3, { user, password }),
513
+ TranslationLoader3.t("dbConnection", CLocal3),
514
+ TranslationLoader3.t("erAccessDeniedError", CLocal3),
515
+ err.stack,
516
+ status3.NOT_ACCEPTABLE
517
+ );
518
+ break;
519
+ case "ER_BAD_DB_ERROR":
520
+ logger.error(
521
+ TranslationLoader3.t("unknownDB", CLocal3, { database }),
522
+ TranslationLoader3.t("dbConnection", CLocal3),
523
+ TranslationLoader3.t("erBadDbError", CLocal3),
524
+ err.stack,
525
+ status3.NOT_ACCEPTABLE
526
+ );
527
+ break;
528
+ default:
529
+ logger.error(
530
+ err.message,
531
+ TranslationLoader3.t("dbConnection", CLocal3),
532
+ TranslationLoader3.t("mysqlErrorCon", CLocal3),
533
+ err.stack,
534
+ status3.NOT_ACCEPTABLE
535
+ );
536
+ break;
537
+ }
538
+ }
539
+
540
+ // src/application/services/checkerMySqlDatabaseConnection.service.ts
541
+ import { LoggerCore as LoggerCore4 } from "opticore-logger";
542
+ import { CLocal as CLocal4, TranslationLoader as TranslationLoader4 } from "opticore-translator";
543
+ function SCheckerMySqlDatabaseConnection(dbConnection, user, database, dbHost, password) {
544
+ const log = new LoggerCore4(loggerConfig);
545
+ dbConnection.connect((err) => {
546
+ if (err) {
547
+ return mySqlErrorHandlerDatabase(err, dbHost, database, user, password);
548
+ } else {
549
+ log.success(
550
+ TranslationLoader4.t("dbConnection", CLocal4),
551
+ TranslationLoader4.t("dbConnexionSuccess", CLocal4)
552
+ );
553
+ return dbConnection.end((endConErr) => {
554
+ if (endConErr) {
555
+ return mySqlErrorHandlerDatabase(err, dbHost, database, user, password);
556
+ } else {
557
+ log.success(
558
+ TranslationLoader4.t("dbConnection", CLocal4),
559
+ TranslationLoader4.t("dbConnectionClosed", CLocal4)
560
+ );
561
+ console.log("");
562
+ }
563
+ });
564
+ }
565
+ });
566
+ }
567
+
568
+ // src/application/services/checkerPostgresDatabaseConnection.service.ts
569
+ import { HttpStatusCode as status4 } from "opticore-http-response";
570
+ import { Client } from "pg";
571
+ import { LoggerCore as LoggerCore5 } from "opticore-logger";
572
+ import { CLocal as CLocal5, TranslationLoader as TranslationLoader5 } from "opticore-translator";
573
+ async function SCheckerPostgresDatabaseConnection(connectionString, keepAlive, stream, statement_timeout, ssl, query_timeout, keepAliveInitialDelayMillis, idle_in_transaction_session_timeout, application_name, connectionTimeoutMillis, types, options) {
574
+ const logger = new LoggerCore5(loggerConfig);
575
+ const configOptions = {
576
+ connectionString,
577
+ keepAlive,
578
+ stream,
579
+ statement_timeout,
580
+ ssl,
581
+ query_timeout,
582
+ keepAliveInitialDelayMillis,
583
+ idle_in_transaction_session_timeout,
584
+ application_name,
585
+ connectionTimeoutMillis,
586
+ types,
587
+ options
588
+ };
589
+ const client = new Client(configOptions);
590
+ await client.connect();
591
+ await client.end().then(
592
+ () => {
593
+ logger.success(
594
+ TranslationLoader5.t("postgresSuccessConn", CLocal5),
595
+ TranslationLoader5.t("postgresClosingConnSuccess", CLocal5)
596
+ );
597
+ },
598
+ (onRejected) => {
599
+ logger.error(
600
+ TranslationLoader5.t("postgresEndClientRejection", CLocal5),
601
+ TranslationLoader5.t("postgresClientError", CLocal5),
602
+ TranslationLoader5.t("postgresEndRejection", CLocal5),
603
+ onRejected,
604
+ status4.BAD_REQUEST
605
+ );
606
+ }
607
+ ).catch((onError) => {
608
+ logger.error(
609
+ onError.message,
610
+ TranslationLoader5.t("postgresConnError", CLocal5),
611
+ TranslationLoader5.t("postgresException", CLocal5),
612
+ onError.stack,
613
+ status4.BAD_REQUEST
614
+ );
615
+ });
616
+ }
617
+
618
+ // src/domains/constants/logLevel.constant.ts
619
+ var CLogLevel = {
620
+ debug: "DEBUG",
621
+ info: "INFO",
622
+ warn: "WARN",
623
+ error: "ERROR"
624
+ };
625
+
626
+ // src/utils/connection/optionalArgumentConnection.util.ts
627
+ import { getEnvVariable as getEnvVariable2 } from "opticore-env-access";
628
+ var optionalArgumentConnectionUtil = getEnvVariable2.argumentsDatabaseConnection;
629
+
630
+ // src/utils/parsing/parsingYaml.utils.ts
631
+ import { readFile } from "fs/promises";
632
+ import { HttpStatusCode } from "opticore-http-response";
633
+ import { LoggerCore as LoggerCore6 } from "opticore-logger";
634
+ import { CLocal as CLocal6, TranslationLoader as TranslationLoader6 } from "opticore-translator";
635
+ var YamlParsing = class {
636
+ static async readFile(filePath) {
637
+ try {
638
+ const yamlContent = await readFile(filePath, "utf-8");
639
+ await this.parsing(yamlContent);
640
+ } catch (error) {
641
+ this.logger.error(
642
+ error.message,
643
+ TranslationLoader6.t("parsingFailed", CLocal6),
644
+ TranslationLoader6.t("readingError", CLocal6),
645
+ error.stack,
646
+ HttpStatusCode.NOT_ACCEPTABLE
647
+ );
648
+ }
649
+ }
650
+ /**
651
+ *
652
+ * @param content
653
+ * @private
654
+ */
655
+ static async parsing(content) {
656
+ const result = {};
657
+ const lines = content.split("\n");
658
+ let currentKey = null;
659
+ for (const line of lines) {
660
+ if (!line.trim() || line.trim().startsWith("#")) {
661
+ continue;
662
+ }
663
+ const keyValueMatch = line.match(/^(\s*)([a-zA-Z0-9_]+):(?:\s*(.*))?$/);
664
+ if (keyValueMatch) {
665
+ const [, indent, key, value] = keyValueMatch;
666
+ if (indent.length > 0 && currentKey) {
667
+ result[currentKey] = result[currentKey] || {};
668
+ result[currentKey][key] = (value == null ? void 0 : value.trim()) || null;
669
+ } else {
670
+ currentKey = key;
671
+ result[key] = (value == null ? void 0 : value.trim()) || null;
672
+ }
673
+ } else {
674
+ this.logger.error(
675
+ TranslationLoader6.t("badFormat", CLocal6, { line }),
676
+ TranslationLoader6.t("parsingFailed", CLocal6),
677
+ TranslationLoader6.t("unsupportedFormat", CLocal6),
678
+ content,
679
+ HttpStatusCode.NOT_ACCEPTABLE
680
+ );
681
+ }
682
+ }
683
+ return result;
684
+ }
685
+ };
686
+ YamlParsing.logger = new LoggerCore6(loggerConfig);
687
+
688
+ // src/utils/dateTimeFormatted.utils.ts
689
+ var dateTimeFormatted = `${(/* @__PURE__ */ new Date()).getMonth()}-${(/* @__PURE__ */ new Date()).getDate()}-${(/* @__PURE__ */ new Date()).getFullYear()} ${(/* @__PURE__ */ new Date()).getHours()}:${(/* @__PURE__ */ new Date()).getMinutes()}:${(/* @__PURE__ */ new Date()).getSeconds()}`;
690
+
691
+ // src/utils/environment.utils.ts
692
+ var Environment = class {
693
+ constructor(config) {
694
+ this.config = config;
695
+ }
696
+ get(key) {
697
+ return this.config[key];
698
+ }
699
+ };
700
+
701
+ // src/core/config/database/connexion.config.database.ts
702
+ import mySQL from "mysql";
703
+ import { HttpStatusCode as status6 } from "opticore-http-response";
704
+ import { getEnvVariable as getEnvVariable3 } from "opticore-env-access";
705
+ import { LoggerCore as LoggerCore8 } from "opticore-logger";
706
+ import { CLocal as CLocal8, TranslationLoader as TranslationLoader8 } from "opticore-translator";
707
+
708
+ // src/core/errors/databaseConnexion.error.ts
709
+ import { HttpStatusCode as status5 } from "opticore-http-response";
710
+ import { LoggerCore as LoggerCore7 } from "opticore-logger";
711
+ import { StackTraceError as StackTraceError2 } from "opticore-catch-exception-error";
712
+ import { CLocal as CLocal7, TranslationLoader as TranslationLoader7 } from "opticore-translator";
713
+ var DbConnexionConfigError = class {
714
+ /**
715
+ *
716
+ * @param e
717
+ */
718
+ static mongoDBAuthenticationFailed(e) {
719
+ const stackTrace = this.traceError(
720
+ TranslationLoader7.t("mongoDBConnection", CLocal7),
721
+ TranslationLoader7.t("mongoDBAuthentication", CLocal7),
722
+ status5.UNAUTHORIZED
723
+ );
724
+ this.logger.error(
725
+ TranslationLoader7.t("mongoDBAuthenticationError", CLocal7),
726
+ TranslationLoader7.t("mongoDBConnection", CLocal7),
727
+ TranslationLoader7.t("mongoDBAuthenticationFailed", CLocal7),
728
+ stackTrace.stack,
729
+ status5.UNAUTHORIZED
730
+ );
731
+ }
732
+ /**
733
+ *
734
+ * @param err
735
+ * @param dbHost
736
+ * @param dbPort
737
+ */
738
+ static mongoDBInvalidUrl(err, dbHost, dbPort) {
739
+ const stackTrace = this.traceError(
740
+ TranslationLoader7.t("mongoDBConnection", CLocal7),
741
+ TranslationLoader7.t("mongoDBUnableParsingUrl", CLocal7),
742
+ status5.BAD_REQUEST
743
+ );
744
+ this.logger.error(
745
+ TranslationLoader7.t("dbUrlParsingError", CLocal7, { dbHost, dbPort }),
746
+ TranslationLoader7.t("mongoDBConnection", CLocal7),
747
+ TranslationLoader7.t("mongoDBUnableParsingUrl", CLocal7),
748
+ stackTrace.stack,
749
+ status5.BAD_REQUEST
750
+ );
751
+ }
752
+ /**
753
+ *
754
+ * @param err
755
+ * @param dbHost
756
+ */
757
+ static mongoDBEaiAgain(err, dbHost) {
758
+ const stackTrace = this.traceError(
759
+ TranslationLoader7.t("mongoDBConnection", CLocal7),
760
+ TranslationLoader7.t("mongoDBServerSelection", CLocal7),
761
+ status5.BAD_REQUEST
762
+ );
763
+ this.logger.error(
764
+ TranslationLoader7.t("mongoServerError", CLocal7, { dbHost }),
765
+ TranslationLoader7.t("mongoDBConnection", CLocal7),
766
+ TranslationLoader7.t("mongoDBServerSelection", CLocal7),
767
+ stackTrace.stack,
768
+ status5.BAD_REQUEST
769
+ );
770
+ }
771
+ /**
772
+ *
773
+ * @param err
774
+ */
775
+ static mongoDbGlobalError(err) {
776
+ const stackTrace = this.traceError(
777
+ err.message,
778
+ TranslationLoader7.t("mongoDBConnection", CLocal7),
779
+ status5.NOT_ACCEPTABLE
780
+ );
781
+ this.logger.error(
782
+ TranslationLoader7.t("mongoDBConnection", CLocal7),
783
+ TranslationLoader7.t("mongoDBConnectionError", CLocal7),
784
+ stackTrace.stack,
785
+ err.message,
786
+ status5.NOT_ACCEPTABLE
787
+ );
788
+ }
789
+ /**
790
+ *
791
+ * @param props
792
+ * @param name
793
+ * @param status
794
+ * @private
795
+ */
796
+ static traceError(props, name, status7) {
797
+ return new StackTraceError2(props, name, status7, true);
798
+ }
799
+ };
800
+ DbConnexionConfigError.logger = new LoggerCore7(loggerConfig);
801
+
802
+ // src/core/config/database/connexion.config.database.ts
803
+ import { StackTraceError as ErrorHandler2 } from "opticore-catch-exception-error";
804
+ var DatabaseConnectionConfig = class {
805
+ constructor() {
806
+ this.env = new Environment(getEnvVariable3);
807
+ this.logger = new LoggerCore8(loggerConfig);
808
+ }
809
+ /**
810
+ * MySQL database connection with an optional arguments
811
+ * Establish the connection between app and Database Management System.
812
+ * Inside this class, a checker verifies if database credentials are right,
813
+ * and it's show off in the log that the connection has been created successfully.
814
+ * But if any error is occurring during trying connection, it'd specify that error by stack traces.
815
+ */
816
+ databaseMySQLConnexionChecker(optionalArgumentConnection) {
817
+ const dbURL = `${this.env.get("dataBaseUser")}:${this.env.get("dataBasePassword")}@${this.env.get("dataBaseHost")}:${this.env.get("dataBasePort")}/${this.env.get("dataBaseName")}`;
818
+ let url = `mysql://${dbURL}?${optionalArgumentConnection}`;
819
+ const dbConnection = mySQL.createConnection(url);
820
+ return SCheckerMySqlDatabaseConnection(dbConnection, this.env.get("dataBaseUser"), this.env.get("dataBaseName"), this.env.get("dataBaseHost"), this.env.get("dataBasePassword"));
821
+ }
822
+ /**
823
+ *
824
+ * @param optionalArgumentConnection
825
+ *
826
+ * Mongo database connection with optional connection arguments
827
+ */
828
+ async databaseMongoDBConnectionChecker(optionalArgumentConnection) {
829
+ const dbUrl = `${this.env.get("dataBaseUser")}:${this.env.get("dataBasePassword")}@${this.env.get("dataBaseHost")}:${this.env.get("dataBasePort")}/${this.env.get("dataBaseName")}`;
830
+ const url = `mongodb://${dbUrl}${optionalArgumentConnection}`;
831
+ try {
832
+ await SCheckerMongoDatabaseConnection(url, this.env.get("dataBaseUser"), this.env.get("dataBasePassword"), this.env.get("dataBaseName"));
833
+ this.logger.success(
834
+ TranslationLoader8.t("mongoDBConnectionChecker", CLocal8),
835
+ TranslationLoader8.t("mongoConnectionSuccess", CLocal8)
836
+ );
837
+ console.log("");
838
+ } catch (e) {
839
+ if (e.code === 18) {
840
+ DbConnexionConfigError.mongoDBAuthenticationFailed(e);
841
+ }
842
+ if (e.cause.code === "ERR_INVALID_URL") {
843
+ DbConnexionConfigError.mongoDBInvalidUrl(e, this.env.get("dataBaseHost"), this.env.get("dataBasePort"));
844
+ }
845
+ if (e.code === void 0) {
846
+ DbConnexionConfigError.mongoDBEaiAgain(e, this.env.get("dataBaseHost"));
847
+ } else {
848
+ DbConnexionConfigError.mongoDbGlobalError(e);
849
+ }
850
+ }
851
+ }
852
+ /**
853
+ *
854
+ * @param keepAlive
855
+ * @param stream
856
+ * @param statement_timeout
857
+ * @param ssl
858
+ * @param query_timeout
859
+ * @param keepAliveInitialDelayMillis
860
+ * @param idle_in_transaction_session_timeout
861
+ * @param application_name
862
+ * @param connectionTimeoutMillis
863
+ * @param types
864
+ * @param options
865
+ *
866
+ * Postgres database connection with optional connection arguments
867
+ */
868
+ async databasePostgresDBConnectionChecker(keepAlive, stream, statement_timeout, ssl, query_timeout, keepAliveInitialDelayMillis, idle_in_transaction_session_timeout, application_name, connectionTimeoutMillis, types, options) {
869
+ const url = `postgresql:/${this.env.get("dataBaseUser")}:${this.env.get("dataBasePassword")}@${this.env.get("dataBaseHost")}:${this.env.get("dataBasePort")}/${this.env.get("dataBaseName")}`;
870
+ try {
871
+ await SCheckerPostgresDatabaseConnection(
872
+ url,
873
+ keepAlive,
874
+ stream,
875
+ statement_timeout,
876
+ ssl,
877
+ query_timeout,
878
+ keepAliveInitialDelayMillis,
879
+ idle_in_transaction_session_timeout,
880
+ application_name,
881
+ connectionTimeoutMillis,
882
+ types,
883
+ options
884
+ );
885
+ this.logger.success(TranslationLoader8.t("postgresDBConnectionChecker", CLocal8), TranslationLoader8.t("postgresConnectionSuccess", CLocal8));
886
+ console.log("");
887
+ } catch (err) {
888
+ const stackTrace = this.traceError(
889
+ TranslationLoader8.t(`${err.message}`, CLocal8),
890
+ "PostgresConnectionError",
891
+ status6.NOT_ACCEPTABLE
892
+ );
893
+ this.logger.error(
894
+ err.message,
895
+ "PostgresConnectionError",
896
+ "Postgres connection error",
897
+ stackTrace.stack,
898
+ status6.NOT_ACCEPTABLE
899
+ );
900
+ }
901
+ }
902
+ traceError(props, name, status7) {
903
+ return new ErrorHandler2(props, name, status7, true);
904
+ }
905
+ };
906
+
907
+ // src/core/config/database/middleware/mongoChecker.database.ts
908
+ var MMongoCheckerDatabase = (optionalArgumentConnection) => {
909
+ const DbConnexion = new DatabaseConnectionConfig();
910
+ return DbConnexion.databaseMongoDBConnectionChecker(optionalArgumentConnection);
911
+ };
912
+
913
+ // src/core/config/database/middleware/mySqlChecker.database.ts
914
+ var MMySqlCheckerDatabase = (optionalArgumentConnection) => {
915
+ const DbConnexion = new DatabaseConnectionConfig();
916
+ return DbConnexion.databaseMySQLConnexionChecker(optionalArgumentConnection);
917
+ };
918
+
919
+ // src/core/config/database/middleware/postgresChecker.database.ts
920
+ var MPostgresCheckerDatabase = (optionalArgumentConnection) => {
921
+ const DbConnexion = new DatabaseConnectionConfig();
922
+ return DbConnexion.databasePostgresDBConnectionChecker(optionalArgumentConnection);
923
+ };
924
+
925
+ // src/utils/utility.utils.ts
926
+ import process2 from "node:process";
927
+ import chalk from "chalk";
928
+ import colors from "ansi-colors";
929
+ import path from "path";
930
+ import fs from "fs";
931
+ import { CLocal as CLocal9, TranslationLoader as TranslationLoader9 } from "opticore-translator";
932
+ var Utility = class {
933
+ /**
934
+ *
935
+ * @param data
936
+ * @private
937
+ * Return a string converted in MegaBytes
938
+ */
939
+ formatMemoryUsage(data) {
940
+ return `${Math.round(data / 1024 / 1024 * 100) / 100} MB`;
941
+ }
942
+ /**
943
+ * Returns an Object containing a node version, openssl, and v0
944
+ */
945
+ getVersions() {
946
+ const processVers = process2.versions;
947
+ const data = {
948
+ "node version": processVers.node,
949
+ "openssl": processVers.openssl,
950
+ "v8": processVers.v8
951
+ };
952
+ return {
953
+ "nodeVersion": data["node version"],
954
+ "openssl": data.openssl,
955
+ "v8": data.v8
956
+ };
957
+ }
958
+ /**
959
+ * Return an Object containing a Resident Set Size - total memory allocated for the process execution
960
+ * Total size of the allocated heap
961
+ * Actual memory used during the execution
962
+ * Memory usage user
963
+ * and Memory usage system
964
+ */
965
+ getUsageMemory() {
966
+ const memoryData = process2.memoryUsage();
967
+ const data = {
968
+ "Resident Set Size - total memory allocated for the process execution": this.formatMemoryUsage(memoryData.rss),
969
+ "Total size of the allocated heap": this.formatMemoryUsage(memoryData.heapTotal),
970
+ "Actual memory used during the execution": this.formatMemoryUsage(memoryData.heapUsed),
971
+ "V8 external memory": this.formatMemoryUsage(memoryData.external),
972
+ "Memory usage user": this.formatMemoryUsage(process2.cpuUsage().user),
973
+ "Memory usage system": this.formatMemoryUsage(process2.cpuUsage().system)
974
+ };
975
+ return {
976
+ "rss": data["Resident Set Size - total memory allocated for the process execution"],
977
+ "heapTotal": data["Total size of the allocated heap"],
978
+ "heapUsed": data["Actual memory used during the execution"],
979
+ "external": data["V8 external memory"],
980
+ "user": data["Memory usage user"],
981
+ "system": data["Memory usage system"]
982
+ };
983
+ }
984
+ /**
985
+ * Return an Object containing a project path and running server time
986
+ */
987
+ getProjectInfo() {
988
+ const startTime = process2.hrtime();
989
+ const endTime = process2.hrtime(startTime);
990
+ const executionTime = (endTime[0] * 1e9 + endTime[1]) / 1e6;
991
+ return {
992
+ "projectPath": path.join(process2.cwd()),
993
+ "startingTime": `${executionTime.toFixed(5)} ms`
994
+ };
995
+ }
996
+ /**
997
+ *
998
+ * @param filePath
999
+ * @private
1000
+ */
1001
+ getEnvFileLoading(filePath) {
1002
+ const fullPath = path.resolve(process2.cwd(), filePath);
1003
+ if (fs.existsSync(fullPath)) {
1004
+ const env = fs.readFileSync(fullPath, "utf-8");
1005
+ const lines = env.split("\n");
1006
+ lines.forEach((line) => {
1007
+ const match = line.match(/^([^#=]+)=([^#]+)$/);
1008
+ if (match) {
1009
+ const key = match[1].trim();
1010
+ process2.env[key] = match[2].trim();
1011
+ }
1012
+ });
1013
+ }
1014
+ }
1015
+ /**
1016
+ *
1017
+ * @param development
1018
+ * @param production
1019
+ */
1020
+ getServerRunningMode(development, production) {
1021
+ this.getEnvFileLoading(".env");
1022
+ const isDevelopment = process2.env.NODE_ENV === "development";
1023
+ if (isDevelopment) {
1024
+ return `${TranslationLoader9.t("serverRunning", CLocal9)} ${colors.bgBlue(`${colors.bold(`${development}`)}`)} mode`;
1025
+ } else {
1026
+ return `${TranslationLoader9.t("serverRunning", CLocal9)} ${colors.bgBlue(`${colors.bold(`${production}`)}`)} mode`;
1027
+ }
1028
+ }
1029
+ infoServer(nodeVersion, startingTime, host, port, rss, heapUsed, user, system) {
1030
+ const paddingLength = 52;
1031
+ const msg0 = " ".padEnd(paddingLength, " ");
1032
+ const msg1 = ` ${TranslationLoader9.t("okServerListening", CLocal9)}`;
1033
+ const msg2Value = `${colors.bgBlue(`${colors.bold(`${nodeVersion}`)}`)}`;
1034
+ const msg2 = ` ${TranslationLoader9.t("webServerUseNodeVersion", CLocal9)}`;
1035
+ const msg3Value = `${colors.bgBlue(`${colors.bold(`${startingTime}`)}`)}`;
1036
+ const msg3 = ` ${TranslationLoader9.t("startupTime", CLocal9)}`;
1037
+ const msg4 = ` ${this.getServerRunningMode("development", "production")}`;
1038
+ const msg5 = ` ${colors.underline(`http://${host}:${port}`)}`;
1039
+ console.log(chalk.bgGreen.white(msg0.padEnd(paddingLength, " ")));
1040
+ console.log(chalk.bgGreen.white(msg1.padEnd(paddingLength, " ")));
1041
+ console.log(chalk.bgGreen.white(msg2, msg2Value.padEnd(30.5, " ")));
1042
+ console.log(chalk.bgGreen.white(msg3, msg3Value.padEnd(56, " ")));
1043
+ console.log(chalk.bgGreen.white(msg4.padEnd(71, " ")));
1044
+ console.log(chalk.bgGreen.white(msg5.padEnd(61, " ")));
1045
+ console.log(chalk.bgGreen.white(msg0.padEnd(paddingLength, " ")));
1046
+ console.log(``);
1047
+ console.log(`${`${TranslationLoader9.t("totalMemory", CLocal9)}`} ${colors.cyan(`${colors.bold(`${rss}`)}`)}`);
1048
+ console.log(`${`${TranslationLoader9.t("memoryUsedDuringExecution", CLocal9)}`} ${colors.cyan(`${colors.bold(`${heapUsed}`)}`)}`);
1049
+ console.log(`${`${TranslationLoader9.t("memoryUsedByUser", CLocal9)}`} ${colors.cyan(`${colors.bold(`${user}`)}`)}`);
1050
+ console.log(`${`${TranslationLoader9.t("memoryUsedBySystem", CLocal9)}`} ${colors.cyan(`${colors.bold(`${system}`)}`)}`);
1051
+ console.log(``);
1052
+ }
1053
+ };
1054
+
1055
+ // src/core/events/pathModuleVerifier.event.ts
1056
+ import { resolve } from "path";
1057
+ import { LoggerCore as LoggerCore9 } from "opticore-logger";
1058
+ import { HttpStatusCode as HttpStatusCode2 } from "opticore-http-response";
1059
+ import { CLocal as CLocal10, TranslationLoader as TranslationLoader10 } from "opticore-translator";
1060
+ var PathModuleVerifier = class {
1061
+ /**
1062
+ * Verifies if modules at specific paths are loaded.
1063
+ * If any module is not loaded, it throws an error.
1064
+ * @param modulePaths - An array of paths to the modules to verify.
1065
+ */
1066
+ static verifyModulePaths(modulePaths) {
1067
+ const notLoadedPaths = [];
1068
+ for (const modulePath of modulePaths) {
1069
+ if (!this.isModulePathLoaded(modulePath)) {
1070
+ notLoadedPaths.push(modulePath);
1071
+ }
1072
+ }
1073
+ if (notLoadedPaths.length > 0) {
1074
+ this.log.error(
1075
+ TranslationLoader10.t("moduleNotLoaded", CLocal10, { notLoadedPaths: notLoadedPaths.join(", ") }),
1076
+ "",
1077
+ "",
1078
+ modulePaths,
1079
+ HttpStatusCode2.NOT_ACCEPTABLE
1080
+ );
1081
+ throw new Error();
1082
+ }
1083
+ }
1084
+ /**
1085
+ * Checks if a specific module at a given path is loaded in the Node.js require cache.
1086
+ * @param modulePath - The path to the module.
1087
+ * @returns True if the module is loaded, false otherwise.
1088
+ */
1089
+ static isModulePathLoaded(modulePath) {
1090
+ try {
1091
+ const resolvedPath = resolve(modulePath);
1092
+ return __require.cache[resolvedPath] !== void 0;
1093
+ } catch (e) {
1094
+ return false;
1095
+ }
1096
+ }
1097
+ };
1098
+ PathModuleVerifier.log = new LoggerCore9(loggerConfig);
1099
+
1100
+ // src/core/config/loaders/translateLanguage.loader.ts
1101
+ import path2 from "path";
1102
+ import { TranslationLoader as TranslationLoader11 } from "opticore-translator";
1103
+ import { getEnvVariable as getEnvVariable4 } from "opticore-env-access";
1104
+ var translateLanguageLoader = () => {
1105
+ TranslationLoader11.loadTranslations(path2.join(process.cwd(), "src", "utils", "translations"), getEnvVariable4.defaultLocal);
1106
+ };
1107
+ export {
1108
+ CLogLevel,
1109
+ CSignRSAKeyComponent,
1110
+ Environment,
1111
+ MMongoCheckerDatabase,
1112
+ MMySqlCheckerDatabase,
1113
+ MPostgresCheckerDatabase,
1114
+ PathModuleVerifier,
1115
+ RSAKeyDecryption,
1116
+ RSAKeyEncryption,
1117
+ SAsymmetricCryptionDataWithPrivateRSAKey,
1118
+ SAsymmetricCryptionDataWithPublicRSAKey,
1119
+ SCheckerMongoDatabaseConnection,
1120
+ SCheckerMySqlDatabaseConnection,
1121
+ SCheckerPostgresDatabaseConnection,
1122
+ Utility,
1123
+ YamlParsing,
1124
+ dateTimeFormatted,
1125
+ loggerConfig,
1126
+ optionalArgumentConnectionUtil,
1127
+ translateLanguageLoader
1128
+ };