opticore-webapp 1.0.18 → 1.0.19
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 +34 -26
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +35 -27
- package/package.json +3 -3
- package/src/core/handlers/eventProcess.handler.ts +1 -1
- package/src/core/helpers/modulesLoaded.utils.ts +7 -7
- package/src/core/webServer.core.ts +28 -19
package/dist/index.cjs
CHANGED
|
@@ -45,7 +45,6 @@ var import_cors = __toESM(require("cors"), 1);
|
|
|
45
45
|
var import_opticore_catch_exception_error4 = require("opticore-catch-exception-error");
|
|
46
46
|
var import_opticore_express2 = require("opticore-express");
|
|
47
47
|
var import_opticore_env_access = require("opticore-env-access");
|
|
48
|
-
var import_opticore_requests_called_events = require("opticore-requests-called-events");
|
|
49
48
|
var import_opticore_translator4 = require("opticore-translator");
|
|
50
49
|
|
|
51
50
|
// src/core/handlers/eventProcess.handler.ts
|
|
@@ -144,13 +143,13 @@ var LogMessageUtils = class {
|
|
|
144
143
|
var import_opticore_translator = require("opticore-translator");
|
|
145
144
|
function modulesLoadedUtils(allAppRoutes, dbConChecker, localeLanguage) {
|
|
146
145
|
LogMessageUtils.success(
|
|
147
|
-
`${import_opticore_translator.TranslationLoader.t("kernel", localeLanguage
|
|
148
|
-
`${import_opticore_translator.TranslationLoader.t("loadKernel", localeLanguage
|
|
149
|
-
`${import_opticore_translator.TranslationLoader.t("moduleAppLoaded", localeLanguage
|
|
146
|
+
`${import_opticore_translator.TranslationLoader.t("kernel", localeLanguage)}`,
|
|
147
|
+
`${import_opticore_translator.TranslationLoader.t("loadKernel", localeLanguage)}`,
|
|
148
|
+
`${import_opticore_translator.TranslationLoader.t("moduleAppLoaded", localeLanguage)}`
|
|
150
149
|
);
|
|
151
|
-
console.log(`${import_ansi_colors2.default.whiteBright(` ${import_opticore_translator.TranslationLoader.t("content", localeLanguage
|
|
152
|
-
allAppRoutes ? console.log(`${import_ansi_colors2.default.whiteBright(` ${import_opticore_translator.TranslationLoader.t("content", localeLanguage
|
|
153
|
-
typeof dbConChecker == "function" ? console.log(`${import_ansi_colors2.default.whiteBright(` ${import_opticore_translator.TranslationLoader.t("content", localeLanguage
|
|
150
|
+
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("serverSide", localeLanguage)}`)}`)} ${import_opticore_translator.TranslationLoader.t("hasBeenLoadedSuccessfully", localeLanguage)} ${import_ansi_colors2.default.green(`\u2714`)}`);
|
|
151
|
+
allAppRoutes ? 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("routerService", localeLanguage)}`)} `)} ${import_ansi_colors2.default.green(`\u2714`)}`) : console.log(`${import_ansi_colors2.default.red(`\u2718`)} ${import_ansi_colors2.default.bgRed(` ${import_ansi_colors2.default.bold(`${import_ansi_colors2.default.white(` ${import_opticore_translator.TranslationLoader.t("registerRoutes", localeLanguage)} `)}`)} `)} | ${dateTimeFormattedUtils} | [ ${import_ansi_colors2.default.red(`${import_ansi_colors2.default.bold(` ${import_opticore_translator.TranslationLoader.t("fail", localeLanguage)} `)}`)} ] | [ ${import_ansi_colors2.default.bold(` ${import_opticore_translator.TranslationLoader.t("loading", localeLanguage)} `)} ] - ${import_ansi_colors2.default.red(` ${import_opticore_translator.TranslationLoader.t("routers", localeLanguage)} `)} - ${import_opticore_translator.TranslationLoader.t("registerLoadingFailed", localeLanguage)} `);
|
|
152
|
+
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`)}`) : "";
|
|
154
153
|
}
|
|
155
154
|
|
|
156
155
|
// src/application/service/core.service.ts
|
|
@@ -276,7 +275,7 @@ var CoreService = class {
|
|
|
276
275
|
console.log(`${`Memory usage by system :`} ${import_ansi_colors3.default.cyan(`${import_ansi_colors3.default.bold(`${system}`)}`)}`);
|
|
277
276
|
console.log(``);
|
|
278
277
|
}
|
|
279
|
-
coreListenerEventLoaderModuleService(kernelModule, localeLanguage,
|
|
278
|
+
coreListenerEventLoaderModuleService(kernelModule, localeLanguage, loggerConfig) {
|
|
280
279
|
let router = [];
|
|
281
280
|
let dbCon;
|
|
282
281
|
kernelModule.forEach((module2) => {
|
|
@@ -293,8 +292,8 @@ var CoreService = class {
|
|
|
293
292
|
})();
|
|
294
293
|
} else {
|
|
295
294
|
const stackTrace = new import_opticore_catch_exception_error2.StackTraceError(
|
|
296
|
-
import_opticore_translator2.TranslationLoader.t("loadedModulesError", localeLanguage,
|
|
297
|
-
import_opticore_translator2.TranslationLoader.t("loadedModules", localeLanguage,
|
|
295
|
+
import_opticore_translator2.TranslationLoader.t("loadedModulesError", localeLanguage, loggerConfig),
|
|
296
|
+
import_opticore_translator2.TranslationLoader.t("loadedModules", localeLanguage, loggerConfig),
|
|
298
297
|
import_opticore_http_response.HttpStatusCode.NOT_ACCEPTABLE,
|
|
299
298
|
true
|
|
300
299
|
);
|
|
@@ -417,26 +416,27 @@ var SServerStartError = (err) => {
|
|
|
417
416
|
};
|
|
418
417
|
|
|
419
418
|
// src/core/webServer.core.ts
|
|
419
|
+
var import_opticore_request_call_event = require("opticore-request-call-event");
|
|
420
420
|
var WebServerCore = class {
|
|
421
421
|
serverUtility = new CoreService();
|
|
422
422
|
expressApp = (0, import_opticore_express2.express)();
|
|
423
423
|
localLanguage;
|
|
424
424
|
loggerConfig;
|
|
425
425
|
routerExpressApp;
|
|
426
|
-
|
|
427
|
-
|
|
426
|
+
getEnvironnement;
|
|
427
|
+
environnementPath;
|
|
428
428
|
serverListenEvent;
|
|
429
429
|
javaScriptErrors;
|
|
430
430
|
internalErrors;
|
|
431
431
|
assertionErrors;
|
|
432
432
|
openSSLErrors;
|
|
433
433
|
systemErrors;
|
|
434
|
-
constructor(app,
|
|
435
|
-
this.
|
|
436
|
-
this.host = import_opticore_env_access.getEnvVariable.appHost;
|
|
434
|
+
constructor(app, loggerConfig, localLanguage, environnementPath, corsOriginOptions) {
|
|
435
|
+
this.getEnvironnement = (0, import_opticore_env_access.getEnvironnementValue)(environnementPath);
|
|
437
436
|
this.routerExpressApp = app;
|
|
438
|
-
this.loggerConfig =
|
|
437
|
+
this.loggerConfig = loggerConfig;
|
|
439
438
|
this.localLanguage = localLanguage;
|
|
439
|
+
this.environnementPath = environnementPath;
|
|
440
440
|
this.expressApp.use(import_opticore_express2.express.json());
|
|
441
441
|
this.expressApp.use(import_opticore_express2.express.raw());
|
|
442
442
|
this.expressApp.use(import_opticore_express2.express.text());
|
|
@@ -453,15 +453,15 @@ var WebServerCore = class {
|
|
|
453
453
|
}
|
|
454
454
|
onStartServer(routers) {
|
|
455
455
|
return this.expressApp.listen(
|
|
456
|
-
this.
|
|
457
|
-
this.
|
|
456
|
+
this.getEnvironnement.appHost,
|
|
457
|
+
this.getEnvironnement.appPort,
|
|
458
458
|
() => {
|
|
459
459
|
try {
|
|
460
|
-
if (this.
|
|
461
|
-
this.serverListenEvent.hostPortUndefined(this.
|
|
462
|
-
} else if (this.
|
|
463
|
-
this.serverListenEvent.hostUndefined(this.
|
|
464
|
-
} else if (this.
|
|
460
|
+
if (this.getEnvironnement.appHost === "" && this.getEnvironnement.appPort === 0) {
|
|
461
|
+
this.serverListenEvent.hostPortUndefined(this.getEnvironnement.appPort);
|
|
462
|
+
} else if (this.getEnvironnement.appHost === "") {
|
|
463
|
+
this.serverListenEvent.hostUndefined(this.getEnvironnement.appHost);
|
|
464
|
+
} else if (this.getEnvironnement.appPort === 0) {
|
|
465
465
|
this.serverListenEvent.portUndefined();
|
|
466
466
|
} else {
|
|
467
467
|
this.registerRoutes(routers);
|
|
@@ -486,7 +486,15 @@ var WebServerCore = class {
|
|
|
486
486
|
}
|
|
487
487
|
onRequestOnServerEvent(serverWeb) {
|
|
488
488
|
serverWeb.on(import_opticore_catch_exception_error4.CEventNameError.request, (req, res) => {
|
|
489
|
-
(0,
|
|
489
|
+
(0, import_opticore_request_call_event.requestCallsEvent)(
|
|
490
|
+
req,
|
|
491
|
+
res,
|
|
492
|
+
this.getEnvironnement.appHost,
|
|
493
|
+
this.getEnvironnement.appPort,
|
|
494
|
+
dateTimeFormattedUtils,
|
|
495
|
+
this.environnementPath,
|
|
496
|
+
this.localLanguage
|
|
497
|
+
);
|
|
490
498
|
});
|
|
491
499
|
}
|
|
492
500
|
translationWebAppLoader() {
|
|
@@ -509,8 +517,8 @@ var WebServerCore = class {
|
|
|
509
517
|
this.serverUtility.infoServer(
|
|
510
518
|
this.serverUtility.getVersions().nodeVersion,
|
|
511
519
|
this.serverUtility.getProjectInfo().startingTime,
|
|
512
|
-
|
|
513
|
-
Number(
|
|
520
|
+
this.getEnvironnement.appHost,
|
|
521
|
+
Number(this.getEnvironnement.appPort),
|
|
514
522
|
this.serverUtility.getUsageMemory().rss,
|
|
515
523
|
this.serverUtility.getUsageMemory().heapUsed,
|
|
516
524
|
this.serverUtility.getUsageMemory().user,
|
package/dist/index.d.cts
CHANGED
|
@@ -14,15 +14,15 @@ declare class WebServerCore {
|
|
|
14
14
|
private readonly localLanguage;
|
|
15
15
|
private readonly loggerConfig;
|
|
16
16
|
private readonly routerExpressApp;
|
|
17
|
-
private readonly
|
|
18
|
-
private readonly
|
|
17
|
+
private readonly getEnvironnement;
|
|
18
|
+
private readonly environnementPath;
|
|
19
19
|
private serverListenEvent;
|
|
20
20
|
private javaScriptErrors;
|
|
21
21
|
private internalErrors;
|
|
22
22
|
private assertionErrors;
|
|
23
23
|
private openSSLErrors;
|
|
24
24
|
private systemErrors;
|
|
25
|
-
constructor(app: express.Application, loggerConfig: LoggerCore, localLanguage: string, corsOriginOptions?: Partial<CorsOptions>);
|
|
25
|
+
constructor(app: express.Application, loggerConfig: LoggerCore, localLanguage: string, environnementPath: any, corsOriginOptions?: Partial<CorsOptions>);
|
|
26
26
|
onStartServer(routers: {
|
|
27
27
|
featureRoute: IRouteDefinition[];
|
|
28
28
|
}[]): any;
|
package/dist/index.d.ts
CHANGED
|
@@ -14,15 +14,15 @@ declare class WebServerCore {
|
|
|
14
14
|
private readonly localLanguage;
|
|
15
15
|
private readonly loggerConfig;
|
|
16
16
|
private readonly routerExpressApp;
|
|
17
|
-
private readonly
|
|
18
|
-
private readonly
|
|
17
|
+
private readonly getEnvironnement;
|
|
18
|
+
private readonly environnementPath;
|
|
19
19
|
private serverListenEvent;
|
|
20
20
|
private javaScriptErrors;
|
|
21
21
|
private internalErrors;
|
|
22
22
|
private assertionErrors;
|
|
23
23
|
private openSSLErrors;
|
|
24
24
|
private systemErrors;
|
|
25
|
-
constructor(app: express.Application, loggerConfig: LoggerCore, localLanguage: string, corsOriginOptions?: Partial<CorsOptions>);
|
|
25
|
+
constructor(app: express.Application, loggerConfig: LoggerCore, localLanguage: string, environnementPath: any, corsOriginOptions?: Partial<CorsOptions>);
|
|
26
26
|
onStartServer(routers: {
|
|
27
27
|
featureRoute: IRouteDefinition[];
|
|
28
28
|
}[]): any;
|
package/dist/index.js
CHANGED
|
@@ -12,8 +12,7 @@ import {
|
|
|
12
12
|
SystemErrors
|
|
13
13
|
} from "opticore-catch-exception-error";
|
|
14
14
|
import { express as express2 } from "opticore-express";
|
|
15
|
-
import {
|
|
16
|
-
import { requestCallsEvent } from "opticore-requests-called-events";
|
|
15
|
+
import { getEnvironnementValue } from "opticore-env-access";
|
|
17
16
|
import { TranslationLoader as TranslationLoader4 } from "opticore-translator";
|
|
18
17
|
|
|
19
18
|
// src/core/handlers/eventProcess.handler.ts
|
|
@@ -116,13 +115,13 @@ var LogMessageUtils = class {
|
|
|
116
115
|
import { TranslationLoader } from "opticore-translator";
|
|
117
116
|
function modulesLoadedUtils(allAppRoutes, dbConChecker, localeLanguage) {
|
|
118
117
|
LogMessageUtils.success(
|
|
119
|
-
`${TranslationLoader.t("kernel", localeLanguage
|
|
120
|
-
`${TranslationLoader.t("loadKernel", localeLanguage
|
|
121
|
-
`${TranslationLoader.t("moduleAppLoaded", localeLanguage
|
|
118
|
+
`${TranslationLoader.t("kernel", localeLanguage)}`,
|
|
119
|
+
`${TranslationLoader.t("loadKernel", localeLanguage)}`,
|
|
120
|
+
`${TranslationLoader.t("moduleAppLoaded", localeLanguage)}`
|
|
122
121
|
);
|
|
123
|
-
console.log(`${colors2.whiteBright(` ${TranslationLoader.t("content", localeLanguage
|
|
124
|
-
allAppRoutes ? console.log(`${colors2.whiteBright(` ${TranslationLoader.t("content", localeLanguage
|
|
125
|
-
typeof dbConChecker == "function" ? console.log(`${colors2.whiteBright(` ${TranslationLoader.t("content", localeLanguage
|
|
122
|
+
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`)}`);
|
|
123
|
+
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)} `);
|
|
124
|
+
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`)}`) : "";
|
|
126
125
|
}
|
|
127
126
|
|
|
128
127
|
// src/application/service/core.service.ts
|
|
@@ -248,7 +247,7 @@ var CoreService = class {
|
|
|
248
247
|
console.log(`${`Memory usage by system :`} ${colors3.cyan(`${colors3.bold(`${system}`)}`)}`);
|
|
249
248
|
console.log(``);
|
|
250
249
|
}
|
|
251
|
-
coreListenerEventLoaderModuleService(kernelModule, localeLanguage,
|
|
250
|
+
coreListenerEventLoaderModuleService(kernelModule, localeLanguage, loggerConfig) {
|
|
252
251
|
let router = [];
|
|
253
252
|
let dbCon;
|
|
254
253
|
kernelModule.forEach((module) => {
|
|
@@ -265,8 +264,8 @@ var CoreService = class {
|
|
|
265
264
|
})();
|
|
266
265
|
} else {
|
|
267
266
|
const stackTrace = new StackTraceError(
|
|
268
|
-
TranslationLoader2.t("loadedModulesError", localeLanguage,
|
|
269
|
-
TranslationLoader2.t("loadedModules", localeLanguage,
|
|
267
|
+
TranslationLoader2.t("loadedModulesError", localeLanguage, loggerConfig),
|
|
268
|
+
TranslationLoader2.t("loadedModules", localeLanguage, loggerConfig),
|
|
270
269
|
status.NOT_ACCEPTABLE,
|
|
271
270
|
true
|
|
272
271
|
);
|
|
@@ -389,26 +388,27 @@ var SServerStartError = (err) => {
|
|
|
389
388
|
};
|
|
390
389
|
|
|
391
390
|
// src/core/webServer.core.ts
|
|
391
|
+
import { requestCallsEvent } from "opticore-request-call-event";
|
|
392
392
|
var WebServerCore = class {
|
|
393
393
|
serverUtility = new CoreService();
|
|
394
394
|
expressApp = express2();
|
|
395
395
|
localLanguage;
|
|
396
396
|
loggerConfig;
|
|
397
397
|
routerExpressApp;
|
|
398
|
-
|
|
399
|
-
|
|
398
|
+
getEnvironnement;
|
|
399
|
+
environnementPath;
|
|
400
400
|
serverListenEvent;
|
|
401
401
|
javaScriptErrors;
|
|
402
402
|
internalErrors;
|
|
403
403
|
assertionErrors;
|
|
404
404
|
openSSLErrors;
|
|
405
405
|
systemErrors;
|
|
406
|
-
constructor(app,
|
|
407
|
-
this.
|
|
408
|
-
this.host = getEnvVariable.appHost;
|
|
406
|
+
constructor(app, loggerConfig, localLanguage, environnementPath, corsOriginOptions) {
|
|
407
|
+
this.getEnvironnement = getEnvironnementValue(environnementPath);
|
|
409
408
|
this.routerExpressApp = app;
|
|
410
|
-
this.loggerConfig =
|
|
409
|
+
this.loggerConfig = loggerConfig;
|
|
411
410
|
this.localLanguage = localLanguage;
|
|
411
|
+
this.environnementPath = environnementPath;
|
|
412
412
|
this.expressApp.use(express2.json());
|
|
413
413
|
this.expressApp.use(express2.raw());
|
|
414
414
|
this.expressApp.use(express2.text());
|
|
@@ -425,15 +425,15 @@ var WebServerCore = class {
|
|
|
425
425
|
}
|
|
426
426
|
onStartServer(routers) {
|
|
427
427
|
return this.expressApp.listen(
|
|
428
|
-
this.
|
|
429
|
-
this.
|
|
428
|
+
this.getEnvironnement.appHost,
|
|
429
|
+
this.getEnvironnement.appPort,
|
|
430
430
|
() => {
|
|
431
431
|
try {
|
|
432
|
-
if (this.
|
|
433
|
-
this.serverListenEvent.hostPortUndefined(this.
|
|
434
|
-
} else if (this.
|
|
435
|
-
this.serverListenEvent.hostUndefined(this.
|
|
436
|
-
} else if (this.
|
|
432
|
+
if (this.getEnvironnement.appHost === "" && this.getEnvironnement.appPort === 0) {
|
|
433
|
+
this.serverListenEvent.hostPortUndefined(this.getEnvironnement.appPort);
|
|
434
|
+
} else if (this.getEnvironnement.appHost === "") {
|
|
435
|
+
this.serverListenEvent.hostUndefined(this.getEnvironnement.appHost);
|
|
436
|
+
} else if (this.getEnvironnement.appPort === 0) {
|
|
437
437
|
this.serverListenEvent.portUndefined();
|
|
438
438
|
} else {
|
|
439
439
|
this.registerRoutes(routers);
|
|
@@ -458,7 +458,15 @@ var WebServerCore = class {
|
|
|
458
458
|
}
|
|
459
459
|
onRequestOnServerEvent(serverWeb) {
|
|
460
460
|
serverWeb.on(eventName2.request, (req, res) => {
|
|
461
|
-
requestCallsEvent(
|
|
461
|
+
requestCallsEvent(
|
|
462
|
+
req,
|
|
463
|
+
res,
|
|
464
|
+
this.getEnvironnement.appHost,
|
|
465
|
+
this.getEnvironnement.appPort,
|
|
466
|
+
dateTimeFormattedUtils,
|
|
467
|
+
this.environnementPath,
|
|
468
|
+
this.localLanguage
|
|
469
|
+
);
|
|
462
470
|
});
|
|
463
471
|
}
|
|
464
472
|
translationWebAppLoader() {
|
|
@@ -481,8 +489,8 @@ var WebServerCore = class {
|
|
|
481
489
|
this.serverUtility.infoServer(
|
|
482
490
|
this.serverUtility.getVersions().nodeVersion,
|
|
483
491
|
this.serverUtility.getProjectInfo().startingTime,
|
|
484
|
-
|
|
485
|
-
Number(
|
|
492
|
+
this.getEnvironnement.appHost,
|
|
493
|
+
Number(this.getEnvironnement.appPort),
|
|
486
494
|
this.serverUtility.getUsageMemory().rss,
|
|
487
495
|
this.serverUtility.getUsageMemory().heapUsed,
|
|
488
496
|
this.serverUtility.getUsageMemory().user,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opticore-webapp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.19",
|
|
4
4
|
"description": "wep server",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
"dotenv": "^16.4.7",
|
|
31
31
|
"gradient-string": "^2.0.2",
|
|
32
32
|
"opticore-catch-exception-error": "^1.0.17",
|
|
33
|
-
"opticore-env-access": "^1.0.
|
|
33
|
+
"opticore-env-access": "^1.0.5",
|
|
34
34
|
"opticore-express": "^1.0.3",
|
|
35
35
|
"opticore-http-response": "^1.0.3",
|
|
36
36
|
"opticore-logger": "^1.0.13",
|
|
37
|
-
"opticore-
|
|
37
|
+
"opticore-request-call-event": "^1.0.1",
|
|
38
38
|
"opticore-router": "^1.0.10",
|
|
39
39
|
"opticore-translator": "^1.0.7",
|
|
40
40
|
"opticore-validator": "^1.0.3"
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
export function eventProcessHandler(localeLanguage: string): void {
|
|
16
16
|
const errorEmitter = new EventEmitter();
|
|
17
17
|
const app = express();
|
|
18
|
-
const serverListenEvent = new ServerListenEventError(localeLanguage);
|
|
18
|
+
const serverListenEvent: ServerListenEventError = new ServerListenEventError(localeLanguage);
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Listener for error events
|
|
@@ -9,15 +9,15 @@ import { LoggerCore } from "opticore-logger";
|
|
|
9
9
|
|
|
10
10
|
export function modulesLoadedUtils(allAppRoutes: Router[], dbConChecker: () => void, localeLanguage: string): void {
|
|
11
11
|
LogMessageUtils.success(
|
|
12
|
-
`${TranslationLoader.t("kernel", localeLanguage
|
|
13
|
-
`${TranslationLoader.t("loadKernel", localeLanguage
|
|
14
|
-
`${TranslationLoader.t("moduleAppLoaded", localeLanguage
|
|
12
|
+
`${TranslationLoader.t("kernel", localeLanguage)}`,
|
|
13
|
+
`${TranslationLoader.t("loadKernel", localeLanguage)}`,
|
|
14
|
+
`${TranslationLoader.t("moduleAppLoaded", localeLanguage)}`
|
|
15
15
|
);
|
|
16
|
-
console.log(`${colors.whiteBright(` ${TranslationLoader.t("content", localeLanguage
|
|
16
|
+
console.log(`${colors.whiteBright(` ${TranslationLoader.t("content", localeLanguage)}`)} ${colors.green(`${TranslationLoader.t("kernel", localeLanguage)} :`)} ${colors.cyan(`${colors.bold(`${TranslationLoader.t("serverSide", localeLanguage)}`)}`)} ${TranslationLoader.t("hasBeenLoadedSuccessfully", localeLanguage)} ${colors.green(`✔`)}`);
|
|
17
17
|
allAppRoutes
|
|
18
|
-
? console.log(`${colors.whiteBright(` ${TranslationLoader.t("content", localeLanguage
|
|
19
|
-
: console.log(`${colors.red(`✘`)} ${colors.bgRed(` ${colors.bold(`${colors.white(` ${TranslationLoader.t("registerRoutes", localeLanguage
|
|
18
|
+
? console.log(`${colors.whiteBright(` ${TranslationLoader.t("content", localeLanguage)}`)} ${colors.green(`${TranslationLoader.t("kernel", localeLanguage)} :`)} ${colors.cyan(`${colors.bold(`${TranslationLoader.t("routerService", localeLanguage)}`)} `)} ${colors.green(`✔`)}`)
|
|
19
|
+
: console.log(`${colors.red(`✘`)} ${colors.bgRed(` ${colors.bold(`${colors.white(` ${TranslationLoader.t("registerRoutes", localeLanguage)} `)}`)} `)} | ${dateTimeFormattedUtils} | [ ${colors.red(`${colors.bold(` ${TranslationLoader.t("fail", localeLanguage)} `)}`)} ] | [ ${colors.bold(` ${TranslationLoader.t("loading", localeLanguage)} `)} ] - ${colors.red(` ${TranslationLoader.t("routers", localeLanguage)} `)} - ${TranslationLoader.t("registerLoadingFailed", localeLanguage)} `);
|
|
20
20
|
typeof dbConChecker == "function"
|
|
21
|
-
? console.log(`${colors.whiteBright(` ${TranslationLoader.t("content", localeLanguage
|
|
21
|
+
? console.log(`${colors.whiteBright(` ${TranslationLoader.t("content", localeLanguage)}`)} ${colors.green(`${TranslationLoader.t("kernel", localeLanguage)} :`)} ${colors.cyan(`${colors.bold(`${TranslationLoader.t("dbConnChecker", localeLanguage)}`)}`)} ${TranslationLoader.t("hasBeenLoadedSuccessfully", localeLanguage)} ${colors.green(`✔`)}`)
|
|
22
22
|
: "";
|
|
23
23
|
}
|
|
@@ -16,8 +16,7 @@ import {
|
|
|
16
16
|
StackTraceError,
|
|
17
17
|
} from "opticore-catch-exception-error";
|
|
18
18
|
import { express } from "opticore-express";
|
|
19
|
-
import {
|
|
20
|
-
import { requestCallsEvent } from "opticore-requests-called-events";
|
|
19
|
+
import { getEnvironnementValue } from "opticore-env-access";
|
|
21
20
|
import { TranslationLoader } from "opticore-translator";
|
|
22
21
|
import { LoggerCore } from "opticore-logger";
|
|
23
22
|
|
|
@@ -26,32 +25,34 @@ import { eventProcessHandler } from "@webApp/core/handlers/eventProcess.handler"
|
|
|
26
25
|
import { CoreService } from "@webApp/application/service/core.service";
|
|
27
26
|
import { dateTimeFormattedUtils as currentDate } from "@webApp/core/helpers/dateTimeFormatted.utils";
|
|
28
27
|
import { SServerStartError } from "@webApp/application/service/serverStartError.service";
|
|
28
|
+
import {requestCallsEvent} from "opticore-request-call-event";
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
export class WebServerCore {
|
|
32
32
|
private serverUtility: CoreService = new CoreService();
|
|
33
|
-
|
|
34
33
|
private expressApp = express();
|
|
35
34
|
|
|
36
35
|
private readonly localLanguage: string;
|
|
37
36
|
private readonly loggerConfig: LoggerCore;
|
|
38
37
|
private readonly routerExpressApp: express.Application;
|
|
39
|
-
private readonly
|
|
40
|
-
private readonly
|
|
41
|
-
|
|
38
|
+
private readonly getEnvironnement: any;
|
|
39
|
+
private readonly environnementPath: string;
|
|
40
|
+
|
|
42
41
|
private serverListenEvent: ServerListenEventError;
|
|
43
42
|
private javaScriptErrors: JavaScriptErrors;
|
|
44
43
|
private internalErrors: InternalErrors;
|
|
45
44
|
private assertionErrors: AssertionErrors;
|
|
46
45
|
private openSSLErrors: OpenSSLErrors;
|
|
47
46
|
private systemErrors: SystemErrors;
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
constructor(app: express.Application, loggerConfig: LoggerCore, localLanguage: string, environnementPath: any, corsOriginOptions?: Partial<CorsOptions>) {
|
|
50
|
+
this.getEnvironnement = getEnvironnementValue(environnementPath);
|
|
48
51
|
|
|
49
|
-
constructor(app: express.Application, loggerConfig: LoggerCore, localLanguage: string, corsOriginOptions?: Partial<CorsOptions>) {
|
|
50
|
-
this.port = Number(getEnvVariable.appPort);
|
|
51
|
-
this.host = getEnvVariable.appHost;
|
|
52
52
|
this.routerExpressApp = app;
|
|
53
53
|
this.loggerConfig = loggerConfig;
|
|
54
54
|
this.localLanguage = localLanguage;
|
|
55
|
+
this.environnementPath = environnementPath;
|
|
55
56
|
|
|
56
57
|
this.expressApp.use(express.json());
|
|
57
58
|
this.expressApp.use(express.raw());
|
|
@@ -73,15 +74,15 @@ export class WebServerCore {
|
|
|
73
74
|
|
|
74
75
|
public onStartServer(routers: { featureRoute: IRouteDefinition[] }[]) {
|
|
75
76
|
return this.expressApp.listen(
|
|
76
|
-
this.
|
|
77
|
-
this.
|
|
77
|
+
this.getEnvironnement.appHost,
|
|
78
|
+
this.getEnvironnement.appPort,
|
|
78
79
|
(): void => {
|
|
79
80
|
try {
|
|
80
|
-
if (this.
|
|
81
|
-
this.serverListenEvent.hostPortUndefined(this.
|
|
82
|
-
} else if (this.
|
|
83
|
-
this.serverListenEvent.hostUndefined(this.
|
|
84
|
-
} else if (this.
|
|
81
|
+
if (this.getEnvironnement.appHost === "" && this.getEnvironnement.appPort === 0) {
|
|
82
|
+
this.serverListenEvent.hostPortUndefined(this.getEnvironnement.appPort);
|
|
83
|
+
} else if (this.getEnvironnement.appHost === "") {
|
|
84
|
+
this.serverListenEvent.hostUndefined(this.getEnvironnement.appHost);
|
|
85
|
+
} else if (this.getEnvironnement.appPort === 0) {
|
|
85
86
|
this.serverListenEvent.portUndefined();
|
|
86
87
|
} else {
|
|
87
88
|
this.registerRoutes(routers);
|
|
@@ -109,7 +110,15 @@ export class WebServerCore {
|
|
|
109
110
|
|
|
110
111
|
public onRequestOnServerEvent(serverWeb: serverWebApp): void {
|
|
111
112
|
serverWeb.on(eventName.request, (req: IncomingMessage, res: ServerResponse): void => {
|
|
112
|
-
requestCallsEvent(
|
|
113
|
+
requestCallsEvent(
|
|
114
|
+
req,
|
|
115
|
+
res,
|
|
116
|
+
this.getEnvironnement.appHost,
|
|
117
|
+
this.getEnvironnement.appPort,
|
|
118
|
+
currentDate,
|
|
119
|
+
this.environnementPath,
|
|
120
|
+
this.localLanguage
|
|
121
|
+
);
|
|
113
122
|
});
|
|
114
123
|
}
|
|
115
124
|
|
|
@@ -134,8 +143,8 @@ export class WebServerCore {
|
|
|
134
143
|
this.serverUtility.infoServer(
|
|
135
144
|
this.serverUtility.getVersions().nodeVersion,
|
|
136
145
|
this.serverUtility.getProjectInfo().startingTime,
|
|
137
|
-
|
|
138
|
-
Number(
|
|
146
|
+
this.getEnvironnement.appHost,
|
|
147
|
+
Number(this.getEnvironnement.appPort),
|
|
139
148
|
this.serverUtility.getUsageMemory().rss,
|
|
140
149
|
this.serverUtility.getUsageMemory().heapUsed,
|
|
141
150
|
this.serverUtility.getUsageMemory().user,
|