opticore-webapp-core 1.0.15 → 1.0.17
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 +35 -12
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +45 -23
- 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,
|
|
@@ -1011,18 +1012,8 @@ var DatabaseConnectionConfig = class {
|
|
|
1011
1012
|
);
|
|
1012
1013
|
console.log("");
|
|
1013
1014
|
} catch (err) {
|
|
1014
|
-
const stackTrace = this.traceError(
|
|
1015
|
-
|
|
1016
|
-
"PostgresConnectionError",
|
|
1017
|
-
import_opticore_http_response8.HttpStatusCode.NOT_ACCEPTABLE
|
|
1018
|
-
);
|
|
1019
|
-
this.logger.error(
|
|
1020
|
-
err.message,
|
|
1021
|
-
"PostgresConnectionError",
|
|
1022
|
-
"Postgres connection error",
|
|
1023
|
-
stackTrace.stack,
|
|
1024
|
-
import_opticore_http_response8.HttpStatusCode.NOT_ACCEPTABLE
|
|
1025
|
-
);
|
|
1015
|
+
const stackTrace = this.traceError(import_opticore_translator9.TranslationLoader.t(`${err.message}`, this.localeLanguage, loggerConfig), "PostgresConnectionError", import_opticore_http_response8.HttpStatusCode.NOT_ACCEPTABLE);
|
|
1016
|
+
this.logger.error(err.message, "PostgresConnectionError", "Postgres connection error", stackTrace.stack, import_opticore_http_response8.HttpStatusCode.NOT_ACCEPTABLE);
|
|
1026
1017
|
}
|
|
1027
1018
|
}
|
|
1028
1019
|
traceError(props, name, status7) {
|
|
@@ -1242,11 +1233,43 @@ var PathModuleVerifier = class {
|
|
|
1242
1233
|
}
|
|
1243
1234
|
}
|
|
1244
1235
|
};
|
|
1236
|
+
|
|
1237
|
+
// src/core/config/loaders/localLanguage.loader.ts
|
|
1238
|
+
var import_path4 = __toESM(require("path"), 1);
|
|
1239
|
+
var import_opticore_translator12 = require("opticore-translator");
|
|
1240
|
+
var import_opticore_http_response10 = require("opticore-http-response");
|
|
1241
|
+
var LocalLanguageLoader = class {
|
|
1242
|
+
localeLanguage;
|
|
1243
|
+
environnementPath;
|
|
1244
|
+
constructor(localeLanguage, environnementPath) {
|
|
1245
|
+
this.localeLanguage = localeLanguage;
|
|
1246
|
+
this.environnementPath = environnementPath;
|
|
1247
|
+
}
|
|
1248
|
+
load() {
|
|
1249
|
+
try {
|
|
1250
|
+
const translateMsgJsonFilePath = this.absolutPath();
|
|
1251
|
+
import_opticore_translator12.TranslationLoader.loadTranslations(translateMsgJsonFilePath);
|
|
1252
|
+
} catch (err) {
|
|
1253
|
+
SLoggerFileConfiguration(this.environnementPath).error(
|
|
1254
|
+
//TranslationLoader.t(err.message, this.localeLanguage),
|
|
1255
|
+
err.message,
|
|
1256
|
+
err.code,
|
|
1257
|
+
err.code,
|
|
1258
|
+
err.stackTrace,
|
|
1259
|
+
import_opticore_http_response10.HttpStatusCode.INTERNAL_SERVER_ERROR
|
|
1260
|
+
);
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
absolutPath() {
|
|
1264
|
+
return import_path4.default.join(process.cwd(), "src", "utils", "translations");
|
|
1265
|
+
}
|
|
1266
|
+
};
|
|
1245
1267
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1246
1268
|
0 && (module.exports = {
|
|
1247
1269
|
CLogLevel,
|
|
1248
1270
|
CSignRSAKeyComponent,
|
|
1249
1271
|
Environment,
|
|
1272
|
+
LocalLanguageLoader,
|
|
1250
1273
|
MMongoCheckerDatabase,
|
|
1251
1274
|
MMySqlCheckerDatabase,
|
|
1252
1275
|
MPostgresCheckerDatabase,
|
package/dist/index.d.cts
CHANGED
|
@@ -385,6 +385,14 @@ 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
|
+
absolutPath(): string;
|
|
394
|
+
}
|
|
395
|
+
|
|
388
396
|
interface IBodyParserOptions {
|
|
389
397
|
type: string;
|
|
390
398
|
}
|
|
@@ -463,4 +471,4 @@ declare function TTextBodyParser(options: IBodyParserOptions, localLanguage: str
|
|
|
463
471
|
*/
|
|
464
472
|
declare function TUrlencodedBodyParser(options: IBodyParserOptions, localLanguage: string, environnementPath: any): void;
|
|
465
473
|
|
|
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 };
|
|
474
|
+
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,14 @@ 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
|
+
absolutPath(): string;
|
|
394
|
+
}
|
|
395
|
+
|
|
388
396
|
interface IBodyParserOptions {
|
|
389
397
|
type: string;
|
|
390
398
|
}
|
|
@@ -463,4 +471,4 @@ declare function TTextBodyParser(options: IBodyParserOptions, localLanguage: str
|
|
|
463
471
|
*/
|
|
464
472
|
declare function TUrlencodedBodyParser(options: IBodyParserOptions, localLanguage: string, environnementPath: any): void;
|
|
465
473
|
|
|
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 };
|
|
474
|
+
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
|
@@ -960,18 +960,8 @@ var DatabaseConnectionConfig = class {
|
|
|
960
960
|
);
|
|
961
961
|
console.log("");
|
|
962
962
|
} catch (err) {
|
|
963
|
-
const stackTrace = this.traceError(
|
|
964
|
-
|
|
965
|
-
"PostgresConnectionError",
|
|
966
|
-
status6.NOT_ACCEPTABLE
|
|
967
|
-
);
|
|
968
|
-
this.logger.error(
|
|
969
|
-
err.message,
|
|
970
|
-
"PostgresConnectionError",
|
|
971
|
-
"Postgres connection error",
|
|
972
|
-
stackTrace.stack,
|
|
973
|
-
status6.NOT_ACCEPTABLE
|
|
974
|
-
);
|
|
963
|
+
const stackTrace = this.traceError(TranslationLoader9.t(`${err.message}`, this.localeLanguage, loggerConfig), "PostgresConnectionError", status6.NOT_ACCEPTABLE);
|
|
964
|
+
this.logger.error(err.message, "PostgresConnectionError", "Postgres connection error", stackTrace.stack, status6.NOT_ACCEPTABLE);
|
|
975
965
|
}
|
|
976
966
|
}
|
|
977
967
|
traceError(props, name, status7) {
|
|
@@ -1010,7 +1000,7 @@ var MPostgresCheckerDatabase = (localLanguage, environnementPath, keepAlive, str
|
|
|
1010
1000
|
};
|
|
1011
1001
|
|
|
1012
1002
|
// src/utils/utility.utils.ts
|
|
1013
|
-
import
|
|
1003
|
+
import process2 from "node:process";
|
|
1014
1004
|
import chalk from "chalk";
|
|
1015
1005
|
import colors from "ansi-colors";
|
|
1016
1006
|
import path2 from "path";
|
|
@@ -1034,7 +1024,7 @@ var Utility = class {
|
|
|
1034
1024
|
* Returns an Object containing a node version, openssl, and v0
|
|
1035
1025
|
*/
|
|
1036
1026
|
getVersions() {
|
|
1037
|
-
const processVers =
|
|
1027
|
+
const processVers = process2.versions;
|
|
1038
1028
|
const data = {
|
|
1039
1029
|
"node version": processVers.node,
|
|
1040
1030
|
"openssl": processVers.openssl,
|
|
@@ -1054,14 +1044,14 @@ var Utility = class {
|
|
|
1054
1044
|
* and Memory usage system
|
|
1055
1045
|
*/
|
|
1056
1046
|
getUsageMemory() {
|
|
1057
|
-
const memoryData =
|
|
1047
|
+
const memoryData = process2.memoryUsage();
|
|
1058
1048
|
const data = {
|
|
1059
1049
|
"Resident Set Size - total memory allocated for the process execution": this.formatMemoryUsage(memoryData.rss),
|
|
1060
1050
|
"Total size of the allocated heap": this.formatMemoryUsage(memoryData.heapTotal),
|
|
1061
1051
|
"Actual memory used during the execution": this.formatMemoryUsage(memoryData.heapUsed),
|
|
1062
1052
|
"V8 external memory": this.formatMemoryUsage(memoryData.external),
|
|
1063
|
-
"Memory usage user": this.formatMemoryUsage(
|
|
1064
|
-
"Memory usage system": this.formatMemoryUsage(
|
|
1053
|
+
"Memory usage user": this.formatMemoryUsage(process2.cpuUsage().user),
|
|
1054
|
+
"Memory usage system": this.formatMemoryUsage(process2.cpuUsage().system)
|
|
1065
1055
|
};
|
|
1066
1056
|
return {
|
|
1067
1057
|
"rss": data["Resident Set Size - total memory allocated for the process execution"],
|
|
@@ -1076,11 +1066,11 @@ var Utility = class {
|
|
|
1076
1066
|
* Return an Object containing a project path and running server time
|
|
1077
1067
|
*/
|
|
1078
1068
|
getProjectInfo() {
|
|
1079
|
-
const startTime =
|
|
1080
|
-
const endTime =
|
|
1069
|
+
const startTime = process2.hrtime();
|
|
1070
|
+
const endTime = process2.hrtime(startTime);
|
|
1081
1071
|
const executionTime = (endTime[0] * 1e9 + endTime[1]) / 1e6;
|
|
1082
1072
|
return {
|
|
1083
|
-
"projectPath": path2.join(
|
|
1073
|
+
"projectPath": path2.join(process2.cwd()),
|
|
1084
1074
|
"startingTime": `${executionTime.toFixed(5)} ms`
|
|
1085
1075
|
};
|
|
1086
1076
|
}
|
|
@@ -1090,7 +1080,7 @@ var Utility = class {
|
|
|
1090
1080
|
* @private
|
|
1091
1081
|
*/
|
|
1092
1082
|
getEnvFileLoading(filePath) {
|
|
1093
|
-
const fullPath = path2.resolve(
|
|
1083
|
+
const fullPath = path2.resolve(process2.cwd(), filePath);
|
|
1094
1084
|
if (fs.existsSync(fullPath)) {
|
|
1095
1085
|
const env = fs.readFileSync(fullPath, "utf-8");
|
|
1096
1086
|
const lines = env.split("\n");
|
|
@@ -1098,7 +1088,7 @@ var Utility = class {
|
|
|
1098
1088
|
const match = line.match(/^([^#=]+)=([^#]+)$/);
|
|
1099
1089
|
if (match) {
|
|
1100
1090
|
const key = match[1].trim();
|
|
1101
|
-
|
|
1091
|
+
process2.env[key] = match[2].trim();
|
|
1102
1092
|
}
|
|
1103
1093
|
});
|
|
1104
1094
|
}
|
|
@@ -1110,7 +1100,7 @@ var Utility = class {
|
|
|
1110
1100
|
*/
|
|
1111
1101
|
getServerRunningMode(development, production) {
|
|
1112
1102
|
this.getEnvFileLoading(".env");
|
|
1113
|
-
const isDevelopment =
|
|
1103
|
+
const isDevelopment = process2.env.NODE_ENV === "development";
|
|
1114
1104
|
if (isDevelopment) {
|
|
1115
1105
|
return `${TranslationLoader10.t("serverRunning", this.localLang)} ${colors.bgBlue(`${colors.bold(`${development}`)}`)} mode`;
|
|
1116
1106
|
} else {
|
|
@@ -1191,10 +1181,42 @@ var PathModuleVerifier = class {
|
|
|
1191
1181
|
}
|
|
1192
1182
|
}
|
|
1193
1183
|
};
|
|
1184
|
+
|
|
1185
|
+
// src/core/config/loaders/localLanguage.loader.ts
|
|
1186
|
+
import path3 from "path";
|
|
1187
|
+
import { TranslationLoader as TranslationLoader12 } from "opticore-translator";
|
|
1188
|
+
import { HttpStatusCode as HttpStatusCode4 } from "opticore-http-response";
|
|
1189
|
+
var LocalLanguageLoader = class {
|
|
1190
|
+
localeLanguage;
|
|
1191
|
+
environnementPath;
|
|
1192
|
+
constructor(localeLanguage, environnementPath) {
|
|
1193
|
+
this.localeLanguage = localeLanguage;
|
|
1194
|
+
this.environnementPath = environnementPath;
|
|
1195
|
+
}
|
|
1196
|
+
load() {
|
|
1197
|
+
try {
|
|
1198
|
+
const translateMsgJsonFilePath = this.absolutPath();
|
|
1199
|
+
TranslationLoader12.loadTranslations(translateMsgJsonFilePath);
|
|
1200
|
+
} catch (err) {
|
|
1201
|
+
SLoggerFileConfiguration(this.environnementPath).error(
|
|
1202
|
+
//TranslationLoader.t(err.message, this.localeLanguage),
|
|
1203
|
+
err.message,
|
|
1204
|
+
err.code,
|
|
1205
|
+
err.code,
|
|
1206
|
+
err.stackTrace,
|
|
1207
|
+
HttpStatusCode4.INTERNAL_SERVER_ERROR
|
|
1208
|
+
);
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
absolutPath() {
|
|
1212
|
+
return path3.join(process.cwd(), "src", "utils", "translations");
|
|
1213
|
+
}
|
|
1214
|
+
};
|
|
1194
1215
|
export {
|
|
1195
1216
|
CLogLevel,
|
|
1196
1217
|
CSignRSAKeyComponent,
|
|
1197
1218
|
Environment,
|
|
1219
|
+
LocalLanguageLoader,
|
|
1198
1220
|
MMongoCheckerDatabase,
|
|
1199
1221
|
MMySqlCheckerDatabase,
|
|
1200
1222
|
MPostgresCheckerDatabase,
|