opticore-webapp-core 1.0.16 → 1.0.18
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 +97 -102
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +85 -90
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -706,16 +706,45 @@ var UOptionalArgumentConnection = (environnementPath) => {
|
|
|
706
706
|
|
|
707
707
|
// src/utils/parsing/parsingYaml.utils.ts
|
|
708
708
|
var import_promises = require("fs/promises");
|
|
709
|
-
var
|
|
709
|
+
var import_opticore_http_response6 = require("opticore-http-response");
|
|
710
710
|
var import_opticore_logger3 = require("opticore-logger");
|
|
711
|
+
var import_opticore_translator7 = require("opticore-translator");
|
|
712
|
+
|
|
713
|
+
// src/core/config/loaders/translateLanguage.loader.ts
|
|
714
|
+
var import_path = __toESM(require("path"), 1);
|
|
715
|
+
var import_module = require("module");
|
|
711
716
|
var import_opticore_translator6 = require("opticore-translator");
|
|
717
|
+
var import_opticore_http_response5 = require("opticore-http-response");
|
|
718
|
+
var translateWebAppCoreLanguageLoader = (environnementPath, localLang) => {
|
|
719
|
+
try {
|
|
720
|
+
const require2 = (0, import_module.createRequire)(importMetaUrl);
|
|
721
|
+
const packagePath = import_path.default.dirname(require2.resolve("opticore-webapp-core"));
|
|
722
|
+
const translateMsgJsonFilePath = import_path.default.join(packagePath, "utils", "translations");
|
|
723
|
+
import_opticore_translator6.TranslationLoader.loadTranslations(translateMsgJsonFilePath);
|
|
724
|
+
} catch (err) {
|
|
725
|
+
SLoggerFileConfiguration(environnementPath).error(
|
|
726
|
+
import_opticore_translator6.TranslationLoader.t(err.message, localLang),
|
|
727
|
+
err.code,
|
|
728
|
+
err.code,
|
|
729
|
+
err.stackTrace,
|
|
730
|
+
import_opticore_http_response5.HttpStatusCode.INTERNAL_SERVER_ERROR
|
|
731
|
+
);
|
|
732
|
+
}
|
|
733
|
+
};
|
|
734
|
+
|
|
735
|
+
// src/utils/parsing/parsingYaml.utils.ts
|
|
736
|
+
var import_path2 = __toESM(require("path"), 1);
|
|
712
737
|
var YamlParsing = class {
|
|
713
738
|
logger;
|
|
714
739
|
localeLanguage;
|
|
715
740
|
constructor(localeLanguage, environnementPath) {
|
|
741
|
+
translateWebAppCoreLanguageLoader(environnementPath, localeLanguage);
|
|
716
742
|
this.localeLanguage = localeLanguage;
|
|
717
743
|
this.logger = new import_opticore_logger3.LoggerCore(loggerConfig(environnementPath));
|
|
718
744
|
}
|
|
745
|
+
absolutPath() {
|
|
746
|
+
return import_path2.default.join(process.cwd(), "src", "utils", "translations");
|
|
747
|
+
}
|
|
719
748
|
async readFile(filePath) {
|
|
720
749
|
try {
|
|
721
750
|
const yamlContent = await (0, import_promises.readFile)(filePath, "utf-8");
|
|
@@ -723,10 +752,10 @@ var YamlParsing = class {
|
|
|
723
752
|
} catch (error) {
|
|
724
753
|
this.logger.error(
|
|
725
754
|
error.message,
|
|
726
|
-
|
|
727
|
-
|
|
755
|
+
import_opticore_translator7.TranslationLoader.t("parsingFailed", this.localeLanguage, this.logger),
|
|
756
|
+
import_opticore_translator7.TranslationLoader.t("readingError", this.localeLanguage, this.logger),
|
|
728
757
|
error.stack,
|
|
729
|
-
|
|
758
|
+
import_opticore_http_response6.HttpStatusCode.NOT_ACCEPTABLE
|
|
730
759
|
);
|
|
731
760
|
}
|
|
732
761
|
}
|
|
@@ -755,11 +784,11 @@ var YamlParsing = class {
|
|
|
755
784
|
}
|
|
756
785
|
} else {
|
|
757
786
|
this.logger.error(
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
787
|
+
import_opticore_translator7.TranslationLoader.t("badFormat", this.localeLanguage, { line }),
|
|
788
|
+
import_opticore_translator7.TranslationLoader.t("parsingFailed", this.localeLanguage, this.logger),
|
|
789
|
+
import_opticore_translator7.TranslationLoader.t("unsupportedFormat", this.localeLanguage, this.logger),
|
|
761
790
|
content,
|
|
762
|
-
|
|
791
|
+
import_opticore_http_response6.HttpStatusCode.NOT_ACCEPTABLE
|
|
763
792
|
);
|
|
764
793
|
}
|
|
765
794
|
}
|
|
@@ -783,14 +812,14 @@ var Environment = class {
|
|
|
783
812
|
|
|
784
813
|
// src/core/config/database/connexion.config.database.ts
|
|
785
814
|
var import_mysql = __toESM(require("mysql"), 1);
|
|
786
|
-
var
|
|
815
|
+
var import_opticore_http_response8 = require("opticore-http-response");
|
|
787
816
|
var import_opticore_logger4 = require("opticore-logger");
|
|
788
|
-
var
|
|
817
|
+
var import_opticore_translator9 = require("opticore-translator");
|
|
789
818
|
|
|
790
819
|
// src/core/errors/databaseConnexion.error.ts
|
|
791
|
-
var
|
|
820
|
+
var import_opticore_http_response7 = require("opticore-http-response");
|
|
792
821
|
var import_opticore_catch_exception_error3 = require("opticore-catch-exception-error");
|
|
793
|
-
var
|
|
822
|
+
var import_opticore_translator8 = require("opticore-translator");
|
|
794
823
|
var DbConnexionConfigError = class {
|
|
795
824
|
logger;
|
|
796
825
|
localeLanguage;
|
|
@@ -804,16 +833,16 @@ var DbConnexionConfigError = class {
|
|
|
804
833
|
*/
|
|
805
834
|
mongoDBAuthenticationFailed(e) {
|
|
806
835
|
const stackTrace = this.traceError(
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
836
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", this.localeLanguage, { e }),
|
|
837
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBAuthentication", this.localeLanguage),
|
|
838
|
+
import_opticore_http_response7.HttpStatusCode.UNAUTHORIZED
|
|
810
839
|
);
|
|
811
840
|
this.logger.error(
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
841
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBAuthenticationError", this.localeLanguage),
|
|
842
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", this.localeLanguage),
|
|
843
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBAuthenticationFailed", this.localeLanguage),
|
|
815
844
|
stackTrace.stack,
|
|
816
|
-
|
|
845
|
+
import_opticore_http_response7.HttpStatusCode.UNAUTHORIZED
|
|
817
846
|
);
|
|
818
847
|
}
|
|
819
848
|
/**
|
|
@@ -824,16 +853,16 @@ var DbConnexionConfigError = class {
|
|
|
824
853
|
*/
|
|
825
854
|
mongoDBInvalidUrl(err, dbHost, dbPort) {
|
|
826
855
|
const stackTrace = this.traceError(
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
856
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", this.localeLanguage, { err }),
|
|
857
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBUnableParsingUrl", this.localeLanguage),
|
|
858
|
+
import_opticore_http_response7.HttpStatusCode.BAD_REQUEST
|
|
830
859
|
);
|
|
831
860
|
this.logger.error(
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
861
|
+
import_opticore_translator8.TranslationLoader.t("dbUrlParsingError", this.localeLanguage, { dbHost, dbPort }),
|
|
862
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", this.localeLanguage),
|
|
863
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBUnableParsingUrl", this.localeLanguage),
|
|
835
864
|
stackTrace.stack,
|
|
836
|
-
|
|
865
|
+
import_opticore_http_response7.HttpStatusCode.BAD_REQUEST
|
|
837
866
|
);
|
|
838
867
|
}
|
|
839
868
|
/**
|
|
@@ -843,16 +872,16 @@ var DbConnexionConfigError = class {
|
|
|
843
872
|
*/
|
|
844
873
|
mongoDBEaiAgain(err, dbHost) {
|
|
845
874
|
const stackTrace = this.traceError(
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
875
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", this.localeLanguage, { err }),
|
|
876
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBServerSelection", this.localeLanguage),
|
|
877
|
+
import_opticore_http_response7.HttpStatusCode.BAD_REQUEST
|
|
849
878
|
);
|
|
850
879
|
this.logger.error(
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
880
|
+
import_opticore_translator8.TranslationLoader.t("mongoServerError", this.localeLanguage, { dbHost }),
|
|
881
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", this.localeLanguage),
|
|
882
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBServerSelection", this.localeLanguage),
|
|
854
883
|
stackTrace.stack,
|
|
855
|
-
|
|
884
|
+
import_opticore_http_response7.HttpStatusCode.BAD_REQUEST
|
|
856
885
|
);
|
|
857
886
|
}
|
|
858
887
|
/**
|
|
@@ -861,16 +890,16 @@ var DbConnexionConfigError = class {
|
|
|
861
890
|
*/
|
|
862
891
|
mongoDbGlobalError(err) {
|
|
863
892
|
const stackTrace = this.traceError(
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
893
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", this.localeLanguage, { err }),
|
|
894
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", this.localeLanguage),
|
|
895
|
+
import_opticore_http_response7.HttpStatusCode.NOT_ACCEPTABLE
|
|
867
896
|
);
|
|
868
897
|
this.logger.error(
|
|
869
|
-
|
|
870
|
-
|
|
898
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", this.localeLanguage),
|
|
899
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnectionError", this.localeLanguage),
|
|
871
900
|
stackTrace.stack,
|
|
872
901
|
err.message,
|
|
873
|
-
|
|
902
|
+
import_opticore_http_response7.HttpStatusCode.NOT_ACCEPTABLE
|
|
874
903
|
);
|
|
875
904
|
}
|
|
876
905
|
/**
|
|
@@ -928,8 +957,8 @@ var DatabaseConnectionConfig = class {
|
|
|
928
957
|
try {
|
|
929
958
|
await SCheckerMongoDatabaseConnection(url, this.env.get("dataBaseUser"), this.env.get("dataBasePassword"), this.env.get("dataBaseName"));
|
|
930
959
|
this.logger.success(
|
|
931
|
-
|
|
932
|
-
|
|
960
|
+
import_opticore_translator9.TranslationLoader.t("mongoDBConnectionChecker", this.localeLanguage, loggerConfig),
|
|
961
|
+
import_opticore_translator9.TranslationLoader.t("mongoConnectionSuccess", this.localeLanguage, loggerConfig)
|
|
933
962
|
);
|
|
934
963
|
console.log("");
|
|
935
964
|
} catch (e) {
|
|
@@ -982,23 +1011,13 @@ var DatabaseConnectionConfig = class {
|
|
|
982
1011
|
options
|
|
983
1012
|
);
|
|
984
1013
|
this.logger.success(
|
|
985
|
-
|
|
986
|
-
|
|
1014
|
+
import_opticore_translator9.TranslationLoader.t("postgresDBConnectionChecker", this.localeLanguage, loggerConfig),
|
|
1015
|
+
import_opticore_translator9.TranslationLoader.t("postgresConnectionSuccess", this.localeLanguage, loggerConfig)
|
|
987
1016
|
);
|
|
988
1017
|
console.log("");
|
|
989
1018
|
} catch (err) {
|
|
990
|
-
const stackTrace = this.traceError(
|
|
991
|
-
|
|
992
|
-
"PostgresConnectionError",
|
|
993
|
-
import_opticore_http_response7.HttpStatusCode.NOT_ACCEPTABLE
|
|
994
|
-
);
|
|
995
|
-
this.logger.error(
|
|
996
|
-
err.message,
|
|
997
|
-
"PostgresConnectionError",
|
|
998
|
-
"Postgres connection error",
|
|
999
|
-
stackTrace.stack,
|
|
1000
|
-
import_opticore_http_response7.HttpStatusCode.NOT_ACCEPTABLE
|
|
1001
|
-
);
|
|
1019
|
+
const stackTrace = this.traceError(import_opticore_translator9.TranslationLoader.t(`${err.message}`, this.localeLanguage, loggerConfig), "PostgresConnectionError", import_opticore_http_response8.HttpStatusCode.NOT_ACCEPTABLE);
|
|
1020
|
+
this.logger.error(err.message, "PostgresConnectionError", "Postgres connection error", stackTrace.stack, import_opticore_http_response8.HttpStatusCode.NOT_ACCEPTABLE);
|
|
1002
1021
|
}
|
|
1003
1022
|
}
|
|
1004
1023
|
traceError(props, name, status7) {
|
|
@@ -1040,9 +1059,9 @@ var MPostgresCheckerDatabase = (localLanguage, environnementPath, keepAlive, str
|
|
|
1040
1059
|
var import_node_process = __toESM(require("process"), 1);
|
|
1041
1060
|
var import_chalk = __toESM(require("chalk"), 1);
|
|
1042
1061
|
var import_ansi_colors = __toESM(require("ansi-colors"), 1);
|
|
1043
|
-
var
|
|
1062
|
+
var import_path3 = __toESM(require("path"), 1);
|
|
1044
1063
|
var import_fs = __toESM(require("fs"), 1);
|
|
1045
|
-
var
|
|
1064
|
+
var import_opticore_translator10 = require("opticore-translator");
|
|
1046
1065
|
var Utility = class {
|
|
1047
1066
|
localLang;
|
|
1048
1067
|
constructor(localLanguage) {
|
|
@@ -1107,7 +1126,7 @@ var Utility = class {
|
|
|
1107
1126
|
const endTime = import_node_process.default.hrtime(startTime);
|
|
1108
1127
|
const executionTime = (endTime[0] * 1e9 + endTime[1]) / 1e6;
|
|
1109
1128
|
return {
|
|
1110
|
-
"projectPath":
|
|
1129
|
+
"projectPath": import_path3.default.join(import_node_process.default.cwd()),
|
|
1111
1130
|
"startingTime": `${executionTime.toFixed(5)} ms`
|
|
1112
1131
|
};
|
|
1113
1132
|
}
|
|
@@ -1117,7 +1136,7 @@ var Utility = class {
|
|
|
1117
1136
|
* @private
|
|
1118
1137
|
*/
|
|
1119
1138
|
getEnvFileLoading(filePath) {
|
|
1120
|
-
const fullPath =
|
|
1139
|
+
const fullPath = import_path3.default.resolve(import_node_process.default.cwd(), filePath);
|
|
1121
1140
|
if (import_fs.default.existsSync(fullPath)) {
|
|
1122
1141
|
const env = import_fs.default.readFileSync(fullPath, "utf-8");
|
|
1123
1142
|
const lines = env.split("\n");
|
|
@@ -1139,19 +1158,19 @@ var Utility = class {
|
|
|
1139
1158
|
this.getEnvFileLoading(".env");
|
|
1140
1159
|
const isDevelopment = import_node_process.default.env.NODE_ENV === "development";
|
|
1141
1160
|
if (isDevelopment) {
|
|
1142
|
-
return `${
|
|
1161
|
+
return `${import_opticore_translator10.TranslationLoader.t("serverRunning", this.localLang)} ${import_ansi_colors.default.bgBlue(`${import_ansi_colors.default.bold(`${development}`)}`)} mode`;
|
|
1143
1162
|
} else {
|
|
1144
|
-
return `${
|
|
1163
|
+
return `${import_opticore_translator10.TranslationLoader.t("serverRunning", this.localLang)} ${import_ansi_colors.default.bgBlue(`${import_ansi_colors.default.bold(`${production}`)}`)} mode`;
|
|
1145
1164
|
}
|
|
1146
1165
|
}
|
|
1147
1166
|
infoServer(nodeVersion, startingTime, host, port, rss, heapUsed, user, system) {
|
|
1148
1167
|
const paddingLength = 52;
|
|
1149
1168
|
const msg0 = " ".padEnd(paddingLength, " ");
|
|
1150
|
-
const msg1 = ` ${
|
|
1169
|
+
const msg1 = ` ${import_opticore_translator10.TranslationLoader.t("okServerListening", this.localLang)}`;
|
|
1151
1170
|
const msg2Value = `${import_ansi_colors.default.bgBlue(`${import_ansi_colors.default.bold(`${nodeVersion}`)}`)}`;
|
|
1152
|
-
const msg2 = ` ${
|
|
1171
|
+
const msg2 = ` ${import_opticore_translator10.TranslationLoader.t("webServerUseNodeVersion", this.localLang)}`;
|
|
1153
1172
|
const msg3Value = `${import_ansi_colors.default.bgBlue(`${import_ansi_colors.default.bold(`${startingTime}`)}`)}`;
|
|
1154
|
-
const msg3 = ` ${
|
|
1173
|
+
const msg3 = ` ${import_opticore_translator10.TranslationLoader.t("startupTime", this.localLang)}`;
|
|
1155
1174
|
const msg4 = ` ${this.getServerRunningMode("development", "production")}`;
|
|
1156
1175
|
const msg5 = ` ${import_ansi_colors.default.underline(`http://${host}:${port}`)}`;
|
|
1157
1176
|
console.log(import_chalk.default.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
@@ -1162,18 +1181,18 @@ var Utility = class {
|
|
|
1162
1181
|
console.log(import_chalk.default.bgGreen.white(msg5.padEnd(61, " ")));
|
|
1163
1182
|
console.log(import_chalk.default.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
1164
1183
|
console.log(``);
|
|
1165
|
-
console.log(`${`${
|
|
1166
|
-
console.log(`${`${
|
|
1167
|
-
console.log(`${`${
|
|
1168
|
-
console.log(`${`${
|
|
1184
|
+
console.log(`${`${import_opticore_translator10.TranslationLoader.t("totalMemory", this.localLang)}`} ${import_ansi_colors.default.cyan(`${import_ansi_colors.default.bold(`${rss}`)}`)}`);
|
|
1185
|
+
console.log(`${`${import_opticore_translator10.TranslationLoader.t("memoryUsedDuringExecution", this.localLang)}`} ${import_ansi_colors.default.cyan(`${import_ansi_colors.default.bold(`${heapUsed}`)}`)}`);
|
|
1186
|
+
console.log(`${`${import_opticore_translator10.TranslationLoader.t("memoryUsedByUser", this.localLang)}`} ${import_ansi_colors.default.cyan(`${import_ansi_colors.default.bold(`${user}`)}`)}`);
|
|
1187
|
+
console.log(`${`${import_opticore_translator10.TranslationLoader.t("memoryUsedBySystem", this.localLang)}`} ${import_ansi_colors.default.cyan(`${import_ansi_colors.default.bold(`${system}`)}`)}`);
|
|
1169
1188
|
console.log(``);
|
|
1170
1189
|
}
|
|
1171
1190
|
};
|
|
1172
1191
|
|
|
1173
1192
|
// src/core/events/pathModuleVerifier.event.ts
|
|
1174
|
-
var
|
|
1175
|
-
var
|
|
1176
|
-
var
|
|
1193
|
+
var import_path4 = require("path");
|
|
1194
|
+
var import_opticore_http_response9 = require("opticore-http-response");
|
|
1195
|
+
var import_opticore_translator11 = require("opticore-translator");
|
|
1177
1196
|
var PathModuleVerifier = class {
|
|
1178
1197
|
log;
|
|
1179
1198
|
localeLanguage;
|
|
@@ -1195,11 +1214,11 @@ var PathModuleVerifier = class {
|
|
|
1195
1214
|
}
|
|
1196
1215
|
if (notLoadedPaths.length > 0) {
|
|
1197
1216
|
this.log.error(
|
|
1198
|
-
|
|
1217
|
+
import_opticore_translator11.TranslationLoader.t("moduleNotLoaded", this.localeLanguage, { notLoadedPaths: notLoadedPaths.join(", ") }),
|
|
1199
1218
|
"",
|
|
1200
1219
|
"",
|
|
1201
1220
|
modulePaths,
|
|
1202
|
-
|
|
1221
|
+
import_opticore_http_response9.HttpStatusCode.NOT_ACCEPTABLE
|
|
1203
1222
|
);
|
|
1204
1223
|
throw new Error();
|
|
1205
1224
|
}
|
|
@@ -1211,7 +1230,7 @@ var PathModuleVerifier = class {
|
|
|
1211
1230
|
*/
|
|
1212
1231
|
isModulePathLoaded(modulePath) {
|
|
1213
1232
|
try {
|
|
1214
|
-
const resolvedPath = (0,
|
|
1233
|
+
const resolvedPath = (0, import_path4.resolve)(modulePath);
|
|
1215
1234
|
return require.cache[resolvedPath] !== void 0;
|
|
1216
1235
|
} catch {
|
|
1217
1236
|
return false;
|
|
@@ -1220,48 +1239,24 @@ var PathModuleVerifier = class {
|
|
|
1220
1239
|
};
|
|
1221
1240
|
|
|
1222
1241
|
// src/core/config/loaders/localLanguage.loader.ts
|
|
1223
|
-
var
|
|
1242
|
+
var import_path5 = __toESM(require("path"), 1);
|
|
1224
1243
|
var import_opticore_translator12 = require("opticore-translator");
|
|
1225
1244
|
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
1245
|
var LocalLanguageLoader = class {
|
|
1251
1246
|
localeLanguage;
|
|
1252
1247
|
environnementPath;
|
|
1253
1248
|
constructor(localeLanguage, environnementPath) {
|
|
1254
1249
|
this.localeLanguage = localeLanguage;
|
|
1255
1250
|
this.environnementPath = environnementPath;
|
|
1256
|
-
translateWebAppCoreLanguageLoader(environnementPath, localeLanguage);
|
|
1257
1251
|
}
|
|
1258
1252
|
load() {
|
|
1259
1253
|
try {
|
|
1260
|
-
const translateMsgJsonFilePath =
|
|
1254
|
+
const translateMsgJsonFilePath = import_path5.default.join(process.cwd(), "src", "utils", "translations");
|
|
1261
1255
|
import_opticore_translator12.TranslationLoader.loadTranslations(translateMsgJsonFilePath);
|
|
1262
1256
|
} catch (err) {
|
|
1263
1257
|
SLoggerFileConfiguration(this.environnementPath).error(
|
|
1264
|
-
|
|
1258
|
+
//TranslationLoader.t(err.message, this.localeLanguage),
|
|
1259
|
+
err.message,
|
|
1265
1260
|
err.code,
|
|
1266
1261
|
err.code,
|
|
1267
1262
|
err.stackTrace,
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -654,16 +654,45 @@ var UOptionalArgumentConnection = (environnementPath) => {
|
|
|
654
654
|
|
|
655
655
|
// src/utils/parsing/parsingYaml.utils.ts
|
|
656
656
|
import { readFile } from "fs/promises";
|
|
657
|
-
import { HttpStatusCode } from "opticore-http-response";
|
|
657
|
+
import { HttpStatusCode as HttpStatusCode2 } 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";
|
|
659
664
|
import { TranslationLoader as TranslationLoader6 } from "opticore-translator";
|
|
665
|
+
import { HttpStatusCode } from "opticore-http-response";
|
|
666
|
+
var translateWebAppCoreLanguageLoader = (environnementPath, localLang) => {
|
|
667
|
+
try {
|
|
668
|
+
const require2 = createRequire(import.meta.url);
|
|
669
|
+
const packagePath = path.dirname(require2.resolve("opticore-webapp-core"));
|
|
670
|
+
const translateMsgJsonFilePath = path.join(packagePath, "utils", "translations");
|
|
671
|
+
TranslationLoader6.loadTranslations(translateMsgJsonFilePath);
|
|
672
|
+
} catch (err) {
|
|
673
|
+
SLoggerFileConfiguration(environnementPath).error(
|
|
674
|
+
TranslationLoader6.t(err.message, localLang),
|
|
675
|
+
err.code,
|
|
676
|
+
err.code,
|
|
677
|
+
err.stackTrace,
|
|
678
|
+
HttpStatusCode.INTERNAL_SERVER_ERROR
|
|
679
|
+
);
|
|
680
|
+
}
|
|
681
|
+
};
|
|
682
|
+
|
|
683
|
+
// src/utils/parsing/parsingYaml.utils.ts
|
|
684
|
+
import path2 from "path";
|
|
660
685
|
var YamlParsing = class {
|
|
661
686
|
logger;
|
|
662
687
|
localeLanguage;
|
|
663
688
|
constructor(localeLanguage, environnementPath) {
|
|
689
|
+
translateWebAppCoreLanguageLoader(environnementPath, localeLanguage);
|
|
664
690
|
this.localeLanguage = localeLanguage;
|
|
665
691
|
this.logger = new LoggerCore3(loggerConfig(environnementPath));
|
|
666
692
|
}
|
|
693
|
+
absolutPath() {
|
|
694
|
+
return path2.join(process.cwd(), "src", "utils", "translations");
|
|
695
|
+
}
|
|
667
696
|
async readFile(filePath) {
|
|
668
697
|
try {
|
|
669
698
|
const yamlContent = await readFile(filePath, "utf-8");
|
|
@@ -671,10 +700,10 @@ var YamlParsing = class {
|
|
|
671
700
|
} catch (error) {
|
|
672
701
|
this.logger.error(
|
|
673
702
|
error.message,
|
|
674
|
-
|
|
675
|
-
|
|
703
|
+
TranslationLoader7.t("parsingFailed", this.localeLanguage, this.logger),
|
|
704
|
+
TranslationLoader7.t("readingError", this.localeLanguage, this.logger),
|
|
676
705
|
error.stack,
|
|
677
|
-
|
|
706
|
+
HttpStatusCode2.NOT_ACCEPTABLE
|
|
678
707
|
);
|
|
679
708
|
}
|
|
680
709
|
}
|
|
@@ -703,11 +732,11 @@ var YamlParsing = class {
|
|
|
703
732
|
}
|
|
704
733
|
} else {
|
|
705
734
|
this.logger.error(
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
735
|
+
TranslationLoader7.t("badFormat", this.localeLanguage, { line }),
|
|
736
|
+
TranslationLoader7.t("parsingFailed", this.localeLanguage, this.logger),
|
|
737
|
+
TranslationLoader7.t("unsupportedFormat", this.localeLanguage, this.logger),
|
|
709
738
|
content,
|
|
710
|
-
|
|
739
|
+
HttpStatusCode2.NOT_ACCEPTABLE
|
|
711
740
|
);
|
|
712
741
|
}
|
|
713
742
|
}
|
|
@@ -733,12 +762,12 @@ var Environment = class {
|
|
|
733
762
|
import mySQL from "mysql";
|
|
734
763
|
import { HttpStatusCode as status6 } from "opticore-http-response";
|
|
735
764
|
import { LoggerCore as LoggerCore4 } from "opticore-logger";
|
|
736
|
-
import { TranslationLoader as
|
|
765
|
+
import { TranslationLoader as TranslationLoader9 } from "opticore-translator";
|
|
737
766
|
|
|
738
767
|
// src/core/errors/databaseConnexion.error.ts
|
|
739
768
|
import { HttpStatusCode as status5 } from "opticore-http-response";
|
|
740
769
|
import { StackTraceError as StackTraceError2 } from "opticore-catch-exception-error";
|
|
741
|
-
import { TranslationLoader as
|
|
770
|
+
import { TranslationLoader as TranslationLoader8 } from "opticore-translator";
|
|
742
771
|
var DbConnexionConfigError = class {
|
|
743
772
|
logger;
|
|
744
773
|
localeLanguage;
|
|
@@ -752,14 +781,14 @@ var DbConnexionConfigError = class {
|
|
|
752
781
|
*/
|
|
753
782
|
mongoDBAuthenticationFailed(e) {
|
|
754
783
|
const stackTrace = this.traceError(
|
|
755
|
-
|
|
756
|
-
|
|
784
|
+
TranslationLoader8.t("mongoDBConnection", this.localeLanguage, { e }),
|
|
785
|
+
TranslationLoader8.t("mongoDBAuthentication", this.localeLanguage),
|
|
757
786
|
status5.UNAUTHORIZED
|
|
758
787
|
);
|
|
759
788
|
this.logger.error(
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
789
|
+
TranslationLoader8.t("mongoDBAuthenticationError", this.localeLanguage),
|
|
790
|
+
TranslationLoader8.t("mongoDBConnection", this.localeLanguage),
|
|
791
|
+
TranslationLoader8.t("mongoDBAuthenticationFailed", this.localeLanguage),
|
|
763
792
|
stackTrace.stack,
|
|
764
793
|
status5.UNAUTHORIZED
|
|
765
794
|
);
|
|
@@ -772,14 +801,14 @@ var DbConnexionConfigError = class {
|
|
|
772
801
|
*/
|
|
773
802
|
mongoDBInvalidUrl(err, dbHost, dbPort) {
|
|
774
803
|
const stackTrace = this.traceError(
|
|
775
|
-
|
|
776
|
-
|
|
804
|
+
TranslationLoader8.t("mongoDBConnection", this.localeLanguage, { err }),
|
|
805
|
+
TranslationLoader8.t("mongoDBUnableParsingUrl", this.localeLanguage),
|
|
777
806
|
status5.BAD_REQUEST
|
|
778
807
|
);
|
|
779
808
|
this.logger.error(
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
809
|
+
TranslationLoader8.t("dbUrlParsingError", this.localeLanguage, { dbHost, dbPort }),
|
|
810
|
+
TranslationLoader8.t("mongoDBConnection", this.localeLanguage),
|
|
811
|
+
TranslationLoader8.t("mongoDBUnableParsingUrl", this.localeLanguage),
|
|
783
812
|
stackTrace.stack,
|
|
784
813
|
status5.BAD_REQUEST
|
|
785
814
|
);
|
|
@@ -791,14 +820,14 @@ var DbConnexionConfigError = class {
|
|
|
791
820
|
*/
|
|
792
821
|
mongoDBEaiAgain(err, dbHost) {
|
|
793
822
|
const stackTrace = this.traceError(
|
|
794
|
-
|
|
795
|
-
|
|
823
|
+
TranslationLoader8.t("mongoDBConnection", this.localeLanguage, { err }),
|
|
824
|
+
TranslationLoader8.t("mongoDBServerSelection", this.localeLanguage),
|
|
796
825
|
status5.BAD_REQUEST
|
|
797
826
|
);
|
|
798
827
|
this.logger.error(
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
828
|
+
TranslationLoader8.t("mongoServerError", this.localeLanguage, { dbHost }),
|
|
829
|
+
TranslationLoader8.t("mongoDBConnection", this.localeLanguage),
|
|
830
|
+
TranslationLoader8.t("mongoDBServerSelection", this.localeLanguage),
|
|
802
831
|
stackTrace.stack,
|
|
803
832
|
status5.BAD_REQUEST
|
|
804
833
|
);
|
|
@@ -809,13 +838,13 @@ var DbConnexionConfigError = class {
|
|
|
809
838
|
*/
|
|
810
839
|
mongoDbGlobalError(err) {
|
|
811
840
|
const stackTrace = this.traceError(
|
|
812
|
-
|
|
813
|
-
|
|
841
|
+
TranslationLoader8.t("mongoDBConnection", this.localeLanguage, { err }),
|
|
842
|
+
TranslationLoader8.t("mongoDBConnection", this.localeLanguage),
|
|
814
843
|
status5.NOT_ACCEPTABLE
|
|
815
844
|
);
|
|
816
845
|
this.logger.error(
|
|
817
|
-
|
|
818
|
-
|
|
846
|
+
TranslationLoader8.t("mongoDBConnection", this.localeLanguage),
|
|
847
|
+
TranslationLoader8.t("mongoDBConnectionError", this.localeLanguage),
|
|
819
848
|
stackTrace.stack,
|
|
820
849
|
err.message,
|
|
821
850
|
status5.NOT_ACCEPTABLE
|
|
@@ -876,8 +905,8 @@ var DatabaseConnectionConfig = class {
|
|
|
876
905
|
try {
|
|
877
906
|
await SCheckerMongoDatabaseConnection(url, this.env.get("dataBaseUser"), this.env.get("dataBasePassword"), this.env.get("dataBaseName"));
|
|
878
907
|
this.logger.success(
|
|
879
|
-
|
|
880
|
-
|
|
908
|
+
TranslationLoader9.t("mongoDBConnectionChecker", this.localeLanguage, loggerConfig),
|
|
909
|
+
TranslationLoader9.t("mongoConnectionSuccess", this.localeLanguage, loggerConfig)
|
|
881
910
|
);
|
|
882
911
|
console.log("");
|
|
883
912
|
} catch (e) {
|
|
@@ -930,23 +959,13 @@ var DatabaseConnectionConfig = class {
|
|
|
930
959
|
options
|
|
931
960
|
);
|
|
932
961
|
this.logger.success(
|
|
933
|
-
|
|
934
|
-
|
|
962
|
+
TranslationLoader9.t("postgresDBConnectionChecker", this.localeLanguage, loggerConfig),
|
|
963
|
+
TranslationLoader9.t("postgresConnectionSuccess", this.localeLanguage, loggerConfig)
|
|
935
964
|
);
|
|
936
965
|
console.log("");
|
|
937
966
|
} catch (err) {
|
|
938
|
-
const stackTrace = this.traceError(
|
|
939
|
-
|
|
940
|
-
"PostgresConnectionError",
|
|
941
|
-
status6.NOT_ACCEPTABLE
|
|
942
|
-
);
|
|
943
|
-
this.logger.error(
|
|
944
|
-
err.message,
|
|
945
|
-
"PostgresConnectionError",
|
|
946
|
-
"Postgres connection error",
|
|
947
|
-
stackTrace.stack,
|
|
948
|
-
status6.NOT_ACCEPTABLE
|
|
949
|
-
);
|
|
967
|
+
const stackTrace = this.traceError(TranslationLoader9.t(`${err.message}`, this.localeLanguage, loggerConfig), "PostgresConnectionError", status6.NOT_ACCEPTABLE);
|
|
968
|
+
this.logger.error(err.message, "PostgresConnectionError", "Postgres connection error", stackTrace.stack, status6.NOT_ACCEPTABLE);
|
|
950
969
|
}
|
|
951
970
|
}
|
|
952
971
|
traceError(props, name, status7) {
|
|
@@ -988,9 +1007,9 @@ var MPostgresCheckerDatabase = (localLanguage, environnementPath, keepAlive, str
|
|
|
988
1007
|
import process2 from "node:process";
|
|
989
1008
|
import chalk from "chalk";
|
|
990
1009
|
import colors from "ansi-colors";
|
|
991
|
-
import
|
|
1010
|
+
import path3 from "path";
|
|
992
1011
|
import fs from "fs";
|
|
993
|
-
import { TranslationLoader as
|
|
1012
|
+
import { TranslationLoader as TranslationLoader10 } from "opticore-translator";
|
|
994
1013
|
var Utility = class {
|
|
995
1014
|
localLang;
|
|
996
1015
|
constructor(localLanguage) {
|
|
@@ -1055,7 +1074,7 @@ var Utility = class {
|
|
|
1055
1074
|
const endTime = process2.hrtime(startTime);
|
|
1056
1075
|
const executionTime = (endTime[0] * 1e9 + endTime[1]) / 1e6;
|
|
1057
1076
|
return {
|
|
1058
|
-
"projectPath":
|
|
1077
|
+
"projectPath": path3.join(process2.cwd()),
|
|
1059
1078
|
"startingTime": `${executionTime.toFixed(5)} ms`
|
|
1060
1079
|
};
|
|
1061
1080
|
}
|
|
@@ -1065,7 +1084,7 @@ var Utility = class {
|
|
|
1065
1084
|
* @private
|
|
1066
1085
|
*/
|
|
1067
1086
|
getEnvFileLoading(filePath) {
|
|
1068
|
-
const fullPath =
|
|
1087
|
+
const fullPath = path3.resolve(process2.cwd(), filePath);
|
|
1069
1088
|
if (fs.existsSync(fullPath)) {
|
|
1070
1089
|
const env = fs.readFileSync(fullPath, "utf-8");
|
|
1071
1090
|
const lines = env.split("\n");
|
|
@@ -1087,19 +1106,19 @@ var Utility = class {
|
|
|
1087
1106
|
this.getEnvFileLoading(".env");
|
|
1088
1107
|
const isDevelopment = process2.env.NODE_ENV === "development";
|
|
1089
1108
|
if (isDevelopment) {
|
|
1090
|
-
return `${
|
|
1109
|
+
return `${TranslationLoader10.t("serverRunning", this.localLang)} ${colors.bgBlue(`${colors.bold(`${development}`)}`)} mode`;
|
|
1091
1110
|
} else {
|
|
1092
|
-
return `${
|
|
1111
|
+
return `${TranslationLoader10.t("serverRunning", this.localLang)} ${colors.bgBlue(`${colors.bold(`${production}`)}`)} mode`;
|
|
1093
1112
|
}
|
|
1094
1113
|
}
|
|
1095
1114
|
infoServer(nodeVersion, startingTime, host, port, rss, heapUsed, user, system) {
|
|
1096
1115
|
const paddingLength = 52;
|
|
1097
1116
|
const msg0 = " ".padEnd(paddingLength, " ");
|
|
1098
|
-
const msg1 = ` ${
|
|
1117
|
+
const msg1 = ` ${TranslationLoader10.t("okServerListening", this.localLang)}`;
|
|
1099
1118
|
const msg2Value = `${colors.bgBlue(`${colors.bold(`${nodeVersion}`)}`)}`;
|
|
1100
|
-
const msg2 = ` ${
|
|
1119
|
+
const msg2 = ` ${TranslationLoader10.t("webServerUseNodeVersion", this.localLang)}`;
|
|
1101
1120
|
const msg3Value = `${colors.bgBlue(`${colors.bold(`${startingTime}`)}`)}`;
|
|
1102
|
-
const msg3 = ` ${
|
|
1121
|
+
const msg3 = ` ${TranslationLoader10.t("startupTime", this.localLang)}`;
|
|
1103
1122
|
const msg4 = ` ${this.getServerRunningMode("development", "production")}`;
|
|
1104
1123
|
const msg5 = ` ${colors.underline(`http://${host}:${port}`)}`;
|
|
1105
1124
|
console.log(chalk.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
@@ -1110,18 +1129,18 @@ var Utility = class {
|
|
|
1110
1129
|
console.log(chalk.bgGreen.white(msg5.padEnd(61, " ")));
|
|
1111
1130
|
console.log(chalk.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
1112
1131
|
console.log(``);
|
|
1113
|
-
console.log(`${`${
|
|
1114
|
-
console.log(`${`${
|
|
1115
|
-
console.log(`${`${
|
|
1116
|
-
console.log(`${`${
|
|
1132
|
+
console.log(`${`${TranslationLoader10.t("totalMemory", this.localLang)}`} ${colors.cyan(`${colors.bold(`${rss}`)}`)}`);
|
|
1133
|
+
console.log(`${`${TranslationLoader10.t("memoryUsedDuringExecution", this.localLang)}`} ${colors.cyan(`${colors.bold(`${heapUsed}`)}`)}`);
|
|
1134
|
+
console.log(`${`${TranslationLoader10.t("memoryUsedByUser", this.localLang)}`} ${colors.cyan(`${colors.bold(`${user}`)}`)}`);
|
|
1135
|
+
console.log(`${`${TranslationLoader10.t("memoryUsedBySystem", this.localLang)}`} ${colors.cyan(`${colors.bold(`${system}`)}`)}`);
|
|
1117
1136
|
console.log(``);
|
|
1118
1137
|
}
|
|
1119
1138
|
};
|
|
1120
1139
|
|
|
1121
1140
|
// src/core/events/pathModuleVerifier.event.ts
|
|
1122
1141
|
import { resolve } from "path";
|
|
1123
|
-
import { HttpStatusCode as
|
|
1124
|
-
import { TranslationLoader as
|
|
1142
|
+
import { HttpStatusCode as HttpStatusCode3 } from "opticore-http-response";
|
|
1143
|
+
import { TranslationLoader as TranslationLoader11 } from "opticore-translator";
|
|
1125
1144
|
var PathModuleVerifier = class {
|
|
1126
1145
|
log;
|
|
1127
1146
|
localeLanguage;
|
|
@@ -1143,11 +1162,11 @@ var PathModuleVerifier = class {
|
|
|
1143
1162
|
}
|
|
1144
1163
|
if (notLoadedPaths.length > 0) {
|
|
1145
1164
|
this.log.error(
|
|
1146
|
-
|
|
1165
|
+
TranslationLoader11.t("moduleNotLoaded", this.localeLanguage, { notLoadedPaths: notLoadedPaths.join(", ") }),
|
|
1147
1166
|
"",
|
|
1148
1167
|
"",
|
|
1149
1168
|
modulePaths,
|
|
1150
|
-
|
|
1169
|
+
HttpStatusCode3.NOT_ACCEPTABLE
|
|
1151
1170
|
);
|
|
1152
1171
|
throw new Error();
|
|
1153
1172
|
}
|
|
@@ -1168,48 +1187,24 @@ var PathModuleVerifier = class {
|
|
|
1168
1187
|
};
|
|
1169
1188
|
|
|
1170
1189
|
// src/core/config/loaders/localLanguage.loader.ts
|
|
1171
|
-
import
|
|
1190
|
+
import path4 from "path";
|
|
1172
1191
|
import { TranslationLoader as TranslationLoader12 } from "opticore-translator";
|
|
1173
1192
|
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
1193
|
var LocalLanguageLoader = class {
|
|
1199
1194
|
localeLanguage;
|
|
1200
1195
|
environnementPath;
|
|
1201
1196
|
constructor(localeLanguage, environnementPath) {
|
|
1202
1197
|
this.localeLanguage = localeLanguage;
|
|
1203
1198
|
this.environnementPath = environnementPath;
|
|
1204
|
-
translateWebAppCoreLanguageLoader(environnementPath, localeLanguage);
|
|
1205
1199
|
}
|
|
1206
1200
|
load() {
|
|
1207
1201
|
try {
|
|
1208
|
-
const translateMsgJsonFilePath =
|
|
1202
|
+
const translateMsgJsonFilePath = path4.join(process.cwd(), "src", "utils", "translations");
|
|
1209
1203
|
TranslationLoader12.loadTranslations(translateMsgJsonFilePath);
|
|
1210
1204
|
} catch (err) {
|
|
1211
1205
|
SLoggerFileConfiguration(this.environnementPath).error(
|
|
1212
|
-
|
|
1206
|
+
//TranslationLoader.t(err.message, this.localeLanguage),
|
|
1207
|
+
err.message,
|
|
1213
1208
|
err.code,
|
|
1214
1209
|
err.code,
|
|
1215
1210
|
err.stackTrace,
|