opticore-webapp-core 1.0.6 → 1.0.7
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 +67 -63
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +66 -62
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -682,7 +682,20 @@ var optionalArgumentConnectionUtil = import_opticore_env_access2.getEnvVariable.
|
|
|
682
682
|
var import_promises = require("fs/promises");
|
|
683
683
|
var import_opticore_http_response5 = require("opticore-http-response");
|
|
684
684
|
var import_opticore_logger6 = require("opticore-logger");
|
|
685
|
+
var import_opticore_translator7 = require("opticore-translator");
|
|
686
|
+
|
|
687
|
+
// src/core/config/loaders/translateLanguage.loader.ts
|
|
688
|
+
var import_path = __toESM(require("path"), 1);
|
|
689
|
+
var import_module = require("module");
|
|
685
690
|
var import_opticore_translator6 = require("opticore-translator");
|
|
691
|
+
var translateWebAppCoreLanguageLoader = (defaultLocalLang) => {
|
|
692
|
+
const require2 = (0, import_module.createRequire)(importMetaUrl);
|
|
693
|
+
const packagePath = import_path.default.dirname(require2.resolve("opticore-webapp-core"));
|
|
694
|
+
const translateMsgJsonFilePath = import_path.default.join(packagePath, "utils", "translations");
|
|
695
|
+
import_opticore_translator6.TranslationLoader.loadTranslations(translateMsgJsonFilePath, defaultLocalLang);
|
|
696
|
+
};
|
|
697
|
+
|
|
698
|
+
// src/utils/parsing/parsingYaml.utils.ts
|
|
686
699
|
var YamlParsing = class {
|
|
687
700
|
static logger = new import_opticore_logger6.LoggerCore(loggerConfig);
|
|
688
701
|
static async readFile(filePath) {
|
|
@@ -692,13 +705,21 @@ var YamlParsing = class {
|
|
|
692
705
|
} catch (error) {
|
|
693
706
|
this.logger.error(
|
|
694
707
|
error.message,
|
|
695
|
-
|
|
696
|
-
|
|
708
|
+
import_opticore_translator7.TranslationLoader.t("parsingFailed", import_opticore_translator7.CLocal),
|
|
709
|
+
import_opticore_translator7.TranslationLoader.t("readingError", import_opticore_translator7.CLocal),
|
|
697
710
|
error.stack,
|
|
698
711
|
import_opticore_http_response5.HttpStatusCode.NOT_ACCEPTABLE
|
|
699
712
|
);
|
|
700
713
|
}
|
|
701
714
|
}
|
|
715
|
+
/**
|
|
716
|
+
*
|
|
717
|
+
* @param defaultLocalLang
|
|
718
|
+
*/
|
|
719
|
+
static __init(defaultLocalLang) {
|
|
720
|
+
translateWebAppCoreLanguageLoader(defaultLocalLang);
|
|
721
|
+
return this;
|
|
722
|
+
}
|
|
702
723
|
/**
|
|
703
724
|
*
|
|
704
725
|
* @param content
|
|
@@ -724,9 +745,9 @@ var YamlParsing = class {
|
|
|
724
745
|
}
|
|
725
746
|
} else {
|
|
726
747
|
this.logger.error(
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
748
|
+
import_opticore_translator7.TranslationLoader.t("badFormat", import_opticore_translator7.CLocal, { line }),
|
|
749
|
+
import_opticore_translator7.TranslationLoader.t("parsingFailed", import_opticore_translator7.CLocal),
|
|
750
|
+
import_opticore_translator7.TranslationLoader.t("unsupportedFormat", import_opticore_translator7.CLocal),
|
|
730
751
|
content,
|
|
731
752
|
import_opticore_http_response5.HttpStatusCode.NOT_ACCEPTABLE
|
|
732
753
|
);
|
|
@@ -755,13 +776,13 @@ var import_mysql = __toESM(require("mysql"), 1);
|
|
|
755
776
|
var import_opticore_http_response7 = require("opticore-http-response");
|
|
756
777
|
var import_opticore_env_access3 = require("opticore-env-access");
|
|
757
778
|
var import_opticore_logger8 = require("opticore-logger");
|
|
758
|
-
var
|
|
779
|
+
var import_opticore_translator9 = require("opticore-translator");
|
|
759
780
|
|
|
760
781
|
// src/core/errors/databaseConnexion.error.ts
|
|
761
782
|
var import_opticore_http_response6 = require("opticore-http-response");
|
|
762
783
|
var import_opticore_logger7 = require("opticore-logger");
|
|
763
784
|
var import_opticore_catch_exception_error3 = require("opticore-catch-exception-error");
|
|
764
|
-
var
|
|
785
|
+
var import_opticore_translator8 = require("opticore-translator");
|
|
765
786
|
var DbConnexionConfigError = class {
|
|
766
787
|
static logger = new import_opticore_logger7.LoggerCore(loggerConfig);
|
|
767
788
|
/**
|
|
@@ -770,14 +791,14 @@ var DbConnexionConfigError = class {
|
|
|
770
791
|
*/
|
|
771
792
|
static mongoDBAuthenticationFailed(e) {
|
|
772
793
|
const stackTrace = this.traceError(
|
|
773
|
-
|
|
774
|
-
|
|
794
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", import_opticore_translator8.CLocal),
|
|
795
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBAuthentication", import_opticore_translator8.CLocal),
|
|
775
796
|
import_opticore_http_response6.HttpStatusCode.UNAUTHORIZED
|
|
776
797
|
);
|
|
777
798
|
this.logger.error(
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
799
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBAuthenticationError", import_opticore_translator8.CLocal),
|
|
800
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", import_opticore_translator8.CLocal),
|
|
801
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBAuthenticationFailed", import_opticore_translator8.CLocal),
|
|
781
802
|
stackTrace.stack,
|
|
782
803
|
import_opticore_http_response6.HttpStatusCode.UNAUTHORIZED
|
|
783
804
|
);
|
|
@@ -790,14 +811,14 @@ var DbConnexionConfigError = class {
|
|
|
790
811
|
*/
|
|
791
812
|
static mongoDBInvalidUrl(err, dbHost, dbPort) {
|
|
792
813
|
const stackTrace = this.traceError(
|
|
793
|
-
|
|
794
|
-
|
|
814
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", import_opticore_translator8.CLocal),
|
|
815
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBUnableParsingUrl", import_opticore_translator8.CLocal),
|
|
795
816
|
import_opticore_http_response6.HttpStatusCode.BAD_REQUEST
|
|
796
817
|
);
|
|
797
818
|
this.logger.error(
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
819
|
+
import_opticore_translator8.TranslationLoader.t("dbUrlParsingError", import_opticore_translator8.CLocal, { dbHost, dbPort }),
|
|
820
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", import_opticore_translator8.CLocal),
|
|
821
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBUnableParsingUrl", import_opticore_translator8.CLocal),
|
|
801
822
|
stackTrace.stack,
|
|
802
823
|
import_opticore_http_response6.HttpStatusCode.BAD_REQUEST
|
|
803
824
|
);
|
|
@@ -809,14 +830,14 @@ var DbConnexionConfigError = class {
|
|
|
809
830
|
*/
|
|
810
831
|
static mongoDBEaiAgain(err, dbHost) {
|
|
811
832
|
const stackTrace = this.traceError(
|
|
812
|
-
|
|
813
|
-
|
|
833
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", import_opticore_translator8.CLocal),
|
|
834
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBServerSelection", import_opticore_translator8.CLocal),
|
|
814
835
|
import_opticore_http_response6.HttpStatusCode.BAD_REQUEST
|
|
815
836
|
);
|
|
816
837
|
this.logger.error(
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
838
|
+
import_opticore_translator8.TranslationLoader.t("mongoServerError", import_opticore_translator8.CLocal, { dbHost }),
|
|
839
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", import_opticore_translator8.CLocal),
|
|
840
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBServerSelection", import_opticore_translator8.CLocal),
|
|
820
841
|
stackTrace.stack,
|
|
821
842
|
import_opticore_http_response6.HttpStatusCode.BAD_REQUEST
|
|
822
843
|
);
|
|
@@ -828,12 +849,12 @@ var DbConnexionConfigError = class {
|
|
|
828
849
|
static mongoDbGlobalError(err) {
|
|
829
850
|
const stackTrace = this.traceError(
|
|
830
851
|
err.message,
|
|
831
|
-
|
|
852
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", import_opticore_translator8.CLocal),
|
|
832
853
|
import_opticore_http_response6.HttpStatusCode.NOT_ACCEPTABLE
|
|
833
854
|
);
|
|
834
855
|
this.logger.error(
|
|
835
|
-
|
|
836
|
-
|
|
856
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnection", import_opticore_translator8.CLocal),
|
|
857
|
+
import_opticore_translator8.TranslationLoader.t("mongoDBConnectionError", import_opticore_translator8.CLocal),
|
|
837
858
|
stackTrace.stack,
|
|
838
859
|
err.message,
|
|
839
860
|
import_opticore_http_response6.HttpStatusCode.NOT_ACCEPTABLE
|
|
@@ -881,8 +902,8 @@ var DatabaseConnectionConfig = class {
|
|
|
881
902
|
try {
|
|
882
903
|
await SCheckerMongoDatabaseConnection(url, this.env.get("dataBaseUser"), this.env.get("dataBasePassword"), this.env.get("dataBaseName"));
|
|
883
904
|
this.logger.success(
|
|
884
|
-
|
|
885
|
-
|
|
905
|
+
import_opticore_translator9.TranslationLoader.t("mongoDBConnectionChecker", import_opticore_translator9.CLocal),
|
|
906
|
+
import_opticore_translator9.TranslationLoader.t("mongoConnectionSuccess", import_opticore_translator9.CLocal)
|
|
886
907
|
);
|
|
887
908
|
console.log("");
|
|
888
909
|
} catch (e) {
|
|
@@ -932,11 +953,11 @@ var DatabaseConnectionConfig = class {
|
|
|
932
953
|
types,
|
|
933
954
|
options
|
|
934
955
|
);
|
|
935
|
-
this.logger.success(
|
|
956
|
+
this.logger.success(import_opticore_translator9.TranslationLoader.t("postgresDBConnectionChecker", import_opticore_translator9.CLocal), import_opticore_translator9.TranslationLoader.t("postgresConnectionSuccess", import_opticore_translator9.CLocal));
|
|
936
957
|
console.log("");
|
|
937
958
|
} catch (err) {
|
|
938
959
|
const stackTrace = this.traceError(
|
|
939
|
-
|
|
960
|
+
import_opticore_translator9.TranslationLoader.t(`${err.message}`, import_opticore_translator9.CLocal),
|
|
940
961
|
"PostgresConnectionError",
|
|
941
962
|
import_opticore_http_response7.HttpStatusCode.NOT_ACCEPTABLE
|
|
942
963
|
);
|
|
@@ -976,9 +997,9 @@ var MPostgresCheckerDatabase = (optionalArgumentConnection) => {
|
|
|
976
997
|
var import_node_process = __toESM(require("process"), 1);
|
|
977
998
|
var import_chalk = __toESM(require("chalk"), 1);
|
|
978
999
|
var import_ansi_colors = __toESM(require("ansi-colors"), 1);
|
|
979
|
-
var
|
|
1000
|
+
var import_path2 = __toESM(require("path"), 1);
|
|
980
1001
|
var import_fs = __toESM(require("fs"), 1);
|
|
981
|
-
var
|
|
1002
|
+
var import_opticore_translator10 = require("opticore-translator");
|
|
982
1003
|
var Utility = class {
|
|
983
1004
|
/**
|
|
984
1005
|
*
|
|
@@ -1039,7 +1060,7 @@ var Utility = class {
|
|
|
1039
1060
|
const endTime = import_node_process.default.hrtime(startTime);
|
|
1040
1061
|
const executionTime = (endTime[0] * 1e9 + endTime[1]) / 1e6;
|
|
1041
1062
|
return {
|
|
1042
|
-
"projectPath":
|
|
1063
|
+
"projectPath": import_path2.default.join(import_node_process.default.cwd()),
|
|
1043
1064
|
"startingTime": `${executionTime.toFixed(5)} ms`
|
|
1044
1065
|
};
|
|
1045
1066
|
}
|
|
@@ -1049,7 +1070,7 @@ var Utility = class {
|
|
|
1049
1070
|
* @private
|
|
1050
1071
|
*/
|
|
1051
1072
|
getEnvFileLoading(filePath) {
|
|
1052
|
-
const fullPath =
|
|
1073
|
+
const fullPath = import_path2.default.resolve(import_node_process.default.cwd(), filePath);
|
|
1053
1074
|
if (import_fs.default.existsSync(fullPath)) {
|
|
1054
1075
|
const env = import_fs.default.readFileSync(fullPath, "utf-8");
|
|
1055
1076
|
const lines = env.split("\n");
|
|
@@ -1071,19 +1092,19 @@ var Utility = class {
|
|
|
1071
1092
|
this.getEnvFileLoading(".env");
|
|
1072
1093
|
const isDevelopment = import_node_process.default.env.NODE_ENV === "development";
|
|
1073
1094
|
if (isDevelopment) {
|
|
1074
|
-
return `${
|
|
1095
|
+
return `${import_opticore_translator10.TranslationLoader.t("serverRunning", import_opticore_translator10.CLocal)} ${import_ansi_colors.default.bgBlue(`${import_ansi_colors.default.bold(`${development}`)}`)} mode`;
|
|
1075
1096
|
} else {
|
|
1076
|
-
return `${
|
|
1097
|
+
return `${import_opticore_translator10.TranslationLoader.t("serverRunning", import_opticore_translator10.CLocal)} ${import_ansi_colors.default.bgBlue(`${import_ansi_colors.default.bold(`${production}`)}`)} mode`;
|
|
1077
1098
|
}
|
|
1078
1099
|
}
|
|
1079
1100
|
infoServer(nodeVersion, startingTime, host, port, rss, heapUsed, user, system) {
|
|
1080
1101
|
const paddingLength = 52;
|
|
1081
1102
|
const msg0 = " ".padEnd(paddingLength, " ");
|
|
1082
|
-
const msg1 = ` ${
|
|
1103
|
+
const msg1 = ` ${import_opticore_translator10.TranslationLoader.t("okServerListening", import_opticore_translator10.CLocal)}`;
|
|
1083
1104
|
const msg2Value = `${import_ansi_colors.default.bgBlue(`${import_ansi_colors.default.bold(`${nodeVersion}`)}`)}`;
|
|
1084
|
-
const msg2 = ` ${
|
|
1105
|
+
const msg2 = ` ${import_opticore_translator10.TranslationLoader.t("webServerUseNodeVersion", import_opticore_translator10.CLocal)}`;
|
|
1085
1106
|
const msg3Value = `${import_ansi_colors.default.bgBlue(`${import_ansi_colors.default.bold(`${startingTime}`)}`)}`;
|
|
1086
|
-
const msg3 = ` ${
|
|
1107
|
+
const msg3 = ` ${import_opticore_translator10.TranslationLoader.t("startupTime", import_opticore_translator10.CLocal)}`;
|
|
1087
1108
|
const msg4 = ` ${this.getServerRunningMode("development", "production")}`;
|
|
1088
1109
|
const msg5 = ` ${import_ansi_colors.default.underline(`http://${host}:${port}`)}`;
|
|
1089
1110
|
console.log(import_chalk.default.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
@@ -1094,19 +1115,19 @@ var Utility = class {
|
|
|
1094
1115
|
console.log(import_chalk.default.bgGreen.white(msg5.padEnd(61, " ")));
|
|
1095
1116
|
console.log(import_chalk.default.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
1096
1117
|
console.log(``);
|
|
1097
|
-
console.log(`${`${
|
|
1098
|
-
console.log(`${`${
|
|
1099
|
-
console.log(`${`${
|
|
1100
|
-
console.log(`${`${
|
|
1118
|
+
console.log(`${`${import_opticore_translator10.TranslationLoader.t("totalMemory", import_opticore_translator10.CLocal)}`} ${import_ansi_colors.default.cyan(`${import_ansi_colors.default.bold(`${rss}`)}`)}`);
|
|
1119
|
+
console.log(`${`${import_opticore_translator10.TranslationLoader.t("memoryUsedDuringExecution", import_opticore_translator10.CLocal)}`} ${import_ansi_colors.default.cyan(`${import_ansi_colors.default.bold(`${heapUsed}`)}`)}`);
|
|
1120
|
+
console.log(`${`${import_opticore_translator10.TranslationLoader.t("memoryUsedByUser", import_opticore_translator10.CLocal)}`} ${import_ansi_colors.default.cyan(`${import_ansi_colors.default.bold(`${user}`)}`)}`);
|
|
1121
|
+
console.log(`${`${import_opticore_translator10.TranslationLoader.t("memoryUsedBySystem", import_opticore_translator10.CLocal)}`} ${import_ansi_colors.default.cyan(`${import_ansi_colors.default.bold(`${system}`)}`)}`);
|
|
1101
1122
|
console.log(``);
|
|
1102
1123
|
}
|
|
1103
1124
|
};
|
|
1104
1125
|
|
|
1105
1126
|
// src/core/events/pathModuleVerifier.event.ts
|
|
1106
|
-
var
|
|
1127
|
+
var import_path3 = require("path");
|
|
1107
1128
|
var import_opticore_logger9 = require("opticore-logger");
|
|
1108
1129
|
var import_opticore_http_response8 = require("opticore-http-response");
|
|
1109
|
-
var
|
|
1130
|
+
var import_opticore_translator11 = require("opticore-translator");
|
|
1110
1131
|
var PathModuleVerifier = class {
|
|
1111
1132
|
static log = new import_opticore_logger9.LoggerCore(loggerConfig);
|
|
1112
1133
|
/**
|
|
@@ -1123,7 +1144,7 @@ var PathModuleVerifier = class {
|
|
|
1123
1144
|
}
|
|
1124
1145
|
if (notLoadedPaths.length > 0) {
|
|
1125
1146
|
this.log.error(
|
|
1126
|
-
|
|
1147
|
+
import_opticore_translator11.TranslationLoader.t("moduleNotLoaded", import_opticore_translator11.CLocal, { notLoadedPaths: notLoadedPaths.join(", ") }),
|
|
1127
1148
|
"",
|
|
1128
1149
|
"",
|
|
1129
1150
|
modulePaths,
|
|
@@ -1139,30 +1160,13 @@ var PathModuleVerifier = class {
|
|
|
1139
1160
|
*/
|
|
1140
1161
|
static isModulePathLoaded(modulePath) {
|
|
1141
1162
|
try {
|
|
1142
|
-
const resolvedPath = (0,
|
|
1163
|
+
const resolvedPath = (0, import_path3.resolve)(modulePath);
|
|
1143
1164
|
return require.cache[resolvedPath] !== void 0;
|
|
1144
1165
|
} catch {
|
|
1145
1166
|
return false;
|
|
1146
1167
|
}
|
|
1147
1168
|
}
|
|
1148
1169
|
};
|
|
1149
|
-
|
|
1150
|
-
// src/core/config/loaders/translateLanguage.loader.ts
|
|
1151
|
-
var import_path3 = __toESM(require("path"), 1);
|
|
1152
|
-
var import_module = require("module");
|
|
1153
|
-
var import_opticore_translator11 = require("opticore-translator");
|
|
1154
|
-
var import_opticore_env_access4 = require("opticore-env-access");
|
|
1155
|
-
var translateWebAppCoreLanguageLoader = () => {
|
|
1156
|
-
const require2 = (0, import_module.createRequire)(importMetaUrl);
|
|
1157
|
-
const packagePath = import_path3.default.dirname(require2.resolve("opticore-webapp-core"));
|
|
1158
|
-
const translateMsgJsonFilePath = import_path3.default.join(packagePath, "utils", "translations");
|
|
1159
|
-
import_opticore_translator11.TranslationLoader.loadTranslations(translateMsgJsonFilePath, import_opticore_env_access4.getEnvVariable.defaultLocal);
|
|
1160
|
-
};
|
|
1161
|
-
|
|
1162
|
-
// src/index.ts
|
|
1163
|
-
(() => {
|
|
1164
|
-
translateWebAppCoreLanguageLoader();
|
|
1165
|
-
})();
|
|
1166
1170
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1167
1171
|
0 && (module.exports = {
|
|
1168
1172
|
CLogLevel,
|
package/dist/index.d.cts
CHANGED
|
@@ -170,6 +170,11 @@ declare class RSAKeyEncryption {
|
|
|
170
170
|
declare class YamlParsing {
|
|
171
171
|
private static logger;
|
|
172
172
|
static readFile(filePath: string): Promise<void>;
|
|
173
|
+
/**
|
|
174
|
+
*
|
|
175
|
+
* @param defaultLocalLang
|
|
176
|
+
*/
|
|
177
|
+
static __init(defaultLocalLang: string): typeof YamlParsing;
|
|
173
178
|
/**
|
|
174
179
|
*
|
|
175
180
|
* @param content
|
package/dist/index.d.ts
CHANGED
|
@@ -170,6 +170,11 @@ declare class RSAKeyEncryption {
|
|
|
170
170
|
declare class YamlParsing {
|
|
171
171
|
private static logger;
|
|
172
172
|
static readFile(filePath: string): Promise<void>;
|
|
173
|
+
/**
|
|
174
|
+
*
|
|
175
|
+
* @param defaultLocalLang
|
|
176
|
+
*/
|
|
177
|
+
static __init(defaultLocalLang: string): typeof YamlParsing;
|
|
173
178
|
/**
|
|
174
179
|
*
|
|
175
180
|
* @param content
|
package/dist/index.js
CHANGED
|
@@ -631,7 +631,20 @@ var optionalArgumentConnectionUtil = getEnvVariable2.argumentsDatabaseConnection
|
|
|
631
631
|
import { readFile } from "fs/promises";
|
|
632
632
|
import { HttpStatusCode } from "opticore-http-response";
|
|
633
633
|
import { LoggerCore as LoggerCore6 } from "opticore-logger";
|
|
634
|
-
import { CLocal as CLocal6, TranslationLoader as
|
|
634
|
+
import { CLocal as CLocal6, TranslationLoader as TranslationLoader7 } from "opticore-translator";
|
|
635
|
+
|
|
636
|
+
// src/core/config/loaders/translateLanguage.loader.ts
|
|
637
|
+
import path from "path";
|
|
638
|
+
import { createRequire } from "module";
|
|
639
|
+
import { TranslationLoader as TranslationLoader6 } from "opticore-translator";
|
|
640
|
+
var translateWebAppCoreLanguageLoader = (defaultLocalLang) => {
|
|
641
|
+
const require2 = createRequire(import.meta.url);
|
|
642
|
+
const packagePath = path.dirname(require2.resolve("opticore-webapp-core"));
|
|
643
|
+
const translateMsgJsonFilePath = path.join(packagePath, "utils", "translations");
|
|
644
|
+
TranslationLoader6.loadTranslations(translateMsgJsonFilePath, defaultLocalLang);
|
|
645
|
+
};
|
|
646
|
+
|
|
647
|
+
// src/utils/parsing/parsingYaml.utils.ts
|
|
635
648
|
var YamlParsing = class {
|
|
636
649
|
static logger = new LoggerCore6(loggerConfig);
|
|
637
650
|
static async readFile(filePath) {
|
|
@@ -641,13 +654,21 @@ var YamlParsing = class {
|
|
|
641
654
|
} catch (error) {
|
|
642
655
|
this.logger.error(
|
|
643
656
|
error.message,
|
|
644
|
-
|
|
645
|
-
|
|
657
|
+
TranslationLoader7.t("parsingFailed", CLocal6),
|
|
658
|
+
TranslationLoader7.t("readingError", CLocal6),
|
|
646
659
|
error.stack,
|
|
647
660
|
HttpStatusCode.NOT_ACCEPTABLE
|
|
648
661
|
);
|
|
649
662
|
}
|
|
650
663
|
}
|
|
664
|
+
/**
|
|
665
|
+
*
|
|
666
|
+
* @param defaultLocalLang
|
|
667
|
+
*/
|
|
668
|
+
static __init(defaultLocalLang) {
|
|
669
|
+
translateWebAppCoreLanguageLoader(defaultLocalLang);
|
|
670
|
+
return this;
|
|
671
|
+
}
|
|
651
672
|
/**
|
|
652
673
|
*
|
|
653
674
|
* @param content
|
|
@@ -673,9 +694,9 @@ var YamlParsing = class {
|
|
|
673
694
|
}
|
|
674
695
|
} else {
|
|
675
696
|
this.logger.error(
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
697
|
+
TranslationLoader7.t("badFormat", CLocal6, { line }),
|
|
698
|
+
TranslationLoader7.t("parsingFailed", CLocal6),
|
|
699
|
+
TranslationLoader7.t("unsupportedFormat", CLocal6),
|
|
679
700
|
content,
|
|
680
701
|
HttpStatusCode.NOT_ACCEPTABLE
|
|
681
702
|
);
|
|
@@ -704,13 +725,13 @@ import mySQL from "mysql";
|
|
|
704
725
|
import { HttpStatusCode as status6 } from "opticore-http-response";
|
|
705
726
|
import { getEnvVariable as getEnvVariable3 } from "opticore-env-access";
|
|
706
727
|
import { LoggerCore as LoggerCore8 } from "opticore-logger";
|
|
707
|
-
import { CLocal as CLocal8, TranslationLoader as
|
|
728
|
+
import { CLocal as CLocal8, TranslationLoader as TranslationLoader9 } from "opticore-translator";
|
|
708
729
|
|
|
709
730
|
// src/core/errors/databaseConnexion.error.ts
|
|
710
731
|
import { HttpStatusCode as status5 } from "opticore-http-response";
|
|
711
732
|
import { LoggerCore as LoggerCore7 } from "opticore-logger";
|
|
712
733
|
import { StackTraceError as StackTraceError2 } from "opticore-catch-exception-error";
|
|
713
|
-
import { CLocal as CLocal7, TranslationLoader as
|
|
734
|
+
import { CLocal as CLocal7, TranslationLoader as TranslationLoader8 } from "opticore-translator";
|
|
714
735
|
var DbConnexionConfigError = class {
|
|
715
736
|
static logger = new LoggerCore7(loggerConfig);
|
|
716
737
|
/**
|
|
@@ -719,14 +740,14 @@ var DbConnexionConfigError = class {
|
|
|
719
740
|
*/
|
|
720
741
|
static mongoDBAuthenticationFailed(e) {
|
|
721
742
|
const stackTrace = this.traceError(
|
|
722
|
-
|
|
723
|
-
|
|
743
|
+
TranslationLoader8.t("mongoDBConnection", CLocal7),
|
|
744
|
+
TranslationLoader8.t("mongoDBAuthentication", CLocal7),
|
|
724
745
|
status5.UNAUTHORIZED
|
|
725
746
|
);
|
|
726
747
|
this.logger.error(
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
748
|
+
TranslationLoader8.t("mongoDBAuthenticationError", CLocal7),
|
|
749
|
+
TranslationLoader8.t("mongoDBConnection", CLocal7),
|
|
750
|
+
TranslationLoader8.t("mongoDBAuthenticationFailed", CLocal7),
|
|
730
751
|
stackTrace.stack,
|
|
731
752
|
status5.UNAUTHORIZED
|
|
732
753
|
);
|
|
@@ -739,14 +760,14 @@ var DbConnexionConfigError = class {
|
|
|
739
760
|
*/
|
|
740
761
|
static mongoDBInvalidUrl(err, dbHost, dbPort) {
|
|
741
762
|
const stackTrace = this.traceError(
|
|
742
|
-
|
|
743
|
-
|
|
763
|
+
TranslationLoader8.t("mongoDBConnection", CLocal7),
|
|
764
|
+
TranslationLoader8.t("mongoDBUnableParsingUrl", CLocal7),
|
|
744
765
|
status5.BAD_REQUEST
|
|
745
766
|
);
|
|
746
767
|
this.logger.error(
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
768
|
+
TranslationLoader8.t("dbUrlParsingError", CLocal7, { dbHost, dbPort }),
|
|
769
|
+
TranslationLoader8.t("mongoDBConnection", CLocal7),
|
|
770
|
+
TranslationLoader8.t("mongoDBUnableParsingUrl", CLocal7),
|
|
750
771
|
stackTrace.stack,
|
|
751
772
|
status5.BAD_REQUEST
|
|
752
773
|
);
|
|
@@ -758,14 +779,14 @@ var DbConnexionConfigError = class {
|
|
|
758
779
|
*/
|
|
759
780
|
static mongoDBEaiAgain(err, dbHost) {
|
|
760
781
|
const stackTrace = this.traceError(
|
|
761
|
-
|
|
762
|
-
|
|
782
|
+
TranslationLoader8.t("mongoDBConnection", CLocal7),
|
|
783
|
+
TranslationLoader8.t("mongoDBServerSelection", CLocal7),
|
|
763
784
|
status5.BAD_REQUEST
|
|
764
785
|
);
|
|
765
786
|
this.logger.error(
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
787
|
+
TranslationLoader8.t("mongoServerError", CLocal7, { dbHost }),
|
|
788
|
+
TranslationLoader8.t("mongoDBConnection", CLocal7),
|
|
789
|
+
TranslationLoader8.t("mongoDBServerSelection", CLocal7),
|
|
769
790
|
stackTrace.stack,
|
|
770
791
|
status5.BAD_REQUEST
|
|
771
792
|
);
|
|
@@ -777,12 +798,12 @@ var DbConnexionConfigError = class {
|
|
|
777
798
|
static mongoDbGlobalError(err) {
|
|
778
799
|
const stackTrace = this.traceError(
|
|
779
800
|
err.message,
|
|
780
|
-
|
|
801
|
+
TranslationLoader8.t("mongoDBConnection", CLocal7),
|
|
781
802
|
status5.NOT_ACCEPTABLE
|
|
782
803
|
);
|
|
783
804
|
this.logger.error(
|
|
784
|
-
|
|
785
|
-
|
|
805
|
+
TranslationLoader8.t("mongoDBConnection", CLocal7),
|
|
806
|
+
TranslationLoader8.t("mongoDBConnectionError", CLocal7),
|
|
786
807
|
stackTrace.stack,
|
|
787
808
|
err.message,
|
|
788
809
|
status5.NOT_ACCEPTABLE
|
|
@@ -830,8 +851,8 @@ var DatabaseConnectionConfig = class {
|
|
|
830
851
|
try {
|
|
831
852
|
await SCheckerMongoDatabaseConnection(url, this.env.get("dataBaseUser"), this.env.get("dataBasePassword"), this.env.get("dataBaseName"));
|
|
832
853
|
this.logger.success(
|
|
833
|
-
|
|
834
|
-
|
|
854
|
+
TranslationLoader9.t("mongoDBConnectionChecker", CLocal8),
|
|
855
|
+
TranslationLoader9.t("mongoConnectionSuccess", CLocal8)
|
|
835
856
|
);
|
|
836
857
|
console.log("");
|
|
837
858
|
} catch (e) {
|
|
@@ -881,11 +902,11 @@ var DatabaseConnectionConfig = class {
|
|
|
881
902
|
types,
|
|
882
903
|
options
|
|
883
904
|
);
|
|
884
|
-
this.logger.success(
|
|
905
|
+
this.logger.success(TranslationLoader9.t("postgresDBConnectionChecker", CLocal8), TranslationLoader9.t("postgresConnectionSuccess", CLocal8));
|
|
885
906
|
console.log("");
|
|
886
907
|
} catch (err) {
|
|
887
908
|
const stackTrace = this.traceError(
|
|
888
|
-
|
|
909
|
+
TranslationLoader9.t(`${err.message}`, CLocal8),
|
|
889
910
|
"PostgresConnectionError",
|
|
890
911
|
status6.NOT_ACCEPTABLE
|
|
891
912
|
);
|
|
@@ -925,9 +946,9 @@ var MPostgresCheckerDatabase = (optionalArgumentConnection) => {
|
|
|
925
946
|
import process from "node:process";
|
|
926
947
|
import chalk from "chalk";
|
|
927
948
|
import colors from "ansi-colors";
|
|
928
|
-
import
|
|
949
|
+
import path2 from "path";
|
|
929
950
|
import fs from "fs";
|
|
930
|
-
import { CLocal as CLocal9, TranslationLoader as
|
|
951
|
+
import { CLocal as CLocal9, TranslationLoader as TranslationLoader10 } from "opticore-translator";
|
|
931
952
|
var Utility = class {
|
|
932
953
|
/**
|
|
933
954
|
*
|
|
@@ -988,7 +1009,7 @@ var Utility = class {
|
|
|
988
1009
|
const endTime = process.hrtime(startTime);
|
|
989
1010
|
const executionTime = (endTime[0] * 1e9 + endTime[1]) / 1e6;
|
|
990
1011
|
return {
|
|
991
|
-
"projectPath":
|
|
1012
|
+
"projectPath": path2.join(process.cwd()),
|
|
992
1013
|
"startingTime": `${executionTime.toFixed(5)} ms`
|
|
993
1014
|
};
|
|
994
1015
|
}
|
|
@@ -998,7 +1019,7 @@ var Utility = class {
|
|
|
998
1019
|
* @private
|
|
999
1020
|
*/
|
|
1000
1021
|
getEnvFileLoading(filePath) {
|
|
1001
|
-
const fullPath =
|
|
1022
|
+
const fullPath = path2.resolve(process.cwd(), filePath);
|
|
1002
1023
|
if (fs.existsSync(fullPath)) {
|
|
1003
1024
|
const env = fs.readFileSync(fullPath, "utf-8");
|
|
1004
1025
|
const lines = env.split("\n");
|
|
@@ -1020,19 +1041,19 @@ var Utility = class {
|
|
|
1020
1041
|
this.getEnvFileLoading(".env");
|
|
1021
1042
|
const isDevelopment = process.env.NODE_ENV === "development";
|
|
1022
1043
|
if (isDevelopment) {
|
|
1023
|
-
return `${
|
|
1044
|
+
return `${TranslationLoader10.t("serverRunning", CLocal9)} ${colors.bgBlue(`${colors.bold(`${development}`)}`)} mode`;
|
|
1024
1045
|
} else {
|
|
1025
|
-
return `${
|
|
1046
|
+
return `${TranslationLoader10.t("serverRunning", CLocal9)} ${colors.bgBlue(`${colors.bold(`${production}`)}`)} mode`;
|
|
1026
1047
|
}
|
|
1027
1048
|
}
|
|
1028
1049
|
infoServer(nodeVersion, startingTime, host, port, rss, heapUsed, user, system) {
|
|
1029
1050
|
const paddingLength = 52;
|
|
1030
1051
|
const msg0 = " ".padEnd(paddingLength, " ");
|
|
1031
|
-
const msg1 = ` ${
|
|
1052
|
+
const msg1 = ` ${TranslationLoader10.t("okServerListening", CLocal9)}`;
|
|
1032
1053
|
const msg2Value = `${colors.bgBlue(`${colors.bold(`${nodeVersion}`)}`)}`;
|
|
1033
|
-
const msg2 = ` ${
|
|
1054
|
+
const msg2 = ` ${TranslationLoader10.t("webServerUseNodeVersion", CLocal9)}`;
|
|
1034
1055
|
const msg3Value = `${colors.bgBlue(`${colors.bold(`${startingTime}`)}`)}`;
|
|
1035
|
-
const msg3 = ` ${
|
|
1056
|
+
const msg3 = ` ${TranslationLoader10.t("startupTime", CLocal9)}`;
|
|
1036
1057
|
const msg4 = ` ${this.getServerRunningMode("development", "production")}`;
|
|
1037
1058
|
const msg5 = ` ${colors.underline(`http://${host}:${port}`)}`;
|
|
1038
1059
|
console.log(chalk.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
@@ -1043,10 +1064,10 @@ var Utility = class {
|
|
|
1043
1064
|
console.log(chalk.bgGreen.white(msg5.padEnd(61, " ")));
|
|
1044
1065
|
console.log(chalk.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
1045
1066
|
console.log(``);
|
|
1046
|
-
console.log(`${`${
|
|
1047
|
-
console.log(`${`${
|
|
1048
|
-
console.log(`${`${
|
|
1049
|
-
console.log(`${`${
|
|
1067
|
+
console.log(`${`${TranslationLoader10.t("totalMemory", CLocal9)}`} ${colors.cyan(`${colors.bold(`${rss}`)}`)}`);
|
|
1068
|
+
console.log(`${`${TranslationLoader10.t("memoryUsedDuringExecution", CLocal9)}`} ${colors.cyan(`${colors.bold(`${heapUsed}`)}`)}`);
|
|
1069
|
+
console.log(`${`${TranslationLoader10.t("memoryUsedByUser", CLocal9)}`} ${colors.cyan(`${colors.bold(`${user}`)}`)}`);
|
|
1070
|
+
console.log(`${`${TranslationLoader10.t("memoryUsedBySystem", CLocal9)}`} ${colors.cyan(`${colors.bold(`${system}`)}`)}`);
|
|
1050
1071
|
console.log(``);
|
|
1051
1072
|
}
|
|
1052
1073
|
};
|
|
@@ -1055,7 +1076,7 @@ var Utility = class {
|
|
|
1055
1076
|
import { resolve } from "path";
|
|
1056
1077
|
import { LoggerCore as LoggerCore9 } from "opticore-logger";
|
|
1057
1078
|
import { HttpStatusCode as HttpStatusCode2 } from "opticore-http-response";
|
|
1058
|
-
import { CLocal as CLocal10, TranslationLoader as
|
|
1079
|
+
import { CLocal as CLocal10, TranslationLoader as TranslationLoader11 } from "opticore-translator";
|
|
1059
1080
|
var PathModuleVerifier = class {
|
|
1060
1081
|
static log = new LoggerCore9(loggerConfig);
|
|
1061
1082
|
/**
|
|
@@ -1072,7 +1093,7 @@ var PathModuleVerifier = class {
|
|
|
1072
1093
|
}
|
|
1073
1094
|
if (notLoadedPaths.length > 0) {
|
|
1074
1095
|
this.log.error(
|
|
1075
|
-
|
|
1096
|
+
TranslationLoader11.t("moduleNotLoaded", CLocal10, { notLoadedPaths: notLoadedPaths.join(", ") }),
|
|
1076
1097
|
"",
|
|
1077
1098
|
"",
|
|
1078
1099
|
modulePaths,
|
|
@@ -1095,23 +1116,6 @@ var PathModuleVerifier = class {
|
|
|
1095
1116
|
}
|
|
1096
1117
|
}
|
|
1097
1118
|
};
|
|
1098
|
-
|
|
1099
|
-
// src/core/config/loaders/translateLanguage.loader.ts
|
|
1100
|
-
import path2 from "path";
|
|
1101
|
-
import { createRequire } from "module";
|
|
1102
|
-
import { TranslationLoader as TranslationLoader11 } from "opticore-translator";
|
|
1103
|
-
import { getEnvVariable as getEnvVariable4 } from "opticore-env-access";
|
|
1104
|
-
var translateWebAppCoreLanguageLoader = () => {
|
|
1105
|
-
const require2 = createRequire(import.meta.url);
|
|
1106
|
-
const packagePath = path2.dirname(require2.resolve("opticore-webapp-core"));
|
|
1107
|
-
const translateMsgJsonFilePath = path2.join(packagePath, "utils", "translations");
|
|
1108
|
-
TranslationLoader11.loadTranslations(translateMsgJsonFilePath, getEnvVariable4.defaultLocal);
|
|
1109
|
-
};
|
|
1110
|
-
|
|
1111
|
-
// src/index.ts
|
|
1112
|
-
(() => {
|
|
1113
|
-
translateWebAppCoreLanguageLoader();
|
|
1114
|
-
})();
|
|
1115
1119
|
export {
|
|
1116
1120
|
CLogLevel,
|
|
1117
1121
|
CSignRSAKeyComponent,
|