opticore-webapp 1.0.20 → 1.0.21

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 CHANGED
@@ -45,7 +45,7 @@ var import_module = require("module");
45
45
  var import_cors = __toESM(require("cors"), 1);
46
46
  var import_opticore_catch_exception_error4 = require("opticore-catch-exception-error");
47
47
  var import_opticore_express2 = require("opticore-express");
48
- var import_opticore_env_access = require("opticore-env-access");
48
+ var import_opticore_env_access3 = require("opticore-env-access");
49
49
  var import_opticore_translator4 = require("opticore-translator");
50
50
 
51
51
  // src/core/handlers/eventProcess.handler.ts
@@ -110,6 +110,9 @@ var path = __toESM(require("path"), 1);
110
110
  var fs = __toESM(require("fs"), 1);
111
111
  var import_ansi_colors3 = __toESM(require("ansi-colors"), 1);
112
112
  var import_opticore_http_response = require("opticore-http-response");
113
+ var import_opticore_translator2 = require("opticore-translator");
114
+ var import_opticore_env_access2 = require("opticore-env-access");
115
+ var import_opticore_logger = require("opticore-logger");
113
116
 
114
117
  // src/core/helpers/modulesLoaded.utils.ts
115
118
  var import_ansi_colors2 = __toESM(require("ansi-colors"), 1);
@@ -152,17 +155,51 @@ function modulesLoadedUtils(allAppRoutes, dbConChecker, localeLanguage) {
152
155
  typeof dbConChecker == "function" ? console.log(`${import_ansi_colors2.default.whiteBright(` ${import_opticore_translator.TranslationLoader.t("content", localeLanguage)}`)} ${import_ansi_colors2.default.green(`${import_opticore_translator.TranslationLoader.t("kernel", localeLanguage)} :`)} ${import_ansi_colors2.default.cyan(`${import_ansi_colors2.default.bold(`${import_opticore_translator.TranslationLoader.t("dbConnChecker", localeLanguage)}`)}`)} ${import_opticore_translator.TranslationLoader.t("hasBeenLoadedSuccessfully", localeLanguage)} ${import_ansi_colors2.default.green(`\u2714`)}`) : "";
153
156
  }
154
157
 
155
- // src/application/service/core.service.ts
156
- var import_opticore_translator2 = require("opticore-translator");
157
-
158
158
  // src/application/service/traceError.service.ts
159
159
  var import_opticore_catch_exception_error2 = require("opticore-catch-exception-error");
160
160
  var STraceError = (props, name, httpCode, isOperational) => {
161
161
  return new import_opticore_catch_exception_error2.StackTraceError(props, name, httpCode, isOperational);
162
162
  };
163
163
 
164
+ // src/core/config/logger/logger.config.ts
165
+ var import_opticore_env_access = require("opticore-env-access");
166
+ var loggerConfig = (envDir) => {
167
+ const getEnvAccess = (0, import_opticore_env_access.getEnvironnementValue)(envDir);
168
+ return {
169
+ logLevels: [
170
+ getEnvAccess.logLevelInfo,
171
+ getEnvAccess.logLevelWarning,
172
+ getEnvAccess.logLevelSuccess,
173
+ getEnvAccess.logLevelError,
174
+ getEnvAccess.logLevelDebug
175
+ ],
176
+ transports: {
177
+ file: {
178
+ enabled: getEnvAccess.logFileEnabled,
179
+ maxSizeMB: getEnvAccess.logFileMaxSize,
180
+ rotate: getEnvAccess.logFileRotate
181
+ },
182
+ console: {
183
+ enabled: getEnvAccess.logConsoleEnabled
184
+ },
185
+ remote: {
186
+ enabled: getEnvAccess.logRemoteEnabled,
187
+ endpoint: getEnvAccess.logRemoteEndPoint
188
+ }
189
+ }
190
+ };
191
+ };
192
+
164
193
  // src/application/service/core.service.ts
