opticore-webapp 1.0.9 → 1.0.11
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 +37 -93
- package/dist/index.d.cts +6 -8
- package/dist/index.d.ts +6 -8
- package/dist/index.js +37 -93
- package/package.json +3 -1
- package/src/application/service/core.service.ts +4 -4
- package/src/core/{utils → helpers}/logMessage.utils.ts +1 -1
- package/src/core/helpers/modulesLoaded.utils.ts +22 -0
- package/src/core/webServer.core.ts +10 -8
- package/src/utils/translations/messages.exception.en.json +78 -0
- package/src/utils/translations/messages.exception.fr.json +78 -0
- package/src/application/exceptions/messages.exception.ts +0 -67
- package/src/core/utils/modulesLoaded.utils.ts +0 -17
- /package/src/core/{utils → helpers}/dateTimeFormatted.utils.ts +0 -0
package/dist/index.cjs
CHANGED
|
@@ -101,18 +101,20 @@ var import_node_process2 = __toESM(require("process"), 1);
|
|
|
101
101
|
var import_chalk = __toESM(require("chalk"), 1);
|
|
102
102
|
var path = __toESM(require("path"), 1);
|
|
103
103
|
var fs = __toESM(require("fs"), 1);
|
|
104
|
-
var
|
|
104
|
+
var import_ansi_colors3 = __toESM(require("ansi-colors"), 1);
|
|
105
105
|
var import_opticore_http_response = require("opticore-http-response");
|
|
106
106
|
var import_opticore_catch_exception_error2 = require("opticore-catch-exception-error");
|
|
107
107
|
|
|
108
|
-
// src/core/
|
|
108
|
+
// src/core/helpers/modulesLoaded.utils.ts
|
|
109
109
|
var import_ansi_colors2 = __toESM(require("ansi-colors"), 1);
|
|
110
110
|
|
|
111
|
-
// src/core/
|
|
111
|
+
// src/core/helpers/logMessage.utils.ts
|
|
112
|
+
var import_ansi_colors = __toESM(require("ansi-colors"), 1);
|
|
113
|
+
|
|
114
|
+
// src/core/helpers/dateTimeFormatted.utils.ts
|
|
112
115
|
var dateTimeFormattedUtils = `${(/* @__PURE__ */ new Date()).getMonth()}-${(/* @__PURE__ */ new Date()).getDate()}-${(/* @__PURE__ */ new Date()).getFullYear()} ${(/* @__PURE__ */ new Date()).getHours()}:${(/* @__PURE__ */ new Date()).getMinutes()}:${(/* @__PURE__ */ new Date()).getSeconds()}`;
|
|
113
116
|
|
|
114
|
-
// src/core/
|
|
115
|
-
var import_ansi_colors = __toESM(require("ansi-colors"), 1);
|
|
117
|
+
// src/core/helpers/logMessage.utils.ts
|
|
116
118
|
var LogMessageUtils = class {
|
|
117
119
|
static success(title, action, contentAction) {
|
|
118
120
|
console.log(`${import_ansi_colors.default.green(`\u2714`)} ${import_ansi_colors.default.bgGreen(` ${import_ansi_colors.default.bold(`${import_ansi_colors.default.white(`${title}`)}`)} `)} ${dateTimeFormattedUtils} | ${import_ansi_colors.default.bgGreen(`${import_ansi_colors.default.white(` Success `)}`)} [ ${action} ] ${contentAction} - [ Status ] ${import_ansi_colors.default.bgGreen(`${import_ansi_colors.default.white(` 200 `)}`)}`);
|
|
@@ -131,83 +133,21 @@ var LogMessageUtils = class {
|
|
|
131
133
|
}
|
|
132
134
|
};
|
|
133
135
|
|
|
134
|
-
// src/core/
|
|
136
|
+
// src/core/helpers/modulesLoaded.utils.ts
|
|
137
|
+
var import_opticore_translator = require("opticore-translator");
|
|
135
138
|
function modulesLoadedUtils(allAppRoutes, dbConChecker) {
|
|
136
|
-
LogMessageUtils.success(
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
139
|
+
LogMessageUtils.success(
|
|
140
|
+
`${import_opticore_translator.TranslationLoader.t("kernel", import_opticore_translator.CLocal)}`,
|
|
141
|
+
`${import_opticore_translator.TranslationLoader.t("loadKernel", import_opticore_translator.CLocal)}`,
|
|
142
|
+
`${import_opticore_translator.TranslationLoader.t("moduleAppLoaded", import_opticore_translator.CLocal)}`
|
|
143
|
+
);
|
|
144
|
+
console.log(`${import_ansi_colors2.default.whiteBright(` ${import_opticore_translator.TranslationLoader.t("content", import_opticore_translator.CLocal)}`)} ${import_ansi_colors2.default.green(`${import_opticore_translator.TranslationLoader.t("kernel", import_opticore_translator.CLocal)} :`)} ${import_ansi_colors2.default.cyan(`${import_ansi_colors2.default.bold(`${import_opticore_translator.TranslationLoader.t("serverSide", import_opticore_translator.CLocal)}`)}`)} ${import_opticore_translator.TranslationLoader.t("hasBeenLoadedSuccessfully", import_opticore_translator.CLocal)} ${import_ansi_colors2.default.green(`\u2714`)}`);
|
|
145
|
+
allAppRoutes ? console.log(`${import_ansi_colors2.default.whiteBright(` ${import_opticore_translator.TranslationLoader.t("content", import_opticore_translator.CLocal)}`)} ${import_ansi_colors2.default.green(`${import_opticore_translator.TranslationLoader.t("kernel", import_opticore_translator.CLocal)} :`)} ${import_ansi_colors2.default.cyan(`${import_ansi_colors2.default.bold(`${import_opticore_translator.TranslationLoader.t("routerService", import_opticore_translator.CLocal)}`)} `)} ${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", import_opticore_translator.CLocal)} `)}`)} `)} | ${dateTimeFormattedUtils} | [ ${import_ansi_colors2.default.red(`${import_ansi_colors2.default.bold(` ${import_opticore_translator.TranslationLoader.t("fail", import_opticore_translator.CLocal)} `)}`)} ] | [ ${import_ansi_colors2.default.bold(` ${import_opticore_translator.TranslationLoader.t("loading", import_opticore_translator.CLocal)} `)} ] - ${import_ansi_colors2.default.red(` ${import_opticore_translator.TranslationLoader.t("routers", import_opticore_translator.CLocal)} `)} - ${import_opticore_translator.TranslationLoader.t("registerLoadingFailed", import_opticore_translator.CLocal)} `);
|
|
146
|
+
typeof dbConChecker == "function" ? console.log(`${import_ansi_colors2.default.whiteBright(` ${import_opticore_translator.TranslationLoader.t("content", import_opticore_translator.CLocal)}`)} ${import_ansi_colors2.default.green(`${import_opticore_translator.TranslationLoader.t("kernel", import_opticore_translator.CLocal)} :`)} ${import_ansi_colors2.default.cyan(`${import_ansi_colors2.default.bold(`${import_opticore_translator.TranslationLoader.t("dbConnChecker", import_opticore_translator.CLocal)}`)}`)} ${import_opticore_translator.TranslationLoader.t("hasBeenLoadedSuccessfully", import_opticore_translator.CLocal)} ${import_ansi_colors2.default.green(`\u2714`)}`) : "";
|
|
140
147
|
}
|
|
141
148
|
|
|
142
|
-
// src/application/exceptions/messages.exception.ts
|
|
143
|
-
var import_ansi_colors3 = __toESM(require("ansi-colors"), 1);
|
|
144
|
-
var messageException = {
|
|
145
|
-
dbConnection: "DataBase connection",
|
|
146
|
-
dbConnectionClosed: "MySQL connection is closed",
|
|
147
|
-
mysqlErrorCon: "MysqlError connection",
|
|
148
|
-
mySQLError: "MysqlError",
|
|
149
|
-
mySqlCloseConnection: "MySql close connection",
|
|
150
|
-
verifyExistingKey: "Verify Existing Key",
|
|
151
|
-
invalidRequest: "Invalid request",
|
|
152
|
-
tokenNotProvided: "No token provided.",
|
|
153
|
-
ExpiresToken: "Expires Token. You're not authorize",
|
|
154
|
-
privateKeyNotExist: "A private key doesn't exist.",
|
|
155
|
-
publicKeyNotExist: "A public key doesn't exist.",
|
|
156
|
-
errorNamePublicKeyNotExist: "No public key",
|
|
157
|
-
errorAuthorPublicKeyNotExist: "PublicKey not existing",
|
|
158
|
-
errorDecryption: "Error decryption with private key",
|
|
159
|
-
rsaKeyNotFound: "RSA key provided is not found.",
|
|
160
|
-
notVerifyingRSAKey: "Not verify RSA Key",
|
|
161
|
-
errorNameNotVerifyingRSAKey: "Error Verify RSA Key",
|
|
162
|
-
errorEncryptionPublicKey: "Error encryption with public key",
|
|
163
|
-
errorEncryptionPrivateKey: "Error encryption with private key",
|
|
164
|
-
errorNameRsaVerifyExistingKey: "Verify existing key",
|
|
165
|
-
signatureRSAKeyFailed: "Signature verification failed.",
|
|
166
|
-
encryptionWithPrivateKeyFailed: "Encryption With PrivateKey",
|
|
167
|
-
encryptionFailed: "Encryption failed",
|
|
168
|
-
decryptionWithPublicKeyFailed: "Decryption With PublicKey",
|
|
169
|
-
decryptionFailed: "Decryption failed",
|
|
170
|
-
verifyRSAKey: "Verify RSA Keys",
|
|
171
|
-
verifyRSAKeyFailed: "Verify RSA Keys Failed",
|
|
172
|
-
notVerifying: "Verification failed",
|
|
173
|
-
signatureRSAKeysError: "Signature RSA Keys Error",
|
|
174
|
-
encryptionWithPublicKey: "Encryption error",
|
|
175
|
-
errorDecryptionWithPrivateKey: "Error Decryption With PrivateKey",
|
|
176
|
-
verifyPublicRSAKey: "Verify Public RSA Key",
|
|
177
|
-
PostgresDBConnectionChecker: "PostgresDB Connection Checker",
|
|
178
|
-
PostgresConnection: "connection",
|
|
179
|
-
MongoDBConnectionChecker: "MongoDB Connection Checker",
|
|
180
|
-
MongoConnection: "connection",
|
|
181
|
-
mongoDBAuthentication: "authentication",
|
|
182
|
-
mongoDBConnection: "MongoDB connection",
|
|
183
|
-
mongoDBAuthenticationFailed: "failed",
|
|
184
|
-
mongoDBUnableParsingUrl: "unable to parse",
|
|
185
|
-
mongoDBConnectionUrl: "url",
|
|
186
|
-
mongoDBServerSelection: "MongoServer selection error",
|
|
187
|
-
mongoDBServer: "MongoServer",
|
|
188
|
-
mongoDBConnectionError: "connection error",
|
|
189
|
-
mongoDBError: "error",
|
|
190
|
-
loadedModules: "Loading core modules",
|
|
191
|
-
loadedModulesError: "Required core modules are not loaded properly",
|
|
192
|
-
dbConnexionSuccess: "The database connection was successful \u{1F680}",
|
|
193
|
-
mongoConnectionSuccess: "Connection to database is successfully.",
|
|
194
|
-
PostgresConnectionSuccess: "Connection to database is successfully.",
|
|
195
|
-
verifyExistingKeyError: "The provided key is not found",
|
|
196
|
-
webServer: "Web server",
|
|
197
|
-
listening: "listening",
|
|
198
|
-
webHost: "host",
|
|
199
|
-
badHost: "bad host",
|
|
200
|
-
hostNotFound: "not found",
|
|
201
|
-
errorHostUrl: "The host and port are not define, please define them in .env",
|
|
202
|
-
badPort: "bad port",
|
|
203
|
-
errorPort: "The port is not correct. Please define a right port with number port.",
|
|
204
|
-
errorHost: "The host can't be empty or blank. Please define a string host in .env",
|
|
205
|
-
accessDeniedToDBCon: (user, password) => `Access denied for user ${user}. Database credentials in .env file are User: ${user} and Password: ${password}. '${user}''${password}'@'localhost'. Try to set user and password in .env file`,
|
|
206
|
-
unknownDB: (database) => `Database ${database} is unknown. Please try to use Database CLI to create your database, or do it manually in your Database Management System`,
|
|
207
|
-
errorDBHost: (host) => `A database host ${host} does not allow connection. Please either set the host like this: ${import_ansi_colors3.default.bgRed(`${import_ansi_colors3.default.white(`localhost`)}`)} in your .env file`
|
|
208
|
-
};
|
|
209
|
-
|
|
210
149
|
// src/application/service/core.service.ts
|
|
150
|
+
var import_opticore_translator2 = require("opticore-translator");
|
|
211
151
|
var CoreService = class {
|
|
212
152
|
/**
|
|
213
153
|
*
|
|
@@ -300,21 +240,21 @@ var CoreService = class {
|
|
|
300
240
|
this.getEnvFileLoading(".env");
|
|
301
241
|
const isDevelopment = import_node_process2.default.env.NODE_ENV === "development";
|
|
302
242
|
if (isDevelopment) {
|
|
303
|
-
return `The server is running in ${
|
|
243
|
+
return `The server is running in ${import_ansi_colors3.default.bgBlue(`${import_ansi_colors3.default.bold(`${development}`)}`)} mode`;
|
|
304
244
|
} else {
|
|
305
|
-
return `The server is running in ${
|
|
245
|
+
return `The server is running in ${import_ansi_colors3.default.bgBlue(`${import_ansi_colors3.default.bold(`${production}`)}`)} mode`;
|
|
306
246
|
}
|
|
307
247
|
}
|
|
308
248
|
infoServer(nodeVersion, startingTime, host, port, rss, heapUsed, user, system) {
|
|
309
249
|
const paddingLength = 52;
|
|
310
250
|
const msg0 = " ".padEnd(paddingLength, " ");
|
|
311
251
|
const msg1 = " [OK] Web server listening";
|
|
312
|
-
const msg2Value = `${
|
|
252
|
+
const msg2Value = `${import_ansi_colors3.default.bgBlue(`${import_ansi_colors3.default.bold(`${nodeVersion}`)}`)}`;
|
|
313
253
|
const msg2 = ` The Web server is using Node.js version`;
|
|
314
|
-
const msg3Value = `${
|
|
254
|
+
const msg3Value = `${import_ansi_colors3.default.bgBlue(`${import_ansi_colors3.default.bold(`${startingTime}`)}`)}`;
|
|
315
255
|
const msg3 = ` Startup time:`;
|
|
316
256
|
const msg4 = ` ${this.getServerRunningMode("development", "production")}`;
|
|
317
|
-
const msg5 = ` ${
|
|
257
|
+
const msg5 = ` ${import_ansi_colors3.default.underline(`http://${host}:${port}`)}`;
|
|
318
258
|
console.log(import_chalk.default.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
319
259
|
console.log(import_chalk.default.bgGreen.white(msg1.padEnd(paddingLength, " ")));
|
|
320
260
|
console.log(import_chalk.default.bgGreen.white(msg2, msg2Value.padEnd(30.5, " ")));
|
|
@@ -323,10 +263,10 @@ var CoreService = class {
|
|
|
323
263
|
console.log(import_chalk.default.bgGreen.white(msg5.padEnd(61, " ")));
|
|
324
264
|
console.log(import_chalk.default.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
325
265
|
console.log(``);
|
|
326
|
-
console.log(`${`Resident Set Size - total memory allocated for the process execution :`} ${
|
|
327
|
-
console.log(`${`Actual memory used during the execution :`} ${
|
|
328
|
-
console.log(`${`Memory usage by user :`} ${
|
|
329
|
-
console.log(`${`Memory usage by system :`} ${
|
|
266
|
+
console.log(`${`Resident Set Size - total memory allocated for the process execution :`} ${import_ansi_colors3.default.cyan(`${import_ansi_colors3.default.bold(`${rss}`)}`)}`);
|
|
267
|
+
console.log(`${`Actual memory used during the execution :`} ${import_ansi_colors3.default.cyan(`${import_ansi_colors3.default.bold(`${heapUsed}`)}`)}`);
|
|
268
|
+
console.log(`${`Memory usage by user :`} ${import_ansi_colors3.default.cyan(`${import_ansi_colors3.default.bold(`${user}`)}`)}`);
|
|
269
|
+
console.log(`${`Memory usage by system :`} ${import_ansi_colors3.default.cyan(`${import_ansi_colors3.default.bold(`${system}`)}`)}`);
|
|
330
270
|
console.log(``);
|
|
331
271
|
}
|
|
332
272
|
coreListenerEventLoaderModuleService(kernelModule) {
|
|
@@ -346,8 +286,8 @@ var CoreService = class {
|
|
|
346
286
|
})();
|
|
347
287
|
} else {
|
|
348
288
|
const stackTrace = new import_opticore_catch_exception_error2.StackTraceError(
|
|
349
|
-
|
|
350
|
-
|
|
289
|
+
import_opticore_translator2.TranslationLoader.t("loadedModulesError", import_opticore_translator2.CLocal),
|
|
290
|
+
import_opticore_translator2.TranslationLoader.t("loadedModules", import_opticore_translator2.CLocal),
|
|
351
291
|
import_opticore_http_response.HttpStatusCode.NOT_ACCEPTABLE,
|
|
352
292
|
true
|
|
353
293
|
);
|
|
@@ -357,6 +297,9 @@ var CoreService = class {
|
|
|
357
297
|
};
|
|
358
298
|
|
|
359
299
|
// src/core/webServer.core.ts
|
|
300
|
+
var import_opticore_translator3 = require("opticore-translator");
|
|
301
|
+
var path2 = __toESM(require("path"), 1);
|
|
302
|
+
var import_node_process3 = __toESM(require("process"), 1);
|
|
360
303
|
var WebServerCore = class {
|
|
361
304
|
constructor(app, corsOriginOptions) {
|
|
362
305
|
this.serverUtility = new CoreService();
|
|
@@ -370,6 +313,7 @@ var WebServerCore = class {
|
|
|
370
313
|
this.expressApp.use(import_opticore_express2.express.urlencoded({ extended: true }));
|
|
371
314
|
this.expressApp.use((0, import_cors.default)(corsOriginOptions));
|
|
372
315
|
this.stackTraceErrorHandling();
|
|
316
|
+
this.translationWebAppLoader();
|
|
373
317
|
}
|
|
374
318
|
onStartServer(routers) {
|
|
375
319
|
return this.expressApp.listen(
|
|
@@ -392,7 +336,8 @@ var WebServerCore = class {
|
|
|
392
336
|
}
|
|
393
337
|
);
|
|
394
338
|
}
|
|
395
|
-
|
|
339
|
+
//, kernelModule: KernelModuleType
|
|
340
|
+
onListeningOnServerEvent(serverWeb) {
|
|
396
341
|
serverWeb.on(import_opticore_catch_exception_error3.CEventNameError.error, (err) => {
|
|
397
342
|
import_opticore_catch_exception_error3.ServerListenEventError.onEventError(err);
|
|
398
343
|
}).on(import_opticore_catch_exception_error3.CEventNameError.close, () => {
|
|
@@ -401,7 +346,6 @@ var WebServerCore = class {
|
|
|
401
346
|
import_opticore_catch_exception_error3.ServerListenEventError.dropNewConnection();
|
|
402
347
|
}).on(import_opticore_catch_exception_error3.CEventNameError.listening, () => {
|
|
403
348
|
this.infoWebApp();
|
|
404
|
-
this.serverUtility.coreListenerEventLoaderModuleService(kernelModule);
|
|
405
349
|
});
|
|
406
350
|
}
|
|
407
351
|
onRequestOnServerEvent(serverWeb) {
|
|
@@ -409,8 +353,8 @@ var WebServerCore = class {
|
|
|
409
353
|
(0, import_opticore_requests_called_events.requestCallsEvent)(req, res, this.host, this.port, dateTimeFormattedUtils);
|
|
410
354
|
});
|
|
411
355
|
}
|
|
412
|
-
|
|
413
|
-
|
|
356
|
+
translationWebAppLoader() {
|
|
357
|
+
import_opticore_translator3.TranslationLoader.loadTranslations(path2.join(import_node_process3.default.cwd(), "src", "utils", "translations"), import_opticore_env_access.getEnvVariable.defaultLocal);
|
|
414
358
|
}
|
|
415
359
|
registerRoutes(allFeatureRoutes) {
|
|
416
360
|
allFeatureRoutes.map((router) => {
|
package/dist/index.d.cts
CHANGED
|
@@ -7,10 +7,6 @@ interface IRouteDefinition {
|
|
|
7
7
|
handler: Router;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
type KernelModuleType = [{
|
|
11
|
-
featureRoute: IRouteDefinition[];
|
|
12
|
-
}[], () => void];
|
|
13
|
-
|
|
14
10
|
declare class WebServerCore {
|
|
15
11
|
private serverUtility;
|
|
16
12
|
private expressApp;
|
|
@@ -21,15 +17,17 @@ declare class WebServerCore {
|
|
|
21
17
|
onStartServer(routers: {
|
|
22
18
|
featureRoute: IRouteDefinition[];
|
|
23
19
|
}[]): any;
|
|
24
|
-
onListeningOnServerEvent(serverWeb: Server
|
|
20
|
+
onListeningOnServerEvent(serverWeb: Server): void;
|
|
25
21
|
onRequestOnServerEvent(serverWeb: Server): void;
|
|
26
|
-
|
|
27
|
-
featureRoute: IRouteDefinition[];
|
|
28
|
-
}[], dbConnection: () => void): KernelModuleType;
|
|
22
|
+
private translationWebAppLoader;
|
|
29
23
|
private registerRoutes;
|
|
30
24
|
private stackTraceErrorHandling;
|
|
31
25
|
private infoWebApp;
|
|
32
26
|
private traceError;
|
|
33
27
|
}
|
|
34
28
|
|
|
29
|
+
type KernelModuleType = [{
|
|
30
|
+
featureRoute: IRouteDefinition[];
|
|
31
|
+
}[], () => void];
|
|
32
|
+
|
|
35
33
|
export { type IRouteDefinition, type KernelModuleType, WebServerCore as WebServer };
|
package/dist/index.d.ts
CHANGED
|
@@ -7,10 +7,6 @@ interface IRouteDefinition {
|
|
|
7
7
|
handler: Router;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
type KernelModuleType = [{
|
|
11
|
-
featureRoute: IRouteDefinition[];
|
|
12
|
-
}[], () => void];
|
|
13
|
-
|
|
14
10
|
declare class WebServerCore {
|
|
15
11
|
private serverUtility;
|
|
16
12
|
private expressApp;
|
|
@@ -21,15 +17,17 @@ declare class WebServerCore {
|
|
|
21
17
|
onStartServer(routers: {
|
|
22
18
|
featureRoute: IRouteDefinition[];
|
|
23
19
|
}[]): any;
|
|
24
|
-
onListeningOnServerEvent(serverWeb: Server
|
|
20
|
+
onListeningOnServerEvent(serverWeb: Server): void;
|
|
25
21
|
onRequestOnServerEvent(serverWeb: Server): void;
|
|
26
|
-
|
|
27
|
-
featureRoute: IRouteDefinition[];
|
|
28
|
-
}[], dbConnection: () => void): KernelModuleType;
|
|
22
|
+
private translationWebAppLoader;
|
|
29
23
|
private registerRoutes;
|
|
30
24
|
private stackTraceErrorHandling;
|
|
31
25
|
private infoWebApp;
|
|
32
26
|
private traceError;
|
|
33
27
|
}
|
|
34
28
|
|
|
29
|
+
type KernelModuleType = [{
|
|
30
|
+
featureRoute: IRouteDefinition[];
|
|
31
|
+
}[], () => void];
|
|
32
|
+
|
|
35
33
|
export { type IRouteDefinition, type KernelModuleType, WebServerCore as WebServer };
|
package/dist/index.js
CHANGED
|
@@ -73,18 +73,20 @@ import process2 from "node:process";
|
|
|
73
73
|
import chalk from "chalk";
|
|
74
74
|
import * as path from "path";
|
|
75
75
|
import * as fs from "fs";
|
|
76
|
-
import
|
|
76
|
+
import colors3 from "ansi-colors";
|
|
77
77
|
import { HttpStatusCode as status } from "opticore-http-response";
|
|
78
78
|
import { StackTraceError } from "opticore-catch-exception-error";
|
|
79
79
|
|
|
80
|
-
// src/core/
|
|
80
|
+
// src/core/helpers/modulesLoaded.utils.ts
|
|
81
81
|
import colors2 from "ansi-colors";
|
|
82
82
|
|
|
83
|
-
// src/core/
|
|
83
|
+
// src/core/helpers/logMessage.utils.ts
|
|
84
|
+
import colors from "ansi-colors";
|
|
85
|
+
|
|
86
|
+
// src/core/helpers/dateTimeFormatted.utils.ts
|
|
84
87
|
var dateTimeFormattedUtils = `${(/* @__PURE__ */ new Date()).getMonth()}-${(/* @__PURE__ */ new Date()).getDate()}-${(/* @__PURE__ */ new Date()).getFullYear()} ${(/* @__PURE__ */ new Date()).getHours()}:${(/* @__PURE__ */ new Date()).getMinutes()}:${(/* @__PURE__ */ new Date()).getSeconds()}`;
|
|
85
88
|
|
|
86
|
-
// src/core/
|
|
87
|
-
import colors from "ansi-colors";
|
|
89
|
+
// src/core/helpers/logMessage.utils.ts
|
|
88
90
|
var LogMessageUtils = class {
|
|
89
91
|
static success(title, action, contentAction) {
|
|
90
92
|
console.log(`${colors.green(`\u2714`)} ${colors.bgGreen(` ${colors.bold(`${colors.white(`${title}`)}`)} `)} ${dateTimeFormattedUtils} | ${colors.bgGreen(`${colors.white(` Success `)}`)} [ ${action} ] ${contentAction} - [ Status ] ${colors.bgGreen(`${colors.white(` 200 `)}`)}`);
|
|
@@ -103,83 +105,21 @@ var LogMessageUtils = class {
|
|
|
103
105
|
}
|
|
104
106
|
};
|
|
105
107
|
|
|
106
|
-
// src/core/
|
|
108
|
+
// src/core/helpers/modulesLoaded.utils.ts
|
|
109
|
+
import { CLocal, TranslationLoader } from "opticore-translator";
|
|
107
110
|
function modulesLoadedUtils(allAppRoutes, dbConChecker) {
|
|
108
|
-
LogMessageUtils.success(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
111
|
+
LogMessageUtils.success(
|
|
112
|
+
`${TranslationLoader.t("kernel", CLocal)}`,
|
|
113
|
+
`${TranslationLoader.t("loadKernel", CLocal)}`,
|
|
114
|
+
`${TranslationLoader.t("moduleAppLoaded", CLocal)}`
|
|
115
|
+
);
|
|
116
|
+
console.log(`${colors2.whiteBright(` ${TranslationLoader.t("content", CLocal)}`)} ${colors2.green(`${TranslationLoader.t("kernel", CLocal)} :`)} ${colors2.cyan(`${colors2.bold(`${TranslationLoader.t("serverSide", CLocal)}`)}`)} ${TranslationLoader.t("hasBeenLoadedSuccessfully", CLocal)} ${colors2.green(`\u2714`)}`);
|
|
117
|
+
allAppRoutes ? console.log(`${colors2.whiteBright(` ${TranslationLoader.t("content", CLocal)}`)} ${colors2.green(`${TranslationLoader.t("kernel", CLocal)} :`)} ${colors2.cyan(`${colors2.bold(`${TranslationLoader.t("routerService", CLocal)}`)} `)} ${colors2.green(`\u2714`)}`) : console.log(`${colors2.red(`\u2718`)} ${colors2.bgRed(` ${colors2.bold(`${colors2.white(` ${TranslationLoader.t("registerRoutes", CLocal)} `)}`)} `)} | ${dateTimeFormattedUtils} | [ ${colors2.red(`${colors2.bold(` ${TranslationLoader.t("fail", CLocal)} `)}`)} ] | [ ${colors2.bold(` ${TranslationLoader.t("loading", CLocal)} `)} ] - ${colors2.red(` ${TranslationLoader.t("routers", CLocal)} `)} - ${TranslationLoader.t("registerLoadingFailed", CLocal)} `);
|
|
118
|
+
typeof dbConChecker == "function" ? console.log(`${colors2.whiteBright(` ${TranslationLoader.t("content", CLocal)}`)} ${colors2.green(`${TranslationLoader.t("kernel", CLocal)} :`)} ${colors2.cyan(`${colors2.bold(`${TranslationLoader.t("dbConnChecker", CLocal)}`)}`)} ${TranslationLoader.t("hasBeenLoadedSuccessfully", CLocal)} ${colors2.green(`\u2714`)}`) : "";
|
|
112
119
|
}
|
|
113
120
|
|
|
114
|
-
// src/application/exceptions/messages.exception.ts
|
|
115
|
-
import colors3 from "ansi-colors";
|
|
116
|
-
var messageException = {
|
|
117
|
-
dbConnection: "DataBase connection",
|
|
118
|
-
dbConnectionClosed: "MySQL connection is closed",
|
|
119
|
-
mysqlErrorCon: "MysqlError connection",
|
|
120
|
-
mySQLError: "MysqlError",
|
|
121
|
-
mySqlCloseConnection: "MySql close connection",
|
|
122
|
-
verifyExistingKey: "Verify Existing Key",
|
|
123
|
-
invalidRequest: "Invalid request",
|
|
124
|
-
tokenNotProvided: "No token provided.",
|
|
125
|
-
ExpiresToken: "Expires Token. You're not authorize",
|
|
126
|
-
privateKeyNotExist: "A private key doesn't exist.",
|
|
127
|
-
publicKeyNotExist: "A public key doesn't exist.",
|
|
128
|
-
errorNamePublicKeyNotExist: "No public key",
|
|
129
|
-
errorAuthorPublicKeyNotExist: "PublicKey not existing",
|
|
130
|
-
errorDecryption: "Error decryption with private key",
|
|
131
|
-
rsaKeyNotFound: "RSA key provided is not found.",
|
|
132
|
-
notVerifyingRSAKey: "Not verify RSA Key",
|
|
133
|
-
errorNameNotVerifyingRSAKey: "Error Verify RSA Key",
|
|
134
|
-
errorEncryptionPublicKey: "Error encryption with public key",
|
|
135
|
-
errorEncryptionPrivateKey: "Error encryption with private key",
|
|
136
|
-
errorNameRsaVerifyExistingKey: "Verify existing key",
|
|
137
|
-
signatureRSAKeyFailed: "Signature verification failed.",
|
|
138
|
-
encryptionWithPrivateKeyFailed: "Encryption With PrivateKey",
|
|
139
|
-
encryptionFailed: "Encryption failed",
|
|
140
|
-
decryptionWithPublicKeyFailed: "Decryption With PublicKey",
|
|
141
|
-
decryptionFailed: "Decryption failed",
|
|
142
|
-
verifyRSAKey: "Verify RSA Keys",
|
|
143
|
-
verifyRSAKeyFailed: "Verify RSA Keys Failed",
|
|
144
|
-
notVerifying: "Verification failed",
|
|
145
|
-
signatureRSAKeysError: "Signature RSA Keys Error",
|
|
146
|
-
encryptionWithPublicKey: "Encryption error",
|
|
147
|
-
errorDecryptionWithPrivateKey: "Error Decryption With PrivateKey",
|
|
148
|
-
verifyPublicRSAKey: "Verify Public RSA Key",
|
|
149
|
-
PostgresDBConnectionChecker: "PostgresDB Connection Checker",
|
|
150
|
-
PostgresConnection: "connection",
|
|
151
|
-
MongoDBConnectionChecker: "MongoDB Connection Checker",
|
|
152
|
-
MongoConnection: "connection",
|
|
153
|
-
mongoDBAuthentication: "authentication",
|
|
154
|
-
mongoDBConnection: "MongoDB connection",
|
|
155
|
-
mongoDBAuthenticationFailed: "failed",
|
|
156
|
-
mongoDBUnableParsingUrl: "unable to parse",
|
|
157
|
-
mongoDBConnectionUrl: "url",
|
|
158
|
-
mongoDBServerSelection: "MongoServer selection error",
|
|
159
|
-
mongoDBServer: "MongoServer",
|
|
160
|
-
mongoDBConnectionError: "connection error",
|
|
161
|
-
mongoDBError: "error",
|
|
162
|
-
loadedModules: "Loading core modules",
|
|
163
|
-
loadedModulesError: "Required core modules are not loaded properly",
|
|
164
|
-
dbConnexionSuccess: "The database connection was successful \u{1F680}",
|
|
165
|
-
mongoConnectionSuccess: "Connection to database is successfully.",
|
|
166
|
-
PostgresConnectionSuccess: "Connection to database is successfully.",
|
|
167
|
-
verifyExistingKeyError: "The provided key is not found",
|
|
168
|
-
webServer: "Web server",
|
|
169
|
-
listening: "listening",
|
|
170
|
-
webHost: "host",
|
|
171
|
-
badHost: "bad host",
|
|
172
|
-
hostNotFound: "not found",
|
|
173
|
-
errorHostUrl: "The host and port are not define, please define them in .env",
|
|
174
|
-
badPort: "bad port",
|
|
175
|
-
errorPort: "The port is not correct. Please define a right port with number port.",
|
|
176
|
-
errorHost: "The host can't be empty or blank. Please define a string host in .env",
|
|
177
|
-
accessDeniedToDBCon: (user, password) => `Access denied for user ${user}. Database credentials in .env file are User: ${user} and Password: ${password}. '${user}''${password}'@'localhost'. Try to set user and password in .env file`,
|
|
178
|
-
unknownDB: (database) => `Database ${database} is unknown. Please try to use Database CLI to create your database, or do it manually in your Database Management System`,
|
|
179
|
-
errorDBHost: (host) => `A database host ${host} does not allow connection. Please either set the host like this: ${colors3.bgRed(`${colors3.white(`localhost`)}`)} in your .env file`
|
|
180
|
-
};
|
|
181
|
-
|
|
182
121
|
// src/application/service/core.service.ts
|
|
122
|
+
import { CLocal as CLocal2, TranslationLoader as TranslationLoader2 } from "opticore-translator";
|
|
183
123
|
var CoreService = class {
|
|
184
124
|
/**
|
|
185
125
|
*
|
|
@@ -272,21 +212,21 @@ var CoreService = class {
|
|
|
272
212
|
this.getEnvFileLoading(".env");
|
|
273
213
|
const isDevelopment = process2.env.NODE_ENV === "development";
|
|
274
214
|
if (isDevelopment) {
|
|
275
|
-
return `The server is running in ${
|
|
215
|
+
return `The server is running in ${colors3.bgBlue(`${colors3.bold(`${development}`)}`)} mode`;
|
|
276
216
|
} else {
|
|
277
|
-
return `The server is running in ${
|
|
217
|
+
return `The server is running in ${colors3.bgBlue(`${colors3.bold(`${production}`)}`)} mode`;
|
|
278
218
|
}
|
|
279
219
|
}
|
|
280
220
|
infoServer(nodeVersion, startingTime, host, port, rss, heapUsed, user, system) {
|
|
281
221
|
const paddingLength = 52;
|
|
282
222
|
const msg0 = " ".padEnd(paddingLength, " ");
|
|
283
223
|
const msg1 = " [OK] Web server listening";
|
|
284
|
-
const msg2Value = `${
|
|
224
|
+
const msg2Value = `${colors3.bgBlue(`${colors3.bold(`${nodeVersion}`)}`)}`;
|
|
285
225
|
const msg2 = ` The Web server is using Node.js version`;
|
|
286
|
-
const msg3Value = `${
|
|
226
|
+
const msg3Value = `${colors3.bgBlue(`${colors3.bold(`${startingTime}`)}`)}`;
|
|
287
227
|
const msg3 = ` Startup time:`;
|
|
288
228
|
const msg4 = ` ${this.getServerRunningMode("development", "production")}`;
|
|
289
|
-
const msg5 = ` ${
|
|
229
|
+
const msg5 = ` ${colors3.underline(`http://${host}:${port}`)}`;
|
|
290
230
|
console.log(chalk.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
291
231
|
console.log(chalk.bgGreen.white(msg1.padEnd(paddingLength, " ")));
|
|
292
232
|
console.log(chalk.bgGreen.white(msg2, msg2Value.padEnd(30.5, " ")));
|
|
@@ -295,10 +235,10 @@ var CoreService = class {
|
|
|
295
235
|
console.log(chalk.bgGreen.white(msg5.padEnd(61, " ")));
|
|
296
236
|
console.log(chalk.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
297
237
|
console.log(``);
|
|
298
|
-
console.log(`${`Resident Set Size - total memory allocated for the process execution :`} ${
|
|
299
|
-
console.log(`${`Actual memory used during the execution :`} ${
|
|
300
|
-
console.log(`${`Memory usage by user :`} ${
|
|
301
|
-
console.log(`${`Memory usage by system :`} ${
|
|
238
|
+
console.log(`${`Resident Set Size - total memory allocated for the process execution :`} ${colors3.cyan(`${colors3.bold(`${rss}`)}`)}`);
|
|
239
|
+
console.log(`${`Actual memory used during the execution :`} ${colors3.cyan(`${colors3.bold(`${heapUsed}`)}`)}`);
|
|
240
|
+
console.log(`${`Memory usage by user :`} ${colors3.cyan(`${colors3.bold(`${user}`)}`)}`);
|
|
241
|
+
console.log(`${`Memory usage by system :`} ${colors3.cyan(`${colors3.bold(`${system}`)}`)}`);
|
|
302
242
|
console.log(``);
|
|
303
243
|
}
|
|
304
244
|
coreListenerEventLoaderModuleService(kernelModule) {
|
|
@@ -318,8 +258,8 @@ var CoreService = class {
|
|
|
318
258
|
})();
|
|
319
259
|
} else {
|
|
320
260
|
const stackTrace = new StackTraceError(
|
|
321
|
-
|
|
322
|
-
|
|
261
|
+
TranslationLoader2.t("loadedModulesError", CLocal2),
|
|
262
|
+
TranslationLoader2.t("loadedModules", CLocal2),
|
|
323
263
|
status.NOT_ACCEPTABLE,
|
|
324
264
|
true
|
|
325
265
|
);
|
|
@@ -329,6 +269,9 @@ var CoreService = class {
|
|
|
329
269
|
};
|
|
330
270
|
|
|
331
271
|
// src/core/webServer.core.ts
|
|
272
|
+
import { TranslationLoader as TranslationLoader3 } from "opticore-translator";
|
|
273
|
+
import * as path2 from "path";
|
|
274
|
+
import process3 from "node:process";
|
|
332
275
|
var WebServerCore = class {
|
|
333
276
|
constructor(app, corsOriginOptions) {
|
|
334
277
|
this.serverUtility = new CoreService();
|
|
@@ -342,6 +285,7 @@ var WebServerCore = class {
|
|
|
342
285
|
this.expressApp.use(express2.urlencoded({ extended: true }));
|
|
343
286
|
this.expressApp.use(corsOrigin(corsOriginOptions));
|
|
344
287
|
this.stackTraceErrorHandling();
|
|
288
|
+
this.translationWebAppLoader();
|
|
345
289
|
}
|
|
346
290
|
onStartServer(routers) {
|
|
347
291
|
return this.expressApp.listen(
|
|
@@ -364,7 +308,8 @@ var WebServerCore = class {
|
|
|
364
308
|
}
|
|
365
309
|
);
|
|
366
310
|
}
|
|
367
|
-
|
|
311
|
+
//, kernelModule: KernelModuleType
|
|
312
|
+
onListeningOnServerEvent(serverWeb) {
|
|
368
313
|
serverWeb.on(eventName2.error, (err) => {
|
|
369
314
|
eventErrorOnListeningServer.onEventError(err);
|
|
370
315
|
}).on(eventName2.close, () => {
|
|
@@ -373,7 +318,6 @@ var WebServerCore = class {
|
|
|
373
318
|
eventErrorOnListeningServer.dropNewConnection();
|
|
374
319
|
}).on(eventName2.listening, () => {
|
|
375
320
|
this.infoWebApp();
|
|
376
|
-
this.serverUtility.coreListenerEventLoaderModuleService(kernelModule);
|
|
377
321
|
});
|
|
378
322
|
}
|
|
379
323
|
onRequestOnServerEvent(serverWeb) {
|
|
@@ -381,8 +325,8 @@ var WebServerCore = class {
|
|
|
381
325
|
requestCallsEvent(req, res, this.host, this.port, dateTimeFormattedUtils);
|
|
382
326
|
});
|
|
383
327
|
}
|
|
384
|
-
|
|
385
|
-
|
|
328
|
+
translationWebAppLoader() {
|
|
329
|
+
TranslationLoader3.loadTranslations(path2.join(process3.cwd(), "src", "utils", "translations"), getEnvVariable.defaultLocal);
|
|
386
330
|
}
|
|
387
331
|
registerRoutes(allFeatureRoutes) {
|
|
388
332
|
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.11",
|
|
4
4
|
"description": "wep server",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -36,7 +36,9 @@
|
|
|
36
36
|
"opticore-logger": "^1.0.10",
|
|
37
37
|
"opticore-requests-called-events": "^1.0.0",
|
|
38
38
|
"opticore-router": "^1.0.7",
|
|
39
|
+
"opticore-translator": "^1.0.1",
|
|
39
40
|
"opticore-validator": "^1.0.3",
|
|
41
|
+
"tslib": "^2.8.1",
|
|
40
42
|
"typescript": "^5.4.5"
|
|
41
43
|
},
|
|
42
44
|
"devDependencies": {
|
|
@@ -9,8 +9,8 @@ import { StackTraceError } from "opticore-catch-exception-error";
|
|
|
9
9
|
import { Router } from "opticore-express";
|
|
10
10
|
|
|
11
11
|
import { KernelModuleType } from "@webApp/domains/types/kernelModule.type";
|
|
12
|
-
import { modulesLoadedUtils as loadedModules } from "@webApp/core/
|
|
13
|
-
import {
|
|
12
|
+
import { modulesLoadedUtils as loadedModules } from "@webApp/core/helpers/modulesLoaded.utils";
|
|
13
|
+
import {CLocal, TranslationLoader} from "opticore-translator";
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
@@ -172,8 +172,8 @@ export class CoreService {
|
|
|
172
172
|
((): void => { dbCon(); })();
|
|
173
173
|
} else {
|
|
174
174
|
const stackTrace: StackTraceError = new StackTraceError(
|
|
175
|
-
|
|
176
|
-
|
|
175
|
+
TranslationLoader.t("loadedModulesError", CLocal),
|
|
176
|
+
TranslationLoader.t("loadedModules", CLocal),
|
|
177
177
|
status.NOT_ACCEPTABLE,
|
|
178
178
|
true
|
|
179
179
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import colors from "ansi-colors";
|
|
2
|
-
import {
|
|
2
|
+
import {dateTimeFormattedUtils} from "@webApp/core/helpers/dateTimeFormatted.utils";
|
|
3
3
|
|
|
4
4
|
export class LogMessageUtils {
|
|
5
5
|
static success(title: string, action: string, contentAction: string): void {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import colors from "ansi-colors";
|
|
2
|
+
import { Router } from "opticore-express";
|
|
3
|
+
import { LogMessageUtils } from "@webApp/core/helpers/logMessage.utils";
|
|
4
|
+
import { dateTimeFormattedUtils } from "@webApp/core/helpers/dateTimeFormatted.utils";
|
|
5
|
+
import {CLocal, TranslationLoader} from "opticore-translator";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export function modulesLoadedUtils(allAppRoutes: Router[], dbConChecker: () => void): void {
|
|
10
|
+
LogMessageUtils.success(
|
|
11
|
+
`${TranslationLoader.t("kernel", CLocal)}`,
|
|
12
|
+
`${TranslationLoader.t("loadKernel", CLocal)}`,
|
|
13
|
+
`${TranslationLoader.t("moduleAppLoaded", CLocal)}`
|
|
14
|
+
);
|
|
15
|
+
console.log(`${colors.whiteBright(` ${TranslationLoader.t("content", CLocal)}`)} ${colors.green(`${TranslationLoader.t("kernel", CLocal)} :`)} ${colors.cyan(`${colors.bold(`${TranslationLoader.t("serverSide", CLocal)}`)}`)} ${TranslationLoader.t("hasBeenLoadedSuccessfully", CLocal)} ${colors.green(`✔`)}`);
|
|
16
|
+
allAppRoutes
|
|
17
|
+
? console.log(`${colors.whiteBright(` ${TranslationLoader.t("content", CLocal)}`)} ${colors.green(`${TranslationLoader.t("kernel", CLocal)} :`)} ${colors.cyan(`${colors.bold(`${TranslationLoader.t("routerService", CLocal)}`)} `)} ${colors.green(`✔`)}`)
|
|
18
|
+
: console.log(`${colors.red(`✘`)} ${colors.bgRed(` ${colors.bold(`${colors.white(` ${TranslationLoader.t("registerRoutes", CLocal)} `)}`)} `)} | ${dateTimeFormattedUtils} | [ ${colors.red(`${colors.bold(` ${TranslationLoader.t("fail", CLocal)} `)}`)} ] | [ ${colors.bold(` ${TranslationLoader.t("loading", CLocal)} `)} ] - ${colors.red(` ${TranslationLoader.t("routers", CLocal)} `)} - ${TranslationLoader.t("registerLoadingFailed", CLocal)} `);
|
|
19
|
+
typeof dbConChecker == "function"
|
|
20
|
+
? console.log(`${colors.whiteBright(` ${TranslationLoader.t("content", CLocal)}`)} ${colors.green(`${TranslationLoader.t("kernel", CLocal)} :`)} ${colors.cyan(`${colors.bold(`${TranslationLoader.t("dbConnChecker", CLocal)}`)}`)} ${TranslationLoader.t("hasBeenLoadedSuccessfully", CLocal)} ${colors.green(`✔`)}`)
|
|
21
|
+
: "";
|
|
22
|
+
}
|
|
@@ -15,9 +15,10 @@ import { IRouteDefinition } from "@webApp/domains/interfaces/routeDefinition.int
|
|
|
15
15
|
import { KernelModuleType } from "@webApp/domains/types/kernelModule.type";
|
|
16
16
|
import { eventProcessHandler } from "@webApp/core/handlers/eventProcess.handler";
|
|
17
17
|
import { CoreService } from "@webApp/application/service/core.service";
|
|
18
|
-
import { dateTimeFormattedUtils as currentDate } from "@webApp/core/
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
import { dateTimeFormattedUtils as currentDate } from "@webApp/core/helpers/dateTimeFormatted.utils";
|
|
19
|
+
import {TranslationLoader} from "opticore-translator";
|
|
20
|
+
import * as path from "path";
|
|
21
|
+
import process from "node:process";
|
|
21
22
|
|
|
22
23
|
|
|
23
24
|
export class WebServerCore {
|
|
@@ -39,6 +40,7 @@ export class WebServerCore {
|
|
|
39
40
|
this.expressApp.use(corsOrigin(corsOriginOptions));
|
|
40
41
|
|
|
41
42
|
this.stackTraceErrorHandling();
|
|
43
|
+
this.translationWebAppLoader();
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
public onStartServer(routers: { featureRoute: IRouteDefinition[] }[]) {
|
|
@@ -63,7 +65,8 @@ export class WebServerCore {
|
|
|
63
65
|
);
|
|
64
66
|
}
|
|
65
67
|
|
|
66
|
-
|
|
68
|
+
//, kernelModule: KernelModuleType
|
|
69
|
+
public onListeningOnServerEvent(serverWeb: serverWebApp): void {
|
|
67
70
|
serverWeb.on(eventName.error, (err: Error): void => {
|
|
68
71
|
eventErrorOnListeningServer.onEventError(err);
|
|
69
72
|
}).on(eventName.close, (): void => {
|
|
@@ -72,7 +75,7 @@ export class WebServerCore {
|
|
|
72
75
|
eventErrorOnListeningServer.dropNewConnection();
|
|
73
76
|
}).on(eventName.listening, (): void => {
|
|
74
77
|
this.infoWebApp();
|
|
75
|
-
this.serverUtility.coreListenerEventLoaderModuleService(kernelModule);
|
|
78
|
+
//this.serverUtility.coreListenerEventLoaderModuleService(kernelModule);
|
|
76
79
|
});
|
|
77
80
|
}
|
|
78
81
|
|
|
@@ -82,10 +85,9 @@ export class WebServerCore {
|
|
|
82
85
|
});
|
|
83
86
|
}
|
|
84
87
|
|
|
85
|
-
|
|
86
|
-
|
|
88
|
+
private translationWebAppLoader(): void {
|
|
89
|
+
TranslationLoader.loadTranslations(path.join(process.cwd(), 'src', 'utils', 'translations'), getEnvVariable.defaultLocal);
|
|
87
90
|
}
|
|
88
|
-
|
|
89
91
|
private registerRoutes(allFeatureRoutes: { featureRoute: IRouteDefinition[] }[]): void {
|
|
90
92
|
allFeatureRoutes.map((router: {featureRoute: IRouteDefinition[]} ): void => {
|
|
91
93
|
router.featureRoute.map((route: IRouteDefinition): void => {
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{
|
|
2
|
+
"dbConnection": "DataBase connection",
|
|
3
|
+
"dbConnectionClosed": "MySQL connection is closed",
|
|
4
|
+
"mysqlErrorCon": "MysqlError connection",
|
|
5
|
+
"mySQLError": "MysqlError",
|
|
6
|
+
"mySqlCloseConnection": "MySql close connection",
|
|
7
|
+
"verifyExistingKey": "Verify Existing Key",
|
|
8
|
+
"invalidRequest": "Invalid request",
|
|
9
|
+
"tokenNotProvided": "No token provided.",
|
|
10
|
+
"ExpiresToken": "Expires Token. You're not authorize",
|
|
11
|
+
"privateKeyNotExist": "A private key doesn't exist.",
|
|
12
|
+
"publicKeyNotExist": "A public key doesn't exist.",
|
|
13
|
+
"errorNamePublicKeyNotExist": "No public key",
|
|
14
|
+
"errorAuthorPublicKeyNotExist": "PublicKey not existing",
|
|
15
|
+
"errorDecryption": "Error decryption with private key",
|
|
16
|
+
"rsaKeyNotFound": "RSA key provided is not found.",
|
|
17
|
+
"notVerifyingRSAKey": "Not verify RSA Key",
|
|
18
|
+
"errorNameNotVerifyingRSAKey": "Error Verify RSA Key",
|
|
19
|
+
"errorEncryptionPublicKey": "Error encryption with public key",
|
|
20
|
+
"errorEncryptionPrivateKey": "Error encryption with private key",
|
|
21
|
+
"errorNameRsaVerifyExistingKey": "Verify existing key",
|
|
22
|
+
"signatureRSAKeyFailed": "Signature verification failed.",
|
|
23
|
+
"encryptionWithPrivateKeyFailed": "Encryption With PrivateKey",
|
|
24
|
+
"encryptionFailed": "Encryption failed",
|
|
25
|
+
"decryptionWithPublicKeyFailed": "Decryption With PublicKey",
|
|
26
|
+
"decryptionFailed": "Decryption failed",
|
|
27
|
+
"verifyRSAKey": "Verify RSA Keys",
|
|
28
|
+
"verifyRSAKeyFailed": "Verify RSA Keys Failed",
|
|
29
|
+
"notVerifying": "Verification failed",
|
|
30
|
+
"signatureRSAKeysError": "Signature RSA Keys Error",
|
|
31
|
+
"encryptionWithPublicKey": "Encryption error",
|
|
32
|
+
"errorDecryptionWithPrivateKey": "Error Decryption With PrivateKey",
|
|
33
|
+
"verifyPublicRSAKey": "Verify Public RSA Key",
|
|
34
|
+
"PostgresDBConnectionChecker": "PostgresDB Connection Checker",
|
|
35
|
+
"PostgresConnection": "connection",
|
|
36
|
+
"MongoDBConnectionChecker": "MongoDB Connection Checker",
|
|
37
|
+
"MongoConnection": "connection",
|
|
38
|
+
"mongoDBAuthentication": "authentication",
|
|
39
|
+
"mongoDBConnection": "MongoDB connection",
|
|
40
|
+
"mongoDBAuthenticationFailed": "failed",
|
|
41
|
+
"mongoDBUnableParsingUrl": "unable to parse",
|
|
42
|
+
"mongoDBConnectionUrl": "url",
|
|
43
|
+
"mongoDBServerSelection": "MongoServer selection error",
|
|
44
|
+
"mongoDBServer": "MongoServer",
|
|
45
|
+
"mongoDBConnectionError": "connection error",
|
|
46
|
+
"mongoDBError": "error",
|
|
47
|
+
"loadedModules": "Loading core modules",
|
|
48
|
+
"kernel": "Kernel",
|
|
49
|
+
"loadKernel": "load kernel",
|
|
50
|
+
"moduleAppLoaded": "Modules app have been successfully loaded",
|
|
51
|
+
"content": "content",
|
|
52
|
+
"serverSide": "server side",
|
|
53
|
+
"hasBeenLoadedSuccessfully": "has been loaded successfully",
|
|
54
|
+
"routerService": "Routers service",
|
|
55
|
+
"registerRoutes": "Register routes",
|
|
56
|
+
"fail": "fail",
|
|
57
|
+
"loading": "loading",
|
|
58
|
+
"routers": "routers",
|
|
59
|
+
"registerLoadingFailed": "The route register failed to load",
|
|
60
|
+
"dbConnChecker": "database checker connection",
|
|
61
|
+
"loadedModulesError": "Required core modules are not loaded properly",
|
|
62
|
+
"dbConnexionSuccess": "The database connection was successful 🚀",
|
|
63
|
+
"mongoConnectionSuccess": "Connection to database is successfully.",
|
|
64
|
+
"PostgresConnectionSuccess": "Connection to database is successfully.",
|
|
65
|
+
"verifyExistingKeyError": "The provided key is not found",
|
|
66
|
+
"webServer": "Web server",
|
|
67
|
+
"listening": "listening",
|
|
68
|
+
"webHost": "host",
|
|
69
|
+
"badHost": "bad host",
|
|
70
|
+
"hostNotFound": "not found",
|
|
71
|
+
"errorHostUrl": "The host and port are not define, please define them in .env",
|
|
72
|
+
"badPort": "bad port",
|
|
73
|
+
"errorPort": "The port is not correct. Please define a right port with number port.",
|
|
74
|
+
"errorHost": "The host can't be empty or blank. Please define a string host in .env",
|
|
75
|
+
"accessDeniedToDBCon": "Access denied for user {user}. Database credentials in .env file are User: {user} and Password: {password}. {user}''{password}'@'localhost'. Try to set user and password in .env file",
|
|
76
|
+
"unknownDB": "Database {database} is unknown. Please try to use Database CLI to create your database, or do it manually in your Database Management System",
|
|
77
|
+
"errorDBHost": "A database host ${host} does not allow connection. Please either set the host like this: {localhost} in your .env file"
|
|
78
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{
|
|
2
|
+
"dbConnection": "DataBase connection",
|
|
3
|
+
"dbConnectionClosed": "MySQL connection is closed",
|
|
4
|
+
"mysqlErrorCon": "MysqlError connection",
|
|
5
|
+
"mySQLError": "MysqlError",
|
|
6
|
+
"mySqlCloseConnection": "MySql close connection",
|
|
7
|
+
"verifyExistingKey": "Verify Existing Key",
|
|
8
|
+
"invalidRequest": "Invalid request",
|
|
9
|
+
"tokenNotProvided": "No token provided.",
|
|
10
|
+
"ExpiresToken": "Expires Token. You're not authorize",
|
|
11
|
+
"privateKeyNotExist": "A private key doesn't exist.",
|
|
12
|
+
"publicKeyNotExist": "A public key doesn't exist.",
|
|
13
|
+
"errorNamePublicKeyNotExist": "No public key",
|
|
14
|
+
"errorAuthorPublicKeyNotExist": "PublicKey not existing",
|
|
15
|
+
"errorDecryption": "Error decryption with private key",
|
|
16
|
+
"rsaKeyNotFound": "RSA key provided is not found.",
|
|
17
|
+
"notVerifyingRSAKey": "Not verify RSA Key",
|
|
18
|
+
"errorNameNotVerifyingRSAKey": "Error Verify RSA Key",
|
|
19
|
+
"errorEncryptionPublicKey": "Error encryption with public key",
|
|
20
|
+
"errorEncryptionPrivateKey": "Error encryption with private key",
|
|
21
|
+
"errorNameRsaVerifyExistingKey": "Verify existing key",
|
|
22
|
+
"signatureRSAKeyFailed": "Signature verification failed.",
|
|
23
|
+
"encryptionWithPrivateKeyFailed": "Encryption With PrivateKey",
|
|
24
|
+
"encryptionFailed": "Encryption failed",
|
|
25
|
+
"decryptionWithPublicKeyFailed": "Decryption With PublicKey",
|
|
26
|
+
"decryptionFailed": "Decryption failed",
|
|
27
|
+
"verifyRSAKey": "Verify RSA Keys",
|
|
28
|
+
"verifyRSAKeyFailed": "Verify RSA Keys Failed",
|
|
29
|
+
"notVerifying": "Verification failed",
|
|
30
|
+
"signatureRSAKeysError": "Signature RSA Keys Error",
|
|
31
|
+
"encryptionWithPublicKey": "Encryption error",
|
|
32
|
+
"errorDecryptionWithPrivateKey": "Error Decryption With PrivateKey",
|
|
33
|
+
"verifyPublicRSAKey": "Verify Public RSA Key",
|
|
34
|
+
"PostgresDBConnectionChecker": "PostgresDB Connection Checker",
|
|
35
|
+
"PostgresConnection": "connection",
|
|
36
|
+
"MongoDBConnectionChecker": "MongoDB Connection Checker",
|
|
37
|
+
"MongoConnection": "connection",
|
|
38
|
+
"mongoDBAuthentication": "authentication",
|
|
39
|
+
"mongoDBConnection": "MongoDB connection",
|
|
40
|
+
"mongoDBAuthenticationFailed": "failed",
|
|
41
|
+
"mongoDBUnableParsingUrl": "unable to parse",
|
|
42
|
+
"mongoDBConnectionUrl": "url",
|
|
43
|
+
"mongoDBServerSelection": "MongoServer selection error",
|
|
44
|
+
"mongoDBServer": "MongoServer",
|
|
45
|
+
"mongoDBConnectionError": "connection error",
|
|
46
|
+
"mongoDBError": "error",
|
|
47
|
+
"loadedModules": "Loading core modules",
|
|
48
|
+
"kernel": "Kernel",
|
|
49
|
+
"loadKernel": "load kernel",
|
|
50
|
+
"moduleAppLoaded": "Modules app have been successfully loaded",
|
|
51
|
+
"content": "content",
|
|
52
|
+
"serverSide": "server side",
|
|
53
|
+
"hasBeenLoadedSuccessfully": "has been loaded successfully",
|
|
54
|
+
"routerService": "Routers service",
|
|
55
|
+
"registerRoutes": "Register routes",
|
|
56
|
+
"fail": "fail",
|
|
57
|
+
"loading": "loading",
|
|
58
|
+
"routers": "routers",
|
|
59
|
+
"registerLoadingFailed": "The route register failed to load",
|
|
60
|
+
"dbConnChecker": "database checker connection",
|
|
61
|
+
"loadedModulesError": "Required core modules are not loaded properly",
|
|
62
|
+
"dbConnexionSuccess": "The database connection was successful 🚀",
|
|
63
|
+
"mongoConnectionSuccess": "Connection to database is successfully.",
|
|
64
|
+
"PostgresConnectionSuccess": "Connection to database is successfully.",
|
|
65
|
+
"verifyExistingKeyError": "The provided key is not found",
|
|
66
|
+
"webServer": "Web server",
|
|
67
|
+
"listening": "listening",
|
|
68
|
+
"webHost": "host",
|
|
69
|
+
"badHost": "bad host",
|
|
70
|
+
"hostNotFound": "not found",
|
|
71
|
+
"errorHostUrl": "The host and port are not define, please define them in .env",
|
|
72
|
+
"badPort": "bad port",
|
|
73
|
+
"errorPort": "The port is not correct. Please define a right port with number port.",
|
|
74
|
+
"errorHost": "The host can't be empty or blank. Please define a string host in .env",
|
|
75
|
+
"accessDeniedToDBCon": "Access denied for user {user}. Database credentials in .env file are User: {user} and Password: {password}. {user}''{password}'@'localhost'. Try to set user and password in .env file",
|
|
76
|
+
"unknownDB": "Database {database} is unknown. Please try to use Database CLI to create your database, or do it manually in your Database Management System",
|
|
77
|
+
"errorDBHost": "A database host ${host} does not allow connection. Please either set the host like this: {localhost} in your .env file"
|
|
78
|
+
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import colors from "ansi-colors";
|
|
2
|
-
|
|
3
|
-
export const messageException = {
|
|
4
|
-
dbConnection: "DataBase connection",
|
|
5
|
-
dbConnectionClosed: "MySQL connection is closed",
|
|
6
|
-
mysqlErrorCon: "MysqlError connection",
|
|
7
|
-
mySQLError: "MysqlError",
|
|
8
|
-
mySqlCloseConnection: "MySql close connection",
|
|
9
|
-
verifyExistingKey: "Verify Existing Key",
|
|
10
|
-
invalidRequest: "Invalid request",
|
|
11
|
-
tokenNotProvided: "No token provided.",
|
|
12
|
-
ExpiresToken: "Expires Token. You're not authorize",
|
|
13
|
-
privateKeyNotExist: "A private key doesn't exist.",
|
|
14
|
-
publicKeyNotExist: "A public key doesn't exist.",
|
|
15
|
-
errorNamePublicKeyNotExist: "No public key",
|
|
16
|
-
errorAuthorPublicKeyNotExist: "PublicKey not existing",
|
|
17
|
-
errorDecryption: "Error decryption with private key",
|
|
18
|
-
rsaKeyNotFound: "RSA key provided is not found.",
|
|
19
|
-
notVerifyingRSAKey: "Not verify RSA Key",
|
|
20
|
-
errorNameNotVerifyingRSAKey: "Error Verify RSA Key",
|
|
21
|
-
errorEncryptionPublicKey: "Error encryption with public key",
|
|
22
|
-
errorEncryptionPrivateKey: "Error encryption with private key",
|
|
23
|
-
errorNameRsaVerifyExistingKey: "Verify existing key",
|
|
24
|
-
signatureRSAKeyFailed: "Signature verification failed.",
|
|
25
|
-
encryptionWithPrivateKeyFailed: "Encryption With PrivateKey",
|
|
26
|
-
encryptionFailed: "Encryption failed",
|
|
27
|
-
decryptionWithPublicKeyFailed: "Decryption With PublicKey",
|
|
28
|
-
decryptionFailed: "Decryption failed",
|
|
29
|
-
verifyRSAKey: "Verify RSA Keys",
|
|
30
|
-
verifyRSAKeyFailed: "Verify RSA Keys Failed",
|
|
31
|
-
notVerifying: "Verification failed",
|
|
32
|
-
signatureRSAKeysError: "Signature RSA Keys Error",
|
|
33
|
-
encryptionWithPublicKey: "Encryption error",
|
|
34
|
-
errorDecryptionWithPrivateKey: "Error Decryption With PrivateKey",
|
|
35
|
-
verifyPublicRSAKey: "Verify Public RSA Key",
|
|
36
|
-
PostgresDBConnectionChecker: "PostgresDB Connection Checker",
|
|
37
|
-
PostgresConnection: "connection",
|
|
38
|
-
MongoDBConnectionChecker: "MongoDB Connection Checker",
|
|
39
|
-
MongoConnection: "connection",
|
|
40
|
-
mongoDBAuthentication: "authentication",
|
|
41
|
-
mongoDBConnection: "MongoDB connection",
|
|
42
|
-
mongoDBAuthenticationFailed: "failed",
|
|
43
|
-
mongoDBUnableParsingUrl: "unable to parse",
|
|
44
|
-
mongoDBConnectionUrl: "url",
|
|
45
|
-
mongoDBServerSelection: "MongoServer selection error",
|
|
46
|
-
mongoDBServer: "MongoServer",
|
|
47
|
-
mongoDBConnectionError: "connection error",
|
|
48
|
-
mongoDBError: "error",
|
|
49
|
-
loadedModules: "Loading core modules",
|
|
50
|
-
loadedModulesError: "Required core modules are not loaded properly",
|
|
51
|
-
dbConnexionSuccess: "The database connection was successful 🚀",
|
|
52
|
-
mongoConnectionSuccess: "Connection to database is successfully.",
|
|
53
|
-
PostgresConnectionSuccess: "Connection to database is successfully.",
|
|
54
|
-
verifyExistingKeyError: "The provided key is not found",
|
|
55
|
-
webServer: "Web server",
|
|
56
|
-
listening: "listening",
|
|
57
|
-
webHost: "host",
|
|
58
|
-
badHost: "bad host",
|
|
59
|
-
hostNotFound: "not found",
|
|
60
|
-
errorHostUrl: "The host and port are not define, please define them in .env",
|
|
61
|
-
badPort: "bad port",
|
|
62
|
-
errorPort: "The port is not correct. Please define a right port with number port.",
|
|
63
|
-
errorHost: "The host can't be empty or blank. Please define a string host in .env",
|
|
64
|
-
accessDeniedToDBCon: (user: string, password: string): string => `Access denied for user ${user}. Database credentials in .env file are User: ${user} and Password: ${password}. '${user}''${password}'@'localhost'. Try to set user and password in .env file`,
|
|
65
|
-
unknownDB: (database: string): string => `Database ${database} is unknown. Please try to use Database CLI to create your database, or do it manually in your Database Management System`,
|
|
66
|
-
errorDBHost: (host: string): string => `A database host ${host} does not allow connection. Please either set the host like this: ${colors.bgRed(`${colors.white(`localhost`)}`)} in your .env file`
|
|
67
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import colors from "ansi-colors";
|
|
2
|
-
import { Router } from "opticore-express";
|
|
3
|
-
import { dateTimeFormattedUtils } from "./dateTimeFormatted.utils";
|
|
4
|
-
import { LogMessageUtils } from "@webApp/core/utils/logMessage.utils";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export function modulesLoadedUtils(allAppRoutes: Router[], dbConChecker: () => void): void {
|
|
9
|
-
LogMessageUtils.success("Kernel", "load kernel", "Modules app have been successfully loaded");
|
|
10
|
-
console.log(`${colors.whiteBright(` content`)} ${colors.green('Kernel :')} ${colors.cyan(`${colors.bold(`server side`)}`)} has been loaded successfully ${colors.green(`✔`)}`);
|
|
11
|
-
allAppRoutes
|
|
12
|
-
? console.log(`${colors.whiteBright(` content`)} ${colors.green('Kernel :')} ${colors.cyan(`${colors.bold(`Routers service`)} `)} has been loaded successfully ${colors.green(`✔`)}`)
|
|
13
|
-
: console.log(`${colors.red(`✘`)} ${colors.bgRed(` ${colors.bold(`${colors.white(` Register routes `)}`)} `)} | ${dateTimeFormattedUtils} | [ ${colors.red(`${colors.bold(` fail `)}`)} ] | [ ${colors.bold(` loading `)} ] - ${colors.red(` routers `)} - The route register failed to load `);
|
|
14
|
-
typeof dbConChecker == "function"
|
|
15
|
-
? console.log(`${colors.whiteBright(` content`)} ${colors.green('Kernel :')} ${colors.cyan(`${colors.bold(`database checker connection`)}`)} has been loaded successfully ${colors.green(`✔`)}`)
|
|
16
|
-
: "";
|
|
17
|
-
}
|
|
File without changes
|