opticore-webapp 1.0.65 → 1.0.67

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.js CHANGED
@@ -1,27 +1,114 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
7
+
1
8
  // src/core/webServer.core.ts
2
9
  import * as path2 from "path";
3
- import process4 from "node:process";
10
+ import process4 from "process";
4
11
  import corsOrigin from "cors";
5
12
  import { CEventNameError as eventName2, ServerListenEventError as ServerListenEventError2 } from "opticore-catch-exception-error";
6
- import { express as express2 } from "opticore-express";
13
+ import { express } from "opticore-express";
7
14
  import { getEnvironnementValue as getEnvironnementValue2 } from "opticore-env-access";
8
15
 
9
16
  // src/core/handlers/eventProcess.handler.ts
10
- import process from "node:process";
11
- import EventEmitter from "node:events";
12
- import { express } from "opticore-express";
17
+ import process from "process";
18
+ import EventEmitter from "events";
13
19
  import {
14
20
  ServerListenEventError,
15
21
  CEventNameError as eventName,
16
22
  CEvent as event
17
23
  } from "opticore-catch-exception-error";
18
- function eventProcessHandler(localeLanguage) {
24
+
25
+ // src/utils/isTransformError.utils.ts
26
+ var isTransformErrorUtils = (error) => {
27
+ return error?.name === "TransformError" || error?.message?.includes("Transform failed") || error?.message?.includes("esbuild");
28
+ };
29
+
30
+ // src/core/handlers/eventProcess.handler.ts
31
+ function eventProcessHandler(localeLanguage, expressApp) {
19
32
  const errorEmitter = new EventEmitter();
20
- const app = express();
21
33
  const serverListenEvent = new ServerListenEventError(localeLanguage);
34
+ console.log("[Server] Setting up error event handlers...");
22
35
  errorEmitter.on(eventName.error, (error) => {
36
+ console.error("[Server] EventEmitter error caught:", error.message);
37
+ if (isTransformErrorUtils(error)) {
38
+ handleTransformError(error);
39
+ }
23
40
  serverListenEvent.listenerError(error);
24
41
  });
42
+ function handleTransformError(error) {
43
+ console.error("[Server] ============================================");
44
+ console.error("[Server] TRANSFORM ERROR DETECTED");
45
+ console.error("[Server] ============================================");
46
+ console.error("[Server] Message:", error.message);
47
+ console.error("[Server] Stack:", error.stack);
48
+ if (error.errors && Array.isArray(error.errors)) {
49
+ error.errors.forEach((err, index) => {
50
+ console.error(`[Server] Error ${index + 1}:`, err.text);
51
+ if (err.location) {
52
+ console.error(`[Server] File: ${err.location.file}`);
53
+ console.error(`[Server] Line: ${err.location.line}, Column: ${err.location.column}`);
54
+ }
55
+ });
56
+ }
57
+ const fileMatch = error.message.match(/([^:]+\.ts):(\d+):(\d+):/);
58
+ if (fileMatch) {
59
+ console.error("[Server] Problem file:", fileMatch[1]);
60
+ console.error("[Server] Line:", fileMatch[2], "Column:", fileMatch[3]);
61
+ }
62
+ const errorDetailMatch = error.message.match(/ERROR: (.+)$/m);
63
+ if (errorDetailMatch) {
64
+ console.error("[Server] Error detail:", errorDetailMatch[1]);
65
+ }
66
+ console.error("[Server] ============================================");
67
+ if (process.send) {
68
+ process.send({
69
+ type: "TRANSFORM_ERROR",
70
+ error: error.message,
71
+ stack: error.stack,
72
+ errorName: error.name,
73
+ details: error.errors,
74
+ timestamp: Date.now()
75
+ });
76
+ }
77
+ }
78
+ process.on(event.uncaughtException, (error) => {
79
+ console.error("[Server] UNCAUGHT EXCEPTION:", error.message);
80
+ console.error("[Server] Stack:", error.stack);
81
+ if (isTransformErrorUtils(error)) {
82
+ errorEmitter.emit("transformError", error);
83
+ }
84
+ serverListenEvent.uncaughtException(error);
85
+ if (process.send) {
86
+ const messageType = isTransformErrorUtils(error) ? "TRANSFORM_ERROR" : "HOT_RELOAD_ERROR";
87
+ process.send({
88
+ type: messageType,
89
+ error: error.message,
90
+ stack: error.stack,
91
+ errorName: error.name,
92
+ timestamp: Date.now()
93
+ });
94
+ }
95
+ });
96
+ process.on(event.unhandledRejection, (reason, promise) => {
97
+ console.error("[Server] UNHANDLED REJECTION:", reason);
98
+ if (isTransformErrorUtils(reason)) {
99
+ errorEmitter.emit("transformError", reason);
100
+ }
101
+ serverListenEvent.unhandledRejection(reason, promise);
102
+ if (process.send) {
103
+ const messageType = isTransformErrorUtils(reason) ? "TRANSFORM_ERROR" : "HOT_RELOAD_ERROR";
104
+ process.send({
105
+ type: messageType,
106
+ error: reason?.message || String(reason),
107
+ errorName: reason?.name,
108
+ timestamp: Date.now()
109
+ });
110
+ }
111
+ });
25
112
  process.on(event.beforeExit, (code) => {
26
113
  setTimeout(() => {
27
114
  serverListenEvent.processBeforeExit(code);
@@ -36,20 +123,20 @@ function eventProcessHandler(localeLanguage) {
36
123
  process.on(event.rejectionHandled, (promise) => {
37
124
  serverListenEvent.promiseRejectionHandled(promise);
38
125
  });
39
- process.on(event.uncaughtException, (error) => {
40
- serverListenEvent.uncaughtException(error);
41
- });
42
126
  process.on(event.uncaughtExceptionMonitor, (error) => {
127
+ console.error("[Server] UNCAUGHT EXCEPTION MONITOR:", error.message);
128
+ if (isTransformErrorUtils(error)) {
129
+ errorEmitter.emit("transformError", error);
130
+ }
43
131
  serverListenEvent.uncaughtExceptionMonitor(error);
44
132
  });
45
- process.on(event.unhandledRejection, (reason, promise) => {
46
- serverListenEvent.unhandledRejection(reason, promise);
47
- });
48
133
  process.on(event.warning, (warning) => {
49
134
  serverListenEvent.warning(warning);
50
135
  });
51
136
  process.on(event.message, (message) => {
52
- serverListenEvent.message(message);
137
+ if (message.type !== "HOT_RELOAD_REQUEST" && message.type !== "SERVER_READY") {
138
+ serverListenEvent.message(message);
139
+ }
53
140
  });
54
141
  process.on(event.multipleResolves, (type, promise, reason) => {
55
142
  serverListenEvent.multipleResolves(type, promise, reason);
@@ -60,78 +147,47 @@ function eventProcessHandler(localeLanguage) {
60
147
  process.on(event.sigterm, (signal) => {
61
148
  serverListenEvent.sigtermSignalReceived(signal);
62
149
  });
63
- app.use((err, req, res, next) => {
150
+ expressApp.use((err, req, res, next) => {
151
+ console.error("[Server] Express error middleware triggered:", err.message);
152
+ console.error("[Server] Request URL:", req.url);
153
+ console.error("[Server] Request method:", req.method);
154
+ errorEmitter.emit(eventName.error, err);
64
155
  serverListenEvent.expressErrorHandlingMiddleware(errorEmitter, err, req, res, next);
65
156
  });
157
+ console.log("[Server] Error event handlers configured successfully");
158
+ return errorEmitter;
66
159
  }
67
160
 
68
161
  // src/application/service/core.service.ts
69
- import process3 from "node:process";
162
+ import process3 from "process";
70
163
  import chalk from "chalk";
71
164
  import * as path from "path";
72
165
  import * as fs from "fs";
73
- import colors3 from "ansi-colors";
74
- import { HttpStatusCode, HttpStatusCode as status } from "opticore-http-response";
75
- import { TranslationLoader as TranslationLoader2 } from "opticore-translator";
76
- import { getEnvironnementValue } from "opticore-env-access";
77
-
78
- // src/core/helpers/modulesLoaded.utils.ts
79
- import colors2 from "ansi-colors";
80
-
81
- // src/core/helpers/logMessage.utils.ts
82
166
  import colors from "ansi-colors";
83
-
84
- // src/core/helpers/dateTimeFormatted.utils.ts
85
- var dateTimeFormattedUtils = `${(/* @__PURE__ */ new Date()).getMonth()}-${(/* @__PURE__ */ new Date()).getDate()}-${(/* @__PURE__ */ new Date()).getFullYear()} ${(/* @__PURE__ */ new Date()).getHours()}:${(/* @__PURE__ */ new Date()).getMinutes()}:${(/* @__PURE__ */ new Date()).getSeconds()}`;
86
-
87
- // src/core/helpers/logMessage.utils.ts
88
- var LogMessageUtils = class {
89
- static success(title, action, contentAction) {
90
- console.log(`${colors.green(`\u2714`)} ${colors.bgGreen(` ${colors.bold(`${colors.white(`${title}`)}`)} `)} ${dateTimeFormattedUtils} | ${colors.bgGreen(`${colors.white(` Success `)}`)} [ ${action} ] ${contentAction} - [ Status ] ${colors.bgGreen(`${colors.white(` 200 `)}`)}`);
91
- }
92
- static warning(title, action, contentAction) {
93
- console.warn(`${colors.yellow(`\u26A0\uFE0F`)} ${colors.bgYellow(` ${colors.bold(`${colors.white(`${title}`)}`)} `)} ${dateTimeFormattedUtils} | ${colors.bgYellow(`${colors.white(` Warning `)}`)} ${contentAction}`);
94
- }
95
- static info(title, action, contentAction) {
96
- console.info(`${colors.cyan(`\u24D8`)} ${colors.bgCyan(` ${colors.bold(`${colors.white(`${title}`)}`)} `)} ${dateTimeFormattedUtils} | ${colors.bgCyan(`${colors.white(` Info `)}`)} ${contentAction}`);
97
- }
98
- static error(title, errorType, stackTrace, messageContent, httpCodeValue) {
99
- console.error(`${colors.red(`\u2718`)} ${colors.bgRed(` ${colors.bold(`${colors.white(`${title}`)}`)} `)} | ${dateTimeFormattedUtils} | [ ${colors.red(`${colors.bold(` ${errorType} `)}`)} ] | [ ${colors.bold(`stack trace`)} ] ${colors.red(`${stackTrace}`)} - ${colors.red(`${messageContent}`)} - [ ${colors.red(`${colors.bold(` HttpCode `)}`)} ] ${colors.red(`${colors.bold(` ${httpCodeValue} `)}`)} `);
100
- }
101
- static requestError(title, errorName, errorMessage, errorCode) {
102
- console.error(`[ ${colors.red(`${title}`)} ] ${dateTimeFormattedUtils} | ${colors.bgRed(`${colors.white(` ERROR `)}`)} ${colors.red(`[ ${errorName} ]`)} ${colors.red(`${errorMessage}`)} - [ Status ] ${colors.bgRed(`${colors.white(` ${errorCode} `)}`)}`);
103
- }
104
- };
105
-
106
- // src/core/helpers/modulesLoaded.utils.ts
167
+ import { HttpStatusCode, HttpStatusCode as status } from "opticore-http-response";
107
168
  import { TranslationLoader } from "opticore-translator";
108
- function modulesLoadedUtils(allAppRoutes, dbConChecker, localeLanguage) {
109
- LogMessageUtils.success(
110
- `${TranslationLoader.t("kernel", localeLanguage)}`,
111
- `${TranslationLoader.t("loadKernel", localeLanguage)}`,
112
- `${TranslationLoader.t("moduleAppLoaded", localeLanguage)}`
113
- );
114
- console.log(`${colors2.whiteBright(` ${TranslationLoader.t("content", localeLanguage)}`)} ${colors2.green(`${TranslationLoader.t("kernel", localeLanguage)} :`)} ${colors2.cyan(`${colors2.bold(`${TranslationLoader.t("serverSide", localeLanguage)}`)}`)} ${TranslationLoader.t("hasBeenLoadedSuccessfully", localeLanguage)} ${colors2.green(`\u2714`)}`);
115
- allAppRoutes ? console.log(`${colors2.whiteBright(` ${TranslationLoader.t("content", localeLanguage)}`)} ${colors2.green(`${TranslationLoader.t("kernel", localeLanguage)} :`)} ${colors2.cyan(`${colors2.bold(`${TranslationLoader.t("routerService", localeLanguage)}`)} `)} ${colors2.green(`\u2714`)}`) : console.log(`${colors2.red(`\u2718`)} ${colors2.bgRed(` ${colors2.bold(`${colors2.white(` ${TranslationLoader.t("registerRoutes", localeLanguage)} `)}`)} `)} | ${dateTimeFormattedUtils} | [ ${colors2.red(`${colors2.bold(` ${TranslationLoader.t("fail", localeLanguage)} `)}`)} ] | [ ${colors2.bold(` ${TranslationLoader.t("loading", localeLanguage)} `)} ] - ${colors2.red(` ${TranslationLoader.t("routers", localeLanguage)} `)} - ${TranslationLoader.t("registerLoadingFailed", localeLanguage)} `);
116
- 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`)}`) : "";
117
- }
118
-
119
- // src/application/service/traceError.service.ts
120
- import { StackTraceError } from "opticore-catch-exception-error";
121
- var STraceError = (props, name, httpCode, isOperational) => {
122
- return new StackTraceError(props, name, httpCode, isOperational);
123
- };
169
+ import { getEnvironnementValue } from "opticore-env-access";
124
170
 
125
171
  // src/utils/envPath.utils.ts
126
172
  import process2 from "process";
127
173
  var envPath = process2.cwd() + "/config/env/.env";
128
174
 
175
+ // src/application/service/loaderTranslationFile.service.ts
176
+ import { translationLoaderConfig } from "opticore-loader-translation";
177
+ var loaderTranslationFile = (localLanguage) => {
178
+ return translationLoaderConfig({
179
+ packageName: "opticore-webapp",
180
+ locationTranslationFile: ["utils", "translations"],
181
+ localLang: localLanguage
182
+ });
183
+ };
184
+
129
185
  // src/core/providers/dependencies.provider.ts
130
186
  import { SContainer } from "opticore-dependency-inject";
131
187
 
132
188
  // src/application/service/dependencies.service.ts
133
189
  import { LoggerCore } from "opticore-logger";
134
- import { serverLogger } from "opticore-server-logger";
190
+ import { OpticoreLogger } from "opticore-server-logger";
135
191
  var dependencies = [
136
192
  {
137
193
  key: "LoggerCore",
@@ -139,8 +195,8 @@ var dependencies = [
139
195
  scope: "singleton"
140
196
  },
141
197
  {
142
- key: "serverLogger",
143
- factory: () => new serverLogger(),
198
+ key: "OpticoreLogger",
199
+ factory: () => new OpticoreLogger(),
144
200
  scope: "singleton"
145
201
  }
146
202
  ];
@@ -150,33 +206,33 @@ var dependenciesContainerProvider = (localLang) => {
150
206
  return new SContainer(localLang, dependencies);
151
207
  };
152
208
 
209
+ // src/application/service/core.service.ts
210
+ import { LoggerCore as LoggerCore2 } from "opticore-logger";
211
+
153
212
  // src/application/service/logger.service.ts
154
213
  var SLogger = (localLang) => {
155
- const serverLog = dependenciesContainerProvider(localLang).resolve("serverLogger");
156
- const logger = dependenciesContainerProvider(localLang).resolve("LoggerCore");
157
214
  return {
158
- serverLog,
159
- logger
215
+ get serverLog() {
216
+ return dependenciesContainerProvider(localLang).resolve("OpticoreLogger");
217
+ },
218
+ get logger() {
219
+ return dependenciesContainerProvider(localLang).resolve("LoggerCore");
220
+ }
160
221
  };
161
222
  };
162
223
 
163
- // src/application/service/loaderTranslationFile.service.ts
164
- import { translationLoaderConfig } from "opticore-loader-translation";
165
- var loaderTranslationFile = (localLanguage) => {
166
- return translationLoaderConfig({
167
- packageName: "opticore-webapp",
168
- locationTranslationFile: ["utils", "translations"],
169
- localLang: localLanguage
170
- });
171
- };
172
-
173
224
  // src/application/service/core.service.ts
174
225
  var CoreService = class {
175
226
  localLanguage;
176
227
  environmentPath;
228
+ serverLog;
229
+ logger;
177
230
  constructor(localLang, environmentPath) {
178
231
  this.environmentPath = environmentPath;
179
232
  this.localLanguage = localLang;
233
+ loaderTranslationFile(this.localLanguage);
234
+ this.serverLog = dependenciesContainerProvider(localLang).resolve("OpticoreLogger");
235
+ this.logger = dependenciesContainerProvider(localLang).resolve("LoggerCore");
180
236
  }
181
237
  /**
182
238
  *
@@ -215,20 +271,20 @@ var CoreService = class {
215
271
  loaderTranslationFile(this.localLanguage);
216
272
  const memoryData = process3.memoryUsage();
217
273
  const data = {
218
- [TranslationLoader2.t("totalMemoryAllocated", this.localLanguage)]: this.formatMemoryUsage(memoryData.rss),
219
- [TranslationLoader2.t("sizeAllocatedHeap", this.localLanguage)]: this.formatMemoryUsage(memoryData.heapTotal),
220
- [TranslationLoader2.t("memoryUsedExecution", this.localLanguage)]: this.formatMemoryUsage(memoryData.heapUsed),
221
- [TranslationLoader2.t("externalMemory", this.localLanguage)]: this.formatMemoryUsage(memoryData.external),
222
- [TranslationLoader2.t("memoryUsageUser", this.localLanguage)]: this.formatMemoryUsage(process3.cpuUsage().user),
223
- [TranslationLoader2.t("memoryUsageSystem", this.localLanguage)]: this.formatMemoryUsage(process3.cpuUsage().system)
274
+ [TranslationLoader.t("totalMemoryAllocated", this.localLanguage)]: this.formatMemoryUsage(memoryData.rss),
275
+ [TranslationLoader.t("sizeAllocatedHeap", this.localLanguage)]: this.formatMemoryUsage(memoryData.heapTotal),
276
+ [TranslationLoader.t("memoryUsedExecution", this.localLanguage)]: this.formatMemoryUsage(memoryData.heapUsed),
277
+ [TranslationLoader.t("externalMemory", this.localLanguage)]: this.formatMemoryUsage(memoryData.external),
278
+ [TranslationLoader.t("memoryUsageUser", this.localLanguage)]: this.formatMemoryUsage(process3.cpuUsage().user),
279
+ [TranslationLoader.t("memoryUsageSystem", this.localLanguage)]: this.formatMemoryUsage(process3.cpuUsage().system)
224
280
  };
225
281
  return {
226
- "rss": data[TranslationLoader2.t("totalMemoryAllocated", this.localLanguage)],
227
- "heapTotal": data[TranslationLoader2.t("sizeAllocatedHeap", this.localLanguage)],
228
- "heapUsed": data[TranslationLoader2.t("memoryUsedExecution", this.localLanguage)],
229
- "external": data[TranslationLoader2.t("externalMemory", this.localLanguage)],
230
- "user": data[TranslationLoader2.t("memoryUsageUser", this.localLanguage)],
231
- "system": data[TranslationLoader2.t("memoryUsageSystem", this.localLanguage)],
282
+ "rss": data[TranslationLoader.t("totalMemoryAllocated", this.localLanguage)],
283
+ "heapTotal": data[TranslationLoader.t("sizeAllocatedHeap", this.localLanguage)],
284
+ "heapUsed": data[TranslationLoader.t("memoryUsedExecution", this.localLanguage)],
285
+ "external": data[TranslationLoader.t("externalMemory", this.localLanguage)],
286
+ "user": data[TranslationLoader.t("memoryUsageUser", this.localLanguage)],
287
+ "system": data[TranslationLoader.t("memoryUsageSystem", this.localLanguage)],
232
288
  "pid": process3.pid
233
289
  };
234
290
  }
@@ -266,12 +322,12 @@ var CoreService = class {
266
322
  });
267
323
  }
268
324
  } catch (err) {
269
- SLogger(this.localLanguage).logger.error({
325
+ this.logger.error({
270
326
  message: err.message,
271
- title: TranslationLoader2.t("EnvFileLoading", this.localLanguage),
327
+ title: TranslationLoader.t("EnvFileLoading", this.localLanguage),
272
328
  errorType: err.code,
273
329
  stackTrace: err.stack,
274
- httpCodeValue: HttpStatusCode.INTERNAL_SERVER_ERROR
330
+ httpCodeValue: status.INTERNAL_SERVER_ERROR
275
331
  });
276
332
  }
277
333
  }
@@ -289,37 +345,37 @@ var CoreService = class {
289
345
  const env = getEnvironnementValue(path.join(envPath));
290
346
  const isDevelopment = env.devEnv === development && env.prodEnv === "";
291
347
  if (isDevelopment) {
292
- return `${TranslationLoader2.t("serverRunning", this.localLanguage)} ${colors3.bgBlue(`${colors3.bold(`${development}`)}`)} mode`;
348
+ return `${TranslationLoader.t("serverRunning", this.localLanguage)} ${colors.bgBlue(`${colors.bold(`${development}`)}`)} mode`;
293
349
  } else if (!isDevelopment) {
294
- return `${TranslationLoader2.t("serverRunning", this.localLanguage)} ${colors3.bgBlue(`${colors3.bold(`${production}`)}`)} mode`;
350
+ return `${TranslationLoader.t("serverRunning", this.localLanguage)} ${colors.bgBlue(`${colors.bold(`${production}`)}`)} mode`;
295
351
  } else {
296
- return `${TranslationLoader2.t("serverRunning", this.localLanguage)} ${colors3.bgBlue(`${colors3.bold(`${development}`)}`)} mode`;
352
+ return `${TranslationLoader.t("serverRunning", this.localLanguage)} ${colors.bgBlue(`${colors.bold(`${development}`)}`)} mode`;
297
353
  }
298
354
  } catch (err) {
299
- SLogger(this.localLanguage).logger.error({
355
+ this.logger.error({
300
356
  message: err.message,
301
- title: TranslationLoader2.t("serverRunning mode", this.localLanguage),
357
+ title: TranslationLoader.t("serverRunning mode", this.localLanguage),
302
358
  errorType: err.code,
303
359
  stackTrace: err.stack,
304
- httpCodeValue: HttpStatusCode.INTERNAL_SERVER_ERROR
360
+ httpCodeValue: status.INTERNAL_SERVER_ERROR
305
361
  });
306
362
  }
307
363
  }
308
- infoServer(nodeVersion, startingTime, host, port) {
364
+ infoServer(host, port) {
309
365
  try {
310
366
  loaderTranslationFile(this.localLanguage);
311
367
  const getEnvironment = getEnvironnementValue(this.environmentPath);
312
- const msg5 = getEnvironment.protocolTransfert === "" ? colors3.underline(`http://${host}:${port}`) : colors3.underline(`${getEnvironment.protocolTransfert}://${host}:${port}`);
368
+ const msg5 = getEnvironment.protocolTransfert === "" ? colors.underline(`http://${host}:${port}`) : colors.underline(`${getEnvironment.protocolTransfert}://${host}:${port}`);
313
369
  const messages = [
314
- TranslationLoader2.t("webServerListening", this.localLanguage),
315
- TranslationLoader2.t("webServerUsingNodeVersion", this.localLanguage, { nodeVersion: this.getVersions().nodeVersion }),
316
- TranslationLoader2.t("startTime", this.localLanguage, { startTime: this.getProjectInfo().startingTime }),
317
- this.getServerRunningMode(TranslationLoader2.t("runningModeDev", this.localLanguage), TranslationLoader2.t("runningModeProd", this.localLanguage))
370
+ TranslationLoader.t("webServerListening", this.localLanguage),
371
+ TranslationLoader.t("webServerUsingNodeVersion", this.localLanguage, { nodeVersion: this.getVersions().nodeVersion }),
372
+ TranslationLoader.t("startTime", this.localLanguage, { startTime: this.getProjectInfo().startingTime }),
373
+ this.getServerRunningMode(TranslationLoader.t("runningModeDev", this.localLanguage), TranslationLoader.t("runningModeProd", this.localLanguage))
318
374
  ];
319
375
  const maxLength = Math.max(...messages.map((m) => {
320
376
  return m.replace(/\u001b\[[0-9]{1,2}m/g, "").length;
321
377
  })) + 4;
322
- console.log(chalk.blackBright(`${TranslationLoader2.t("tailingServerLog", this.localLanguage)} (${path.join(path.basename(process3.cwd()), "logs", "app.log")})`));
378
+ console.log(chalk.blackBright(`${TranslationLoader.t("tailingServerLog", this.localLanguage)} (${path.join(path.basename(process3.cwd()), "logs", "app.log")})`));
323
379
  const border = chalk.bgGreen.white(" ".repeat(maxLength));
324
380
  console.log(border);
325
381
  messages.forEach((msg) => {
@@ -329,51 +385,33 @@ var CoreService = class {
329
385
  });
330
386
  console.log(border);
331
387
  console.log("\n");
388
+ const logCore = new LoggerCore2();
389
+ logCore.success({
390
+ title: TranslationLoader.t("serverRunningTitle", this.localLanguage),
391
+ message: TranslationLoader.t("serverRunningAt", this.localLanguage, { server: msg5 })
392
+ });
332
393
  SLogger(this.localLanguage).serverLog.serverLog({
333
394
  timestamp: (/* @__PURE__ */ new Date()).toString(),
334
395
  level: "SERVER",
335
- title: TranslationLoader2.t("serverRunningTitle", this.localLanguage),
336
- typeName: TranslationLoader2.t("opticoreServerTypeName", this.localLanguage),
337
- message: TranslationLoader2.t("serverRunningAt", this.localLanguage, { server: msg5 })
396
+ title: TranslationLoader.t("serverRunningTitle", this.localLanguage),
397
+ typeName: TranslationLoader.t("opticoreServerTypeName", this.localLanguage),
398
+ message: TranslationLoader.t("serverRunningAt", this.localLanguage, { server: msg5 })
338
399
  });
339
400
  } catch (err) {
340
401
  SLogger(this.localLanguage).logger.error({
341
402
  message: err.message,
342
- title: TranslationLoader2.t("server", this.localLanguage),
403
+ title: TranslationLoader.t("server", this.localLanguage),
343
404
  errorType: err.code,
344
405
  stackTrace: err.stack,
345
406
  httpCodeValue: HttpStatusCode.INTERNAL_SERVER_ERROR
346
407
  });
347
408
  }
348
409
  }
349
- coreListenerEventLoaderModuleService(kernelModule) {
350
- loaderTranslationFile(this.localLanguage);
351
- let router = [];
352
- let dbCon;
353
- kernelModule.forEach((module) => {
354
- if (Array.isArray(module)) {
355
- router = module;
356
- } else if (typeof module === "function") {
357
- dbCon = module;
358
- }
359
- });
360
- if (router && dbCon) {
361
- modulesLoadedUtils(router, dbCon, this.localLanguage);
362
- (() => {
363
- dbCon();
364
- })();
365
- } else {
366
- const stackTrace = STraceError(
367
- TranslationLoader2.t("loadedModulesError", this.localLanguage),
368
- TranslationLoader2.t("loadedModules", this.localLanguage),
369
- status.NOT_ACCEPTABLE,
370
- true
371
- );
372
- throw new Error(stackTrace.message);
373
- }
374
- }
375
410
  };
376
411
 
412
+ // src/core/helpers/dateTimeFormatted.utils.ts
413
+ var dateTimeFormattedUtils = `${(/* @__PURE__ */ new Date()).getMonth()}-${(/* @__PURE__ */ new Date()).getDate()}-${(/* @__PURE__ */ new Date()).getFullYear()} ${(/* @__PURE__ */ new Date()).getHours()}:${(/* @__PURE__ */ new Date()).getMinutes()}:${(/* @__PURE__ */ new Date()).getSeconds()}`;
414
+
377
415
  // src/application/service/serverStartError.service.ts
378
416
  import {
379
417
  CCodeError,
@@ -414,110 +452,146 @@ var SServerStartError = (err, environmentPath) => {
414
452
  import { requestCallsEvent } from "opticore-request-call-event";
415
453
  import { SContainer as SContainer2 } from "opticore-dependency-inject";
416
454
  import { HttpStatusCode as HttpStatusCode3 } from "opticore-http-response";
417
- import { TranslationLoader as TranslationLoader3 } from "opticore-translator";
455
+ import { TranslationLoader as TranslationLoader2 } from "opticore-translator";
418
456
  var WebServerCore = class {
419
457
  serverUtility;
420
- expressApp = express2();
458
+ expressApp = express();
421
459
  localLanguage;
422
460
  loggerConfig;
423
461
  routerExpressApp;
424
462
  getEnvironment;
425
463
  environmentPath;
426
464
  serverListenEvent;
427
- constructor(app, loggerConfig, localLanguage, environmentPath, corsOriginOptions) {
428
- this.stackTraceErrorHandling(localLanguage);
429
- this.getEnvironment = getEnvironnementValue2(environmentPath);
430
- this.routerExpressApp = app;
431
- this.loggerConfig = loggerConfig;
432
- this.localLanguage = localLanguage;
433
- this.environmentPath = environmentPath;
434
- this.expressApp.use(express2.json());
435
- this.expressApp.use(express2.raw());
436
- this.expressApp.use(express2.text());
437
- this.expressApp.use(express2.urlencoded({ extended: true }));
438
- this.expressApp.use(corsOrigin(corsOriginOptions));
439
- this.serverListenEvent = new ServerListenEventError2(localLanguage);
440
- this.serverUtility = new CoreService(localLanguage, environmentPath);
441
- }
442
- /**
443
- *
444
- * @param dependencies
445
- */
446
- registerDependencies(dependencies2) {
447
- try {
448
- dependenciesContainerProvider(this.localLanguage).getServices();
449
- } catch (err) {
450
- SLogger(this.localLanguage).logger.error({
451
- message: err.message,
452
- title: TranslationLoader3.t("registerDependencies", this.localLanguage),
453
- errorType: err.code,
454
- stackTrace: err.stack,
455
- httpCodeValue: HttpStatusCode3.INTERNAL_SERVER_ERROR
456
- });
457
- }
465
+ currentRoutes = [];
466
+ currentDependencies = [];
467
+ server = void 0;
468
+ errorEmitter;
469
+ // ✅✅✅ ÉTAT DU SERVEUR
470
+ serverState = "READY";
471
+ lastError = null;
472
+ // Statistiques
473
+ hotReloadAttempts = 0;
474
+ hotReloadSuccesses = 0;
475
+ hotReloadFailures = 0;
476
+ constructor(paramsConstructor) {
477
+ this.getEnvironment = getEnvironnementValue2(paramsConstructor.environmentPath);
478
+ this.routerExpressApp = paramsConstructor.app;
479
+ this.loggerConfig = paramsConstructor.loggerConfig;
480
+ this.localLanguage = paramsConstructor.localLanguage;
481
+ this.environmentPath = paramsConstructor.environmentPath;
482
+ this.expressApp.use(express.json());
483
+ this.expressApp.use(express.raw());
484
+ this.expressApp.use(express.text());
485
+ this.expressApp.use(express.urlencoded({ extended: true }));
486
+ this.expressApp.use(corsOrigin(paramsConstructor.corsOriginOptions));
487
+ this.serverListenEvent = new ServerListenEventError2(paramsConstructor.localLanguage);
488
+ this.serverUtility = new CoreService(paramsConstructor.localLanguage, paramsConstructor.environmentPath);
489
+ this.setupSignalHandlers();
490
+ this.setupIPCHandlers();
458
491
  }
459
- /**
460
- *
461
- * @param routers
462
- * @param databaseCallback
463
- * @param dependenciesProvider
464
- */
465
492
  onStartServer(routers, databaseCallback, dependenciesProvider) {
466
493
  loaderTranslationFile(this.localLanguage);
494
+ this.currentRoutes = routers;
495
+ this.currentDependencies = dependenciesProvider || [];
467
496
  if (this.getEnvironment.appPort === "" && Number(this.getEnvironment.appPort) === 0) {
468
497
  this.serverListenEvent.hostPortUndefined(Number(this.getEnvironment.appPort));
469
- } else if (this.getEnvironment.appHost === "") {
498
+ return void 0;
499
+ }
500
+ if (this.getEnvironment.appHost === "") {
470
501
  this.serverListenEvent.hostUndefined(this.getEnvironment.appHost);
471
- } else if (Number(this.getEnvironment.appPort) === 0) {
502
+ return void 0;
503
+ }
504
+ if (Number(this.getEnvironment.appPort) === 0) {
472
505
  this.serverListenEvent.portUndefined();
473
- } else if (this.localLanguage === "") {
506
+ return void 0;
507
+ }
508
+ if (this.localLanguage === "") {
474
509
  SLogger(this.localLanguage).logger.error({
475
- message: TranslationLoader3.t("noDefaultLocalLang", this.localLanguage),
476
- title: TranslationLoader3.t("noLocalLang", this.localLanguage),
477
- errorType: TranslationLoader3.t("localLangMissing", this.localLanguage),
510
+ message: TranslationLoader2.t("noDefaultLocalLang", this.localLanguage),
511
+ title: TranslationLoader2.t("noLocalLang", this.localLanguage),
512
+ errorType: TranslationLoader2.t("localLangMissing", this.localLanguage),
478
513
  stackTrace: void 0,
479
514
  httpCodeValue: HttpStatusCode3.NOT_FOUND
480
515
  });
481
- } else {
482
- return this.expressApp.listen(
483
- Number(this.getEnvironment.appPort),
484
- () => {
485
- loaderTranslationFile(this.localLanguage);
486
- try {
516
+ return void 0;
517
+ }
518
+ this.server = this.expressApp.listen(
519
+ Number(this.getEnvironment.appPort),
520
+ this.getEnvironment.appHost,
521
+ () => {
522
+ try {
523
+ SLogger(this.localLanguage).logger.info({
524
+ message: TranslationLoader2.t("HOT_RELOAD_READY", this.localLanguage),
525
+ title: TranslationLoader2.t("HOT_RELOAD", this.localLanguage)
526
+ });
527
+ if (databaseCallback) {
487
528
  databaseCallback(this.getEnvironment);
488
- new SContainer2(this.localLanguage, dependenciesProvider);
489
- this.expressApp.use(express2.static(path2.join(process4.cwd(), "public/template")));
490
- this.registerRoutes(routers);
491
- } catch (err) {
492
- SServerStartError(err, this.environmentPath);
493
529
  }
530
+ new SContainer2(this.localLanguage, this.currentDependencies);
531
+ this.expressApp.use(express.static(path2.join(process4.cwd(), "public/template")));
532
+ this.registerRoutes(this.currentRoutes);
533
+ this.setupErrorHandling();
534
+ this.setupServerEvents();
535
+ this.serverState = "READY";
536
+ this.infoWebApp();
537
+ this.notifyServerReady();
538
+ } catch (err) {
539
+ SLogger(this.localLanguage).logger.error({
540
+ title: TranslationLoader2.t("STARTUP_ERROR", this.localLanguage),
541
+ message: err.message,
542
+ errorType: err.code,
543
+ stackTrace: err.stackTrace,
544
+ httpCodeValue: HttpStatusCode3.INTERNAL_SERVER_ERROR
545
+ });
546
+ SServerStartError(err, this.environmentPath);
494
547
  }
495
- );
496
- }
548
+ }
549
+ );
550
+ return this.server;
497
551
  }
498
552
  /**
499
- *
500
- * @param serverWeb
553
+ * ✅✅✅ Configuration de la gestion d'erreurs
501
554
  */
502
- onListeningOnServerEvent(serverWeb) {
503
- loaderTranslationFile(this.localLanguage);
504
- serverWeb.on(eventName2.error, (err) => {
555
+ setupErrorHandling() {
556
+ SLogger(this.localLanguage).logger.info({
557
+ title: TranslationLoader2.t("SETTING_UP", this.localLanguage),
558
+ message: TranslationLoader2.t("SETTING_UP_ERROR", this.localLanguage)
559
+ });
560
+ this.errorEmitter = eventProcessHandler(this.localLanguage, this.expressApp);
561
+ if (this.errorEmitter) {
562
+ this.errorEmitter.on("transformError", (error) => {
563
+ SLogger(this.localLanguage).logger.info({
564
+ title: TranslationLoader2.t("", this.localLanguage),
565
+ message: TranslationLoader2.t("", this.localLanguage)
566
+ });
567
+ this.lastError = error;
568
+ this.serverState = "BLOCKED";
569
+ this.notifyWatcherBlockedByError(error);
570
+ });
571
+ this.errorEmitter.on("error", (error) => {
572
+ SLogger(this.localLanguage).logger.info({
573
+ title: TranslationLoader2.t("ERROR_EMITTED", this.localLanguage),
574
+ message: `Error emitted: ${error.message}`
575
+ });
576
+ });
577
+ }
578
+ SLogger(this.localLanguage).logger.info({
579
+ title: TranslationLoader2.t("ERROR_HANDLING", this.localLanguage),
580
+ message: TranslationLoader2.t("ERROR_HANDLING_CONFIGURED", this.localLanguage)
581
+ });
582
+ }
583
+ setupServerEvents() {
584
+ if (!this.server) return;
585
+ this.server.on(eventName2.error, (err) => {
505
586
  this.serverListenEvent.onEventError(err);
506
- }).on(eventName2.close, () => {
587
+ });
588
+ this.server.on(eventName2.close, () => {
507
589
  this.serverListenEvent.serverClosing();
508
- }).on(eventName2.drop, () => {
590
+ });
591
+ this.server.on(eventName2.drop, () => {
509
592
  this.serverListenEvent.dropNewConnection();
510
- }).on(eventName2.listening, () => {
511
- this.infoWebApp();
512
593
  });
513
- }
514
- /**
515
- *
516
- * @param serverWeb
517
- */
518
- onRequestOnServerEvent(serverWeb) {
519
- loaderTranslationFile(this.localLanguage);
520
- serverWeb.on(eventName2.request, (req, res) => {
594
+ this.server.on(eventName2.request, (req, res) => {
521
595
  requestCallsEvent(
522
596
  req,
523
597
  res,
@@ -529,38 +603,271 @@ var WebServerCore = class {
529
603
  );
530
604
  });
531
605
  }
606
+ notifyServerReady() {
607
+ setTimeout(() => {
608
+ if (process4.send) {
609
+ process4.send({
610
+ type: "SERVER_READY",
611
+ timestamp: Date.now(),
612
+ port: Number(this.getEnvironment.appPort),
613
+ host: this.getEnvironment.appHost,
614
+ message: "Server ready for hot reload"
615
+ });
616
+ }
617
+ }, 100);
618
+ }
619
+ setupSignalHandlers() {
620
+ process4.on("SIGHUP", async () => {
621
+ if (this.serverState === "READY") {
622
+ SLogger(this.localLanguage).logger.info({
623
+ title: TranslationLoader2.t("SIGHUP", this.localLanguage),
624
+ message: TranslationLoader2.t("RECEIVED_SIGHUP", this.localLanguage)
625
+ });
626
+ await this.performTrueHotReload();
627
+ }
628
+ });
629
+ process4.on("SIGTERM", () => {
630
+ SLogger(this.localLanguage).logger.info({
631
+ title: TranslationLoader2.t("SIGHUP", this.localLanguage),
632
+ message: TranslationLoader2.t("RECEIVED_SIGHUP", this.localLanguage)
633
+ });
634
+ this.shutdown();
635
+ });
636
+ process4.on("SIGINT", () => {
637
+ SLogger(this.localLanguage).logger.info({
638
+ title: TranslationLoader2.t("SIGINT", this.localLanguage),
639
+ message: TranslationLoader2.t("RECEIVED_SIGINT", this.localLanguage)
640
+ });
641
+ this.shutdown();
642
+ });
643
+ }
644
+ setupIPCHandlers() {
645
+ if (!process4.send) {
646
+ SLogger(this.localLanguage).logger.info({
647
+ title: TranslationLoader2.t("IPC", this.localLanguage),
648
+ message: TranslationLoader2.t("IPC_NOT_AVAILABLE", this.localLanguage)
649
+ });
650
+ return;
651
+ }
652
+ SLogger(this.localLanguage).logger.info({
653
+ title: TranslationLoader2.t("IPC_READY", this.localLanguage),
654
+ message: TranslationLoader2.t("IPC_READY_HOT_RELOAD", this.localLanguage)
655
+ });
656
+ process4.on("message", async (message) => {
657
+ if (message.type === "HOT_RELOAD_REQUEST") {
658
+ if (this.serverState === "BLOCKED") {
659
+ SLogger(this.localLanguage).logger.info({
660
+ title: TranslationLoader2.t("BLOCKED", this.localLanguage),
661
+ message: TranslationLoader2.t("BLOCKED_STATE", this.localLanguage)
662
+ });
663
+ return;
664
+ }
665
+ if (this.serverState === "READY") {
666
+ await this.performTrueHotReload();
667
+ }
668
+ }
669
+ });
670
+ }
532
671
  /**
533
- *
534
- * @param allFeatureRoutes
535
- * @private
672
+ * ✅✅✅ HOT RELOAD avec gestion d'état stricte
536
673
  */
537
- registerRoutes(allFeatureRoutes) {
538
- allFeatureRoutes.map((router) => {
539
- router.featureRoute.map((route) => {
540
- this.expressApp.use(route.path, route.handler);
541
- });
674
+ async performTrueHotReload() {
675
+ this.serverState = "RELOADING";
676
+ this.hotReloadAttempts++;
677
+ const startTime = Date.now();
678
+ SLogger(this.localLanguage).logger.info({
679
+ title: TranslationLoader2.t("RELOAD_STARTING", this.localLanguage),
680
+ message: TranslationLoader2.t("HOT_RELOAD_ATTEMPTED", this.localLanguage, { hotReloadAttempts: this.hotReloadAttempts })
542
681
  });
682
+ try {
683
+ const clearedModules = this.clearApplicationModulesCache();
684
+ SLogger(this.localLanguage).logger.info({
685
+ title: TranslationLoader2.t("APP_MODULES_CLEARED", this.localLanguage),
686
+ message: TranslationLoader2.t("CLEARED_MODULES", this.localLanguage, { clearedModules })
687
+ });
688
+ this.reloadConfigurations();
689
+ SLogger(this.localLanguage).logger.info({
690
+ title: TranslationLoader2.t("APP_MODULES_CLEARED", this.localLanguage),
691
+ message: TranslationLoader2.t("CLEARED_MODULES", this.localLanguage, { hotReloadAttempts: this.hotReloadAttempts })
692
+ });
693
+ this.reloadDependencies();
694
+ SLogger(this.localLanguage).logger.info({
695
+ title: TranslationLoader2.t("DEPENDENCIES", this.localLanguage),
696
+ message: TranslationLoader2.t("RELOAD_DEPENDENCIES", this.localLanguage)
697
+ });
698
+ const duration = Date.now() - startTime;
699
+ this.hotReloadSuccesses++;
700
+ this.serverState = "READY";
701
+ this.lastError = null;
702
+ SLogger(this.localLanguage).logger.info({
703
+ title: TranslationLoader2.t("RELOAD_SUCCESS", this.localLanguage),
704
+ message: TranslationLoader2.t("HOT_RELOAD_SUCCESS", this.localLanguage, { duration })
705
+ });
706
+ this.notifyWatcherReloadSuccess(duration);
707
+ } catch (error) {
708
+ this.hotReloadFailures++;
709
+ const duration = Date.now() - startTime;
710
+ SLogger(this.localLanguage).logger.info({
711
+ title: TranslationLoader2.t("RELOAD_FAILED", this.localLanguage),
712
+ message: TranslationLoader2.t("HOT_RELOAD_FAILED", this.localLanguage, { duration, errorMessage: error.message })
713
+ });
714
+ const isTransformError = error?.name === "TransformError" || error?.message?.includes("Transform failed") || error?.message?.includes("esbuild");
715
+ if (isTransformError) {
716
+ this.lastError = error;
717
+ this.serverState = "BLOCKED";
718
+ this.notifyWatcherBlockedByError(error);
719
+ } else {
720
+ this.serverState = "BLOCKED";
721
+ this.notifyWatcherReloadError(error);
722
+ }
723
+ }
543
724
  }
544
725
  /**
545
- *
546
- * @param localLanguage
547
- * @private
726
+ * Nettoie le cache des modules applicatifs
548
727
  */
549
- stackTraceErrorHandling(localLanguage) {
550
- eventProcessHandler(localLanguage);
728
+ clearApplicationModulesCache() {
729
+ const baseDirs = [
730
+ path2.join(process4.cwd(), "src"),
731
+ path2.join(process4.cwd(), "dist")
732
+ ];
733
+ let clearedCount = 0;
734
+ for (const key in __require.cache) {
735
+ const isApplicationModule = baseDirs.some((dir) => key.startsWith(dir));
736
+ const isNodeModule = key.includes("node_modules");
737
+ const isJsonFile = key.endsWith(".json");
738
+ if (isApplicationModule && !isNodeModule && !isJsonFile) {
739
+ delete __require.cache[key];
740
+ clearedCount++;
741
+ }
742
+ }
743
+ return clearedCount;
744
+ }
745
+ reloadConfigurations() {
746
+ try {
747
+ const newEnv = getEnvironnementValue2(this.environmentPath);
748
+ Object.keys(newEnv).forEach((key) => {
749
+ this.getEnvironment[key] = newEnv[key];
750
+ });
751
+ loaderTranslationFile(this.localLanguage);
752
+ } catch (error) {
753
+ throw new Error(`Configuration reload failed: ${error.message}`);
754
+ }
755
+ }
756
+ reloadDependencies() {
757
+ try {
758
+ new SContainer2(this.localLanguage, this.currentDependencies);
759
+ const container = dependenciesContainerProvider(this.localLanguage);
760
+ if (!container) {
761
+ throw new Error("Dependency container is not available");
762
+ }
763
+ } catch (error) {
764
+ throw new Error(`Dependency reload failed: ${error.message}`);
765
+ }
551
766
  }
552
767
  /**
553
- *
554
- * @private
768
+ * ✅✅✅ Notifier le watcher : SUCCÈS
769
+ */
770
+ notifyWatcherReloadSuccess(duration) {
771
+ if (process4.send && process4.env.WATCHER_MODE === "true") {
772
+ process4.send({
773
+ type: "HOT_RELOAD_SUCCESS",
774
+ timestamp: Date.now(),
775
+ duration,
776
+ serverState: this.serverState,
777
+ message: "Code reloaded successfully"
778
+ });
779
+ }
780
+ }
781
+ /**
782
+ * ✅✅✅ Notifier le watcher : BLOQUÉ PAR ERREUR TRANSFORM
783
+ */
784
+ notifyWatcherBlockedByError(error) {
785
+ if (process4.send && process4.env.WATCHER_MODE === "true") {
786
+ const errorDetails = this.parseTransformError(error);
787
+ process4.send({
788
+ type: "HOT_RELOAD_BLOCKED_BY_ERROR",
789
+ timestamp: Date.now(),
790
+ serverState: this.serverState,
791
+ error: {
792
+ message: error.message,
793
+ errorType: error.name || "TransformError",
794
+ file: errorDetails.file,
795
+ line: errorDetails.line,
796
+ column: errorDetails.column,
797
+ detail: errorDetails.errorDetail,
798
+ tool: errorDetails.tool
799
+ }
800
+ });
801
+ }
802
+ }
803
+ /**
804
+ * ✅✅✅ Notifier le watcher : ERREUR GÉNÉRIQUE
805
+ */
806
+ notifyWatcherReloadError(error) {
807
+ if (process4.send && process4.env.WATCHER_MODE === "true") {
808
+ process4.send({
809
+ type: "HOT_RELOAD_ERROR",
810
+ timestamp: Date.now(),
811
+ serverState: this.serverState,
812
+ error: error.message,
813
+ errorType: error.name || "UNKNOWN_ERROR"
814
+ });
815
+ }
816
+ }
817
+ /**
818
+ * ✅✅✅ Parser les détails d'une TransformError
555
819
  */
820
+ parseTransformError(error) {
821
+ const errorMessage = error.message || String(error);
822
+ let tool = "Unknown";
823
+ if (errorMessage.includes("esbuild")) tool = "esbuild";
824
+ if (errorMessage.includes("webpack")) tool = "webpack";
825
+ const fileMatch = errorMessage.match(/([^:\s]+\.(?:ts|js|tsx|jsx)):(\d+):(\d+):/);
826
+ const file = fileMatch ? fileMatch[1] : null;
827
+ const line = fileMatch ? parseInt(fileMatch[2], 10) : null;
828
+ const column = fileMatch ? parseInt(fileMatch[3], 10) : null;
829
+ const errorDetailMatch = errorMessage.match(/ERROR:\s*(.+?)(?:\n|$)/);
830
+ const errorDetail = errorDetailMatch ? errorDetailMatch[1].trim() : null;
831
+ return {
832
+ message: errorMessage,
833
+ file,
834
+ line,
835
+ column,
836
+ errorDetail,
837
+ tool
838
+ };
839
+ }
840
+ registerRoutes(allFeatureRoutes) {
841
+ allFeatureRoutes.forEach((router) => {
842
+ if (router.routes) {
843
+ router.routes.forEach((route) => {
844
+ this.expressApp.use(route.path, route.handler);
845
+ });
846
+ }
847
+ });
848
+ }
556
849
  infoWebApp() {
557
850
  this.serverUtility.infoServer(
558
- this.serverUtility.getVersions().nodeVersion,
559
- this.serverUtility.getProjectInfo().startingTime,
560
851
  this.getEnvironment.appHost,
561
852
  Number(this.getEnvironment.appPort)
562
853
  );
563
854
  }
855
+ shutdown() {
856
+ if (this.server) {
857
+ this.server.close(() => {
858
+ SLogger(this.localLanguage).logger.info({
859
+ title: TranslationLoader2.t("CLOSED", this.localLanguage),
860
+ message: TranslationLoader2.t("SERVER_CLOSED", this.localLanguage)
861
+ });
862
+ process4.exit(0);
863
+ });
864
+ setTimeout(() => {
865
+ process4.exit(1);
866
+ }, 5e3);
867
+ } else {
868
+ process4.exit(0);
869
+ }
870
+ }
564
871
  };
565
872
  export {
566
873
  WebServerCore as WebServer,