opticore-webapp 1.0.13 → 1.0.15
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 -24
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +30 -24
- package/package.json +9 -7
- package/src/core/handlers/eventProcess.handler.ts +14 -14
- package/src/core/webServer.core.ts +13 -10
- package/tsconfig.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -34,10 +34,14 @@ __export(index_exports, {
|
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(index_exports);
|
|
36
36
|
|
|
37
|
+
// node_modules/tsup/assets/cjs_shims.js
|
|
38
|
+
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
39
|
+
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
40
|
+
|
|
37
41
|
// src/core/webServer.core.ts
|
|
38
42
|
var path2 = __toESM(require("path"), 1);
|
|
39
|
-
var import_node_process3 = __toESM(require("process"), 1);
|
|
40
43
|
var import_cors = __toESM(require("cors"), 1);
|
|
44
|
+
var import_url = require("url");
|
|
41
45
|
var import_opticore_catch_exception_error3 = require("opticore-catch-exception-error");
|
|
42
46
|
var import_opticore_express2 = require("opticore-express");
|
|
43
47
|
var import_opticore_env_access = require("opticore-env-access");
|
|
@@ -53,48 +57,48 @@ function eventProcessHandler() {
|
|
|
53
57
|
const errorEmitter = new import_node_events.default();
|
|
54
58
|
const app = (0, import_opticore_express.express)();
|
|
55
59
|
errorEmitter.on(import_opticore_catch_exception_error.CEventNameError.error, (error) => {
|
|
56
|
-
import_opticore_catch_exception_error.ServerListenEventError.listenerError(error);
|
|
60
|
+
import_opticore_catch_exception_error.ServerListenEventError.__init().listenerError(error);
|
|
57
61
|
});
|
|
58
62
|
import_node_process.default.on(import_opticore_catch_exception_error.CEvent.beforeExit, (code) => {
|
|
59
63
|
setTimeout(() => {
|
|
60
|
-
import_opticore_catch_exception_error.ServerListenEventError.processBeforeExit(code);
|
|
64
|
+
import_opticore_catch_exception_error.ServerListenEventError.__init().processBeforeExit(code);
|
|
61
65
|
}, 100);
|
|
62
66
|
});
|
|
63
67
|
import_node_process.default.on(import_opticore_catch_exception_error.CEvent.disconnect, () => {
|
|
64
|
-
import_opticore_catch_exception_error.ServerListenEventError.processDisconnected();
|
|
68
|
+
import_opticore_catch_exception_error.ServerListenEventError.__init().processDisconnected();
|
|
65
69
|
});
|
|
66
70
|
import_node_process.default.on(import_opticore_catch_exception_error.CEvent.exit, (code) => {
|
|
67
|
-
import_opticore_catch_exception_error.ServerListenEventError.exited(code);
|
|
71
|
+
import_opticore_catch_exception_error.ServerListenEventError.__init().exited(code);
|
|
68
72
|
});
|
|
69
73
|
import_node_process.default.on(import_opticore_catch_exception_error.CEvent.rejectionHandled, (promise) => {
|
|
70
|
-
import_opticore_catch_exception_error.ServerListenEventError.promiseRejectionHandled(promise);
|
|
74
|
+
import_opticore_catch_exception_error.ServerListenEventError.__init().promiseRejectionHandled(promise);
|
|
71
75
|
});
|
|
72
76
|
import_node_process.default.on(import_opticore_catch_exception_error.CEvent.uncaughtException, (error) => {
|
|
73
|
-
import_opticore_catch_exception_error.ServerListenEventError.uncaughtException(error);
|
|
77
|
+
import_opticore_catch_exception_error.ServerListenEventError.__init().uncaughtException(error);
|
|
74
78
|
});
|
|
75
79
|
import_node_process.default.on(import_opticore_catch_exception_error.CEvent.uncaughtExceptionMonitor, (error) => {
|
|
76
|
-
import_opticore_catch_exception_error.ServerListenEventError.uncaughtExceptionMonitor(error);
|
|
80
|
+
import_opticore_catch_exception_error.ServerListenEventError.__init().uncaughtExceptionMonitor(error);
|
|
77
81
|
});
|
|
78
82
|
import_node_process.default.on(import_opticore_catch_exception_error.CEvent.unhandledRejection, (reason, promise) => {
|
|
79
|
-
import_opticore_catch_exception_error.ServerListenEventError.unhandledRejection(reason, promise);
|
|
83
|
+
import_opticore_catch_exception_error.ServerListenEventError.__init().unhandledRejection(reason, promise);
|
|
80
84
|
});
|
|
81
85
|
import_node_process.default.on(import_opticore_catch_exception_error.CEvent.warning, (warning) => {
|
|
82
|
-
import_opticore_catch_exception_error.ServerListenEventError.warning(warning);
|
|
86
|
+
import_opticore_catch_exception_error.ServerListenEventError.__init().warning(warning);
|
|
83
87
|
});
|
|
84
88
|
import_node_process.default.on(import_opticore_catch_exception_error.CEvent.message, (message) => {
|
|
85
|
-
import_opticore_catch_exception_error.ServerListenEventError.message(message);
|
|
89
|
+
import_opticore_catch_exception_error.ServerListenEventError.__init().message(message);
|
|
86
90
|
});
|
|
87
91
|
import_node_process.default.on(import_opticore_catch_exception_error.CEvent.multipleResolves, (type, promise, reason) => {
|
|
88
|
-
import_opticore_catch_exception_error.ServerListenEventError.multipleResolves(type, promise, reason);
|
|
92
|
+
import_opticore_catch_exception_error.ServerListenEventError.__init().multipleResolves(type, promise, reason);
|
|
89
93
|
});
|
|
90
94
|
import_node_process.default.on(import_opticore_catch_exception_error.CEvent.sigint, () => {
|
|
91
|
-
import_opticore_catch_exception_error.ServerListenEventError.processInterrupted();
|
|
95
|
+
import_opticore_catch_exception_error.ServerListenEventError.__init().processInterrupted();
|
|
92
96
|
});
|
|
93
97
|
import_node_process.default.on(import_opticore_catch_exception_error.CEvent.sigterm, (signal) => {
|
|
94
|
-
import_opticore_catch_exception_error.ServerListenEventError.sigtermSignalReceived(signal);
|
|
98
|
+
import_opticore_catch_exception_error.ServerListenEventError.__init().sigtermSignalReceived(signal);
|
|
95
99
|
});
|
|
96
100
|
app.use((err, req, res, next) => {
|
|
97
|
-
import_opticore_catch_exception_error.ServerListenEventError.expressErrorHandlingMiddleware(errorEmitter, err, req, res, next);
|
|
101
|
+
import_opticore_catch_exception_error.ServerListenEventError.__init().expressErrorHandlingMiddleware(errorEmitter, err, req, res, next);
|
|
98
102
|
});
|
|
99
103
|
}
|
|
100
104
|
|
|
@@ -301,9 +305,12 @@ var CoreService = class {
|
|
|
301
305
|
// src/core/webServer.core.ts
|
|
302
306
|
var import_opticore_translator3 = require("opticore-translator");
|
|
303
307
|
var WebServerCore = class {
|
|
308
|
+
serverUtility = new CoreService();
|
|
309
|
+
expressApp = (0, import_opticore_express2.express)();
|
|
310
|
+
routerExpressApp;
|
|
311
|
+
port;
|
|
312
|
+
host;
|
|
304
313
|
constructor(app, corsOriginOptions) {
|
|
305
|
-
this.serverUtility = new CoreService();
|
|
306
|
-
this.expressApp = (0, import_opticore_express2.express)();
|
|
307
314
|
this.port = Number(import_opticore_env_access.getEnvVariable.appPort);
|
|
308
315
|
this.host = import_opticore_env_access.getEnvVariable.appHost;
|
|
309
316
|
this.routerExpressApp = app;
|
|
@@ -322,11 +329,11 @@ var WebServerCore = class {
|
|
|
322
329
|
() => {
|
|
323
330
|
try {
|
|
324
331
|
if (this.host === "" && this.port === 0) {
|
|
325
|
-
import_opticore_catch_exception_error3.ServerListenEventError.hostPortUndefined();
|
|
332
|
+
import_opticore_catch_exception_error3.ServerListenEventError.__init().hostPortUndefined();
|
|
326
333
|
} else if (this.host === "") {
|
|
327
|
-
import_opticore_catch_exception_error3.ServerListenEventError.hostUndefined();
|
|
334
|
+
import_opticore_catch_exception_error3.ServerListenEventError.__init().hostUndefined();
|
|
328
335
|
} else if (this.port === 0) {
|
|
329
|
-
import_opticore_catch_exception_error3.ServerListenEventError.portUndefined();
|
|
336
|
+
import_opticore_catch_exception_error3.ServerListenEventError.__init().portUndefined();
|
|
330
337
|
} else {
|
|
331
338
|
this.registerRoutes(routers);
|
|
332
339
|
}
|
|
@@ -339,11 +346,11 @@ var WebServerCore = class {
|
|
|
339
346
|
//, kernelModule: KernelModuleType
|
|
340
347
|
onListeningOnServerEvent(serverWeb) {
|
|
341
348
|
serverWeb.on(import_opticore_catch_exception_error3.CEventNameError.error, (err) => {
|
|
342
|
-
import_opticore_catch_exception_error3.ServerListenEventError.onEventError(err);
|
|
349
|
+
import_opticore_catch_exception_error3.ServerListenEventError.__init().onEventError(err);
|
|
343
350
|
}).on(import_opticore_catch_exception_error3.CEventNameError.close, () => {
|
|
344
|
-
import_opticore_catch_exception_error3.ServerListenEventError.serverClosing();
|
|
351
|
+
import_opticore_catch_exception_error3.ServerListenEventError.__init().serverClosing();
|
|
345
352
|
}).on(import_opticore_catch_exception_error3.CEventNameError.drop, () => {
|
|
346
|
-
import_opticore_catch_exception_error3.ServerListenEventError.dropNewConnection();
|
|
353
|
+
import_opticore_catch_exception_error3.ServerListenEventError.__init().dropNewConnection();
|
|
347
354
|
}).on(import_opticore_catch_exception_error3.CEventNameError.listening, () => {
|
|
348
355
|
this.infoWebApp();
|
|
349
356
|
});
|
|
@@ -354,7 +361,10 @@ var WebServerCore = class {
|
|
|
354
361
|
});
|
|
355
362
|
}
|
|
356
363
|
translationWebAppLoader() {
|
|
357
|
-
|
|
364
|
+
const __filename2 = (0, import_url.fileURLToPath)(importMetaUrl);
|
|
365
|
+
const __dirname = path2.dirname(__filename2);
|
|
366
|
+
const translateMsgJsonFilePath = path2.join(__dirname, "../../../", "utils", "translations");
|
|
367
|
+
import_opticore_translator3.TranslationLoader.loadTranslations(translateMsgJsonFilePath, import_opticore_env_access.getEnvVariable.defaultLocal);
|
|
358
368
|
}
|
|
359
369
|
registerRoutes(allFeatureRoutes) {
|
|
360
370
|
allFeatureRoutes.map((router) => {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CorsOptions } from 'cors';
|
|
2
2
|
import { Server } from 'http';
|
|
3
|
-
import { Router,
|
|
3
|
+
import { Router, express } from 'opticore-express';
|
|
4
4
|
|
|
5
5
|
interface IRouteDefinition {
|
|
6
6
|
path: string;
|
|
@@ -13,7 +13,7 @@ declare class WebServerCore {
|
|
|
13
13
|
private readonly routerExpressApp;
|
|
14
14
|
private readonly port;
|
|
15
15
|
private readonly host;
|
|
16
|
-
constructor(app: Application, corsOriginOptions?: Partial<CorsOptions>);
|
|
16
|
+
constructor(app: express.Application, corsOriginOptions?: Partial<CorsOptions>);
|
|
17
17
|
onStartServer(routers: {
|
|
18
18
|
featureRoute: IRouteDefinition[];
|
|
19
19
|
}[]): any;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CorsOptions } from 'cors';
|
|
2
2
|
import { Server } from 'http';
|
|
3
|
-
import { Router,
|
|
3
|
+
import { Router, express } from 'opticore-express';
|
|
4
4
|
|
|
5
5
|
interface IRouteDefinition {
|
|
6
6
|
path: string;
|
|
@@ -13,7 +13,7 @@ declare class WebServerCore {
|
|
|
13
13
|
private readonly routerExpressApp;
|
|
14
14
|
private readonly port;
|
|
15
15
|
private readonly host;
|
|
16
|
-
constructor(app: Application, corsOriginOptions?: Partial<CorsOptions>);
|
|
16
|
+
constructor(app: express.Application, corsOriginOptions?: Partial<CorsOptions>);
|
|
17
17
|
onStartServer(routers: {
|
|
18
18
|
featureRoute: IRouteDefinition[];
|
|
19
19
|
}[]): any;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/core/webServer.core.ts
|
|
2
2
|
import * as path2 from "path";
|
|
3
|
-
import process3 from "node:process";
|
|
4
3
|
import corsOrigin from "cors";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
5
|
import {
|
|
6
6
|
CEventNameError as eventName2,
|
|
7
7
|
StackTraceError as StackTraceError2,
|
|
@@ -25,48 +25,48 @@ function eventProcessHandler() {
|
|
|
25
25
|
const errorEmitter = new EventEmitter();
|
|
26
26
|
const app = express();
|
|
27
27
|
errorEmitter.on(eventName.error, (error) => {
|
|
28
|
-
ServerListenEventError.listenerError(error);
|
|
28
|
+
ServerListenEventError.__init().listenerError(error);
|
|
29
29
|
});
|
|
30
30
|
process.on(event.beforeExit, (code) => {
|
|
31
31
|
setTimeout(() => {
|
|
32
|
-
ServerListenEventError.processBeforeExit(code);
|
|
32
|
+
ServerListenEventError.__init().processBeforeExit(code);
|
|
33
33
|
}, 100);
|
|
34
34
|
});
|
|
35
35
|
process.on(event.disconnect, () => {
|
|
36
|
-
ServerListenEventError.processDisconnected();
|
|
36
|
+
ServerListenEventError.__init().processDisconnected();
|
|
37
37
|
});
|
|
38
38
|
process.on(event.exit, (code) => {
|
|
39
|
-
ServerListenEventError.exited(code);
|
|
39
|
+
ServerListenEventError.__init().exited(code);
|
|
40
40
|
});
|
|
41
41
|
process.on(event.rejectionHandled, (promise) => {
|
|
42
|
-
ServerListenEventError.promiseRejectionHandled(promise);
|
|
42
|
+
ServerListenEventError.__init().promiseRejectionHandled(promise);
|
|
43
43
|
});
|
|
44
44
|
process.on(event.uncaughtException, (error) => {
|
|
45
|
-
ServerListenEventError.uncaughtException(error);
|
|
45
|
+
ServerListenEventError.__init().uncaughtException(error);
|
|
46
46
|
});
|
|
47
47
|
process.on(event.uncaughtExceptionMonitor, (error) => {
|
|
48
|
-
ServerListenEventError.uncaughtExceptionMonitor(error);
|
|
48
|
+
ServerListenEventError.__init().uncaughtExceptionMonitor(error);
|
|
49
49
|
});
|
|
50
50
|
process.on(event.unhandledRejection, (reason, promise) => {
|
|
51
|
-
ServerListenEventError.unhandledRejection(reason, promise);
|
|
51
|
+
ServerListenEventError.__init().unhandledRejection(reason, promise);
|
|
52
52
|
});
|
|
53
53
|
process.on(event.warning, (warning) => {
|
|
54
|
-
ServerListenEventError.warning(warning);
|
|
54
|
+
ServerListenEventError.__init().warning(warning);
|
|
55
55
|
});
|
|
56
56
|
process.on(event.message, (message) => {
|
|
57
|
-
ServerListenEventError.message(message);
|
|
57
|
+
ServerListenEventError.__init().message(message);
|
|
58
58
|
});
|
|
59
59
|
process.on(event.multipleResolves, (type, promise, reason) => {
|
|
60
|
-
ServerListenEventError.multipleResolves(type, promise, reason);
|
|
60
|
+
ServerListenEventError.__init().multipleResolves(type, promise, reason);
|
|
61
61
|
});
|
|
62
62
|
process.on(event.sigint, () => {
|
|
63
|
-
ServerListenEventError.processInterrupted();
|
|
63
|
+
ServerListenEventError.__init().processInterrupted();
|
|
64
64
|
});
|
|
65
65
|
process.on(event.sigterm, (signal) => {
|
|
66
|
-
ServerListenEventError.sigtermSignalReceived(signal);
|
|
66
|
+
ServerListenEventError.__init().sigtermSignalReceived(signal);
|
|
67
67
|
});
|
|
68
68
|
app.use((err, req, res, next) => {
|
|
69
|
-
ServerListenEventError.expressErrorHandlingMiddleware(errorEmitter, err, req, res, next);
|
|
69
|
+
ServerListenEventError.__init().expressErrorHandlingMiddleware(errorEmitter, err, req, res, next);
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
|
|
@@ -273,9 +273,12 @@ var CoreService = class {
|
|
|
273
273
|
// src/core/webServer.core.ts
|
|
274
274
|
import { TranslationLoader as TranslationLoader3 } from "opticore-translator";
|
|
275
275
|
var WebServerCore = class {
|
|
276
|
+
serverUtility = new CoreService();
|
|
277
|
+
expressApp = express2();
|
|
278
|
+
routerExpressApp;
|
|
279
|
+
port;
|
|
280
|
+
host;
|
|
276
281
|
constructor(app, corsOriginOptions) {
|
|
277
|
-
this.serverUtility = new CoreService();
|
|
278
|
-
this.expressApp = express2();
|
|
279
282
|
this.port = Number(getEnvVariable.appPort);
|
|
280
283
|
this.host = getEnvVariable.appHost;
|
|
281
284
|
this.routerExpressApp = app;
|
|
@@ -294,11 +297,11 @@ var WebServerCore = class {
|
|
|
294
297
|
() => {
|
|
295
298
|
try {
|
|
296
299
|
if (this.host === "" && this.port === 0) {
|
|
297
|
-
eventErrorOnListeningServer.hostPortUndefined();
|
|
300
|
+
eventErrorOnListeningServer.__init().hostPortUndefined();
|
|
298
301
|
} else if (this.host === "") {
|
|
299
|
-
eventErrorOnListeningServer.hostUndefined();
|
|
302
|
+
eventErrorOnListeningServer.__init().hostUndefined();
|
|
300
303
|
} else if (this.port === 0) {
|
|
301
|
-
eventErrorOnListeningServer.portUndefined();
|
|
304
|
+
eventErrorOnListeningServer.__init().portUndefined();
|
|
302
305
|
} else {
|
|
303
306
|
this.registerRoutes(routers);
|
|
304
307
|
}
|
|
@@ -311,11 +314,11 @@ var WebServerCore = class {
|
|
|
311
314
|
//, kernelModule: KernelModuleType
|
|
312
315
|
onListeningOnServerEvent(serverWeb) {
|
|
313
316
|
serverWeb.on(eventName2.error, (err) => {
|
|
314
|
-
eventErrorOnListeningServer.onEventError(err);
|
|
317
|
+
eventErrorOnListeningServer.__init().onEventError(err);
|
|
315
318
|
}).on(eventName2.close, () => {
|
|
316
|
-
eventErrorOnListeningServer.serverClosing();
|
|
319
|
+
eventErrorOnListeningServer.__init().serverClosing();
|
|
317
320
|
}).on(eventName2.drop, () => {
|
|
318
|
-
eventErrorOnListeningServer.dropNewConnection();
|
|
321
|
+
eventErrorOnListeningServer.__init().dropNewConnection();
|
|
319
322
|
}).on(eventName2.listening, () => {
|
|
320
323
|
this.infoWebApp();
|
|
321
324
|
});
|
|
@@ -326,7 +329,10 @@ var WebServerCore = class {
|
|
|
326
329
|
});
|
|
327
330
|
}
|
|
328
331
|
translationWebAppLoader() {
|
|
329
|
-
|
|
332
|
+
const __filename2 = fileURLToPath(import.meta.url);
|
|
333
|
+
const __dirname2 = path2.dirname(__filename2);
|
|
334
|
+
const translateMsgJsonFilePath = path2.join(__dirname2, "../../../", "utils", "translations");
|
|
335
|
+
TranslationLoader3.loadTranslations(translateMsgJsonFilePath, getEnvVariable.defaultLocal);
|
|
330
336
|
}
|
|
331
337
|
registerRoutes(allFeatureRoutes) {
|
|
332
338
|
allFeatureRoutes.map((router) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opticore-webapp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.15",
|
|
4
4
|
"description": "wep server",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -29,21 +29,23 @@
|
|
|
29
29
|
"cors": "^2.8.5",
|
|
30
30
|
"dotenv": "^16.4.7",
|
|
31
31
|
"gradient-string": "^2.0.2",
|
|
32
|
-
"opticore-catch-exception-error": "^1.0.
|
|
32
|
+
"opticore-catch-exception-error": "^1.0.8",
|
|
33
33
|
"opticore-env-access": "^1.0.2",
|
|
34
34
|
"opticore-express": "^1.0.3",
|
|
35
35
|
"opticore-http-response": "^1.0.3",
|
|
36
36
|
"opticore-logger": "^1.0.13",
|
|
37
37
|
"opticore-requests-called-events": "^1.0.0",
|
|
38
38
|
"opticore-router": "^1.0.10",
|
|
39
|
-
"opticore-translator": "^1.0.
|
|
40
|
-
"opticore-validator": "^1.0.3"
|
|
41
|
-
"tslib": "^2.8.1",
|
|
42
|
-
"typescript": "^5.4.5"
|
|
39
|
+
"opticore-translator": "^1.0.3",
|
|
40
|
+
"opticore-validator": "^1.0.3"
|
|
43
41
|
},
|
|
44
42
|
"devDependencies": {
|
|
43
|
+
"@types/node": "^22.13.5",
|
|
45
44
|
"@types/cors": "^2.8.17",
|
|
46
45
|
"@types/gradient-string": "^1.1.6",
|
|
47
|
-
"
|
|
46
|
+
"reflect-metadata": "^0.2.2",
|
|
47
|
+
"tslib": "^2.8.1",
|
|
48
|
+
"tsup": "^8.3.5",
|
|
49
|
+
"typescript": "^5.4.5"
|
|
48
50
|
}
|
|
49
51
|
}
|
|
@@ -20,7 +20,7 @@ export function eventProcessHandler(): void {
|
|
|
20
20
|
* Listener for error events
|
|
21
21
|
*/
|
|
22
22
|
errorEmitter.on(eventName.error, (error: Error): void => {
|
|
23
|
-
ServerListenEventError.listenerError(error);
|
|
23
|
+
ServerListenEventError.__init().listenerError(error);
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
/**
|
|
@@ -29,7 +29,7 @@ export function eventProcessHandler(): void {
|
|
|
29
29
|
*/
|
|
30
30
|
process.on(event.beforeExit, (code: number): void => {
|
|
31
31
|
setTimeout((): void => {
|
|
32
|
-
ServerListenEventError.processBeforeExit(code);
|
|
32
|
+
ServerListenEventError.__init().processBeforeExit(code);
|
|
33
33
|
}, 100);
|
|
34
34
|
});
|
|
35
35
|
|
|
@@ -37,75 +37,75 @@ export function eventProcessHandler(): void {
|
|
|
37
37
|
*
|
|
38
38
|
*/
|
|
39
39
|
process.on(event.disconnect, (): void => {
|
|
40
|
-
ServerListenEventError.processDisconnected();
|
|
40
|
+
ServerListenEventError.__init().processDisconnected();
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
*
|
|
45
45
|
*/
|
|
46
46
|
process.on(event.exit, (code: number): void => {
|
|
47
|
-
ServerListenEventError.exited(code);
|
|
47
|
+
ServerListenEventError.__init().exited(code);
|
|
48
48
|
});
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
*
|
|
52
52
|
*/
|
|
53
53
|
process.on(event.rejectionHandled, (promise: Promise<any>): void => {
|
|
54
|
-
ServerListenEventError.promiseRejectionHandled(promise);
|
|
54
|
+
ServerListenEventError.__init().promiseRejectionHandled(promise);
|
|
55
55
|
});
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
58
|
*
|
|
59
59
|
*/
|
|
60
60
|
process.on(event.uncaughtException, (error: any): void => {
|
|
61
|
-
ServerListenEventError.uncaughtException(error);
|
|
61
|
+
ServerListenEventError.__init().uncaughtException(error);
|
|
62
62
|
});
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
65
|
*
|
|
66
66
|
*/
|
|
67
67
|
process.on(event.uncaughtExceptionMonitor, (error: any): void => {
|
|
68
|
-
ServerListenEventError.uncaughtExceptionMonitor(error);
|
|
68
|
+
ServerListenEventError.__init().uncaughtExceptionMonitor(error);
|
|
69
69
|
});
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
72
|
*
|
|
73
73
|
*/
|
|
74
74
|
process.on(event.unhandledRejection, (reason: any, promise: Promise<any>): void => {
|
|
75
|
-
ServerListenEventError.unhandledRejection(reason, promise);
|
|
75
|
+
ServerListenEventError.__init().unhandledRejection(reason, promise);
|
|
76
76
|
});
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
79
|
*
|
|
80
80
|
*/
|
|
81
81
|
process.on(event.warning, (warning: any): void => {
|
|
82
|
-
ServerListenEventError.warning(warning);
|
|
82
|
+
ServerListenEventError.__init().warning(warning);
|
|
83
83
|
});
|
|
84
84
|
process.on(event.message, (message: any): void => {
|
|
85
|
-
ServerListenEventError.message(message);
|
|
85
|
+
ServerListenEventError.__init().message(message);
|
|
86
86
|
});
|
|
87
87
|
|
|
88
88
|
/**
|
|
89
89
|
*
|
|
90
90
|
*/
|
|
91
91
|
process.on(event.multipleResolves, (type: string, promise: Promise<any>, reason: any): void => {
|
|
92
|
-
ServerListenEventError.multipleResolves(type, promise, reason);
|
|
92
|
+
ServerListenEventError.__init().multipleResolves(type, promise, reason);
|
|
93
93
|
});
|
|
94
94
|
|
|
95
95
|
/**
|
|
96
96
|
* Handle specific signals
|
|
97
97
|
*/
|
|
98
98
|
process.on(event.sigint, (): void => {
|
|
99
|
-
ServerListenEventError.processInterrupted();
|
|
99
|
+
ServerListenEventError.__init().processInterrupted();
|
|
100
100
|
});
|
|
101
101
|
process.on(event.sigterm, (signal: any): void => {
|
|
102
|
-
ServerListenEventError.sigtermSignalReceived(signal);
|
|
102
|
+
ServerListenEventError.__init().sigtermSignalReceived(signal);
|
|
103
103
|
});
|
|
104
104
|
|
|
105
105
|
/**
|
|
106
106
|
* Express error-handling middleware
|
|
107
107
|
*/
|
|
108
108
|
app.use((err: Error, req: Request, res: Response, next: NextFunction): void => {
|
|
109
|
-
ServerListenEventError.expressErrorHandlingMiddleware(errorEmitter, err, req, res, next);
|
|
109
|
+
ServerListenEventError.__init().expressErrorHandlingMiddleware(errorEmitter, err, req, res, next);
|
|
110
110
|
});
|
|
111
111
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as path from "path";
|
|
2
|
-
import process from "node:process";
|
|
3
2
|
import corsOrigin, { CorsOptions } from "cors";
|
|
4
3
|
import { Server as serverWebApp } from "http";
|
|
5
4
|
import { IncomingMessage, ServerResponse } from "node:http";
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
CEventNameError as eventName,
|
|
@@ -25,11 +25,11 @@ import { TranslationLoader } from "opticore-translator";
|
|
|
25
25
|
export class WebServerCore {
|
|
26
26
|
private serverUtility: CoreService = new CoreService();
|
|
27
27
|
private expressApp = express();
|
|
28
|
-
private readonly routerExpressApp: Application;
|
|
28
|
+
private readonly routerExpressApp: express.Application;
|
|
29
29
|
private readonly port: number;
|
|
30
30
|
private readonly host: string;
|
|
31
31
|
|
|
32
|
-
constructor(app: Application, corsOriginOptions?: Partial<CorsOptions>) {
|
|
32
|
+
constructor(app: express.Application, corsOriginOptions?: Partial<CorsOptions>) {
|
|
33
33
|
this.port = Number(getEnvVariable.appPort);
|
|
34
34
|
this.host = getEnvVariable.appHost;
|
|
35
35
|
this.routerExpressApp = app;
|
|
@@ -51,11 +51,11 @@ export class WebServerCore {
|
|
|
51
51
|
(): void => {
|
|
52
52
|
try {
|
|
53
53
|
if (this.host === "" && this.port === 0) {
|
|
54
|
-
eventErrorOnListeningServer.hostPortUndefined();
|
|
54
|
+
eventErrorOnListeningServer.__init().hostPortUndefined();
|
|
55
55
|
} else if (this.host === "") {
|
|
56
|
-
eventErrorOnListeningServer.hostUndefined();
|
|
56
|
+
eventErrorOnListeningServer.__init().hostUndefined();
|
|
57
57
|
} else if (this.port === 0) {
|
|
58
|
-
eventErrorOnListeningServer.portUndefined();
|
|
58
|
+
eventErrorOnListeningServer.__init().portUndefined();
|
|
59
59
|
} else {
|
|
60
60
|
this.registerRoutes(routers);
|
|
61
61
|
}
|
|
@@ -69,11 +69,11 @@ export class WebServerCore {
|
|
|
69
69
|
//, kernelModule: KernelModuleType
|
|
70
70
|
public onListeningOnServerEvent(serverWeb: serverWebApp): void {
|
|
71
71
|
serverWeb.on(eventName.error, (err: Error): void => {
|
|
72
|
-
eventErrorOnListeningServer.onEventError(err);
|
|
72
|
+
eventErrorOnListeningServer.__init().onEventError(err);
|
|
73
73
|
}).on(eventName.close, (): void => {
|
|
74
|
-
eventErrorOnListeningServer.serverClosing();
|
|
74
|
+
eventErrorOnListeningServer.__init().serverClosing();
|
|
75
75
|
}).on(eventName.drop, (): void => {
|
|
76
|
-
eventErrorOnListeningServer.dropNewConnection();
|
|
76
|
+
eventErrorOnListeningServer.__init().dropNewConnection();
|
|
77
77
|
}).on(eventName.listening, (): void => {
|
|
78
78
|
this.infoWebApp();
|
|
79
79
|
//this.serverUtility.coreListenerEventLoaderModuleService(kernelModule);
|
|
@@ -87,7 +87,10 @@ export class WebServerCore {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
private translationWebAppLoader(): void {
|
|
90
|
-
|
|
90
|
+
const __filename: string = fileURLToPath(import.meta.url);
|
|
91
|
+
const __dirname: string = path.dirname(__filename);
|
|
92
|
+
const translateMsgJsonFilePath: string = path.join(__dirname, '../../../', 'utils', 'translations');
|
|
93
|
+
TranslationLoader.loadTranslations(translateMsgJsonFilePath, getEnvVariable.defaultLocal);
|
|
91
94
|
}
|
|
92
95
|
private registerRoutes(allFeatureRoutes: { featureRoute: IRouteDefinition[] }[]): void {
|
|
93
96
|
allFeatureRoutes.map((router: {featureRoute: IRouteDefinition[]} ): void => {
|
package/tsconfig.json
CHANGED
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
"noImplicitAny": true,
|
|
5
5
|
"esModuleInterop": true,
|
|
6
6
|
"strictNullChecks": true,
|
|
7
|
-
"module": "
|
|
7
|
+
"module": "ES2022",
|
|
8
8
|
"pretty": true,
|
|
9
|
-
"target": "
|
|
9
|
+
"target": "es2022",
|
|
10
10
|
"moduleResolution": "node",
|
|
11
11
|
"declaration": true,
|
|
12
12
|
"isolatedModules": true,
|
|
13
13
|
"noEmit": false,
|
|
14
|
-
"types": ["reflect-metadata"],
|
|
14
|
+
"types": ["reflect-metadata", "node"],
|
|
15
15
|
"experimentalDecorators": true,
|
|
16
16
|
"outDir": "./dist",
|
|
17
17
|
"importHelpers": true,
|