165
194
  var CoreService = class {
195
+ loggerConfig;
196
+ localLanguage;
197
+ environnementPath;
198
+ constructor(localLang, environnementPath) {
199
+ this.loggerConfig = new import_opticore_logger.LoggerCore(loggerConfig(environnementPath));
200
+ this.environnementPath = environnementPath;
201
+ this.localLanguage = localLang;
202
+ }
166
203
  /**
167
204
  *
168
205
  * @param data
@@ -198,20 +235,20 @@ var CoreService = class {
198
235
  getUsageMemory() {
199
236
  const memoryData = import_node_process2.default.memoryUsage();
200
237
  const data = {
201
- "Resident Set Size - total memory allocated for the process execution": this.formatMemoryUsage(memoryData.rss),
202
- "Total size of the allocated heap": this.formatMemoryUsage(memoryData.heapTotal),
203
- "Actual memory used during the execution": this.formatMemoryUsage(memoryData.heapUsed),
204
- "V8 external memory": this.formatMemoryUsage(memoryData.external),
205
- "Memory usage user": this.formatMemoryUsage(import_node_process2.default.cpuUsage().user),
206
- "Memory usage system": this.formatMemoryUsage(import_node_process2.default.cpuUsage().system)
238
+ [`${import_opticore_translator2.TranslationLoader.t("totalMemoryAllocated", this.localLanguage)}}`]: this.formatMemoryUsage(memoryData.rss),
239
+ [`${import_opticore_translator2.TranslationLoader.t("sizeAllocatedHeap", this.localLanguage)}`]: this.formatMemoryUsage(memoryData.heapTotal),
240
+ [`${import_opticore_translator2.TranslationLoader.t("memoryUsedExecution", this.localLanguage)}`]: this.formatMemoryUsage(memoryData.heapUsed),
241
+ [`${import_opticore_translator2.TranslationLoader.t("externalMemory", this.localLanguage)}`]: this.formatMemoryUsage(memoryData.external),
242
+ [`${import_opticore_translator2.TranslationLoader.t("memoryUsageUser", this.localLanguage)}`]: this.formatMemoryUsage(import_node_process2.default.cpuUsage().user),
243
+ [`${import_opticore_translator2.TranslationLoader.t("memoryUsageSystem", this.localLanguage)}`]: this.formatMemoryUsage(import_node_process2.default.cpuUsage().system)
207
244
  };
208
245
  return {
209
- "rss": data["Resident Set Size - total memory allocated for the process execution"],
210
- "heapTotal": data["Total size of the allocated heap"],
211
- "heapUsed": data["Actual memory used during the execution"],
212
- "external": data["V8 external memory"],
213
- "user": data["Memory usage user"],
214
- "system": data["Memory usage system"]
246
+ "rss": data[`${import_opticore_translator2.TranslationLoader.t("totalMemoryAllocated", this.localLanguage)}}`],
247
+ "heapTotal": data[`${import_opticore_translator2.TranslationLoader.t("sizeAllocatedHeap", this.localLanguage)}`],
248
+ "heapUsed": data[`${import_opticore_translator2.TranslationLoader.t("memoryUsedExecution", this.localLanguage)}`],
249
+ "external": data[`${import_opticore_translator2.TranslationLoader.t("externalMemory", this.localLanguage)}`],
250
+ "user": data[`${import_opticore_translator2.TranslationLoader.t("memoryUsageUser", this.localLanguage)}`],
251
+ "system": data[`${import_opticore_translator2.TranslationLoader.t("memoryUsageSystem", this.localLanguage)}`]
215
252
  };
216
253
  }
217
254
  /**
@@ -254,21 +291,22 @@ var CoreService = class {
254
291
  this.getEnvFileLoading(".env");
255
292
  const isDevelopment = import_node_process2.default.env.NODE_ENV === "development";
256
293
  if (isDevelopment) {
257
- return `The server is running in ${import_ansi_colors3.default.bgBlue(`${import_ansi_colors3.default.bold(`${development}`)}`)} mode`;
294
+ return `${import_opticore_translator2.TranslationLoader.t("serverRunning", this.localLanguage)} ${import_ansi_colors3.default.bgBlue(`${import_ansi_colors3.default.bold(`${development}`)}`)} mode`;
258
295
  } else {
259
- return `The server is running in ${import_ansi_colors3.default.bgBlue(`${import_ansi_colors3.default.bold(`${production}`)}`)} mode`;
296
+ return `${import_opticore_translator2.TranslationLoader.t("serverRunning", this.localLanguage)} ${import_ansi_colors3.default.bgBlue(`${import_ansi_colors3.default.bold(`${production}`)}`)} mode`;
260
297
  }
261
298
  }
262
- infoServer(nodeVersion, startingTime, host, port, rss, heapUsed, user, system) {
299
+ infoServer(nodeVersion, startingTime, host, port) {
263
300
  const paddingLength = 52;
301
+ const getEnvironnement = (0, import_opticore_env_access2.getEnvironnementValue)(this.environnementPath);
264
302
  const msg0 = " ".padEnd(paddingLength, " ");
265
- const msg1 = " [OK] Web server listening";
303
+ const msg1 = ` ${import_opticore_translator2.TranslationLoader.t("webServerListening", this.localLanguage)}`;
266
304
  const msg2Value = `${import_ansi_colors3.default.bgBlue(`${import_ansi_colors3.default.bold(`${nodeVersion}`)}`)}`;
267
- const msg2 = ` The Web server is using Node.js version`;
305
+ const msg2 = ` ${import_opticore_translator2.TranslationLoader.t("webServerUsingNodeVersion", this.localLanguage)}`;
268
306
  const msg3Value = `${import_ansi_colors3.default.bgBlue(`${import_ansi_colors3.default.bold(`${startingTime}`)}`)}`;
269
- const msg3 = ` Startup time:`;
270
- const msg4 = ` ${this.getServerRunningMode("development", "production")}`;
271
- const msg5 = ` ${import_ansi_colors3.default.underline(`http://${host}:${port}`)}`;
307
+ const msg3 = ` ${import_opticore_translator2.TranslationLoader.t("startTime", this.localLanguage)}`;
308
+ const msg4 = ` ${this.getServerRunningMode(`${import_opticore_translator2.TranslationLoader.t("runningModeDev", this.localLanguage)}`, `${import_opticore_translator2.TranslationLoader.t("runningModeProd", this.localLanguage)}`)}`;
309
+ const msg5 = ` ${import_ansi_colors3.default.underline(`${getEnvironnement.protocolTransfert}://${host}:${port}`)}`;
272
310
  console.log(import_chalk.default.bgGreen.white(msg0.padEnd(paddingLength, " ")));
273
311
  console.log(import_chalk.default.bgGreen.white(msg1.padEnd(paddingLength, " ")));
274
312
  console.log(import_chalk.default.bgGreen.white(msg2, msg2Value.padEnd(30.5, " ")));
@@ -277,13 +315,8 @@ var CoreService = class {
277
315
  console.log(import_chalk.default.bgGreen.white(msg5.padEnd(61, " ")));
278
316
  console.log(import_chalk.default.bgGreen.white(msg0.padEnd(paddingLength, " ")));
279
317
  console.log(``);
280
- console.log(`${`Resident Set Size - total memory allocated for the process execution :`} ${import_ansi_colors3.default.cyan(`${import_ansi_colors3.default.bold(`${rss}`)}`)}`);
281
- console.log(`${`Actual memory used during the execution :`} ${import_ansi_colors3.default.cyan(`${import_ansi_colors3.default.bold(`${heapUsed}`)}`)}`);
282
- console.log(`${`Memory usage by user :`} ${import_ansi_colors3.default.cyan(`${import_ansi_colors3.default.bold(`${user}`)}`)}`);
283
- console.log(`${`Memory usage by system :`} ${import_ansi_colors3.default.cyan(`${import_ansi_colors3.default.bold(`${system}`)}`)}`);
284
- console.log(``);
285
318
  }
286
- coreListenerEventLoaderModuleService(kernelModule, localLanguage, loggerConfig) {
319
+ coreListenerEventLoaderModuleService(kernelModule) {
287
320
  let router = [];
288
321
  let dbCon;
289
322
  kernelModule.forEach((module2) => {
@@ -294,14 +327,14 @@ var CoreService = class {
294
327
  }
295
328
  });
296
329
  if (router && dbCon) {
297
- modulesLoadedUtils(router, dbCon, localLanguage);
330
+ modulesLoadedUtils(router, dbCon, this.localLanguage);
298
331
  (() => {
299
332
  dbCon();
300
333
  })();
301
334
  } else {
302
335
  const stackTrace = STraceError(
303
- import_opticore_translator2.TranslationLoader.t("loadedModulesError", localLanguage, loggerConfig),
304
- import_opticore_translator2.TranslationLoader.t("loadedModules", localLanguage, loggerConfig),
336
+ import_opticore_translator2.TranslationLoader.t("loadedModulesError", this.localLanguage),
337
+ import_opticore_translator2.TranslationLoader.t("loadedModules", this.localLanguage),
305
338
  import_opticore_http_response.HttpStatusCode.NOT_ACCEPTABLE,
306
339
  true
307
340
  );
@@ -431,7 +464,7 @@ var SServerStartError = (err, javaScriptErrors, systemErrors, openSSLErrors, int
431
464
  // src/core/webServer.core.ts
432
465
  var import_opticore_request_call_event = require("opticore-request-call-event");
433
466
  var WebServerCore = class {
434
- serverUtility = new CoreService();
467
+ serverUtility;
435
468
  expressApp = (0, import_opticore_express2.express)();
436
469
  localLanguage;
437
470
  loggerConfig;
@@ -444,10 +477,10 @@ var WebServerCore = class {
444
477
  assertionErrors;
445
478
  openSSLErrors;
446
479
  systemErrors;
447
- constructor(app, loggerConfig, localLanguage, environnementPath, corsOriginOptions) {
448
- this.getEnvironnement = (0, import_opticore_env_access.getEnvironnementValue)(environnementPath);
480
+ constructor(app, loggerConfig2, localLanguage, environnementPath, corsOriginOptions) {
481
+ this.getEnvironnement = (0, import_opticore_env_access3.getEnvironnementValue)(environnementPath);
449
482
  this.routerExpressApp = app;
450
- this.loggerConfig = loggerConfig;
483
+ this.loggerConfig = loggerConfig2;
451
484
  this.localLanguage = localLanguage;
452
485
  this.environnementPath = environnementPath;
453
486
  this.expressApp.use(import_opticore_express2.express.json());
@@ -461,10 +494,11 @@ var WebServerCore = class {
461
494
  this.internalErrors = new import_opticore_catch_exception_error4.InternalErrors(localLanguage);
462
495
  this.openSSLErrors = new import_opticore_catch_exception_error4.OpenSSLErrors(localLanguage);
463
496
  this.systemErrors = new import_opticore_catch_exception_error4.SystemErrors(localLanguage);
497
+ this.serverUtility = new CoreService(localLanguage, environnementPath);
464
498
  this.stackTraceErrorHandling(localLanguage);
465
499
  this.translationWebAppLoader();
466
500
  }
467
- onStartServer(routers) {
501
+ onStartServer(routers, dbConnexion) {
468
502
  return this.expressApp.listen(
469
503
  Number(this.getEnvironnement.appPort),
470
504
  () => {
@@ -476,6 +510,7 @@ var WebServerCore = class {
476
510
  } else if (Number(this.getEnvironnement.appPort) === 0) {
477
511
  this.serverListenEvent.portUndefined();
478
512
  } else {
513
+ dbConnexion();
479
514
  this.expressApp.use(import_opticore_express2.express.static(path2.join(import_node_process3.default.cwd(), "public/template")));
480
515
  this.registerRoutes(routers);
481
516
  }
@@ -494,7 +529,7 @@ var WebServerCore = class {
494
529
  );
495
530
  }
496
531
  //, kernelModule: KernelModuleType
497
- onListeningOnServerEvent(serverWeb, localLanguage) {
532
+ onListeningOnServerEvent(serverWeb) {
498
533
  serverWeb.on(import_opticore_catch_exception_error4.CEventNameError.error, (err) => {
499
534
  this.serverListenEvent.onEventError(err);
500
535
  }).on(import_opticore_catch_exception_error4.CEventNameError.close, () => {
@@ -539,11 +574,7 @@ var WebServerCore = class {
539
574
  this.serverUtility.getVersions().nodeVersion,
540
575
  this.serverUtility.getProjectInfo().startingTime,
541
576
  this.getEnvironnement.appHost,
542
- Number(this.getEnvironnement.appPort),
543
- this.serverUtility.getUsageMemory().rss,
544
- this.serverUtility.getUsageMemory().heapUsed,
545
- this.serverUtility.getUsageMemory().user,
546
- this.serverUtility.getUsageMemory().system
577
+ Number(this.getEnvironnement.appPort)
547
578
  );
548
579
  }
549
580
  };
package/dist/index.d.cts CHANGED
@@ -27,8 +27,8 @@ declare class WebServerCore {
27
27
  private readonly openSSLErrors;
28
28
  private readonly systemErrors;
29
29
  constructor(app: express.Application, loggerConfig: LoggerCore, localLanguage: string, environnementPath: any, corsOriginOptions?: Partial<CorsOptions>);
30
- onStartServer(routers: TFeatureRoutes[]): any;
31
- onListeningOnServerEvent(serverWeb: Server, localLanguage: string): void;
30
+ onStartServer(routers: TFeatureRoutes[], dbConnexion: () => any): any;
31
+ onListeningOnServerEvent(serverWeb: Server): void;
32
32
  onRequestOnServerEvent(serverWeb: Server): void;
33
33
  private translationWebAppLoader;
34
34
  private registerRoutes;
package/dist/index.d.ts CHANGED
@@ -27,8 +27,8 @@ declare class WebServerCore {
27
27
  private readonly openSSLErrors;
28
28
  private readonly systemErrors;
29
29
  constructor(app: express.Application, loggerConfig: LoggerCore, localLanguage: string, environnementPath: any, corsOriginOptions?: Partial<CorsOptions>);
30
- onStartServer(routers: TFeatureRoutes[]): any;
31
- onListeningOnServerEvent(serverWeb: Server, localLanguage: string): void;
30
+ onStartServer(routers: TFeatureRoutes[], dbConnexion: () => any): any;
31
+ onListeningOnServerEvent(serverWeb: Server): void;
32
32
  onRequestOnServerEvent(serverWeb: Server): void;
33
33
  private translationWebAppLoader;
34
34
  private registerRoutes;
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  SystemErrors
14
14
  } from "opticore-catch-exception-error";
15
15
  import { express as express2 } from "opticore-express";
16
- import { getEnvironnementValue } from "opticore-env-access";
16
+ import { getEnvironnementValue as getEnvironnementValue3 } from "opticore-env-access";
17
17
  import { TranslationLoader as TranslationLoader4 } from "opticore-translator";
18
18
 
19
19
  // src/core/handlers/eventProcess.handler.ts
@@ -82,6 +82,9 @@ import * as path from "path";
82
82
  import * as fs from "fs";
83
83
  import colors3 from "ansi-colors";
84
84
  import { HttpStatusCode as status } from "opticore-http-response";
85
+ import { TranslationLoader as TranslationLoader2 } from "opticore-translator";
86
+ import { getEnvironnementValue as getEnvironnementValue2 } from "opticore-env-access";
87
+ import { LoggerCore } from "opticore-logger";
85
88
 
86
89
  // src/core/helpers/modulesLoaded.utils.ts
87
90
  import colors2 from "ansi-colors";
@@ -124,17 +127,51 @@ function modulesLoadedUtils(allAppRoutes, dbConChecker, localeLanguage) {
124
127
  typeof dbConChecker == "function" ? console.log(`${colors2.whiteBright(` ${TranslationLoader.t("content", localeLanguage)}`)} ${colors2.green(`${TranslationLoader.t("kernel", localeLanguage)} :`)} ${colors2.cyan(`${colors2.bold(`${TranslationLoader.t("dbConnChecker", localeLanguage)}`)}`)} ${TranslationLoader.t("hasBeenLoadedSuccessfully", localeLanguage)} ${colors2.green(`\u2714`)}`) : "";
125
128
  }
126
129
 
127
- // src/application/service/core.service.ts
128
- import { TranslationLoader as TranslationLoader2 } from "opticore-translator";
129
-
130
130
  // src/application/service/traceError.service.ts
131
131
  import { StackTraceError } from "opticore-catch-exception-error";
132
132
  var STraceError = (props, name, httpCode, isOperational) => {
133
133
  return new StackTraceError(props, name, httpCode, isOperational);
134
134
  };
135
135
 
136
+ // src/core/config/logger/logger.config.ts
137
+ import { getEnvironnementValue } from "opticore-env-access";
138
+ var loggerConfig = (envDir) => {
139
+ const getEnvAccess = getEnvironnementValue(envDir);
140
+ return {
141
+ logLevels: [
142
+ getEnvAccess.logLevelInfo,
143
+ getEnvAccess.logLevelWarning,
144
+ getEnvAccess.logLevelSuccess,
145
+ getEnvAccess.logLevelError,
146
+ getEnvAccess.logLevelDebug
147
+ ],
148
+ transports: {
149
+ file: {
150
+ enabled: getEnvAccess.logFileEnabled,
151
+ maxSizeMB: getEnvAccess.logFileMaxSize,
152
+ rotate: getEnvAccess.logFileRotate
153
+ },
154
+ console: {
155
+ enabled: getEnvAccess.logConsoleEnabled
156
+ },
157
+ remote: {
158
+ enabled: getEnvAccess.logRemoteEnabled,
159
+ endpoint: getEnvAccess.logRemoteEndPoint
160
+ }
161
+ }
162
+ };
163
+ };
164
+
136
165
  // src/application/service/core.service.ts
137
166
  var CoreService = class {
167
+ loggerConfig;
168
+ localLanguage;
169
+ environnementPath;
170
+ constructor(localLang, environnementPath) {
171
+ this.loggerConfig = new LoggerCore(loggerConfig(environnementPath));
172
+ this.environnementPath = environnementPath;
173
+ this.localLanguage = localLang;
174
+ }
138
175
  /**
139
176
  *
140
177
  * @param data
@@ -170,20 +207,20 @@ var CoreService = class {
170
207
  getUsageMemory() {
171
208
  const memoryData = process2.memoryUsage();
172
209
  const data = {
173
- "Resident Set Size - total memory allocated for the process execution": this.formatMemoryUsage(memoryData.rss),
174
- "Total size of the allocated heap": this.formatMemoryUsage(memoryData.heapTotal),
175
- "Actual memory used during the execution": this.formatMemoryUsage(memoryData.heapUsed),
176
- "V8 external memory": this.formatMemoryUsage(memoryData.external),
177
- "Memory usage user": this.formatMemoryUsage(process2.cpuUsage().user),
178
- "Memory usage system": this.formatMemoryUsage(process2.cpuUsage().system)
210
+ [`${TranslationLoader2.t("totalMemoryAllocated", this.localLanguage)}}`]: this.formatMemoryUsage(memoryData.rss),
211
+ [`${TranslationLoader2.t("sizeAllocatedHeap", this.localLanguage)}`]: this.formatMemoryUsage(memoryData.heapTotal),
212
+ [`${TranslationLoader2.t("memoryUsedExecution", this.localLanguage)}`]: this.formatMemoryUsage(memoryData.heapUsed),
213
+ [`${TranslationLoader2.t("externalMemory", this.localLanguage)}`]: this.formatMemoryUsage(memoryData.external),
214
+ [`${TranslationLoader2.t("memoryUsageUser", this.localLanguage)}`]: this.formatMemoryUsage(process2.cpuUsage().user),
215
+ [`${TranslationLoader2.t("memoryUsageSystem", this.localLanguage)}`]: this.formatMemoryUsage(process2.cpuUsage().system)
179
216
  };
180
217
  return {
181
- "rss": data["Resident Set Size - total memory allocated for the process execution"],
182
- "heapTotal": data["Total size of the allocated heap"],
183
- "heapUsed": data["Actual memory used during the execution"],
184
- "external": data["V8 external memory"],
185
- "user": data["Memory usage user"],
186
- "system": data["Memory usage system"]
218
+ "rss": data[`${TranslationLoader2.t("totalMemoryAllocated", this.localLanguage)}}`],
219
+ "heapTotal": data[`${TranslationLoader2.t("sizeAllocatedHeap", this.localLanguage)}`],
220
+ "heapUsed": data[`${TranslationLoader2.t("memoryUsedExecution", this.localLanguage)}`],
221
+ "external": data[`${TranslationLoader2.t("externalMemory", this.localLanguage)}`],
222
+ "user": data[`${TranslationLoader2.t("memoryUsageUser", this.localLanguage)}`],
223
+ "system": data[`${TranslationLoader2.t("memoryUsageSystem", this.localLanguage)}`]
187
224
  };
188
225
  }
189
226
  /**
@@ -226,21 +263,22 @@ var CoreService = class {
226
263
  this.getEnvFileLoading(".env");
227
264
  const isDevelopment = process2.env.NODE_ENV === "development";
228
265
  if (isDevelopment) {
229
- return `The server is running in ${colors3.bgBlue(`${colors3.bold(`${development}`)}`)} mode`;
266
+ return `${TranslationLoader2.t("serverRunning", this.localLanguage)} ${colors3.bgBlue(`${colors3.bold(`${development}`)}`)} mode`;
230
267
  } else {
231
- return `The server is running in ${colors3.bgBlue(`${colors3.bold(`${production}`)}`)} mode`;
268
+ return `${TranslationLoader2.t("serverRunning", this.localLanguage)} ${colors3.bgBlue(`${colors3.bold(`${production}`)}`)} mode`;
232
269
  }
233
270
  }
234
- infoServer(nodeVersion, startingTime, host, port, rss, heapUsed, user, system) {
271
+ infoServer(nodeVersion, startingTime, host, port) {
235
272
  const paddingLength = 52;
273
+ const getEnvironnement = getEnvironnementValue2(this.environnementPath);
236
274
  const msg0 = " ".padEnd(paddingLength, " ");
237
- const msg1 = " [OK] Web server listening";
275
+ const msg1 = ` ${TranslationLoader2.t("webServerListening", this.localLanguage)}`;
238
276
  const msg2Value = `${colors3.bgBlue(`${colors3.bold(`${nodeVersion}`)}`)}`;
239
- const msg2 = ` The Web server is using Node.js version`;
277
+ const msg2 = ` ${TranslationLoader2.t("webServerUsingNodeVersion", this.localLanguage)}`;
240
278
  const msg3Value = `${colors3.bgBlue(`${colors3.bold(`${startingTime}`)}`)}`;
241
- const msg3 = ` Startup time:`;
242
- const msg4 = ` ${this.getServerRunningMode("development", "production")}`;
243
- const msg5 = ` ${colors3.underline(`http://${host}:${port}`)}`;
279
+ const msg3 = ` ${TranslationLoader2.t("startTime", this.localLanguage)}`;
280
+ const msg4 = ` ${this.getServerRunningMode(`${TranslationLoader2.t("runningModeDev", this.localLanguage)}`, `${TranslationLoader2.t("runningModeProd", this.localLanguage)}`)}`;
281
+ const msg5 = ` ${colors3.underline(`${getEnvironnement.protocolTransfert}://${host}:${port}`)}`;
244
282
  console.log(chalk.bgGreen.white(msg0.padEnd(paddingLength, " ")));
245
283
  console.log(chalk.bgGreen.white(msg1.padEnd(paddingLength, " ")));
246
284
  console.log(chalk.bgGreen.white(msg2, msg2Value.padEnd(30.5, " ")));
@@ -249,13 +287,8 @@ var CoreService = class {
249
287
  console.log(chalk.bgGreen.white(msg5.padEnd(61, " ")));
250
288
  console.log(chalk.bgGreen.white(msg0.padEnd(paddingLength, " ")));
251
289
  console.log(``);
252
- console.log(`${`Resident Set Size - total memory allocated for the process execution :`} ${colors3.cyan(`${colors3.bold(`${rss}`)}`)}`);
253
- console.log(`${`Actual memory used during the execution :`} ${colors3.cyan(`${colors3.bold(`${heapUsed}`)}`)}`);
254
- console.log(`${`Memory usage by user :`} ${colors3.cyan(`${colors3.bold(`${user}`)}`)}`);
255
- console.log(`${`Memory usage by system :`} ${colors3.cyan(`${colors3.bold(`${system}`)}`)}`);
256
- console.log(``);
257
290
  }
258
- coreListenerEventLoaderModuleService(kernelModule, localLanguage, loggerConfig) {
291
+ coreListenerEventLoaderModuleService(kernelModule) {
259
292
  let router = [];
260
293
  let dbCon;
261
294
  kernelModule.forEach((module) => {
@@ -266,14 +299,14 @@ var CoreService = class {
266
299
  }
267
300
  });
268
301
  if (router && dbCon) {
269
- modulesLoadedUtils(router, dbCon, localLanguage);
302
+ modulesLoadedUtils(router, dbCon, this.localLanguage);
270
303
  (() => {
271
304
  dbCon();
272
305
  })();
273
306
  } else {
274
307
  const stackTrace = STraceError(
275
- TranslationLoader2.t("loadedModulesError", localLanguage, loggerConfig),
276
- TranslationLoader2.t("loadedModules", localLanguage, loggerConfig),
308
+ TranslationLoader2.t("loadedModulesError", this.localLanguage),
309
+ TranslationLoader2.t("loadedModules", this.localLanguage),
277
310
  status.NOT_ACCEPTABLE,
278
311
  true
279
312
  );
@@ -403,7 +436,7 @@ var SServerStartError = (err, javaScriptErrors, systemErrors, openSSLErrors, int
403
436
  // src/core/webServer.core.ts
404
437
  import { requestCallsEvent } from "opticore-request-call-event";
405
438
  var WebServerCore = class {
406
- serverUtility = new CoreService();
439
+ serverUtility;
407
440
  expressApp = express2();
408
441
  localLanguage;
409
442
  loggerConfig;
@@ -416,10 +449,10 @@ var WebServerCore = class {
416
449
  assertionErrors;
417
450
  openSSLErrors;
418
451
  systemErrors;
419
- constructor(app, loggerConfig, localLanguage, environnementPath, corsOriginOptions) {
420
- this.getEnvironnement = getEnvironnementValue(environnementPath);
452
+ constructor(app, loggerConfig2, localLanguage, environnementPath, corsOriginOptions) {
453
+ this.getEnvironnement = getEnvironnementValue3(environnementPath);
421
454
  this.routerExpressApp = app;
422
- this.loggerConfig = loggerConfig;
455
+ this.loggerConfig = loggerConfig2;
423
456
  this.localLanguage = localLanguage;
424
457
  this.environnementPath = environnementPath;
425
458
  this.expressApp.use(express2.json());
@@ -433,10 +466,11 @@ var WebServerCore = class {
433
466
  this.internalErrors = new InternalErrors(localLanguage);
434
467
  this.openSSLErrors = new OpenSSLErrors(localLanguage);
435
468
  this.systemErrors = new SystemErrors(localLanguage);
469
+ this.serverUtility = new CoreService(localLanguage, environnementPath);
436
470
  this.stackTraceErrorHandling(localLanguage);
437
471
  this.translationWebAppLoader();
438
472
  }
439
- onStartServer(routers) {
473
+ onStartServer(routers, dbConnexion) {
440
474
  return this.expressApp.listen(
441
475
  Number(this.getEnvironnement.appPort),
442
476
  () => {
@@ -448,6 +482,7 @@ var WebServerCore = class {
448
482
  } else if (Number(this.getEnvironnement.appPort) === 0) {
449
483
  this.serverListenEvent.portUndefined();
450
484
  } else {
485
+ dbConnexion();
451
486
  this.expressApp.use(express2.static(path2.join(process3.cwd(), "public/template")));
452
487
  this.registerRoutes(routers);
453
488
  }
@@ -466,7 +501,7 @@ var WebServerCore = class {
466
501
  );
467
502
  }
468
503
  //, kernelModule: KernelModuleType
469
- onListeningOnServerEvent(serverWeb, localLanguage) {
504
+ onListeningOnServerEvent(serverWeb) {
470
505
  serverWeb.on(eventName2.error, (err) => {
471
506
  this.serverListenEvent.onEventError(err);
472
507
  }).on(eventName2.close, () => {
@@ -511,11 +546,7 @@ var WebServerCore = class {
511
546
  this.serverUtility.getVersions().nodeVersion,
512
547
  this.serverUtility.getProjectInfo().startingTime,
513
548
  this.getEnvironnement.appHost,
514
- Number(this.getEnvironnement.appPort),
515
- this.serverUtility.getUsageMemory().rss,
516
- this.serverUtility.getUsageMemory().heapUsed,
517
- this.serverUtility.getUsageMemory().user,
518
- this.serverUtility.getUsageMemory().system
549
+ Number(this.getEnvironnement.appPort)
519
550
  );
520
551
  }
521
552
  };
@@ -1,4 +1,16 @@
1
1
  {
2
+ "serverRunning": "The server is running in",
3
+ "webServerListening": "[OK] Web server listening",
4
+ "webServerUsingNodeVersion": "The Web server is using Node.js version",
5
+ "startTime": "Startup time:",
6
+ "runningModeDev": "development",
7
+ "runningModeProd": "production",
8
+ "totalMemoryAllocated": "Resident Set Size - total memory allocated for the process execution",
9
+ "sizeAllocatedHeap": "Total size of the allocated heap",
10
+ "memoryUsedExecution": "Actual memory used during the execution",
11
+ "externalMemory":"V8 external memory",
12
+ "memoryUsageUser": "Memory usage user",
13
+ "memoryUsageSystem": "Memory usage system",
2
14
  "dbConnection": "DataBase connection",
3
15
  "dbConnectionClosed": "MySQL connection is closed",
4
16
  "mysqlErrorCon": "MysqlError connection",
@@ -1,78 +1,90 @@
1
1
  {
2
- "dbConnection": "DataBase connection",
3
- "dbConnectionClosed": "MySQL connection is closed",
2
+ "serverRunning": "Le serveur est en cours d'exécution en",
3
+ "webServerListening": "[OK] Le serveur web écoute",
4
+ "webServerUsingNodeVersion": "Le serveur Web utilise la version Node.js",
5
+ "startTime": "Temps de démarrage :",
6
+ "runningModeDev": "développement",
7
+ "runningModeProd": "production",
8
+ "totalMemoryAllocated": "Taille de l'ensemble résident - mémoire totale allouée à l'exécution du processus",
9
+ "sizeAllocatedHeap": "Taille totale du segment alloué",
10
+ "memoryUsedExecution": "Mémoire réelle utilisée lors de l'exécution",
11
+ "externalMemory":"Mémoire externe V8",
12
+ "memoryUsageUser": "Utilisation de la mémoire par l'utilisateur",
13
+ "memoryUsageSystem": "Système d'usage de la mémoire",
14
+ "dbConnection": "Connexion à la base de données",
15
+ "dbConnectionClosed": "La connexion MySQL est fermée",
4
16
  "mysqlErrorCon": "MysqlError connection",
5
17
  "mySQLError": "MysqlError",
6
- "mySqlCloseConnection": "MySql close connection",
7
- "verifyExistingKey": "Verify Existing Key",
8
- "invalidRequest": "Invalid request",
9
- "tokenNotProvided": "No token provided.",
10
- "ExpiresToken": "Expires Token. You're not authorize",
11
- "privateKeyNotExist": "A private key doesn't exist.",
12
- "publicKeyNotExist": "A public key doesn't exist.",
13
- "errorNamePublicKeyNotExist": "No public key",
14
- "errorAuthorPublicKeyNotExist": "PublicKey not existing",
15
- "errorDecryption": "Error decryption with private key",
16
- "rsaKeyNotFound": "RSA key provided is not found.",
17
- "notVerifyingRSAKey": "Not verify RSA Key",
18
- "errorNameNotVerifyingRSAKey": "Error Verify RSA Key",
19
- "errorEncryptionPublicKey": "Error encryption with public key",
20
- "errorEncryptionPrivateKey": "Error encryption with private key",
21
- "errorNameRsaVerifyExistingKey": "Verify existing key",
22
- "signatureRSAKeyFailed": "Signature verification failed.",
23
- "encryptionWithPrivateKeyFailed": "Encryption With PrivateKey",
24
- "encryptionFailed": "Encryption failed",
25
- "decryptionWithPublicKeyFailed": "Decryption With PublicKey",
26
- "decryptionFailed": "Decryption failed",
27
- "verifyRSAKey": "Verify RSA Keys",
28
- "verifyRSAKeyFailed": "Verify RSA Keys Failed",
29
- "notVerifying": "Verification failed",
30
- "signatureRSAKeysError": "Signature RSA Keys Error",
31
- "encryptionWithPublicKey": "Encryption error",
32
- "errorDecryptionWithPrivateKey": "Error Decryption With PrivateKey",
33
- "verifyPublicRSAKey": "Verify Public RSA Key",
34
- "PostgresDBConnectionChecker": "PostgresDB Connection Checker",
18
+ "mySqlCloseConnection": "Connexion MySql fermée",
19
+ "verifyExistingKey": "Vérifier la clé existante",
20
+ "invalidRequest": "Demande invalide",
21
+ "tokenNotProvided": "Aucun jeton fourni.",
22
+ "ExpiresToken": "Jeton expiré. Vous n'êtes pas autorisé",
23
+ "privateKeyNotExist": "Il n'existe pas de clé privée.",
24
+ "publicKeyNotExist": "Il n'existe pas de clé public.",
25
+ "errorNamePublicKeyNotExist": "Aucune clé public.",
26
+ "errorAuthorPublicKeyNotExist": "Clé publique inexistante",
27
+ "errorDecryption": "Erreur de décryptage avec la clé privée",
28
+ "rsaKeyNotFound": "La clé RSA fournie n'est pas trouvée.",
29
+ "notVerifyingRSAKey": "Pas de vérification de la clé RSA",
30
+ "errorNameNotVerifyingRSAKey": "Erreur lors de la vérification de la clé RSA",
31
+ "errorEncryptionPublicKey": "Erreur de chiffrement avec la clé publique",
32
+ "errorEncryptionPrivateKey": "Erreur de chiffrement avec la clé privée",
33
+ "errorNameRsaVerifyExistingKey": "Vérification de la clé existante",
34
+ "signatureRSAKeyFailed": "La vérification de la signature a échoué.",
35
+ "encryptionWithPrivateKeyFailed": "Chiffrement avec clé privée",
36
+ "encryptionFailed": "Le cryptage a échoué",
37
+ "decryptionWithPublicKeyFailed": "Décryptage avec la clé publique",
38
+ "decryptionFailed": "Le décryptage a échoué",
39
+ "verifyRSAKey": "Vérification des clés RSA",
40
+ "verifyRSAKeyFailed": "Échec de la vérification des clés RSA",
41
+ "notVerifying": "La vérification a échoué",
42
+ "signatureRSAKeysError": "Erreur de clé de signature RSA",
43
+ "encryptionWithPublicKey": "Erreur de cryptage",
44
+ "errorDecryptionWithPrivateKey": "Erreur de décryptage avec la clé privée",
45
+ "verifyPublicRSAKey": "Vérifier la clé publique RSA",
46
+ "PostgresDBConnectionChecker": "Vérificateur de la connexion a la base de donnée Postgres",
35
47
  "PostgresConnection": "connection",
36
- "MongoDBConnectionChecker": "MongoDB Connection Checker",
48
+ "MongoDBConnectionChecker": "Vérificateur de la connexion a la base de donnée connexion MongoDB",
37
49
  "MongoConnection": "connection",
38
50
  "mongoDBAuthentication": "authentication",
39
- "mongoDBConnection": "MongoDB connection",
40
- "mongoDBAuthenticationFailed": "failed",
41
- "mongoDBUnableParsingUrl": "unable to parse",
51
+ "mongoDBConnection": "Connexion à la base de données Mongo",
52
+ "mongoDBAuthenticationFailed": "échoué",
53
+ "mongoDBUnableParsingUrl": "impossible d'analyser",
42
54
  "mongoDBConnectionUrl": "url",
43
- "mongoDBServerSelection": "MongoServer selection error",
44
- "mongoDBServer": "MongoServer",
45
- "mongoDBConnectionError": "connection error",
46
- "mongoDBError": "error",
47
- "loadedModules": "Loading core modules",
48
- "kernel": "Kernel",
49
- "loadKernel": "load kernel",
50
- "moduleAppLoaded": "Modules app have been successfully loaded",
51
- "content": "content",
52
- "serverSide": "server side",
53
- "hasBeenLoadedSuccessfully": "has been loaded successfully",
54
- "routerService": "Routers service",
55
- "registerRoutes": "Register routes",
56
- "fail": "fail",
57
- "loading": "loading",
58
- "routers": "routers",
59
- "registerLoadingFailed": "The route register failed to load",
60
- "dbConnChecker": "database checker connection",
61
- "loadedModulesError": "Required core modules are not loaded properly",
62
- "dbConnexionSuccess": "The database connection was successful 🚀",
63
- "mongoConnectionSuccess": "Connection to database is successfully.",
64
- "PostgresConnectionSuccess": "Connection to database is successfully.",
65
- "verifyExistingKeyError": "The provided key is not found",
66
- "webServer": "Web server",
67
- "listening": "listening",
68
- "webHost": "host",
69
- "badHost": "bad host",
70
- "hostNotFound": "not found",
71
- "errorHostUrl": "The host and port are not define, please define them in .env",
72
- "badPort": "bad port",
73
- "errorPort": "The port is not correct. Please define a right port with number port.",
74
- "errorHost": "The host can't be empty or blank. Please define a string host in .env",
75
- "accessDeniedToDBCon": "Access denied for user {user}. Database credentials in .env file are User: {user} and Password: {password}. {user}''{password}'@'localhost'. Try to set user and password in .env file",
76
- "unknownDB": "Database {database} is unknown. Please try to use Database CLI to create your database, or do it manually in your Database Management System",
77
- "errorDBHost": "A database host ${host} does not allow connection. Please either set the host like this: {localhost} in your .env file"
55
+ "mongoDBServerSelection": "Erreur de sélection du serveur Mongo",
56
+ "mongoDBServer": "Serveur Mongo",
57
+ "mongoDBConnectionError": "Erreur de connection",
58
+ "mongoDBError": "erreur",
59
+ "loadedModules": "Chargement des modules de base",
60
+ "kernel": "Noyau",
61
+ "loadKernel": "charger le kernel",
62
+ "moduleAppLoaded": "Les modules de l'application ont été chargés avec succès",
63
+ "content": "contenu",
64
+ "serverSide": "côté serveur",
65
+ "hasBeenLoadedSuccessfully": "a été chargé avec succès",
66
+ "routerService": "Service de routeurs",
67
+ "registerRoutes": "Registre des routes",
68
+ "fail": "échec",
69
+ "loading": "Chargement",
70
+ "routers": "routes",
71
+ "registerLoadingFailed": "Le registre des routes n'a pas pu être chargé",
72
+ "dbConnChecker": "vérificateur a la connexion de base de données",
73
+ "loadedModulesError": "Les modules de base requis ne sont pas chargés correctement",
74
+ "dbConnexionSuccess": "La connexion à la base de données a réussi 🚀",
75
+ "mongoConnectionSuccess": "La connexion à la base de données est réussie.",
76
+ "PostgresConnectionSuccess": "La connexion à la base de données est réussie.",
77
+ "verifyExistingKeyError": "La clé fournie est introuvable",
78
+ "webServer": "Serveur Web",
79
+ "listening": "écoute",
80
+ "webHost": "hôte",
81
+ "badHost": "mauvais hôte",
82
+ "hostNotFound": "introuvable",
83
+ "errorHostUrl": "L'hôte et le port ne sont pas définis, veuillez les définir dans .env",
84
+ "badPort": "mauvais port",
85
+ "errorPort": "Le port est incorrect. Veuillez définir un port correct avec le numéro port.",
86
+ "errorHost": "L'hôte ne peut être vide. Veuillez définir une chaîne d'hôte dans .env.",
87
+ "accessDeniedToDBCon": "Accès refusé pour l'utilisateur {user}. Les identifiants de la base de données dans le fichier .env sont : utilisateur : {user} et le mot de passe : {password}. {user}''{password}'@'localhost'. Essayez de définir l'utilisateur et le mot de passe dans le fichier .env",
88
+ "unknownDB": "La base de données {database} est inconnue. Veuillez utiliser l'interface de ligne de commande de la base de données pour la créer, ou le faire manuellement dans votre système de gestion de bases de données.",
89
+ "errorDBHost": "L'hôte de la base de données ${host} n'autorise pas la connexion. Veuillez définir l'hôte comme suit : {localhost} dans votre fichier .env"
78
90
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opticore-webapp",
3
- "version": "1.0.20",
3
+ "version": "1.0.21",
4
4
  "description": "wep server",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",