opticore-webapp 1.0.19 → 1.0.20
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 +73 -52
- package/dist/index.d.cts +10 -8
- package/dist/index.d.ts +10 -8
- package/dist/index.js +73 -52
- package/package.json +1 -1
- package/public/template/index.html +23 -0
- package/src/application/service/core.service.ts +0 -184
- package/src/application/service/serverStartError.service.ts +0 -112
- package/src/core/config/.gitkeep +0 -0
- package/src/core/events/.gitkeep +0 -0
- package/src/core/handlers/eventProcess.handler.ts +0 -112
- package/src/core/helpers/dateTimeFormatted.utils.ts +0 -6
- package/src/core/helpers/logMessage.utils.ts +0 -20
- package/src/core/helpers/modulesLoaded.utils.ts +0 -23
- package/src/core/webServer.core.ts +0 -154
- package/src/domains/interfaces/routeDefinition.interface.ts +0 -6
- package/src/domains/types/kernelModule.type.ts +0 -3
- package/src/index.ts +0 -11
- package/src/utils/translations/messages.exception.en.json +0 -78
- package/src/utils/translations/messages.exception.fr.json +0 -78
- package/tsup.config.ts +0 -11
package/dist/index.cjs
CHANGED
|
@@ -40,6 +40,7 @@ var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
|
40
40
|
|
|
41
41
|
// src/core/webServer.core.ts
|
|
42
42
|
var path2 = __toESM(require("path"), 1);
|
|
43
|
+
var import_node_process3 = __toESM(require("process"), 1);
|
|
43
44
|
var import_module = require("module");
|
|
44
45
|
var import_cors = __toESM(require("cors"), 1);
|
|
45
46
|
var import_opticore_catch_exception_error4 = require("opticore-catch-exception-error");
|
|
@@ -109,7 +110,6 @@ var path = __toESM(require("path"), 1);
|
|
|
109
110
|
var fs = __toESM(require("fs"), 1);
|
|
110
111
|
var import_ansi_colors3 = __toESM(require("ansi-colors"), 1);
|
|
111
112
|
var import_opticore_http_response = require("opticore-http-response");
|
|
112
|
-
var import_opticore_catch_exception_error2 = require("opticore-catch-exception-error");
|
|
113
113
|
|
|
114
114
|
// src/core/helpers/modulesLoaded.utils.ts
|
|
115
115
|
var import_ansi_colors2 = __toESM(require("ansi-colors"), 1);
|
|
@@ -154,6 +154,14 @@ function modulesLoadedUtils(allAppRoutes, dbConChecker, localeLanguage) {
|
|
|
154
154
|
|
|
155
155
|
// src/application/service/core.service.ts
|
|
156
156
|
var import_opticore_translator2 = require("opticore-translator");
|
|
157
|
+
|
|
158
|
+
// src/application/service/traceError.service.ts
|
|
159
|
+
var import_opticore_catch_exception_error2 = require("opticore-catch-exception-error");
|
|
160
|
+
var STraceError = (props, name, httpCode, isOperational) => {
|
|
161
|
+
return new import_opticore_catch_exception_error2.StackTraceError(props, name, httpCode, isOperational);
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
// src/application/service/core.service.ts
|
|
157
165
|
var CoreService = class {
|
|
158
166
|
/**
|
|
159
167
|
*
|
|
@@ -275,7 +283,7 @@ var CoreService = class {
|
|
|
275
283
|
console.log(`${`Memory usage by system :`} ${import_ansi_colors3.default.cyan(`${import_ansi_colors3.default.bold(`${system}`)}`)}`);
|
|
276
284
|
console.log(``);
|
|
277
285
|
}
|
|
278
|
-
coreListenerEventLoaderModuleService(kernelModule,
|
|
286
|
+
coreListenerEventLoaderModuleService(kernelModule, localLanguage, loggerConfig) {
|
|
279
287
|
let router = [];
|
|
280
288
|
let dbCon;
|
|
281
289
|
kernelModule.forEach((module2) => {
|
|
@@ -286,14 +294,14 @@ var CoreService = class {
|
|
|
286
294
|
}
|
|
287
295
|
});
|
|
288
296
|
if (router && dbCon) {
|
|
289
|
-
modulesLoadedUtils(router, dbCon);
|
|
297
|
+
modulesLoadedUtils(router, dbCon, localLanguage);
|
|
290
298
|
(() => {
|
|
291
299
|
dbCon();
|
|
292
300
|
})();
|
|
293
301
|
} else {
|
|
294
|
-
const stackTrace =
|
|
295
|
-
import_opticore_translator2.TranslationLoader.t("loadedModulesError",
|
|
296
|
-
import_opticore_translator2.TranslationLoader.t("loadedModules",
|
|
302
|
+
const stackTrace = STraceError(
|
|
303
|
+
import_opticore_translator2.TranslationLoader.t("loadedModulesError", localLanguage, loggerConfig),
|
|
304
|
+
import_opticore_translator2.TranslationLoader.t("loadedModules", localLanguage, loggerConfig),
|
|
297
305
|
import_opticore_http_response.HttpStatusCode.NOT_ACCEPTABLE,
|
|
298
306
|
true
|
|
299
307
|
);
|
|
@@ -307,110 +315,115 @@ var import_assert = __toESM(require("assert"), 1);
|
|
|
307
315
|
var import_opticore_catch_exception_error3 = require("opticore-catch-exception-error");
|
|
308
316
|
var import_opticore_http_response2 = require("opticore-http-response");
|
|
309
317
|
var import_opticore_translator3 = require("opticore-translator");
|
|
310
|
-
var SServerStartError = (err) => {
|
|
318
|
+
var SServerStartError = (err, javaScriptErrors, systemErrors, openSSLErrors, internalErrors, logger, localLanguage) => {
|
|
311
319
|
switch (err.name) {
|
|
312
320
|
case import_opticore_catch_exception_error3.CErrorName.typeError:
|
|
313
|
-
|
|
321
|
+
javaScriptErrors.typeError(err);
|
|
314
322
|
break;
|
|
315
323
|
case import_opticore_catch_exception_error3.CErrorName.error:
|
|
316
|
-
|
|
324
|
+
javaScriptErrors.allError(err);
|
|
317
325
|
break;
|
|
318
326
|
case import_opticore_catch_exception_error3.CErrorName.evalError:
|
|
319
|
-
|
|
327
|
+
javaScriptErrors.evalError(err);
|
|
320
328
|
break;
|
|
321
329
|
case import_opticore_catch_exception_error3.CErrorName.referenceError:
|
|
322
|
-
|
|
330
|
+
javaScriptErrors.referenceError(err);
|
|
323
331
|
break;
|
|
324
332
|
case import_opticore_catch_exception_error3.CErrorName.rangeError:
|
|
325
|
-
|
|
333
|
+
javaScriptErrors.rangeError(err);
|
|
326
334
|
break;
|
|
327
335
|
case import_opticore_catch_exception_error3.CErrorName.syntaxError:
|
|
328
|
-
|
|
336
|
+
javaScriptErrors.syntaxError(err);
|
|
329
337
|
break;
|
|
330
338
|
case import_opticore_catch_exception_error3.CErrorName.uriError:
|
|
331
|
-
|
|
339
|
+
javaScriptErrors.uRIError(err);
|
|
332
340
|
break;
|
|
333
341
|
case import_opticore_catch_exception_error3.CErrorName.eacces:
|
|
334
|
-
|
|
342
|
+
systemErrors.eAcces(err);
|
|
335
343
|
break;
|
|
336
344
|
case import_opticore_catch_exception_error3.CErrorName.eaddrinuse:
|
|
337
|
-
|
|
345
|
+
systemErrors.eAddrInUse(err);
|
|
338
346
|
break;
|
|
339
347
|
case import_opticore_catch_exception_error3.CErrorName.econnrefused:
|
|
340
|
-
|
|
348
|
+
systemErrors.eConnRefused(err);
|
|
341
349
|
break;
|
|
342
350
|
case import_opticore_catch_exception_error3.CErrorName.econnreset:
|
|
343
|
-
|
|
351
|
+
systemErrors.eConnReset(err);
|
|
344
352
|
break;
|
|
345
353
|
case import_opticore_catch_exception_error3.CErrorName.eexist:
|
|
346
|
-
|
|
354
|
+
systemErrors.eExist(err);
|
|
347
355
|
break;
|
|
348
356
|
case import_opticore_catch_exception_error3.CErrorName.eisdir:
|
|
349
|
-
|
|
357
|
+
systemErrors.eIsDir(err);
|
|
350
358
|
break;
|
|
351
359
|
case import_opticore_catch_exception_error3.CErrorName.emfile:
|
|
352
|
-
|
|
360
|
+
systemErrors.eMFile(err);
|
|
353
361
|
break;
|
|
354
362
|
case import_opticore_catch_exception_error3.CErrorName.enoent:
|
|
355
|
-
|
|
363
|
+
systemErrors.eNoEnt(err);
|
|
356
364
|
break;
|
|
357
365
|
case import_opticore_catch_exception_error3.CErrorName.enotdir:
|
|
358
|
-
|
|
366
|
+
systemErrors.eNotDir(err);
|
|
359
367
|
break;
|
|
360
368
|
case import_opticore_catch_exception_error3.CErrorName.enotEmpty:
|
|
361
|
-
|
|
369
|
+
systemErrors.eNotEmpty(err);
|
|
362
370
|
break;
|
|
363
371
|
case import_opticore_catch_exception_error3.CErrorName.eperm:
|
|
364
|
-
|
|
372
|
+
systemErrors.ePerm(err);
|
|
365
373
|
break;
|
|
366
374
|
case import_opticore_catch_exception_error3.CErrorName.epipe:
|
|
367
|
-
|
|
375
|
+
systemErrors.ePipe(err);
|
|
368
376
|
break;
|
|
369
377
|
case import_opticore_catch_exception_error3.CErrorName.etimedout:
|
|
370
|
-
|
|
378
|
+
systemErrors.eTimedOut(err);
|
|
371
379
|
break;
|
|
372
380
|
case import_opticore_catch_exception_error3.CErrorName.assertionError:
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
381
|
+
const stackTrace = STraceError(
|
|
382
|
+
err.message,
|
|
383
|
+
err.name,
|
|
384
|
+
import_opticore_http_response2.HttpStatusCode.NOT_ACCEPTABLE,
|
|
385
|
+
true
|
|
386
|
+
);
|
|
387
|
+
err instanceof import_assert.default.AssertionError ? logger.error(
|
|
388
|
+
import_opticore_translator3.TranslationLoader.t(stackTrace.name, localLanguage),
|
|
376
389
|
"AssertionError",
|
|
377
|
-
|
|
378
|
-
|
|
390
|
+
stackTrace.name,
|
|
391
|
+
stackTrace.stack,
|
|
379
392
|
import_opticore_http_response2.HttpStatusCode.INTERNAL_SERVER_ERROR
|
|
380
|
-
) :
|
|
381
|
-
import_opticore_translator3.TranslationLoader.t(
|
|
393
|
+
) : logger.error(
|
|
394
|
+
import_opticore_translator3.TranslationLoader.t(stackTrace.name, localLanguage),
|
|
382
395
|
"Another Error",
|
|
383
|
-
|
|
384
|
-
|
|
396
|
+
stackTrace.name,
|
|
397
|
+
stackTrace.stack,
|
|
385
398
|
import_opticore_http_response2.HttpStatusCode.INTERNAL_SERVER_ERROR
|
|
386
399
|
);
|
|
387
400
|
break;
|
|
388
401
|
case import_opticore_catch_exception_error3.CErrorName.errOsslEvpUnsupported:
|
|
389
|
-
|
|
402
|
+
openSSLErrors.errOsSLEvpUnsupported(err);
|
|
390
403
|
break;
|
|
391
404
|
case import_opticore_catch_exception_error3.CErrorName.errOsslBadDecrypt:
|
|
392
|
-
|
|
405
|
+
openSSLErrors.errOsSLBadDecrypt(err);
|
|
393
406
|
break;
|
|
394
407
|
case import_opticore_catch_exception_error3.CErrorName.errOsslWrongFinalBlockLength:
|
|
395
|
-
|
|
408
|
+
openSSLErrors.errOsSLWrongFinalBlockLength(err);
|
|
396
409
|
break;
|
|
397
410
|
case import_opticore_catch_exception_error3.CErrorName.errInvalidArgType:
|
|
398
|
-
|
|
411
|
+
internalErrors.errInvalidArgType(err);
|
|
399
412
|
break;
|
|
400
413
|
case import_opticore_catch_exception_error3.CErrorName.errInvalidCallback:
|
|
401
|
-
|
|
414
|
+
internalErrors.errInvalidCallback(err);
|
|
402
415
|
break;
|
|
403
416
|
case import_opticore_catch_exception_error3.CErrorName.errHttpHeadersSent:
|
|
404
|
-
|
|
417
|
+
internalErrors.errHttpHeadersSent(err);
|
|
405
418
|
break;
|
|
406
419
|
case import_opticore_catch_exception_error3.CErrorName.errStreamDestroyed:
|
|
407
|
-
|
|
420
|
+
internalErrors.errStreamDestroyed(err);
|
|
408
421
|
break;
|
|
409
422
|
case import_opticore_catch_exception_error3.CErrorName.errTlsCertAltnameInvalid:
|
|
410
|
-
|
|
423
|
+
internalErrors.errTlsCertAltNameInvalid(err);
|
|
411
424
|
break;
|
|
412
425
|
case import_opticore_catch_exception_error3.CErrorName.errUnsupportedEsmUrlScheme:
|
|
413
|
-
|
|
426
|
+
internalErrors.errUnsupportedEsmUrlScheme(err);
|
|
414
427
|
break;
|
|
415
428
|
}
|
|
416
429
|
};
|
|
@@ -453,21 +466,29 @@ var WebServerCore = class {
|
|
|
453
466
|
}
|
|
454
467
|
onStartServer(routers) {
|
|
455
468
|
return this.expressApp.listen(
|
|
456
|
-
this.getEnvironnement.
|
|
457
|
-
this.getEnvironnement.appPort,
|
|
469
|
+
Number(this.getEnvironnement.appPort),
|
|
458
470
|
() => {
|
|
459
471
|
try {
|
|
460
|
-
if (this.getEnvironnement.appHost === "" && this.getEnvironnement.appPort === 0) {
|
|
461
|
-
this.serverListenEvent.hostPortUndefined(this.getEnvironnement.appPort);
|
|
472
|
+
if (this.getEnvironnement.appHost === "" && Number(this.getEnvironnement.appPort) === 0) {
|
|
473
|
+
this.serverListenEvent.hostPortUndefined(Number(this.getEnvironnement.appPort));
|
|
462
474
|
} else if (this.getEnvironnement.appHost === "") {
|
|
463
475
|
this.serverListenEvent.hostUndefined(this.getEnvironnement.appHost);
|
|
464
|
-
} else if (this.getEnvironnement.appPort === 0) {
|
|
476
|
+
} else if (Number(this.getEnvironnement.appPort) === 0) {
|
|
465
477
|
this.serverListenEvent.portUndefined();
|
|
466
478
|
} else {
|
|
479
|
+
this.expressApp.use(import_opticore_express2.express.static(path2.join(import_node_process3.default.cwd(), "public/template")));
|
|
467
480
|
this.registerRoutes(routers);
|
|
468
481
|
}
|
|
469
482
|
} catch (err) {
|
|
470
|
-
SServerStartError(
|
|
483
|
+
SServerStartError(
|
|
484
|
+
err,
|
|
485
|
+
this.javaScriptErrors,
|
|
486
|
+
this.systemErrors,
|
|
487
|
+
this.openSSLErrors,
|
|
488
|
+
this.internalErrors,
|
|
489
|
+
this.loggerConfig,
|
|
490
|
+
this.localLanguage
|
|
491
|
+
);
|
|
471
492
|
}
|
|
472
493
|
}
|
|
473
494
|
);
|
|
@@ -490,7 +511,7 @@ var WebServerCore = class {
|
|
|
490
511
|
req,
|
|
491
512
|
res,
|
|
492
513
|
this.getEnvironnement.appHost,
|
|
493
|
-
this.getEnvironnement.appPort,
|
|
514
|
+
Number(this.getEnvironnement.appPort),
|
|
494
515
|
dateTimeFormattedUtils,
|
|
495
516
|
this.environnementPath,
|
|
496
517
|
this.localLanguage
|
package/dist/index.d.cts
CHANGED
|
@@ -8,6 +8,10 @@ interface IRouteDefinition {
|
|
|
8
8
|
handler: Router;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
type TFeatureRoutes = {
|
|
12
|
+
featureRoute: IRouteDefinition[];
|
|
13
|
+
};
|
|
14
|
+
|
|
11
15
|
declare class WebServerCore {
|
|
12
16
|
private serverUtility;
|
|
13
17
|
private expressApp;
|
|
@@ -17,15 +21,13 @@ declare class WebServerCore {
|
|
|
17
21
|
private readonly getEnvironnement;
|
|
18
22
|
private readonly environnementPath;
|
|
19
23
|
private serverListenEvent;
|
|
20
|
-
private javaScriptErrors;
|
|
21
|
-
private internalErrors;
|
|
24
|
+
private readonly javaScriptErrors;
|
|
25
|
+
private readonly internalErrors;
|
|
22
26
|
private assertionErrors;
|
|
23
|
-
private openSSLErrors;
|
|
24
|
-
private systemErrors;
|
|
27
|
+
private readonly openSSLErrors;
|
|
28
|
+
private readonly systemErrors;
|
|
25
29
|
constructor(app: express.Application, loggerConfig: LoggerCore, localLanguage: string, environnementPath: any, corsOriginOptions?: Partial<CorsOptions>);
|
|
26
|
-
onStartServer(routers:
|
|
27
|
-
featureRoute: IRouteDefinition[];
|
|
28
|
-
}[]): any;
|
|
30
|
+
onStartServer(routers: TFeatureRoutes[]): any;
|
|
29
31
|
onListeningOnServerEvent(serverWeb: Server, localLanguage: string): void;
|
|
30
32
|
onRequestOnServerEvent(serverWeb: Server): void;
|
|
31
33
|
private translationWebAppLoader;
|
|
@@ -38,4 +40,4 @@ type KernelModuleType = [{
|
|
|
38
40
|
featureRoute: IRouteDefinition[];
|
|
39
41
|
}[], () => void];
|
|
40
42
|
|
|
41
|
-
export { type IRouteDefinition, type KernelModuleType, WebServerCore as WebServer };
|
|
43
|
+
export { type IRouteDefinition, type KernelModuleType, type TFeatureRoutes, WebServerCore as WebServer };
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,10 @@ interface IRouteDefinition {
|
|
|
8
8
|
handler: Router;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
type TFeatureRoutes = {
|
|
12
|
+
featureRoute: IRouteDefinition[];
|
|
13
|
+
};
|
|
14
|
+
|
|
11
15
|
declare class WebServerCore {
|
|
12
16
|
private serverUtility;
|
|
13
17
|
private expressApp;
|
|
@@ -17,15 +21,13 @@ declare class WebServerCore {
|
|
|
17
21
|
private readonly getEnvironnement;
|
|
18
22
|
private readonly environnementPath;
|
|
19
23
|
private serverListenEvent;
|
|
20
|
-
private javaScriptErrors;
|
|
21
|
-
private internalErrors;
|
|
24
|
+
private readonly javaScriptErrors;
|
|
25
|
+
private readonly internalErrors;
|
|
22
26
|
private assertionErrors;
|
|
23
|
-
private openSSLErrors;
|
|
24
|
-
private systemErrors;
|
|
27
|
+
private readonly openSSLErrors;
|
|
28
|
+
private readonly systemErrors;
|
|
25
29
|
constructor(app: express.Application, loggerConfig: LoggerCore, localLanguage: string, environnementPath: any, corsOriginOptions?: Partial<CorsOptions>);
|
|
26
|
-
onStartServer(routers:
|
|
27
|
-
featureRoute: IRouteDefinition[];
|
|
28
|
-
}[]): any;
|
|
30
|
+
onStartServer(routers: TFeatureRoutes[]): any;
|
|
29
31
|
onListeningOnServerEvent(serverWeb: Server, localLanguage: string): void;
|
|
30
32
|
onRequestOnServerEvent(serverWeb: Server): void;
|
|
31
33
|
private translationWebAppLoader;
|
|
@@ -38,4 +40,4 @@ type KernelModuleType = [{
|
|
|
38
40
|
featureRoute: IRouteDefinition[];
|
|
39
41
|
}[], () => void];
|
|
40
42
|
|
|
41
|
-
export { type IRouteDefinition, type KernelModuleType, WebServerCore as WebServer };
|
|
43
|
+
export { type IRouteDefinition, type KernelModuleType, type TFeatureRoutes, WebServerCore as WebServer };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/core/webServer.core.ts
|
|
2
2
|
import * as path2 from "path";
|
|
3
|
+
import process3 from "node:process";
|
|
3
4
|
import { createRequire } from "module";
|
|
4
5
|
import corsOrigin from "cors";
|
|
5
6
|
import {
|
|
@@ -81,7 +82,6 @@ import * as path from "path";
|
|
|
81
82
|
import * as fs from "fs";
|
|
82
83
|
import colors3 from "ansi-colors";
|
|
83
84
|
import { HttpStatusCode as status } from "opticore-http-response";
|
|
84
|
-
import { StackTraceError } from "opticore-catch-exception-error";
|
|
85
85
|
|
|
86
86
|
// src/core/helpers/modulesLoaded.utils.ts
|
|
87
87
|
import colors2 from "ansi-colors";
|
|
@@ -126,6 +126,14 @@ function modulesLoadedUtils(allAppRoutes, dbConChecker, localeLanguage) {
|
|
|
126
126
|
|
|
127
127
|
// src/application/service/core.service.ts
|
|
128
128
|
import { TranslationLoader as TranslationLoader2 } from "opticore-translator";
|
|
129
|
+
|
|
130
|
+
// src/application/service/traceError.service.ts
|
|
131
|
+
import { StackTraceError } from "opticore-catch-exception-error";
|
|
132
|
+
var STraceError = (props, name, httpCode, isOperational) => {
|
|
133
|
+
return new StackTraceError(props, name, httpCode, isOperational);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
// src/application/service/core.service.ts
|
|
129
137
|
var CoreService = class {
|
|
130
138
|
/**
|
|
131
139
|
*
|
|
@@ -247,7 +255,7 @@ var CoreService = class {
|
|
|
247
255
|
console.log(`${`Memory usage by system :`} ${colors3.cyan(`${colors3.bold(`${system}`)}`)}`);
|
|
248
256
|
console.log(``);
|
|
249
257
|
}
|
|
250
|
-
coreListenerEventLoaderModuleService(kernelModule,
|
|
258
|
+
coreListenerEventLoaderModuleService(kernelModule, localLanguage, loggerConfig) {
|
|
251
259
|
let router = [];
|
|
252
260
|
let dbCon;
|
|
253
261
|
kernelModule.forEach((module) => {
|
|
@@ -258,14 +266,14 @@ var CoreService = class {
|
|
|
258
266
|
}
|
|
259
267
|
});
|
|
260
268
|
if (router && dbCon) {
|
|
261
|
-
modulesLoadedUtils(router, dbCon);
|
|
269
|
+
modulesLoadedUtils(router, dbCon, localLanguage);
|
|
262
270
|
(() => {
|
|
263
271
|
dbCon();
|
|
264
272
|
})();
|
|
265
273
|
} else {
|
|
266
|
-
const stackTrace =
|
|
267
|
-
TranslationLoader2.t("loadedModulesError",
|
|
268
|
-
TranslationLoader2.t("loadedModules",
|
|
274
|
+
const stackTrace = STraceError(
|
|
275
|
+
TranslationLoader2.t("loadedModulesError", localLanguage, loggerConfig),
|
|
276
|
+
TranslationLoader2.t("loadedModules", localLanguage, loggerConfig),
|
|
269
277
|
status.NOT_ACCEPTABLE,
|
|
270
278
|
true
|
|
271
279
|
);
|
|
@@ -279,110 +287,115 @@ import assert from "assert";
|
|
|
279
287
|
import { CErrorName } from "opticore-catch-exception-error";
|
|
280
288
|
import { HttpStatusCode } from "opticore-http-response";
|
|
281
289
|
import { TranslationLoader as TranslationLoader3 } from "opticore-translator";
|
|
282
|
-
var SServerStartError = (err) => {
|
|
290
|
+
var SServerStartError = (err, javaScriptErrors, systemErrors, openSSLErrors, internalErrors, logger, localLanguage) => {
|
|
283
291
|
switch (err.name) {
|
|
284
292
|
case CErrorName.typeError:
|
|
285
|
-
|
|
293
|
+
javaScriptErrors.typeError(err);
|
|
286
294
|
break;
|
|
287
295
|
case CErrorName.error:
|
|
288
|
-
|
|
296
|
+
javaScriptErrors.allError(err);
|
|
289
297
|
break;
|
|
290
298
|
case CErrorName.evalError:
|
|
291
|
-
|
|
299
|
+
javaScriptErrors.evalError(err);
|
|
292
300
|
break;
|
|
293
301
|
case CErrorName.referenceError:
|
|
294
|
-
|
|
302
|
+
javaScriptErrors.referenceError(err);
|
|
295
303
|
break;
|
|
296
304
|
case CErrorName.rangeError:
|
|
297
|
-
|
|
305
|
+
javaScriptErrors.rangeError(err);
|
|
298
306
|
break;
|
|
299
307
|
case CErrorName.syntaxError:
|
|
300
|
-
|
|
308
|
+
javaScriptErrors.syntaxError(err);
|
|
301
309
|
break;
|
|
302
310
|
case CErrorName.uriError:
|
|
303
|
-
|
|
311
|
+
javaScriptErrors.uRIError(err);
|
|
304
312
|
break;
|
|
305
313
|
case CErrorName.eacces:
|
|
306
|
-
|
|
314
|
+
systemErrors.eAcces(err);
|
|
307
315
|
break;
|
|
308
316
|
case CErrorName.eaddrinuse:
|
|
309
|
-
|
|
317
|
+
systemErrors.eAddrInUse(err);
|
|
310
318
|
break;
|
|
311
319
|
case CErrorName.econnrefused:
|
|
312
|
-
|
|
320
|
+
systemErrors.eConnRefused(err);
|
|
313
321
|
break;
|
|
314
322
|
case CErrorName.econnreset:
|
|
315
|
-
|
|
323
|
+
systemErrors.eConnReset(err);
|
|
316
324
|
break;
|
|
317
325
|
case CErrorName.eexist:
|
|
318
|
-
|
|
326
|
+
systemErrors.eExist(err);
|
|
319
327
|
break;
|
|
320
328
|
case CErrorName.eisdir:
|
|
321
|
-
|
|
329
|
+
systemErrors.eIsDir(err);
|
|
322
330
|
break;
|
|
323
331
|
case CErrorName.emfile:
|
|
324
|
-
|
|
332
|
+
systemErrors.eMFile(err);
|
|
325
333
|
break;
|
|
326
334
|
case CErrorName.enoent:
|
|
327
|
-
|
|
335
|
+
systemErrors.eNoEnt(err);
|
|
328
336
|
break;
|
|
329
337
|
case CErrorName.enotdir:
|
|
330
|
-
|
|
338
|
+
systemErrors.eNotDir(err);
|
|
331
339
|
break;
|
|
332
340
|
case CErrorName.enotEmpty:
|
|
333
|
-
|
|
341
|
+
systemErrors.eNotEmpty(err);
|
|
334
342
|
break;
|
|
335
343
|
case CErrorName.eperm:
|
|
336
|
-
|
|
344
|
+
systemErrors.ePerm(err);
|
|
337
345
|
break;
|
|
338
346
|
case CErrorName.epipe:
|
|
339
|
-
|
|
347
|
+
systemErrors.ePipe(err);
|
|
340
348
|
break;
|
|
341
349
|
case CErrorName.etimedout:
|
|
342
|
-
|
|
350
|
+
systemErrors.eTimedOut(err);
|
|
343
351
|
break;
|
|
344
352
|
case CErrorName.assertionError:
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
353
|
+
const stackTrace = STraceError(
|
|
354
|
+
err.message,
|
|
355
|
+
err.name,
|
|
356
|
+
HttpStatusCode.NOT_ACCEPTABLE,
|
|
357
|
+
true
|
|
358
|
+
);
|
|
359
|
+
err instanceof assert.AssertionError ? logger.error(
|
|
360
|
+
TranslationLoader3.t(stackTrace.name, localLanguage),
|
|
348
361
|
"AssertionError",
|
|
349
|
-
|
|
350
|
-
|
|
362
|
+
stackTrace.name,
|
|
363
|
+
stackTrace.stack,
|
|
351
364
|
HttpStatusCode.INTERNAL_SERVER_ERROR
|
|
352
|
-
) :
|
|
353
|
-
TranslationLoader3.t(
|
|
365
|
+
) : logger.error(
|
|
366
|
+
TranslationLoader3.t(stackTrace.name, localLanguage),
|
|
354
367
|
"Another Error",
|
|
355
|
-
|
|
356
|
-
|
|
368
|
+
stackTrace.name,
|
|
369
|
+
stackTrace.stack,
|
|
357
370
|
HttpStatusCode.INTERNAL_SERVER_ERROR
|
|
358
371
|
);
|
|
359
372
|
break;
|
|
360
373
|
case CErrorName.errOsslEvpUnsupported:
|
|
361
|
-
|
|
374
|
+
openSSLErrors.errOsSLEvpUnsupported(err);
|
|
362
375
|
break;
|
|
363
376
|
case CErrorName.errOsslBadDecrypt:
|
|
364
|
-
|
|
377
|
+
openSSLErrors.errOsSLBadDecrypt(err);
|
|
365
378
|
break;
|
|
366
379
|
case CErrorName.errOsslWrongFinalBlockLength:
|
|
367
|
-
|
|
380
|
+
openSSLErrors.errOsSLWrongFinalBlockLength(err);
|
|
368
381
|
break;
|
|
369
382
|
case CErrorName.errInvalidArgType:
|
|
370
|
-
|
|
383
|
+
internalErrors.errInvalidArgType(err);
|
|
371
384
|
break;
|
|
372
385
|
case CErrorName.errInvalidCallback:
|
|
373
|
-
|
|
386
|
+
internalErrors.errInvalidCallback(err);
|
|
374
387
|
break;
|
|
375
388
|
case CErrorName.errHttpHeadersSent:
|
|
376
|
-
|
|
389
|
+
internalErrors.errHttpHeadersSent(err);
|
|
377
390
|
break;
|
|
378
391
|
case CErrorName.errStreamDestroyed:
|
|
379
|
-
|
|
392
|
+
internalErrors.errStreamDestroyed(err);
|
|
380
393
|
break;
|
|
381
394
|
case CErrorName.errTlsCertAltnameInvalid:
|
|
382
|
-
|
|
395
|
+
internalErrors.errTlsCertAltNameInvalid(err);
|
|
383
396
|
break;
|
|
384
397
|
case CErrorName.errUnsupportedEsmUrlScheme:
|
|
385
|
-
|
|
398
|
+
internalErrors.errUnsupportedEsmUrlScheme(err);
|
|
386
399
|
break;
|
|
387
400
|
}
|
|
388
401
|
};
|
|
@@ -425,21 +438,29 @@ var WebServerCore = class {
|
|
|
425
438
|
}
|
|
426
439
|
onStartServer(routers) {
|
|
427
440
|
return this.expressApp.listen(
|
|
428
|
-
this.getEnvironnement.
|
|
429
|
-
this.getEnvironnement.appPort,
|
|
441
|
+
Number(this.getEnvironnement.appPort),
|
|
430
442
|
() => {
|
|
431
443
|
try {
|
|
432
|
-
if (this.getEnvironnement.appHost === "" && this.getEnvironnement.appPort === 0) {
|
|
433
|
-
this.serverListenEvent.hostPortUndefined(this.getEnvironnement.appPort);
|
|
444
|
+
if (this.getEnvironnement.appHost === "" && Number(this.getEnvironnement.appPort) === 0) {
|
|
445
|
+
this.serverListenEvent.hostPortUndefined(Number(this.getEnvironnement.appPort));
|
|
434
446
|
} else if (this.getEnvironnement.appHost === "") {
|
|
435
447
|
this.serverListenEvent.hostUndefined(this.getEnvironnement.appHost);
|
|
436
|
-
} else if (this.getEnvironnement.appPort === 0) {
|
|
448
|
+
} else if (Number(this.getEnvironnement.appPort) === 0) {
|
|
437
449
|
this.serverListenEvent.portUndefined();
|
|
438
450
|
} else {
|
|
451
|
+
this.expressApp.use(express2.static(path2.join(process3.cwd(), "public/template")));
|
|
439
452
|
this.registerRoutes(routers);
|
|
440
453
|
}
|
|
441
454
|
} catch (err) {
|
|
442
|
-
SServerStartError(
|
|
455
|
+
SServerStartError(
|
|
456
|
+
err,
|
|
457
|
+
this.javaScriptErrors,
|
|
458
|
+
this.systemErrors,
|
|
459
|
+
this.openSSLErrors,
|
|
460
|
+
this.internalErrors,
|
|
461
|
+
this.loggerConfig,
|
|
462
|
+
this.localLanguage
|
|
463
|
+
);
|
|
443
464
|
}
|
|
444
465
|
}
|
|
445
466
|
);
|
|
@@ -462,7 +483,7 @@ var WebServerCore = class {
|
|
|
462
483
|
req,
|
|
463
484
|
res,
|
|
464
485
|
this.getEnvironnement.appHost,
|
|
465
|
-
this.getEnvironnement.appPort,
|
|
486
|
+
Number(this.getEnvironnement.appPort),
|
|
466
487
|
dateTimeFormattedUtils,
|
|
467
488
|
this.environnementPath,
|
|
468
489
|
this.localLanguage
|
package/package.json
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="fr">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>OptiCore</title>
|
|
7
|
+
<style>
|
|
8
|
+
body {
|
|
9
|
+
font-family: Arial, sans-serif;
|
|
10
|
+
background-color: #f0f0f0;
|
|
11
|
+
text-align: center;
|
|
12
|
+
padding: 50px;
|
|
13
|
+
}
|
|
14
|
+
h1 {
|
|
15
|
+
color: #333;
|
|
16
|
+
}
|
|
17
|
+
</style>
|
|
18
|
+
</head>
|
|
19
|
+
<body>
|
|
20
|
+
<h1>Bienvenue sur la vue par défaut !</h1>
|
|
21
|
+
<p>Ceci est une page HTML servie par Express.js.</p>
|
|
22
|
+
</body>
|
|
23
|
+
</html>
|