opticore-webapp 1.0.31 → 1.0.33

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
@@ -47,7 +47,7 @@ var import_module2 = require("module");
47
47
  var import_cors = __toESM(require("cors"), 1);
48
48
  var import_opticore_catch_exception_error4 = require("opticore-catch-exception-error");
49
49
  var import_opticore_express2 = require("opticore-express");
50
- var import_opticore_env_access3 = require("opticore-env-access");
50
+ var import_opticore_env_access4 = require("opticore-env-access");
51
51
  var import_opticore_translator5 = require("opticore-translator");
52
52
 
53
53
  // src/core/handlers/eventProcess.handler.ts
@@ -218,6 +218,7 @@ var CoreService = class {
218
218
  *
219
219
  * @param data
220
220
  * @private
221
+ *
221
222
  * Return a string converted in MegaBytes
222
223
  */
223
224
  formatMemoryUsage(data) {
@@ -281,6 +282,8 @@ var CoreService = class {
281
282
  *
282
283
  * @param filePath
283
284
  * @private
285
+ *
286
+ * Return void
284
287
  */
285
288
  getEnvFileLoading(filePath) {
286
289
  const fullPath = path2.resolve(import_node_process2.default.cwd(), filePath);
@@ -300,6 +303,8 @@ var CoreService = class {
300
303
  *
301
304
  * @param development
302
305
  * @param production
306
+ *
307
+ * Return string
303
308
  */
304
309
  getServerRunningMode(development, production) {
305
310
  this.getEnvFileLoading(".env");
@@ -320,13 +325,13 @@ var CoreService = class {
320
325
  const msg3Value = `${import_ansi_colors3.default.bgBlue(`${import_ansi_colors3.default.bold(`${startingTime}`)}`)}`;
321
326
  const msg3 = ` ${import_opticore_translator3.TranslationLoader.t("startTime", this.localLanguage)}`;
322
327
  const msg4 = ` ${this.getServerRunningMode(`${import_opticore_translator3.TranslationLoader.t("runningModeDev", this.localLanguage)}`, `${import_opticore_translator3.TranslationLoader.t("runningModeProd", this.localLanguage)}`)}`;
323
- const msg5 = getEnvironnement.protocolTransfert === "" ? "http" : ` ${import_ansi_colors3.default.underline(`${getEnvironnement.protocolTransfert}://${host}:${port}`)}`;
328
+ const msg5 = getEnvironnement.protocolTransfert === "" ? ` ${import_ansi_colors3.default.underline(`http://${host}:${port}`)}` : ` ${import_ansi_colors3.default.underline(`${getEnvironnement.protocolTransfert}://${host}:${port}`)}`;
324
329
  console.log(import_chalk.default.bgGreen.white(msg0.padEnd(paddingLength, " ")));
325
330
  console.log(import_chalk.default.bgGreen.white(msg1.padEnd(paddingLength, " ")));
326
- console.log(import_chalk.default.bgGreen.white(msg2, msg2Value.padEnd(30.5, " ")));
327
- console.log(import_chalk.default.bgGreen.white(msg3, msg3Value.padEnd(56, " ")));
328
- console.log(import_chalk.default.bgGreen.white(msg4.padEnd(71, " ")));
329
- console.log(import_chalk.default.bgGreen.white(msg5.padEnd(61, " ")));
331
+ console.log(import_chalk.default.bgGreen.white(msg2, msg2Value.padEnd(paddingLength, " ")));
332
+ console.log(import_chalk.default.bgGreen.white(msg3, msg3Value.padEnd(paddingLength, " ")));
333
+ console.log(import_chalk.default.bgGreen.white(msg4.padEnd(paddingLength, " ")));
334
+ console.log(import_chalk.default.bgGreen.white(msg5.padEnd(paddingLength, " ")));
330
335
  console.log(import_chalk.default.bgGreen.white(msg0.padEnd(paddingLength, " ")));
331
336
  console.log(``);
332
337
  }
@@ -477,6 +482,27 @@ var SServerStartError = (err, javaScriptErrors, systemErrors, openSSLErrors, int
477
482
 
478
483
  // src/core/webServer.core.ts
479
484
  var import_opticore_request_call_event = require("opticore-request-call-event");
485
+
486
+ // src/application/service/logger.service.ts
487
+ var import_opticore_logger2 = require("opticore-logger");
488
+ var SLogger = () => {
489
+ return new import_opticore_logger2.LoggerCore();
490
+ };
491
+
492
+ // src/application/service/dependenciesContainer.service.ts
493
+ var import_opticore_inject_dependency = require("opticore-inject-dependency");
494
+ var import_opticore_env_access3 = require("opticore-env-access");
495
+
496
+ // src/utils/envPath.utils.ts
497
+ var import_process = __toESM(require("process"), 1);
498
+ var envPath = import_process.default.cwd() + "/config/env/.env";
499
+
500
+ // src/application/service/dependenciesContainer.service.ts
501
+ var SDependenciesContainer = (dependenciesProvider) => {
502
+ return new import_opticore_inject_dependency.SContainer(dependenciesProvider, (0, import_opticore_env_access3.getEnvironnementValue)(envPath).defaultLocal);
503
+ };
504
+
505
+ // src/core/webServer.core.ts
480
506
  var WebServerCore = class {
481
507
  serverUtility;
482
508
  expressApp = (0, import_opticore_express2.express)();
@@ -492,7 +518,7 @@ var WebServerCore = class {
492
518
  openSSLErrors;
493
519
  systemErrors;
494
520
  constructor(app, loggerConfig2, localLanguage, environnementPath, corsOriginOptions) {
495
- this.getEnvironnement = (0, import_opticore_env_access3.getEnvironnementValue)(environnementPath);
521
+ this.getEnvironnement = (0, import_opticore_env_access4.getEnvironnementValue)(environnementPath);
496
522
  this.routerExpressApp = app;
497
523
  this.loggerConfig = loggerConfig2;
498
524
  this.localLanguage = localLanguage;
@@ -512,36 +538,40 @@ var WebServerCore = class {
512
538
  this.stackTraceErrorHandling(localLanguage);
513
539
  this.translationWebAppLoader();
514
540
  }
515
- onStartServer(routers, dbConnexion, dependenciesContainerService) {
516
- return this.expressApp.listen(
517
- Number(this.getEnvironnement.appPort),
518
- () => {
519
- try {
520
- if (this.getEnvironnement.appHost === "" && Number(this.getEnvironnement.appPort) === 0) {
521
- this.serverListenEvent.hostPortUndefined(Number(this.getEnvironnement.appPort));
522
- } else if (this.getEnvironnement.appHost === "") {
523
- this.serverListenEvent.hostUndefined(this.getEnvironnement.appHost);
524
- } else if (Number(this.getEnvironnement.appPort) === 0) {
525
- this.serverListenEvent.portUndefined();
526
- } else {
541
+ onStartServer(routers, dbConnexion, dependenciesProvider) {
542
+ if (this.getEnvironnement.appHost === "" && Number(this.getEnvironnement.appPort) === 0) {
543
+ this.serverListenEvent.hostPortUndefined(Number(this.getEnvironnement.appPort));
544
+ } else if (this.getEnvironnement.appHost === "") {
545
+ this.serverListenEvent.hostUndefined(this.getEnvironnement.appHost);
546
+ } else if (Number(this.getEnvironnement.appPort) === 0) {
547
+ this.serverListenEvent.portUndefined();
548
+ } else if (this.localLanguage === "") {
549
+ SLogger().error(
550
+ import_opticore_translator5.TranslationLoader.t("", this.localLanguage)
551
+ );
552
+ } else {
553
+ return this.expressApp.listen(
554
+ Number(this.getEnvironnement.appPort),
555
+ () => {
556
+ try {
527
557
  dbConnexion;
528
- dependenciesContainerService;
558
+ SDependenciesContainer(dependenciesProvider);
529
559
  this.expressApp.use(import_opticore_express2.express.static(path3.join(import_node_process3.default.cwd(), "public/template")));
530
560
  this.registerRoutes(routers);
561
+ } catch (err) {
562
+ SServerStartError(
563
+ err,
564
+ this.javaScriptErrors,
565
+ this.systemErrors,
566
+ this.openSSLErrors,
567
+ this.internalErrors,
568
+ this.loggerConfig,
569
+ this.localLanguage
570
+ );
531
571
  }
532
- } catch (err) {
533
- SServerStartError(
534
- err,
535
- this.javaScriptErrors,
536
- this.systemErrors,
537
- this.openSSLErrors,
538
- this.internalErrors,
539
- this.loggerConfig,
540
- this.localLanguage
541
- );
542
572
  }
543
- }
544
- );
573
+ );
574
+ }
545
575
  }
546
576
  onListeningOnServerEvent(serverWeb) {
547
577
  serverWeb.on(import_opticore_catch_exception_error4.CEventNameError.error, (err) => {
@@ -593,22 +623,10 @@ var WebServerCore = class {
593
623
  }
594
624
  };
595
625
 
596
- // src/utils/envPath.utils.ts
597
- var import_process = __toESM(require("process"), 1);
598
- var envPath = import_process.default.cwd() + "/config/env/.env";
599
-
600
626
  // src/utils/stopServer.utils.ts
601
627
  var import_dotenv = __toESM(require("dotenv"), 1);
602
628
  var import_child_process = require("child_process");
603
629
  var import_opticore_translator6 = require("opticore-translator");
604
-
605
- // src/application/service/logger.service.ts
606
- var import_opticore_logger2 = require("opticore-logger");
607
- var SLogger = () => {
608
- return new import_opticore_logger2.LoggerCore();
609
- };
610
-
611
- // src/utils/stopServer.utils.ts
612
630
  var UStopServer = () => {
613
631
  import_dotenv.default.config();
614
632
  const port = process.env.PORT;
package/dist/index.d.cts CHANGED
@@ -2,7 +2,7 @@ import { CorsOptions } from 'cors';
2
2
  import { Server } from 'http';
3
3
  import { Router, express } from 'opticore-express';
4
4
  import { LoggerCore } from 'opticore-logger';
5
- import { SContainer } from 'opticore-inject-dependency';
5
+ import { TDependency } from 'opticore-inject-dependency';
6
6
 
7
7
  interface IRouteDefinition {
8
8
  path: string;
@@ -28,7 +28,7 @@ declare class WebServerCore {
28
28
  private readonly openSSLErrors;
29
29
  private readonly systemErrors;
30
30
  constructor(app: express.Application, loggerConfig: LoggerCore, localLanguage: string, environnementPath: any, corsOriginOptions?: Partial<CorsOptions>);
31
- onStartServer(routers: TFeatureRoutes[], dbConnexion: (envPath: any, optionalArgumentConnection?: string | any) => void, dependenciesContainerService: () => SContainer): any;
31
+ onStartServer(routers: TFeatureRoutes[], dbConnexion: (envPath: any, optionalArgumentConnection?: string | any) => void, dependenciesProvider?: TDependency[]): any;
32
32
  onListeningOnServerEvent(serverWeb: Server): void;
33
33
  onRequestOnServerEvent(serverWeb: Server): void;
34
34
  private translationWebAppLoader;
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { CorsOptions } from 'cors';
2
2
  import { Server } from 'http';
3
3
  import { Router, express } from 'opticore-express';
4
4
  import { LoggerCore } from 'opticore-logger';
5
- import { SContainer } from 'opticore-inject-dependency';
5
+ import { TDependency } from 'opticore-inject-dependency';
6
6
 
7
7
  interface IRouteDefinition {
8
8
  path: string;
@@ -28,7 +28,7 @@ declare class WebServerCore {
28
28
  private readonly openSSLErrors;
29
29
  private readonly systemErrors;
30
30
  constructor(app: express.Application, loggerConfig: LoggerCore, localLanguage: string, environnementPath: any, corsOriginOptions?: Partial<CorsOptions>);
31
- onStartServer(routers: TFeatureRoutes[], dbConnexion: (envPath: any, optionalArgumentConnection?: string | any) => void, dependenciesContainerService: () => SContainer): any;
31
+ onStartServer(routers: TFeatureRoutes[], dbConnexion: (envPath: any, optionalArgumentConnection?: string | any) => void, dependenciesProvider?: TDependency[]): any;
32
32
  onListeningOnServerEvent(serverWeb: Server): void;
33
33
  onRequestOnServerEvent(serverWeb: Server): void;
34
34
  private translationWebAppLoader;
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/core/webServer.core.ts
2
2
  import * as path3 from "path";
3
- import process4 from "node:process";
3
+ import process5 from "node:process";
4
4
  import { createRequire as createRequire2 } from "module";
5
5
  import corsOrigin from "cors";
6
6
  import {
@@ -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 as getEnvironnementValue3 } from "opticore-env-access";
16
+ import { getEnvironnementValue as getEnvironnementValue4 } from "opticore-env-access";
17
17
  import { TranslationLoader as TranslationLoader5 } from "opticore-translator";
18
18
 
19
19
  // src/core/handlers/eventProcess.handler.ts
@@ -188,6 +188,7 @@ var CoreService = class {
188
188
  *
189
189
  * @param data
190
190
  * @private
191
+ *
191
192
  * Return a string converted in MegaBytes
192
193
  */
193
194
  formatMemoryUsage(data) {
@@ -251,6 +252,8 @@ var CoreService = class {
251
252
  *
252
253
  * @param filePath
253
254
  * @private
255
+ *
256
+ * Return void
254
257
  */
255
258
  getEnvFileLoading(filePath) {
256
259
  const fullPath = path2.resolve(process3.cwd(), filePath);
@@ -270,6 +273,8 @@ var CoreService = class {
270
273
  *
271
274
  * @param development
272
275
  * @param production
276
+ *
277
+ * Return string
273
278
  */
274
279
  getServerRunningMode(development, production) {
275
280
  this.getEnvFileLoading(".env");
@@ -290,13 +295,13 @@ var CoreService = class {
290
295
  const msg3Value = `${colors3.bgBlue(`${colors3.bold(`${startingTime}`)}`)}`;
291
296
  const msg3 = ` ${TranslationLoader3.t("startTime", this.localLanguage)}`;
292
297
  const msg4 = ` ${this.getServerRunningMode(`${TranslationLoader3.t("runningModeDev", this.localLanguage)}`, `${TranslationLoader3.t("runningModeProd", this.localLanguage)}`)}`;
293
- const msg5 = getEnvironnement.protocolTransfert === "" ? "http" : ` ${colors3.underline(`${getEnvironnement.protocolTransfert}://${host}:${port}`)}`;
298
+ const msg5 = getEnvironnement.protocolTransfert === "" ? ` ${colors3.underline(`http://${host}:${port}`)}` : ` ${colors3.underline(`${getEnvironnement.protocolTransfert}://${host}:${port}`)}`;
294
299
  console.log(chalk.bgGreen.white(msg0.padEnd(paddingLength, " ")));
295
300
  console.log(chalk.bgGreen.white(msg1.padEnd(paddingLength, " ")));
296
- console.log(chalk.bgGreen.white(msg2, msg2Value.padEnd(30.5, " ")));
297
- console.log(chalk.bgGreen.white(msg3, msg3Value.padEnd(56, " ")));
298
- console.log(chalk.bgGreen.white(msg4.padEnd(71, " ")));
299
- console.log(chalk.bgGreen.white(msg5.padEnd(61, " ")));
301
+ console.log(chalk.bgGreen.white(msg2, msg2Value.padEnd(paddingLength, " ")));
302
+ console.log(chalk.bgGreen.white(msg3, msg3Value.padEnd(paddingLength, " ")));
303
+ console.log(chalk.bgGreen.white(msg4.padEnd(paddingLength, " ")));
304
+ console.log(chalk.bgGreen.white(msg5.padEnd(paddingLength, " ")));
300
305
  console.log(chalk.bgGreen.white(msg0.padEnd(paddingLength, " ")));
301
306
  console.log(``);
302
307
  }
@@ -447,6 +452,27 @@ var SServerStartError = (err, javaScriptErrors, systemErrors, openSSLErrors, int
447
452
 
448
453
  // src/core/webServer.core.ts
449
454
  import { requestCallsEvent } from "opticore-request-call-event";
455
+
456
+ // src/application/service/logger.service.ts
457
+ import { LoggerCore as LoggerCore2 } from "opticore-logger";
458
+ var SLogger = () => {
459
+ return new LoggerCore2();
460
+ };
461
+
462
+ // src/application/service/dependenciesContainer.service.ts
463
+ import { SContainer } from "opticore-inject-dependency";
464
+ import { getEnvironnementValue as getEnvironnementValue3 } from "opticore-env-access";
465
+
466
+ // src/utils/envPath.utils.ts
467
+ import process4 from "process";
468
+ var envPath = process4.cwd() + "/config/env/.env";
469
+
470
+ // src/application/service/dependenciesContainer.service.ts
471
+ var SDependenciesContainer = (dependenciesProvider) => {
472
+ return new SContainer(dependenciesProvider, getEnvironnementValue3(envPath).defaultLocal);
473
+ };
474
+
475
+ // src/core/webServer.core.ts
450
476
  var WebServerCore = class {
451
477
  serverUtility;
452
478
  expressApp = express2();
@@ -462,7 +488,7 @@ var WebServerCore = class {
462
488
  openSSLErrors;
463
489
  systemErrors;
464
490
  constructor(app, loggerConfig2, localLanguage, environnementPath, corsOriginOptions) {
465
- this.getEnvironnement = getEnvironnementValue3(environnementPath);
491
+ this.getEnvironnement = getEnvironnementValue4(environnementPath);
466
492
  this.routerExpressApp = app;
467
493
  this.loggerConfig = loggerConfig2;
468
494
  this.localLanguage = localLanguage;
@@ -482,36 +508,40 @@ var WebServerCore = class {
482
508
  this.stackTraceErrorHandling(localLanguage);
483
509
  this.translationWebAppLoader();
484
510
  }
485
- onStartServer(routers, dbConnexion, dependenciesContainerService) {
486
- return this.expressApp.listen(
487
- Number(this.getEnvironnement.appPort),
488
- () => {
489
- try {
490
- if (this.getEnvironnement.appHost === "" && Number(this.getEnvironnement.appPort) === 0) {
491
- this.serverListenEvent.hostPortUndefined(Number(this.getEnvironnement.appPort));
492
- } else if (this.getEnvironnement.appHost === "") {
493
- this.serverListenEvent.hostUndefined(this.getEnvironnement.appHost);
494
- } else if (Number(this.getEnvironnement.appPort) === 0) {
495
- this.serverListenEvent.portUndefined();
496
- } else {
511
+ onStartServer(routers, dbConnexion, dependenciesProvider) {
512
+ if (this.getEnvironnement.appHost === "" && Number(this.getEnvironnement.appPort) === 0) {
513
+ this.serverListenEvent.hostPortUndefined(Number(this.getEnvironnement.appPort));
514
+ } else if (this.getEnvironnement.appHost === "") {
515
+ this.serverListenEvent.hostUndefined(this.getEnvironnement.appHost);
516
+ } else if (Number(this.getEnvironnement.appPort) === 0) {
517
+ this.serverListenEvent.portUndefined();
518
+ } else if (this.localLanguage === "") {
519
+ SLogger().error(
520
+ TranslationLoader5.t("", this.localLanguage)
521
+ );
522
+ } else {
523
+ return this.expressApp.listen(
524
+ Number(this.getEnvironnement.appPort),
525
+ () => {
526
+ try {
497
527
  dbConnexion;
498
- dependenciesContainerService;
499
- this.expressApp.use(express2.static(path3.join(process4.cwd(), "public/template")));
528
+ SDependenciesContainer(dependenciesProvider);
529
+ this.expressApp.use(express2.static(path3.join(process5.cwd(), "public/template")));
500
530
  this.registerRoutes(routers);
531
+ } catch (err) {
532
+ SServerStartError(
533
+ err,
534
+ this.javaScriptErrors,
535
+ this.systemErrors,
536
+ this.openSSLErrors,
537
+ this.internalErrors,
538
+ this.loggerConfig,
539
+ this.localLanguage
540
+ );
501
541
  }
502
- } catch (err) {
503
- SServerStartError(
504
- err,
505
- this.javaScriptErrors,
506
- this.systemErrors,
507
- this.openSSLErrors,
508
- this.internalErrors,
509
- this.loggerConfig,
510
- this.localLanguage
511
- );
512
542
  }
513
- }
514
- );
543
+ );
544
+ }
515
545
  }
516
546
  onListeningOnServerEvent(serverWeb) {
517
547
  serverWeb.on(eventName2.error, (err) => {
@@ -563,22 +593,10 @@ var WebServerCore = class {
563
593
  }
564
594
  };
565
595
 
566
- // src/utils/envPath.utils.ts
567
- import process5 from "process";
568
- var envPath = process5.cwd() + "/config/env/.env";
569
-
570
596
  // src/utils/stopServer.utils.ts
571
597
  import dotenv from "dotenv";
572
598
  import { execSync } from "child_process";
573
599
  import { TranslationLoader as TranslationLoader6 } from "opticore-translator";
574
-
575
- // src/application/service/logger.service.ts
576
- import { LoggerCore as LoggerCore2 } from "opticore-logger";
577
- var SLogger = () => {
578
- return new LoggerCore2();
579
- };
580
-
581
- // src/utils/stopServer.utils.ts
582
600
  var UStopServer = () => {
583
601
  dotenv.config();
584
602
  const port = process.env.PORT;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opticore-webapp",
3
- "version": "1.0.31",
3
+ "version": "1.0.33",
4
4
  "description": "wep server",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",