opticore-webapp-core 1.0.14 → 1.0.16
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 +102 -62
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +108 -69
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -33,6 +33,7 @@ __export(index_exports, {
|
|
|
33
33
|
CLogLevel: () => CLogLevel,
|
|
34
34
|
CSignRSAKeyComponent: () => CSignRSAKeyComponent,
|
|
35
35
|
Environment: () => Environment,
|
|
36
|
+
LocalLanguageLoader: () => LocalLanguageLoader,
|
|
36
37
|
MMongoCheckerDatabase: () => MMongoCheckerDatabase,
|
|
37
38
|
MMySqlCheckerDatabase: () => MMySqlCheckerDatabase,
|
|
38
39
|
MPostgresCheckerDatabase: () => MPostgresCheckerDatabase,
|
|
@@ -707,27 +708,13 @@ var UOptionalArgumentConnection = (environnementPath) => {
|
|
|
707
708
|
var import_promises = require("fs/promises");
|
|
708
709
|
var import_opticore_http_response5 = require("opticore-http-response");
|
|
709
710
|
var import_opticore_logger3 = require("opticore-logger");
|
|
710
|
-
var import_opticore_translator7 = require("opticore-translator");
|
|
711
|
-
|
|
712
|
-
// src/core/config/loaders/translateLanguage.loader.ts
|
|
713
|
-
var import_path = __toESM(require("path"), 1);
|
|
714
|
-
var import_module = require("module");
|
|
715
711
|
var import_opticore_translator6 = require("opticore-translator");
|
|
716
|
-
var translateWebAppCoreLanguageLoader = () => {
|
|
717
|
-
const require2 = (0, import_module.createRequire)(importMetaUrl);
|
|
718
|
-
const packagePath = import_path.default.dirname(require2.resolve("opticore-webapp-core"));
|
|
719
|
-
const translateMsgJsonFilePath = import_path.default.join(packagePath, "utils", "translations");
|
|
720
|
-
import_opticore_translator6.TranslationLoader.loadTranslations(translateMsgJsonFilePath);
|
|
721
|
-
};
|
|
722
|
-
|
|
723
|
-
// src/utils/parsing/parsingYaml.utils.ts
|
|
724
712
|
var YamlParsing = class {
|
|
725
713
|
logger;
|
|
726
714
|
localeLanguage;
|
|
727
715
|
constructor(localeLanguage, environnementPath) {
|
|
728
716
|
this.localeLanguage = localeLanguage;
|
|
729
717
|
this.logger = new import_opticore_logger3.LoggerCore(loggerConfig(environnementPath));
|
|
730
|
-
translateWebAppCoreLanguageLoader();
|
|
731
718
|
}
|
|
732
719
|
async readFile(filePath) {
|
|
733
720
|
try {
|
|
@@ -736,8 +723,8 @@ var YamlParsing = class {
|
|
|
736
723
|
} catch (error) {
|
|
737
724
|
this.logger.error(
|
|
738
725
|
error.message,
|
|
739
|
-
|
|
740
|
-
|
|
726
|
+
import_opticore_translator6.TranslationLoader.t("parsingFailed", this.localeLanguage, this.logger),
|
|
727
|
+
import_opticore_translator6.TranslationLoader.t("readingError", this.localeLanguage, this.logger),
|
|
741
728
|
error.stack,
|
|
742
729
|
import_opticore_http_response5.HttpStatusCode.NOT_ACCEPTABLE
|
|
743
730
|
);
|
|
@@ -768,9 +755,9 @@ var YamlParsing = class {
|
|
|
768
755
|
}
|
|
769
756
|
} else {
|
|
770
757
|
this.logger.error(
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
758
|
+
import_opticore_translator6.TranslationLoader.t("badFormat", this.localeLanguage, { line }),
|
|
759
|
+
import_opticore_translator6.TranslationLoader.t("parsingFailed", this.localeLanguage, this.logger),
|
|
760
|
+
import_opticore_translator6.TranslationLoader.t("unsupportedFormat", this.localeLanguage, this.logger),
|
|
774
761
|
content,
|
|
775
762
|
import_opticore_http_response5.HttpStatusCode.NOT_ACCEPTABLE
|
|
776
763
|
);
|
|
@@ -798,12 +785,12 @@ var Environment = class {
|
|
|
798
785
|
var import_mysql = __toESM(require("mysql"), 1);
|
|
799
786
|
var import_opticore_http_response7 = require("opticore-http-response");
|
|
800
787
|
var import_opticore_logger4 = require("opticore-logger");
|
|
801
|
-
var
|
|
788
|
+
var import_opticore_translator8 = require("opticore-translator");
|
|
802
789
|
|
|
803
790
|
// src/core/errors/databaseConnexion.error.ts
|
|
804
791
|
var import_opticore_http_response6 = require("opticore-http-response");
|
|
805
792
|
var import_opticore_catch_exception_error3 = require("opticore-catch-exception-error");
|
|
806
|
-
var
|
|
793
|
+
var import_opticore_translator7 = require("opticore-translator");
|
|
807
794
|
var DbConnexionConfigError = class {
|
|
808
795
|
logger;
|
|
809
796
|
localeLanguage;
|
|
@@ -817,14 +804,14 @@ var DbConnexionConfigError = class {
|
|
|
817
804
|
*/
|
|
818
805
|
mongoDBAuthenticationFailed(e) {
|
|
819
806
|
const stackTrace = this.traceError(
|
|
820
|
-
|
|
821
|
-
|
|
807
|
+
import_opticore_translator7.TranslationLoader.t("mongoDBConnection", this.localeLanguage, { e }),
|
|
808
|
+
import_opticore_translator7.TranslationLoader.t("mongoDBAuthentication", this.localeLanguage),
|
|
822
809
|
import_opticore_http_response6.HttpStatusCode.UNAUTHORIZED
|
|
823
810
|
);
|
|
824
811
|
this.logger.error(
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
812
|
+
import_opticore_translator7.TranslationLoader.t("mongoDBAuthenticationError", this.localeLanguage),
|
|
813
|
+
import_opticore_translator7.TranslationLoader.t("mongoDBConnection", this.localeLanguage),
|
|
814
|
+
import_opticore_translator7.TranslationLoader.t("mongoDBAuthenticationFailed", this.localeLanguage),
|
|
828
815
|
stackTrace.stack,
|
|
829
816
|
import_opticore_http_response6.HttpStatusCode.UNAUTHORIZED
|
|
830
817
|
);
|
|
@@ -837,14 +824,14 @@ var DbConnexionConfigError = class {
|
|
|
837
824
|
*/
|
|
838
825
|
mongoDBInvalidUrl(err, dbHost, dbPort) {
|
|
839
826
|
const stackTrace = this.traceError(
|
|
840
|
-
|
|
841
|
-
|
|
827
|
+
import_opticore_translator7.TranslationLoader.t("mongoDBConnection", this.localeLanguage, { err }),
|
|
828
|
+
import_opticore_translator7.TranslationLoader.t("mongoDBUnableParsingUrl", this.localeLanguage),
|
|
842
829
|
import_opticore_http_response6.HttpStatusCode.BAD_REQUEST
|
|
843
830
|
);
|
|
844
831
|
this.logger.error(
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
832
|
+
import_opticore_translator7.TranslationLoader.t("dbUrlParsingError", this.localeLanguage, { dbHost, dbPort }),
|
|
833
|
+
import_opticore_translator7.TranslationLoader.t("mongoDBConnection", this.localeLanguage),
|
|
834
|
+
import_opticore_translator7.TranslationLoader.t("mongoDBUnableParsingUrl", this.localeLanguage),
|
|
848
835
|
stackTrace.stack,
|
|
849
836
|
import_opticore_http_response6.HttpStatusCode.BAD_REQUEST
|
|
850
837
|
);
|
|
@@ -856,14 +843,14 @@ var DbConnexionConfigError = class {
|
|
|
856
843
|
*/
|
|
857
844
|
mongoDBEaiAgain(err, dbHost) {
|
|
858
845
|
const stackTrace = this.traceError(
|
|
859
|
-
|
|
860
|
-
|
|
846
|
+
import_opticore_translator7.TranslationLoader.t("mongoDBConnection", this.localeLanguage, { err }),
|
|
847
|
+
import_opticore_translator7.TranslationLoader.t("mongoDBServerSelection", this.localeLanguage),
|
|
861
848
|
import_opticore_http_response6.HttpStatusCode.BAD_REQUEST
|
|
862
849
|
);
|
|
863
850
|
this.logger.error(
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
851
|
+
import_opticore_translator7.TranslationLoader.t("mongoServerError", this.localeLanguage, { dbHost }),
|
|
852
|
+
import_opticore_translator7.TranslationLoader.t("mongoDBConnection", this.localeLanguage),
|
|
853
|
+
import_opticore_translator7.TranslationLoader.t("mongoDBServerSelection", this.localeLanguage),
|
|
867
854
|
stackTrace.stack,
|
|
868
855
|
import_opticore_http_response6.HttpStatusCode.BAD_REQUEST
|
|
869
856
|
);
|
|
@@ -874,13 +861,13 @@ var DbConnexionConfigError = class {
|
|
|
874
861
|
*/
|
|
875
862
|
mongoDbGlobalError(err) {
|
|
876
863
|
const stackTrace = this.traceError(
|
|
877
|
-
|
|
878
|
-
|
|
864
|
+
import_opticore_translator7.TranslationLoader.t("mongoDBConnection", this.localeLanguage, { err }),
|
|
865
|
+
import_opticore_translator7.TranslationLoader.t("mongoDBConnection", this.localeLanguage),
|
|
879
866
|
import_opticore_http_response6.HttpStatusCode.NOT_ACCEPTABLE
|
|
880
867
|
);
|
|
881
868
|
this.logger.error(
|
|
882
|
-
|
|
883
|
-
|
|
869
|
+
import_opticore_translator7.TranslationLoader.t("mongoDBConnection", this.localeLanguage),
|
|
870
|
+
import_opticore_translator7.TranslationLoader.t("mongoDBConnectionError", this.localeLanguage),
|
|
884
871
|
stackTrace.stack,
|
|
885
872
|
err.message,
|
|
886
873
|
import_opticore_http_response6.HttpStatusCode.NOT_ACCEPTABLE
|
|
@@ -941,8 +928,8 @@ var DatabaseConnectionConfig = class {
|
|
|
941
928
|
try {
|
|
942
929
|
await SCheckerMongoDatabaseConnection(url, this.env.get("dataBaseUser"), this.env.get("dataBasePassword"), this.env.get("dataBaseName"));
|
|
943
930
|
this.logger.success(
|
|
944
|
-
|
|
945
|
-
|
|
931
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnectionChecker", this.localeLanguage, loggerConfig),
|
|
932
|
+
import_opticore_translator8.TranslationLoader.t("mongoConnectionSuccess", this.localeLanguage, loggerConfig)
|
|
946
933
|
);
|
|
947
934
|
console.log("");
|
|
948
935
|
} catch (e) {
|
|
@@ -995,13 +982,13 @@ var DatabaseConnectionConfig = class {
|
|
|
995
982
|
options
|
|
996
983
|
);
|
|
997
984
|
this.logger.success(
|
|
998
|
-
|
|
999
|
-
|
|
985
|
+
import_opticore_translator8.TranslationLoader.t("postgresDBConnectionChecker", this.localeLanguage, loggerConfig),
|
|
986
|
+
import_opticore_translator8.TranslationLoader.t("postgresConnectionSuccess", this.localeLanguage, loggerConfig)
|
|
1000
987
|
);
|
|
1001
988
|
console.log("");
|
|
1002
989
|
} catch (err) {
|
|
1003
990
|
const stackTrace = this.traceError(
|
|
1004
|
-
|
|
991
|
+
import_opticore_translator8.TranslationLoader.t(`${err.message}`, this.localeLanguage, loggerConfig),
|
|
1005
992
|
"PostgresConnectionError",
|
|
1006
993
|
import_opticore_http_response7.HttpStatusCode.NOT_ACCEPTABLE
|
|
1007
994
|
);
|
|
@@ -1053,9 +1040,9 @@ var MPostgresCheckerDatabase = (localLanguage, environnementPath, keepAlive, str
|
|
|
1053
1040
|
var import_node_process = __toESM(require("process"), 1);
|
|
1054
1041
|
var import_chalk = __toESM(require("chalk"), 1);
|
|
1055
1042
|
var import_ansi_colors = __toESM(require("ansi-colors"), 1);
|
|
1056
|
-
var
|
|
1043
|
+
var import_path = __toESM(require("path"), 1);
|
|
1057
1044
|
var import_fs = __toESM(require("fs"), 1);
|
|
1058
|
-
var
|
|
1045
|
+
var import_opticore_translator9 = require("opticore-translator");
|
|
1059
1046
|
var Utility = class {
|
|
1060
1047
|
localLang;
|
|
1061
1048
|
constructor(localLanguage) {
|
|
@@ -1120,7 +1107,7 @@ var Utility = class {
|
|
|
1120
1107
|
const endTime = import_node_process.default.hrtime(startTime);
|
|
1121
1108
|
const executionTime = (endTime[0] * 1e9 + endTime[1]) / 1e6;
|
|
1122
1109
|
return {
|
|
1123
|
-
"projectPath":
|
|
1110
|
+
"projectPath": import_path.default.join(import_node_process.default.cwd()),
|
|
1124
1111
|
"startingTime": `${executionTime.toFixed(5)} ms`
|
|
1125
1112
|
};
|
|
1126
1113
|
}
|
|
@@ -1130,7 +1117,7 @@ var Utility = class {
|
|
|
1130
1117
|
* @private
|
|
1131
1118
|
*/
|
|
1132
1119
|
getEnvFileLoading(filePath) {
|
|
1133
|
-
const fullPath =
|
|
1120
|
+
const fullPath = import_path.default.resolve(import_node_process.default.cwd(), filePath);
|
|
1134
1121
|
if (import_fs.default.existsSync(fullPath)) {
|
|
1135
1122
|
const env = import_fs.default.readFileSync(fullPath, "utf-8");
|
|
1136
1123
|
const lines = env.split("\n");
|
|
@@ -1152,19 +1139,19 @@ var Utility = class {
|
|
|
1152
1139
|
this.getEnvFileLoading(".env");
|
|
1153
1140
|
const isDevelopment = import_node_process.default.env.NODE_ENV === "development";
|
|
1154
1141
|
if (isDevelopment) {
|
|
1155
|
-
return `${
|
|
1142
|
+
return `${import_opticore_translator9.TranslationLoader.t("serverRunning", this.localLang)} ${import_ansi_colors.default.bgBlue(`${import_ansi_colors.default.bold(`${development}`)}`)} mode`;
|
|
1156
1143
|
} else {
|
|
1157
|
-
return `${
|
|
1144
|
+
return `${import_opticore_translator9.TranslationLoader.t("serverRunning", this.localLang)} ${import_ansi_colors.default.bgBlue(`${import_ansi_colors.default.bold(`${production}`)}`)} mode`;
|
|
1158
1145
|
}
|
|
1159
1146
|
}
|
|
1160
1147
|
infoServer(nodeVersion, startingTime, host, port, rss, heapUsed, user, system) {
|
|
1161
1148
|
const paddingLength = 52;
|
|
1162
1149
|
const msg0 = " ".padEnd(paddingLength, " ");
|
|
1163
|
-
const msg1 = ` ${
|
|
1150
|
+
const msg1 = ` ${import_opticore_translator9.TranslationLoader.t("okServerListening", this.localLang)}`;
|
|
1164
1151
|
const msg2Value = `${import_ansi_colors.default.bgBlue(`${import_ansi_colors.default.bold(`${nodeVersion}`)}`)}`;
|
|
1165
|
-
const msg2 = ` ${
|
|
1152
|
+
const msg2 = ` ${import_opticore_translator9.TranslationLoader.t("webServerUseNodeVersion", this.localLang)}`;
|
|
1166
1153
|
const msg3Value = `${import_ansi_colors.default.bgBlue(`${import_ansi_colors.default.bold(`${startingTime}`)}`)}`;
|
|
1167
|
-
const msg3 = ` ${
|
|
1154
|
+
const msg3 = ` ${import_opticore_translator9.TranslationLoader.t("startupTime", this.localLang)}`;
|
|
1168
1155
|
const msg4 = ` ${this.getServerRunningMode("development", "production")}`;
|
|
1169
1156
|
const msg5 = ` ${import_ansi_colors.default.underline(`http://${host}:${port}`)}`;
|
|
1170
1157
|
console.log(import_chalk.default.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
@@ -1175,18 +1162,18 @@ var Utility = class {
|
|
|
1175
1162
|
console.log(import_chalk.default.bgGreen.white(msg5.padEnd(61, " ")));
|
|
1176
1163
|
console.log(import_chalk.default.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
1177
1164
|
console.log(``);
|
|
1178
|
-
console.log(`${`${
|
|
1179
|
-
console.log(`${`${
|
|
1180
|
-
console.log(`${`${
|
|
1181
|
-
console.log(`${`${
|
|
1165
|
+
console.log(`${`${import_opticore_translator9.TranslationLoader.t("totalMemory", this.localLang)}`} ${import_ansi_colors.default.cyan(`${import_ansi_colors.default.bold(`${rss}`)}`)}`);
|
|
1166
|
+
console.log(`${`${import_opticore_translator9.TranslationLoader.t("memoryUsedDuringExecution", this.localLang)}`} ${import_ansi_colors.default.cyan(`${import_ansi_colors.default.bold(`${heapUsed}`)}`)}`);
|
|
1167
|
+
console.log(`${`${import_opticore_translator9.TranslationLoader.t("memoryUsedByUser", this.localLang)}`} ${import_ansi_colors.default.cyan(`${import_ansi_colors.default.bold(`${user}`)}`)}`);
|
|
1168
|
+
console.log(`${`${import_opticore_translator9.TranslationLoader.t("memoryUsedBySystem", this.localLang)}`} ${import_ansi_colors.default.cyan(`${import_ansi_colors.default.bold(`${system}`)}`)}`);
|
|
1182
1169
|
console.log(``);
|
|
1183
1170
|
}
|
|
1184
1171
|
};
|
|
1185
1172
|
|
|
1186
1173
|
// src/core/events/pathModuleVerifier.event.ts
|
|
1187
|
-
var
|
|
1174
|
+
var import_path2 = require("path");
|
|
1188
1175
|
var import_opticore_http_response8 = require("opticore-http-response");
|
|
1189
|
-
var
|
|
1176
|
+
var import_opticore_translator10 = require("opticore-translator");
|
|
1190
1177
|
var PathModuleVerifier = class {
|
|
1191
1178
|
log;
|
|
1192
1179
|
localeLanguage;
|
|
@@ -1208,7 +1195,7 @@ var PathModuleVerifier = class {
|
|
|
1208
1195
|
}
|
|
1209
1196
|
if (notLoadedPaths.length > 0) {
|
|
1210
1197
|
this.log.error(
|
|
1211
|
-
|
|
1198
|
+
import_opticore_translator10.TranslationLoader.t("moduleNotLoaded", this.localeLanguage, { notLoadedPaths: notLoadedPaths.join(", ") }),
|
|
1212
1199
|
"",
|
|
1213
1200
|
"",
|
|
1214
1201
|
modulePaths,
|
|
@@ -1224,18 +1211,71 @@ var PathModuleVerifier = class {
|
|
|
1224
1211
|
*/
|
|
1225
1212
|
isModulePathLoaded(modulePath) {
|
|
1226
1213
|
try {
|
|
1227
|
-
const resolvedPath = (0,
|
|
1214
|
+
const resolvedPath = (0, import_path2.resolve)(modulePath);
|
|
1228
1215
|
return require.cache[resolvedPath] !== void 0;
|
|
1229
1216
|
} catch {
|
|
1230
1217
|
return false;
|
|
1231
1218
|
}
|
|
1232
1219
|
}
|
|
1233
1220
|
};
|
|
1221
|
+
|
|
1222
|
+
// src/core/config/loaders/localLanguage.loader.ts
|
|
1223
|
+
var import_path4 = __toESM(require("path"), 1);
|
|
1224
|
+
var import_opticore_translator12 = require("opticore-translator");
|
|
1225
|
+
var import_opticore_http_response10 = require("opticore-http-response");
|
|
1226
|
+
|
|
1227
|
+
// src/core/config/loaders/translateLanguage.loader.ts
|
|
1228
|
+
var import_path3 = __toESM(require("path"), 1);
|
|
1229
|
+
var import_module = require("module");
|
|
1230
|
+
var import_opticore_translator11 = require("opticore-translator");
|
|
1231
|
+
var import_opticore_http_response9 = require("opticore-http-response");
|
|
1232
|
+
var translateWebAppCoreLanguageLoader = (environnementPath, localLang) => {
|
|
1233
|
+
try {
|
|
1234
|
+
const require2 = (0, import_module.createRequire)(importMetaUrl);
|
|
1235
|
+
const packagePath = import_path3.default.dirname(require2.resolve("opticore-webapp-core"));
|
|
1236
|
+
const translateMsgJsonFilePath = import_path3.default.join(packagePath, "utils", "translations");
|
|
1237
|
+
import_opticore_translator11.TranslationLoader.loadTranslations(translateMsgJsonFilePath);
|
|
1238
|
+
} catch (err) {
|
|
1239
|
+
SLoggerFileConfiguration(environnementPath).error(
|
|
1240
|
+
import_opticore_translator11.TranslationLoader.t(err.message, localLang),
|
|
1241
|
+
err.code,
|
|
1242
|
+
err.code,
|
|
1243
|
+
err.stackTrace,
|
|
1244
|
+
import_opticore_http_response9.HttpStatusCode.INTERNAL_SERVER_ERROR
|
|
1245
|
+
);
|
|
1246
|
+
}
|
|
1247
|
+
};
|
|
1248
|
+
|
|
1249
|
+
// src/core/config/loaders/localLanguage.loader.ts
|
|
1250
|
+
var LocalLanguageLoader = class {
|
|
1251
|
+
localeLanguage;
|
|
1252
|
+
environnementPath;
|
|
1253
|
+
constructor(localeLanguage, environnementPath) {
|
|
1254
|
+
this.localeLanguage = localeLanguage;
|
|
1255
|
+
this.environnementPath = environnementPath;
|
|
1256
|
+
translateWebAppCoreLanguageLoader(environnementPath, localeLanguage);
|
|
1257
|
+
}
|
|
1258
|
+
load() {
|
|
1259
|
+
try {
|
|
1260
|
+
const translateMsgJsonFilePath = import_path4.default.join(process.cwd(), "src", "utils", "translations");
|
|
1261
|
+
import_opticore_translator12.TranslationLoader.loadTranslations(translateMsgJsonFilePath);
|
|
1262
|
+
} catch (err) {
|
|
1263
|
+
SLoggerFileConfiguration(this.environnementPath).error(
|
|
1264
|
+
import_opticore_translator12.TranslationLoader.t(err.message, this.localeLanguage),
|
|
1265
|
+
err.code,
|
|
1266
|
+
err.code,
|
|
1267
|
+
err.stackTrace,
|
|
1268
|
+
import_opticore_http_response10.HttpStatusCode.INTERNAL_SERVER_ERROR
|
|
1269
|
+
);
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
};
|
|
1234
1273
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1235
1274
|
0 && (module.exports = {
|
|
1236
1275
|
CLogLevel,
|
|
1237
1276
|
CSignRSAKeyComponent,
|
|
1238
1277
|
Environment,
|
|
1278
|
+
LocalLanguageLoader,
|
|
1239
1279
|
MMongoCheckerDatabase,
|
|
1240
1280
|
MMySqlCheckerDatabase,
|
|
1241
1281
|
MPostgresCheckerDatabase,
|
package/dist/index.d.cts
CHANGED
|
@@ -385,6 +385,13 @@ declare class PathModuleVerifier {
|
|
|
385
385
|
private isModulePathLoaded;
|
|
386
386
|
}
|
|
387
387
|
|
|
388
|
+
declare class LocalLanguageLoader {
|
|
389
|
+
private readonly localeLanguage;
|
|
390
|
+
private readonly environnementPath;
|
|
391
|
+
constructor(localeLanguage: string, environnementPath: any);
|
|
392
|
+
load(): void;
|
|
393
|
+
}
|
|
394
|
+
|
|
388
395
|
interface IBodyParserOptions {
|
|
389
396
|
type: string;
|
|
390
397
|
}
|
|
@@ -463,4 +470,4 @@ declare function TTextBodyParser(options: IBodyParserOptions, localLanguage: str
|
|
|
463
470
|
*/
|
|
464
471
|
declare function TUrlencodedBodyParser(options: IBodyParserOptions, localLanguage: string, environnementPath: any): void;
|
|
465
472
|
|
|
466
|
-
export { CLogLevel, CSignRSAKeyComponent, Environment, type IBodyParserOptions, type IResponseBodyEndFromResponseEvent, type IResponseBodyWriteFromResponseEvent, type IWrappingBodyResponse, MMongoCheckerDatabase, MMySqlCheckerDatabase, MPostgresCheckerDatabase, PathModuleVerifier, RSAKeyDecryption, RSAKeyEncryption, SAsymmetricCryptionDataWithPrivateRSAKey, SAsymmetricCryptionDataWithPublicRSAKey, SCheckerMongoDatabaseConnection, SCheckerMySqlDatabaseConnection, SCheckerPostgresDatabaseConnection, TJSONBodyParser, type TLogLevel, type TOriginalWriteEncoding, type TParseFunction, TRawBodyParser, TTextBodyParser, TUrlencodedBodyParser, UOptionalArgumentConnection, Utility, YamlParsing, dateTimeFormatted, loggerConfig };
|
|
473
|
+
export { CLogLevel, CSignRSAKeyComponent, Environment, type IBodyParserOptions, type IResponseBodyEndFromResponseEvent, type IResponseBodyWriteFromResponseEvent, type IWrappingBodyResponse, LocalLanguageLoader, MMongoCheckerDatabase, MMySqlCheckerDatabase, MPostgresCheckerDatabase, PathModuleVerifier, RSAKeyDecryption, RSAKeyEncryption, SAsymmetricCryptionDataWithPrivateRSAKey, SAsymmetricCryptionDataWithPublicRSAKey, SCheckerMongoDatabaseConnection, SCheckerMySqlDatabaseConnection, SCheckerPostgresDatabaseConnection, TJSONBodyParser, type TLogLevel, type TOriginalWriteEncoding, type TParseFunction, TRawBodyParser, TTextBodyParser, TUrlencodedBodyParser, UOptionalArgumentConnection, Utility, YamlParsing, dateTimeFormatted, loggerConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -385,6 +385,13 @@ declare class PathModuleVerifier {
|
|
|
385
385
|
private isModulePathLoaded;
|
|
386
386
|
}
|
|
387
387
|
|
|
388
|
+
declare class LocalLanguageLoader {
|
|
389
|
+
private readonly localeLanguage;
|
|
390
|
+
private readonly environnementPath;
|
|
391
|
+
constructor(localeLanguage: string, environnementPath: any);
|
|
392
|
+
load(): void;
|
|
393
|
+
}
|
|
394
|
+
|
|
388
395
|
interface IBodyParserOptions {
|
|
389
396
|
type: string;
|
|
390
397
|
}
|
|
@@ -463,4 +470,4 @@ declare function TTextBodyParser(options: IBodyParserOptions, localLanguage: str
|
|
|
463
470
|
*/
|
|
464
471
|
declare function TUrlencodedBodyParser(options: IBodyParserOptions, localLanguage: string, environnementPath: any): void;
|
|
465
472
|
|
|
466
|
-
export { CLogLevel, CSignRSAKeyComponent, Environment, type IBodyParserOptions, type IResponseBodyEndFromResponseEvent, type IResponseBodyWriteFromResponseEvent, type IWrappingBodyResponse, MMongoCheckerDatabase, MMySqlCheckerDatabase, MPostgresCheckerDatabase, PathModuleVerifier, RSAKeyDecryption, RSAKeyEncryption, SAsymmetricCryptionDataWithPrivateRSAKey, SAsymmetricCryptionDataWithPublicRSAKey, SCheckerMongoDatabaseConnection, SCheckerMySqlDatabaseConnection, SCheckerPostgresDatabaseConnection, TJSONBodyParser, type TLogLevel, type TOriginalWriteEncoding, type TParseFunction, TRawBodyParser, TTextBodyParser, TUrlencodedBodyParser, UOptionalArgumentConnection, Utility, YamlParsing, dateTimeFormatted, loggerConfig };
|
|
473
|
+
export { CLogLevel, CSignRSAKeyComponent, Environment, type IBodyParserOptions, type IResponseBodyEndFromResponseEvent, type IResponseBodyWriteFromResponseEvent, type IWrappingBodyResponse, LocalLanguageLoader, MMongoCheckerDatabase, MMySqlCheckerDatabase, MPostgresCheckerDatabase, PathModuleVerifier, RSAKeyDecryption, RSAKeyEncryption, SAsymmetricCryptionDataWithPrivateRSAKey, SAsymmetricCryptionDataWithPublicRSAKey, SCheckerMongoDatabaseConnection, SCheckerMySqlDatabaseConnection, SCheckerPostgresDatabaseConnection, TJSONBodyParser, type TLogLevel, type TOriginalWriteEncoding, type TParseFunction, TRawBodyParser, TTextBodyParser, TUrlencodedBodyParser, UOptionalArgumentConnection, Utility, YamlParsing, dateTimeFormatted, loggerConfig };
|
package/dist/index.js
CHANGED
|
@@ -656,27 +656,13 @@ var UOptionalArgumentConnection = (environnementPath) => {
|
|
|
656
656
|
import { readFile } from "fs/promises";
|
|
657
657
|
import { HttpStatusCode } from "opticore-http-response";
|
|
658
658
|
import { LoggerCore as LoggerCore3 } from "opticore-logger";
|
|
659
|
-
import { TranslationLoader as TranslationLoader7 } from "opticore-translator";
|
|
660
|
-
|
|
661
|
-
// src/core/config/loaders/translateLanguage.loader.ts
|
|
662
|
-
import path from "path";
|
|
663
|
-
import { createRequire } from "module";
|
|
664
659
|
import { TranslationLoader as TranslationLoader6 } from "opticore-translator";
|
|
665
|
-
var translateWebAppCoreLanguageLoader = () => {
|
|
666
|
-
const require2 = createRequire(import.meta.url);
|
|
667
|
-
const packagePath = path.dirname(require2.resolve("opticore-webapp-core"));
|
|
668
|
-
const translateMsgJsonFilePath = path.join(packagePath, "utils", "translations");
|
|
669
|
-
TranslationLoader6.loadTranslations(translateMsgJsonFilePath);
|
|
670
|
-
};
|
|
671
|
-
|
|
672
|
-
// src/utils/parsing/parsingYaml.utils.ts
|
|
673
660
|
var YamlParsing = class {
|
|
674
661
|
logger;
|
|
675
662
|
localeLanguage;
|
|
676
663
|
constructor(localeLanguage, environnementPath) {
|
|
677
664
|
this.localeLanguage = localeLanguage;
|
|
678
665
|
this.logger = new LoggerCore3(loggerConfig(environnementPath));
|
|
679
|
-
translateWebAppCoreLanguageLoader();
|
|
680
666
|
}
|
|
681
667
|
async readFile(filePath) {
|
|
682
668
|
try {
|
|
@@ -685,8 +671,8 @@ var YamlParsing = class {
|
|
|
685
671
|
} catch (error) {
|
|
686
672
|
this.logger.error(
|
|
687
673
|
error.message,
|
|
688
|
-
|
|
689
|
-
|
|
674
|
+
TranslationLoader6.t("parsingFailed", this.localeLanguage, this.logger),
|
|
675
|
+
TranslationLoader6.t("readingError", this.localeLanguage, this.logger),
|
|
690
676
|
error.stack,
|
|
691
677
|
HttpStatusCode.NOT_ACCEPTABLE
|
|
692
678
|
);
|
|
@@ -717,9 +703,9 @@ var YamlParsing = class {
|
|
|
717
703
|
}
|
|
718
704
|
} else {
|
|
719
705
|
this.logger.error(
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
706
|
+
TranslationLoader6.t("badFormat", this.localeLanguage, { line }),
|
|
707
|
+
TranslationLoader6.t("parsingFailed", this.localeLanguage, this.logger),
|
|
708
|
+
TranslationLoader6.t("unsupportedFormat", this.localeLanguage, this.logger),
|
|
723
709
|
content,
|
|
724
710
|
HttpStatusCode.NOT_ACCEPTABLE
|
|
725
711
|
);
|
|
@@ -747,12 +733,12 @@ var Environment = class {
|
|
|
747
733
|
import mySQL from "mysql";
|
|
748
734
|
import { HttpStatusCode as status6 } from "opticore-http-response";
|
|
749
735
|
import { LoggerCore as LoggerCore4 } from "opticore-logger";
|
|
750
|
-
import { TranslationLoader as
|
|
736
|
+
import { TranslationLoader as TranslationLoader8 } from "opticore-translator";
|
|
751
737
|
|
|
752
738
|
// src/core/errors/databaseConnexion.error.ts
|
|
753
739
|
import { HttpStatusCode as status5 } from "opticore-http-response";
|
|
754
740
|
import { StackTraceError as StackTraceError2 } from "opticore-catch-exception-error";
|
|
755
|
-
import { TranslationLoader as
|
|
741
|
+
import { TranslationLoader as TranslationLoader7 } from "opticore-translator";
|
|
756
742
|
var DbConnexionConfigError = class {
|
|
757
743
|
logger;
|
|
758
744
|
localeLanguage;
|
|
@@ -766,14 +752,14 @@ var DbConnexionConfigError = class {
|
|
|
766
752
|
*/
|
|
767
753
|
mongoDBAuthenticationFailed(e) {
|
|
768
754
|
const stackTrace = this.traceError(
|
|
769
|
-
|
|
770
|
-
|
|
755
|
+
TranslationLoader7.t("mongoDBConnection", this.localeLanguage, { e }),
|
|
756
|
+
TranslationLoader7.t("mongoDBAuthentication", this.localeLanguage),
|
|
771
757
|
status5.UNAUTHORIZED
|
|
772
758
|
);
|
|
773
759
|
this.logger.error(
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
760
|
+
TranslationLoader7.t("mongoDBAuthenticationError", this.localeLanguage),
|
|
761
|
+
TranslationLoader7.t("mongoDBConnection", this.localeLanguage),
|
|
762
|
+
TranslationLoader7.t("mongoDBAuthenticationFailed", this.localeLanguage),
|
|
777
763
|
stackTrace.stack,
|
|
778
764
|
status5.UNAUTHORIZED
|
|
779
765
|
);
|
|
@@ -786,14 +772,14 @@ var DbConnexionConfigError = class {
|
|
|
786
772
|
*/
|
|
787
773
|
mongoDBInvalidUrl(err, dbHost, dbPort) {
|
|
788
774
|
const stackTrace = this.traceError(
|
|
789
|
-
|
|
790
|
-
|
|
775
|
+
TranslationLoader7.t("mongoDBConnection", this.localeLanguage, { err }),
|
|
776
|
+
TranslationLoader7.t("mongoDBUnableParsingUrl", this.localeLanguage),
|
|
791
777
|
status5.BAD_REQUEST
|
|
792
778
|
);
|
|
793
779
|
this.logger.error(
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
780
|
+
TranslationLoader7.t("dbUrlParsingError", this.localeLanguage, { dbHost, dbPort }),
|
|
781
|
+
TranslationLoader7.t("mongoDBConnection", this.localeLanguage),
|
|
782
|
+
TranslationLoader7.t("mongoDBUnableParsingUrl", this.localeLanguage),
|
|
797
783
|
stackTrace.stack,
|
|
798
784
|
status5.BAD_REQUEST
|
|
799
785
|
);
|
|
@@ -805,14 +791,14 @@ var DbConnexionConfigError = class {
|
|
|
805
791
|
*/
|
|
806
792
|
mongoDBEaiAgain(err, dbHost) {
|
|
807
793
|
const stackTrace = this.traceError(
|
|
808
|
-
|
|
809
|
-
|
|
794
|
+
TranslationLoader7.t("mongoDBConnection", this.localeLanguage, { err }),
|
|
795
|
+
TranslationLoader7.t("mongoDBServerSelection", this.localeLanguage),
|
|
810
796
|
status5.BAD_REQUEST
|
|
811
797
|
);
|
|
812
798
|
this.logger.error(
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
799
|
+
TranslationLoader7.t("mongoServerError", this.localeLanguage, { dbHost }),
|
|
800
|
+
TranslationLoader7.t("mongoDBConnection", this.localeLanguage),
|
|
801
|
+
TranslationLoader7.t("mongoDBServerSelection", this.localeLanguage),
|
|
816
802
|
stackTrace.stack,
|
|
817
803
|
status5.BAD_REQUEST
|
|
818
804
|
);
|
|
@@ -823,13 +809,13 @@ var DbConnexionConfigError = class {
|
|
|
823
809
|
*/
|
|
824
810
|
mongoDbGlobalError(err) {
|
|
825
811
|
const stackTrace = this.traceError(
|
|
826
|
-
|
|
827
|
-
|
|
812
|
+
TranslationLoader7.t("mongoDBConnection", this.localeLanguage, { err }),
|
|
813
|
+
TranslationLoader7.t("mongoDBConnection", this.localeLanguage),
|
|
828
814
|
status5.NOT_ACCEPTABLE
|
|
829
815
|
);
|
|
830
816
|
this.logger.error(
|
|
831
|
-
|
|
832
|
-
|
|
817
|
+
TranslationLoader7.t("mongoDBConnection", this.localeLanguage),
|
|
818
|
+
TranslationLoader7.t("mongoDBConnectionError", this.localeLanguage),
|
|
833
819
|
stackTrace.stack,
|
|
834
820
|
err.message,
|
|
835
821
|
status5.NOT_ACCEPTABLE
|
|
@@ -890,8 +876,8 @@ var DatabaseConnectionConfig = class {
|
|
|
890
876
|
try {
|
|
891
877
|
await SCheckerMongoDatabaseConnection(url, this.env.get("dataBaseUser"), this.env.get("dataBasePassword"), this.env.get("dataBaseName"));
|
|
892
878
|
this.logger.success(
|
|
893
|
-
|
|
894
|
-
|
|
879
|
+
TranslationLoader8.t("mongoDBConnectionChecker", this.localeLanguage, loggerConfig),
|
|
880
|
+
TranslationLoader8.t("mongoConnectionSuccess", this.localeLanguage, loggerConfig)
|
|
895
881
|
);
|
|
896
882
|
console.log("");
|
|
897
883
|
} catch (e) {
|
|
@@ -944,13 +930,13 @@ var DatabaseConnectionConfig = class {
|
|
|
944
930
|
options
|
|
945
931
|
);
|
|
946
932
|
this.logger.success(
|
|
947
|
-
|
|
948
|
-
|
|
933
|
+
TranslationLoader8.t("postgresDBConnectionChecker", this.localeLanguage, loggerConfig),
|
|
934
|
+
TranslationLoader8.t("postgresConnectionSuccess", this.localeLanguage, loggerConfig)
|
|
949
935
|
);
|
|
950
936
|
console.log("");
|
|
951
937
|
} catch (err) {
|
|
952
938
|
const stackTrace = this.traceError(
|
|
953
|
-
|
|
939
|
+
TranslationLoader8.t(`${err.message}`, this.localeLanguage, loggerConfig),
|
|
954
940
|
"PostgresConnectionError",
|
|
955
941
|
status6.NOT_ACCEPTABLE
|
|
956
942
|
);
|
|
@@ -999,12 +985,12 @@ var MPostgresCheckerDatabase = (localLanguage, environnementPath, keepAlive, str
|
|
|
999
985
|
};
|
|
1000
986
|
|
|
1001
987
|
// src/utils/utility.utils.ts
|
|
1002
|
-
import
|
|
988
|
+
import process2 from "node:process";
|
|
1003
989
|
import chalk from "chalk";
|
|
1004
990
|
import colors from "ansi-colors";
|
|
1005
|
-
import
|
|
991
|
+
import path from "path";
|
|
1006
992
|
import fs from "fs";
|
|
1007
|
-
import { TranslationLoader as
|
|
993
|
+
import { TranslationLoader as TranslationLoader9 } from "opticore-translator";
|
|
1008
994
|
var Utility = class {
|
|
1009
995
|
localLang;
|
|
1010
996
|
constructor(localLanguage) {
|
|
@@ -1023,7 +1009,7 @@ var Utility = class {
|
|
|
1023
1009
|
* Returns an Object containing a node version, openssl, and v0
|
|
1024
1010
|
*/
|
|
1025
1011
|
getVersions() {
|
|
1026
|
-
const processVers =
|
|
1012
|
+
const processVers = process2.versions;
|
|
1027
1013
|
const data = {
|
|
1028
1014
|
"node version": processVers.node,
|
|
1029
1015
|
"openssl": processVers.openssl,
|
|
@@ -1043,14 +1029,14 @@ var Utility = class {
|
|
|
1043
1029
|
* and Memory usage system
|
|
1044
1030
|
*/
|
|
1045
1031
|
getUsageMemory() {
|
|
1046
|
-
const memoryData =
|
|
1032
|
+
const memoryData = process2.memoryUsage();
|
|
1047
1033
|
const data = {
|
|
1048
1034
|
"Resident Set Size - total memory allocated for the process execution": this.formatMemoryUsage(memoryData.rss),
|
|
1049
1035
|
"Total size of the allocated heap": this.formatMemoryUsage(memoryData.heapTotal),
|
|
1050
1036
|
"Actual memory used during the execution": this.formatMemoryUsage(memoryData.heapUsed),
|
|
1051
1037
|
"V8 external memory": this.formatMemoryUsage(memoryData.external),
|
|
1052
|
-
"Memory usage user": this.formatMemoryUsage(
|
|
1053
|
-
"Memory usage system": this.formatMemoryUsage(
|
|
1038
|
+
"Memory usage user": this.formatMemoryUsage(process2.cpuUsage().user),
|
|
1039
|
+
"Memory usage system": this.formatMemoryUsage(process2.cpuUsage().system)
|
|
1054
1040
|
};
|
|
1055
1041
|
return {
|
|
1056
1042
|
"rss": data["Resident Set Size - total memory allocated for the process execution"],
|
|
@@ -1065,11 +1051,11 @@ var Utility = class {
|
|
|
1065
1051
|
* Return an Object containing a project path and running server time
|
|
1066
1052
|
*/
|
|
1067
1053
|
getProjectInfo() {
|
|
1068
|
-
const startTime =
|
|
1069
|
-
const endTime =
|
|
1054
|
+
const startTime = process2.hrtime();
|
|
1055
|
+
const endTime = process2.hrtime(startTime);
|
|
1070
1056
|
const executionTime = (endTime[0] * 1e9 + endTime[1]) / 1e6;
|
|
1071
1057
|
return {
|
|
1072
|
-
"projectPath":
|
|
1058
|
+
"projectPath": path.join(process2.cwd()),
|
|
1073
1059
|
"startingTime": `${executionTime.toFixed(5)} ms`
|
|
1074
1060
|
};
|
|
1075
1061
|
}
|
|
@@ -1079,7 +1065,7 @@ var Utility = class {
|
|
|
1079
1065
|
* @private
|
|
1080
1066
|
*/
|
|
1081
1067
|
getEnvFileLoading(filePath) {
|
|
1082
|
-
const fullPath =
|
|
1068
|
+
const fullPath = path.resolve(process2.cwd(), filePath);
|
|
1083
1069
|
if (fs.existsSync(fullPath)) {
|
|
1084
1070
|
const env = fs.readFileSync(fullPath, "utf-8");
|
|
1085
1071
|
const lines = env.split("\n");
|
|
@@ -1087,7 +1073,7 @@ var Utility = class {
|
|
|
1087
1073
|
const match = line.match(/^([^#=]+)=([^#]+)$/);
|
|
1088
1074
|
if (match) {
|
|
1089
1075
|
const key = match[1].trim();
|
|
1090
|
-
|
|
1076
|
+
process2.env[key] = match[2].trim();
|
|
1091
1077
|
}
|
|
1092
1078
|
});
|
|
1093
1079
|
}
|
|
@@ -1099,21 +1085,21 @@ var Utility = class {
|
|
|
1099
1085
|
*/
|
|
1100
1086
|
getServerRunningMode(development, production) {
|
|
1101
1087
|
this.getEnvFileLoading(".env");
|
|
1102
|
-
const isDevelopment =
|
|
1088
|
+
const isDevelopment = process2.env.NODE_ENV === "development";
|
|
1103
1089
|
if (isDevelopment) {
|
|
1104
|
-
return `${
|
|
1090
|
+
return `${TranslationLoader9.t("serverRunning", this.localLang)} ${colors.bgBlue(`${colors.bold(`${development}`)}`)} mode`;
|
|
1105
1091
|
} else {
|
|
1106
|
-
return `${
|
|
1092
|
+
return `${TranslationLoader9.t("serverRunning", this.localLang)} ${colors.bgBlue(`${colors.bold(`${production}`)}`)} mode`;
|
|
1107
1093
|
}
|
|
1108
1094
|
}
|
|
1109
1095
|
infoServer(nodeVersion, startingTime, host, port, rss, heapUsed, user, system) {
|
|
1110
1096
|
const paddingLength = 52;
|
|
1111
1097
|
const msg0 = " ".padEnd(paddingLength, " ");
|
|
1112
|
-
const msg1 = ` ${
|
|
1098
|
+
const msg1 = ` ${TranslationLoader9.t("okServerListening", this.localLang)}`;
|
|
1113
1099
|
const msg2Value = `${colors.bgBlue(`${colors.bold(`${nodeVersion}`)}`)}`;
|
|
1114
|
-
const msg2 = ` ${
|
|
1100
|
+
const msg2 = ` ${TranslationLoader9.t("webServerUseNodeVersion", this.localLang)}`;
|
|
1115
1101
|
const msg3Value = `${colors.bgBlue(`${colors.bold(`${startingTime}`)}`)}`;
|
|
1116
|
-
const msg3 = ` ${
|
|
1102
|
+
const msg3 = ` ${TranslationLoader9.t("startupTime", this.localLang)}`;
|
|
1117
1103
|
const msg4 = ` ${this.getServerRunningMode("development", "production")}`;
|
|
1118
1104
|
const msg5 = ` ${colors.underline(`http://${host}:${port}`)}`;
|
|
1119
1105
|
console.log(chalk.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
@@ -1124,10 +1110,10 @@ var Utility = class {
|
|
|
1124
1110
|
console.log(chalk.bgGreen.white(msg5.padEnd(61, " ")));
|
|
1125
1111
|
console.log(chalk.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
1126
1112
|
console.log(``);
|
|
1127
|
-
console.log(`${`${
|
|
1128
|
-
console.log(`${`${
|
|
1129
|
-
console.log(`${`${
|
|
1130
|
-
console.log(`${`${
|
|
1113
|
+
console.log(`${`${TranslationLoader9.t("totalMemory", this.localLang)}`} ${colors.cyan(`${colors.bold(`${rss}`)}`)}`);
|
|
1114
|
+
console.log(`${`${TranslationLoader9.t("memoryUsedDuringExecution", this.localLang)}`} ${colors.cyan(`${colors.bold(`${heapUsed}`)}`)}`);
|
|
1115
|
+
console.log(`${`${TranslationLoader9.t("memoryUsedByUser", this.localLang)}`} ${colors.cyan(`${colors.bold(`${user}`)}`)}`);
|
|
1116
|
+
console.log(`${`${TranslationLoader9.t("memoryUsedBySystem", this.localLang)}`} ${colors.cyan(`${colors.bold(`${system}`)}`)}`);
|
|
1131
1117
|
console.log(``);
|
|
1132
1118
|
}
|
|
1133
1119
|
};
|
|
@@ -1135,7 +1121,7 @@ var Utility = class {
|
|
|
1135
1121
|
// src/core/events/pathModuleVerifier.event.ts
|
|
1136
1122
|
import { resolve } from "path";
|
|
1137
1123
|
import { HttpStatusCode as HttpStatusCode2 } from "opticore-http-response";
|
|
1138
|
-
import { TranslationLoader as
|
|
1124
|
+
import { TranslationLoader as TranslationLoader10 } from "opticore-translator";
|
|
1139
1125
|
var PathModuleVerifier = class {
|
|
1140
1126
|
log;
|
|
1141
1127
|
localeLanguage;
|
|
@@ -1157,7 +1143,7 @@ var PathModuleVerifier = class {
|
|
|
1157
1143
|
}
|
|
1158
1144
|
if (notLoadedPaths.length > 0) {
|
|
1159
1145
|
this.log.error(
|
|
1160
|
-
|
|
1146
|
+
TranslationLoader10.t("moduleNotLoaded", this.localeLanguage, { notLoadedPaths: notLoadedPaths.join(", ") }),
|
|
1161
1147
|
"",
|
|
1162
1148
|
"",
|
|
1163
1149
|
modulePaths,
|
|
@@ -1180,10 +1166,63 @@ var PathModuleVerifier = class {
|
|
|
1180
1166
|
}
|
|
1181
1167
|
}
|
|
1182
1168
|
};
|
|
1169
|
+
|
|
1170
|
+
// src/core/config/loaders/localLanguage.loader.ts
|
|
1171
|
+
import path3 from "path";
|
|
1172
|
+
import { TranslationLoader as TranslationLoader12 } from "opticore-translator";
|
|
1173
|
+
import { HttpStatusCode as HttpStatusCode4 } from "opticore-http-response";
|
|
1174
|
+
|
|
1175
|
+
// src/core/config/loaders/translateLanguage.loader.ts
|
|
1176
|
+
import path2 from "path";
|
|
1177
|
+
import { createRequire } from "module";
|
|
1178
|
+
import { TranslationLoader as TranslationLoader11 } from "opticore-translator";
|
|
1179
|
+
import { HttpStatusCode as HttpStatusCode3 } from "opticore-http-response";
|
|
1180
|
+
var translateWebAppCoreLanguageLoader = (environnementPath, localLang) => {
|
|
1181
|
+
try {
|
|
1182
|
+
const require2 = createRequire(import.meta.url);
|
|
1183
|
+
const packagePath = path2.dirname(require2.resolve("opticore-webapp-core"));
|
|
1184
|
+
const translateMsgJsonFilePath = path2.join(packagePath, "utils", "translations");
|
|
1185
|
+
TranslationLoader11.loadTranslations(translateMsgJsonFilePath);
|
|
1186
|
+
} catch (err) {
|
|
1187
|
+
SLoggerFileConfiguration(environnementPath).error(
|
|
1188
|
+
TranslationLoader11.t(err.message, localLang),
|
|
1189
|
+
err.code,
|
|
1190
|
+
err.code,
|
|
1191
|
+
err.stackTrace,
|
|
1192
|
+
HttpStatusCode3.INTERNAL_SERVER_ERROR
|
|
1193
|
+
);
|
|
1194
|
+
}
|
|
1195
|
+
};
|
|
1196
|
+
|
|
1197
|
+
// src/core/config/loaders/localLanguage.loader.ts
|
|
1198
|
+
var LocalLanguageLoader = class {
|
|
1199
|
+
localeLanguage;
|
|
1200
|
+
environnementPath;
|
|
1201
|
+
constructor(localeLanguage, environnementPath) {
|
|
1202
|
+
this.localeLanguage = localeLanguage;
|
|
1203
|
+
this.environnementPath = environnementPath;
|
|
1204
|
+
translateWebAppCoreLanguageLoader(environnementPath, localeLanguage);
|
|
1205
|
+
}
|
|
1206
|
+
load() {
|
|
1207
|
+
try {
|
|
1208
|
+
const translateMsgJsonFilePath = path3.join(process.cwd(), "src", "utils", "translations");
|
|
1209
|
+
TranslationLoader12.loadTranslations(translateMsgJsonFilePath);
|
|
1210
|
+
} catch (err) {
|
|
1211
|
+
SLoggerFileConfiguration(this.environnementPath).error(
|
|
1212
|
+
TranslationLoader12.t(err.message, this.localeLanguage),
|
|
1213
|
+
err.code,
|
|
1214
|
+
err.code,
|
|
1215
|
+
err.stackTrace,
|
|
1216
|
+
HttpStatusCode4.INTERNAL_SERVER_ERROR
|
|
1217
|
+
);
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
};
|
|
1183
1221
|
export {
|
|
1184
1222
|
CLogLevel,
|
|
1185
1223
|
CSignRSAKeyComponent,
|
|
1186
1224
|
Environment,
|
|
1225
|
+
LocalLanguageLoader,
|
|
1187
1226
|
MMongoCheckerDatabase,
|
|
1188
1227
|
MMySqlCheckerDatabase,
|
|
1189
1228
|
MPostgresCheckerDatabase,
|