opticore-webapp-core 1.0.19 → 1.0.21
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 +11 -11
- package/dist/index.d.cts +13 -9
- package/dist/index.d.ts +13 -9
- package/dist/index.js +12 -12
- package/package.json +7 -8
- package/src/application/middlewares/bodyParser.middleware.ts +74 -0
- package/src/application/services/asymmetricCryptionDataWithPrivateRSAKey.service.ts +194 -0
- package/src/application/services/asymmetricCryptionDataWithPublicRSAKey.service.ts +188 -0
- package/src/application/services/loggerFileConfiguration.service.ts +6 -0
- package/src/core/config/database/connexion.config.database.ts +116 -0
- package/src/core/config/database/middleware/postgresChecker.database.ts +35 -0
- package/src/core/config/loaders/localLanguage.loader.ts +31 -0
- package/src/core/config/loaders/translateLanguage.loader.ts +27 -0
- package/src/core/config/logger/logger.config.ts +33 -0
- package/src/core/constants/signRSA/algorithm.constant.ts +54 -0
- package/src/core/constants/signRSA/encodingFormat.constant.ts +14 -0
- package/src/core/constants/signRSA/keyType.constant.ts +4 -0
- package/src/core/constants/signRSA/outputFormat.constant.ts +6 -0
- package/src/core/constants/signRSAKeyComponent.constant.ts +11 -0
- package/src/core/errors/databaseConnexion.error.ts +107 -0
- package/src/core/events/pathModuleVerifier.event.ts +58 -0
- package/src/domains/constants/logLevel.constant.ts +6 -0
- package/src/index.ts +56 -0
- package/src/interfaces/bodyParserOptions.interface.ts +4 -0
- package/src/interfaces/responseBodyEndFromResponseEvent.interface.ts +7 -0
- package/src/interfaces/responseBodyWriteFromResponseEvent.interface.ts +4 -0
- package/src/interfaces/wrappingBodyResponse.interface.ts +4 -0
- package/src/types/json.type.ts +18 -0
- package/src/types/logLevel.type.ts +3 -0
- package/src/types/originalWriteEncoding.type.ts +1 -0
- package/src/types/parseFunction.type.ts +1 -0
- package/src/types/raw.type.ts +23 -0
- package/src/types/text.type.ts +18 -0
- package/src/types/urlencoded.type.ts +19 -0
- package/src/utils/cryptography/decryption/rsaKey.decryption.ts +19 -0
- package/src/utils/cryptography/encryption/rsaKey.encryption.ts +25 -0
- package/src/utils/dateTimeFormatted.utils.ts +6 -0
- package/src/utils/environment.utils.ts +11 -0
- package/src/utils/logMessage.utils.ts +20 -0
- package/src/utils/parseUrlencoded.utils.ts +17 -0
- package/src/utils/parsing/parsingYaml.utils.ts +81 -0
- package/src/utils/translations/message.translation.en.json +130 -0
- package/src/utils/translations/message.translation.fr.json +49 -0
- package/src/utils/utility.utils.ts +154 -0
- package/tsup.config.ts +11 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { resolve } from "path";
|
|
2
|
+
import { LoggerCore } from "opticore-logger";
|
|
3
|
+
import { HttpStatusCode } from "opticore-http-response";
|
|
4
|
+
import { TranslationLoader } from "opticore-translator";
|
|
5
|
+
import { SLoggerFileConfiguration } from "@webAppCore/application/services/loggerFileConfiguration.service";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export class PathModuleVerifier {
|
|
9
|
+
private log: LoggerCore;
|
|
10
|
+
private readonly localeLanguage: string;
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
constructor(localeLanguage: string, environmentPath: any) {
|
|
14
|
+
this.localeLanguage = localeLanguage;
|
|
15
|
+
this.log = SLoggerFileConfiguration(environmentPath);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Verifies if modules at specific paths are loaded.
|
|
21
|
+
* If any module is not loaded, it throws an error.
|
|
22
|
+
* @param modulePaths - An array of paths to the modules to verify.
|
|
23
|
+
*/
|
|
24
|
+
public verifyModulePaths(modulePaths: string[]): void {
|
|
25
|
+
const notLoadedPaths: string[] = [];
|
|
26
|
+
|
|
27
|
+
for (const modulePath of modulePaths) {
|
|
28
|
+
if (!this.isModulePathLoaded(modulePath)) {
|
|
29
|
+
notLoadedPaths.push(modulePath);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (notLoadedPaths.length > 0) {
|
|
34
|
+
this.log.error({
|
|
35
|
+
message: TranslationLoader.t("moduleNotLoaded", this.localeLanguage, {notLoadedPaths: notLoadedPaths.join(', ')}),
|
|
36
|
+
title: '',
|
|
37
|
+
errorType: '',
|
|
38
|
+
stackTrace: modulePaths,
|
|
39
|
+
httpCodeValue: HttpStatusCode.NOT_ACCEPTABLE
|
|
40
|
+
});
|
|
41
|
+
throw new Error();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Checks if a specific module at a given path is loaded in the Node.js require cache.
|
|
47
|
+
* @param modulePath - The path to the module.
|
|
48
|
+
* @returns True if the module is loaded, false otherwise.
|
|
49
|
+
*/
|
|
50
|
+
private isModulePathLoaded(modulePath: string): boolean {
|
|
51
|
+
try {
|
|
52
|
+
const resolvedPath: string = resolve(modulePath);
|
|
53
|
+
return require.cache[resolvedPath] !== undefined;
|
|
54
|
+
} catch {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { SAsymmetricCryptionDataWithPrivateRSAKey } from "@webAppCore/application/services/asymmetricCryptionDataWithPrivateRSAKey.service";
|
|
2
|
+
import { SAsymmetricCryptionDataWithPublicRSAKey } from "@webAppCore/application/services/asymmetricCryptionDataWithPublicRSAKey.service";
|
|
3
|
+
import { CLogLevel } from "@webAppCore/domains/constants/logLevel.constant";
|
|
4
|
+
import { RSAKeyDecryption } from "@webAppCore/utils/cryptography/decryption/rsaKey.decryption";
|
|
5
|
+
import { RSAKeyEncryption } from "@webAppCore/utils/cryptography/encryption/rsaKey.encryption";
|
|
6
|
+
import { YamlParsing } from "@webAppCore/utils/parsing/parsingYaml.utils";
|
|
7
|
+
import { dateTimeFormatted } from "@webAppCore/utils/dateTimeFormatted.utils";
|
|
8
|
+
import { Environment } from "@webAppCore/utils/environment.utils";
|
|
9
|
+
import { loggerConfig } from "@webAppCore/core/config/logger/logger.config";
|
|
10
|
+
import { CSignRSAKeyComponent } from "@webAppCore/core/constants/signRSAKeyComponent.constant";
|
|
11
|
+
import { Utility } from "@webAppCore/utils/utility.utils";
|
|
12
|
+
import { PathModuleVerifier } from "@webAppCore/core/events/pathModuleVerifier.event";
|
|
13
|
+
import { LocalLanguageLoader } from "@webAppCore/core/config/loaders/localLanguage.loader";
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Interfaces exported
|
|
19
|
+
*/
|
|
20
|
+
export { type IBodyParserOptions } from "@webAppCore/interfaces/bodyParserOptions.interface";
|
|
21
|
+
export { type IResponseBodyEndFromResponseEvent } from "@webAppCore/interfaces/responseBodyEndFromResponseEvent.interface";
|
|
22
|
+
export { type IResponseBodyWriteFromResponseEvent} from "@webAppCore/interfaces/responseBodyWriteFromResponseEvent.interface";
|
|
23
|
+
export { type IWrappingBodyResponse } from "@webAppCore/interfaces/wrappingBodyResponse.interface";
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Types exported
|
|
28
|
+
*/
|
|
29
|
+
export { type TLogLevel } from "@webAppCore/types/logLevel.type";
|
|
30
|
+
export { type TOriginalWriteEncoding } from "@webAppCore/types/originalWriteEncoding.type";
|
|
31
|
+
export { type TParseFunction } from "@webAppCore/types/parseFunction.type";
|
|
32
|
+
/**
|
|
33
|
+
* Types function exported
|
|
34
|
+
*/
|
|
35
|
+
export { type TJSONBodyParser } from "@webAppCore/types/json.type";
|
|
36
|
+
export { type TRawBodyParser } from "@webAppCore/types/raw.type";
|
|
37
|
+
export { type TTextBodyParser } from "@webAppCore/types/text.type";
|
|
38
|
+
export { type TUrlencodedBodyParser } from "@webAppCore/types/urlencoded.type";
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
export {
|
|
43
|
+
CLogLevel,
|
|
44
|
+
CSignRSAKeyComponent,
|
|
45
|
+
dateTimeFormatted,
|
|
46
|
+
Environment,
|
|
47
|
+
loggerConfig,
|
|
48
|
+
LocalLanguageLoader,
|
|
49
|
+
PathModuleVerifier,
|
|
50
|
+
RSAKeyDecryption,
|
|
51
|
+
RSAKeyEncryption,
|
|
52
|
+
SAsymmetricCryptionDataWithPrivateRSAKey,
|
|
53
|
+
SAsymmetricCryptionDataWithPublicRSAKey,
|
|
54
|
+
Utility,
|
|
55
|
+
YamlParsing
|
|
56
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
+
|
|
3
|
+
export interface IResponseBodyEndFromResponseEvent {
|
|
4
|
+
(cb?: () => void): ServerResponse<IncomingMessage>;
|
|
5
|
+
(chunk: any, cb?: () => void): ServerResponse<IncomingMessage>;
|
|
6
|
+
(chunk: any, encoding: BufferEncoding, cb?: () => void): ServerResponse<IncomingMessage>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IBodyParserOptions } from "@webAppCore/interfaces/bodyParserOptions.interface";
|
|
2
|
+
import { MBodyParser } from "@webAppCore/application/middlewares/bodyParser.middleware";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param options
|
|
8
|
+
* @param localLanguage
|
|
9
|
+
* @param environnementPath
|
|
10
|
+
*
|
|
11
|
+
* Use by this: TJSONBodyParser({ type: 'application/vnd.custom-type' })
|
|
12
|
+
*
|
|
13
|
+
* in express, it can be used like this: app.use(TJSONBodyParser({ type: 'application/vnd.custom-type' }));
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
export function TJSONBodyParser(options: IBodyParserOptions, localLanguage: string, environnementPath: any) {
|
|
17
|
+
return MBodyParser(JSON.parse, options, localLanguage, environnementPath);
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type TOriginalWriteEncoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "utf-16le" | "ucs2" | "ucs-2" | "base64" | "base64url" | "latin1" | "binary" | "hex";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type TParseFunction = (rawBody: string) => any;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { IBodyParserOptions } from "@webAppCore/interfaces/bodyParserOptions.interface";
|
|
2
|
+
import { MBodyParser } from "@webAppCore/application/middlewares/bodyParser.middleware";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param options
|
|
8
|
+
* @param localLanguage
|
|
9
|
+
* @param environnementPath
|
|
10
|
+
*
|
|
11
|
+
* Use by this: TRawBodyParser({ type: 'application/vnd.custom-type' })
|
|
12
|
+
*
|
|
13
|
+
* in express, it can be used like this: app.use(rawBodyParserType({ type: 'application/vnd.custom-type' }));
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
export function TRawBodyParser(options: IBodyParserOptions, localLanguage: string, environnementPath: any) {
|
|
17
|
+
return MBodyParser(
|
|
18
|
+
(rawBody: string) => Buffer.from(rawBody, "binary"),
|
|
19
|
+
options,
|
|
20
|
+
localLanguage,
|
|
21
|
+
environnementPath
|
|
22
|
+
);
|
|
23
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { MBodyParser } from "@webAppCore/application/middlewares/bodyParser.middleware";
|
|
2
|
+
import { IBodyParserOptions } from "@webAppCore/interfaces/bodyParserOptions.interface";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param options
|
|
8
|
+
* @param localLanguage
|
|
9
|
+
* @param environmentPath
|
|
10
|
+
*
|
|
11
|
+
* Use by this: textBodyParserType({ type: 'text/html' })
|
|
12
|
+
*
|
|
13
|
+
* in express, it can be used like this: app.use(textBodyParserType({ type: 'text/html' }));
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
export function TTextBodyParser(options: IBodyParserOptions, localLanguage: string, environmentPath: any) {
|
|
17
|
+
return MBodyParser((rawBody: string) => rawBody, options, localLanguage, environmentPath);
|
|
18
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IBodyParserOptions } from "@webAppCore/interfaces/bodyParserOptions.interface";
|
|
2
|
+
import { MBodyParser } from "@webAppCore/application/middlewares/bodyParser.middleware";
|
|
3
|
+
import { UParseUrlencoded } from "@webAppCore/utils/parseUrlencoded.utils";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param options
|
|
9
|
+
* @param localLanguage
|
|
10
|
+
* @param environmentPath
|
|
11
|
+
*
|
|
12
|
+
* Use by this: urlencodedBodyParserType({ type: 'application/x-www-form-urlencoded' })
|
|
13
|
+
*
|
|
14
|
+
* in express, it can be used like this: app.use(urlencodedBodyParserType({ type: 'application/x-www-form-urlencoded' }));
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
export function TUrlencodedBodyParser(options: IBodyParserOptions, localLanguage: string, environmentPath: any) {
|
|
18
|
+
return MBodyParser(UParseUrlencoded, options, localLanguage, environmentPath);
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import crypto from "crypto";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This class contains methods that allow to decrypt data using public and private keys.
|
|
6
|
+
*/
|
|
7
|
+
export class RSAKeyDecryption {
|
|
8
|
+
static privateDecrypt(privateKey: any, decryptData: any): Buffer {
|
|
9
|
+
const rsaPrivateKey = { key: privateKey };
|
|
10
|
+
|
|
11
|
+
return crypto.privateDecrypt(rsaPrivateKey, decryptData);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
static publicDecrypt(publicKey: any, decryptData: any): Buffer {
|
|
15
|
+
const rsaPublicKey = { key: publicKey };
|
|
16
|
+
|
|
17
|
+
return crypto.publicDecrypt(rsaPublicKey, decryptData);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import crypto from "crypto";
|
|
2
|
+
import { CSignRSAKeyComponent } from "@webAppCore/core/constants/signRSAKeyComponent.constant";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* This class contains methods which allow encrypting data by passing as arguments
|
|
7
|
+
* the public/private keys and the data to be encrypted.
|
|
8
|
+
*/
|
|
9
|
+
export class RSAKeyEncryption {
|
|
10
|
+
static privateEncrypt(privateKey: any, encryptData: any): Buffer {
|
|
11
|
+
const rsaPrivateKey = {
|
|
12
|
+
key: privateKey
|
|
13
|
+
};
|
|
14
|
+
const bufferData: Buffer = Buffer.from(encryptData, CSignRSAKeyComponent.encodingFormat.utf8 as BufferEncoding);
|
|
15
|
+
|
|
16
|
+
return crypto.privateEncrypt(rsaPrivateKey, bufferData);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static publicEncrypt(publicKey: any, encryptData: any): Buffer {
|
|
20
|
+
const rsaPublicKey = { key: publicKey };
|
|
21
|
+
const bufferData: Buffer = Buffer.from(encryptData, CSignRSAKeyComponent.encodingFormat.utf8 as BufferEncoding);
|
|
22
|
+
|
|
23
|
+
return crypto.publicEncrypt(rsaPublicKey, bufferData);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import colors from "ansi-colors";
|
|
2
|
+
import { dateTimeFormatted as dateTime } from "@webAppCore/utils/dateTimeFormatted.utils";
|
|
3
|
+
|
|
4
|
+
export class LogMessage {
|
|
5
|
+
static success(title: string, action: string, contentAction: string): void {
|
|
6
|
+
console.log(`${colors.green(`✔`)} ${colors.bgGreen(` ${colors.bold(`${colors.white(`${title}`)}`)} `)} ${dateTime} | ${colors.bgGreen(`${colors.white(` Success `)}`)} [ ${action} ] ${contentAction} - [ Status ] ${colors.bgGreen(`${colors.white(` 200 `)}`)}`);
|
|
7
|
+
}
|
|
8
|
+
static warning(title: string, action: string, contentAction: string): void {
|
|
9
|
+
console.warn(`${colors.yellow(`⚠️`)} ${colors.bgYellow(` ${colors.bold(`${colors.white(`${title}`)}`)} `)} ${dateTime} | ${colors.bgYellow(`${colors.white(` Warning `)}`)} ${contentAction}`);
|
|
10
|
+
}
|
|
11
|
+
static info(title: string, action: string, contentAction: string): void {
|
|
12
|
+
console.info(`${colors.cyan(`ⓘ`)} ${colors.bgCyan(` ${colors.bold(`${colors.white(`${title}`)}`)} `)} ${dateTime} | ${colors.bgCyan(`${colors.white(` Info `)}`)} ${contentAction}`);
|
|
13
|
+
}
|
|
14
|
+
static error(title: string, errorType: any, stackTrace: any, messageContent: any, httpCodeValue: number): void {
|
|
15
|
+
console.error(`${colors.red(`✘`)} ${colors.bgRed(` ${colors.bold(`${colors.white(`${title}`)}`)} `)} | ${dateTime} | [ ${colors.red(`${colors.bold(` ${errorType} `)}`)} ] | [ ${colors.bold(`stack trace`)} ] ${colors.red(`${stackTrace}`)} - ${colors.red(`${messageContent}`)} - [ ${colors.red(`${colors.bold(` HttpCode `)}`)} ] ${colors.red(`${colors.bold(` ${httpCodeValue} `)}`)} `);
|
|
16
|
+
}
|
|
17
|
+
static requestError(title: string, errorName: string, errorMessage: string, errorCode: number): void {
|
|
18
|
+
console.error(`[ ${colors.red(`${title}`)} ] ${dateTime} | ${colors.bgRed(`${colors.white(` ERROR `)}`)} ${colors.red(`[ ${errorName} ]`)} ${colors.red(`${errorMessage}`)} - [ Status ] ${colors.bgRed(`${colors.white(` ${errorCode} `)}`)}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param rawBody
|
|
4
|
+
*
|
|
5
|
+
* URL-encoded body parse function
|
|
6
|
+
*/
|
|
7
|
+
export function UParseUrlencoded(rawBody: string): any {
|
|
8
|
+
const pairs: string[] = rawBody.split('&');
|
|
9
|
+
const result: { [key: string]: string } = {};
|
|
10
|
+
for (const pair of pairs) {
|
|
11
|
+
const [key, value] = pair.split('=');
|
|
12
|
+
if (key && value) {
|
|
13
|
+
result[decodeURIComponent(key)] = decodeURIComponent(value);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { readFile } from "fs/promises";
|
|
2
|
+
import { HttpStatusCode } from "opticore-http-response";
|
|
3
|
+
import { ILoggerConfig, LoggerCore } from "opticore-logger";
|
|
4
|
+
import { TranslationLoader } from "opticore-translator";
|
|
5
|
+
import { loggerConfig } from "@webAppCore/core/config/logger/logger.config";
|
|
6
|
+
import { translateWebAppCoreLanguageLoader } from "@webAppCore/core/config/loaders/translateLanguage.loader";
|
|
7
|
+
import path from "path";
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export class YamlParsing {
|
|
11
|
+
private readonly logger: LoggerCore;
|
|
12
|
+
private readonly localeLanguage: string;
|
|
13
|
+
|
|
14
|
+
constructor(localeLanguage: string, environmentPath: any) {
|
|
15
|
+
translateWebAppCoreLanguageLoader(environmentPath, localeLanguage);
|
|
16
|
+
|
|
17
|
+
this.localeLanguage = localeLanguage;
|
|
18
|
+
this.logger = new LoggerCore(loggerConfig(environmentPath) as ILoggerConfig);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public absolutPath(): string {
|
|
22
|
+
return path.join(process.cwd(), "src", "utils", "translations");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public async readFile(filePath: string): Promise<void> {
|
|
26
|
+
try {
|
|
27
|
+
const yamlContent: string = await readFile(filePath, "utf-8");
|
|
28
|
+
await this.parsing(yamlContent);
|
|
29
|
+
} catch (error: any) {
|
|
30
|
+
this.logger.error({
|
|
31
|
+
message: error.message,
|
|
32
|
+
title: TranslationLoader.t("parsingFailed", this.localeLanguage, this.logger),
|
|
33
|
+
errorType: TranslationLoader.t("readingError", this.localeLanguage, this.logger),
|
|
34
|
+
stackTrace: error.stack,
|
|
35
|
+
httpCodeValue: HttpStatusCode.NOT_ACCEPTABLE
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
* @param content
|
|
43
|
+
* @private
|
|
44
|
+
*/
|
|
45
|
+
private async parsing(content: string): Promise<Record<any, any>> {
|
|
46
|
+
const result: Record<string, any> = {};
|
|
47
|
+
const lines: string[] = content.split("\n");
|
|
48
|
+
let currentKey: string | null = null;
|
|
49
|
+
|
|
50
|
+
for (const line of lines) {
|
|
51
|
+
// Ignore empty lines or comments
|
|
52
|
+
if (!line.trim() || line.trim().startsWith("#")) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const keyValueMatch: RegExpMatchArray | null = line.match(/^(\s*)([a-zA-Z0-9_]+):(?:\s*(.*))?$/);
|
|
57
|
+
if (keyValueMatch) {
|
|
58
|
+
const [, indent, key, value] = keyValueMatch;
|
|
59
|
+
// Handle nested objects (simple one-level nesting)
|
|
60
|
+
if (indent.length > 0 && currentKey) {
|
|
61
|
+
result[currentKey] = result[currentKey] || {};
|
|
62
|
+
result[currentKey][key] = value?.trim() || null;
|
|
63
|
+
} else {
|
|
64
|
+
currentKey = key;
|
|
65
|
+
result[key] = value?.trim() || null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
} else {
|
|
69
|
+
this.logger.error({
|
|
70
|
+
message: TranslationLoader.t("badFormat", this.localeLanguage, {line: line}),
|
|
71
|
+
title: TranslationLoader.t("parsingFailed", this.localeLanguage, this.logger),
|
|
72
|
+
errorType: TranslationLoader.t("unsupportedFormat", this.localeLanguage, this.logger),
|
|
73
|
+
stackTrace: content,
|
|
74
|
+
httpCodeValue: HttpStatusCode.NOT_ACCEPTABLE
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
{
|
|
2
|
+
"erBadDbError": "ER_BAD_DB_ERROR",
|
|
3
|
+
"erAccessDeniedError": "ER_ACCESS_DENIED_ERROR",
|
|
4
|
+
"erNotSupportedAuthMode": "ER_NOT_SUPPORTED_AUTH_MODE",
|
|
5
|
+
"eAiAgain": "EAI_AGAIN",
|
|
6
|
+
"dbConnection": "Database connection",
|
|
7
|
+
"dbConnectionClosed": "MySQL connection is closed",
|
|
8
|
+
"mysqlErrorCon": "MysqlError connection",
|
|
9
|
+
"mySQLError": "MysqlError",
|
|
10
|
+
"mySqlCloseConnection": "MySql close connection",
|
|
11
|
+
"dbConnexionSuccess": "The database connection was successful 🚀",
|
|
12
|
+
"mongoConnectionSuccess": "Connection to database is successfully.",
|
|
13
|
+
"connSuccess": "success connection",
|
|
14
|
+
"mongoDBConnectionChecker": "MongoDB Connection Checker",
|
|
15
|
+
"mongoConnection": "connection",
|
|
16
|
+
"mongoDBAuthentication": "authentication",
|
|
17
|
+
"mongoDBConnection": "MongoDB connection : {err}",
|
|
18
|
+
"mongoDBAuthenticationFailed": "failed",
|
|
19
|
+
"mongoDBUnableParsingUrl": "unable to parse",
|
|
20
|
+
"mongoDBConnectionUrl": "url",
|
|
21
|
+
"mongoDBServerSelection": "MongoServer selection error",
|
|
22
|
+
"mongoDBServer": "MongoServer",
|
|
23
|
+
"mongoDBConnectionError": "connection error",
|
|
24
|
+
"mongoDBError": "error",
|
|
25
|
+
"mongoDBAuthenticationError": "Authentication failed, be sure the credentials is correct.",
|
|
26
|
+
"postgresDBConnectionChecker": "PostgresDB Connection Checker",
|
|
27
|
+
"postgresConnection": "connection",
|
|
28
|
+
"postgresConnectionSuccess": "Connection to database is successfully.",
|
|
29
|
+
"postgresSuccessConn": "Postgres client Connection",
|
|
30
|
+
"postgresClosingConnSuccess": "Postgres client is close connection.",
|
|
31
|
+
"postgresEndClientRejection": "Postgres client end rejected",
|
|
32
|
+
"postgresClientError": "Postgres client error",
|
|
33
|
+
"postgresEndRejection": "End rejected",
|
|
34
|
+
"postgresConnError": "Postgres connection error",
|
|
35
|
+
"postgresException": "Exception",
|
|
36
|
+
"rsaKeyNotFound": "RSA key provided is not found.",
|
|
37
|
+
"encryptionWithPrivateKeyFailed": "Encryption With PrivateKey",
|
|
38
|
+
"encryptionFailed": "Encryption failed",
|
|
39
|
+
"verifyExistingKey": "Verify Existing Key",
|
|
40
|
+
"signatureRSAKeyFailed": "Signature verification failed.",
|
|
41
|
+
"signatureRSAKeysError": "Signature RSA Keys Error",
|
|
42
|
+
"errorDecryption": "Error decryption with private key",
|
|
43
|
+
"errorNameNotVerifyingRSAKey": "Error Verify RSA Key",
|
|
44
|
+
"decryptionWithPublicKeyFailed": "Decryption With PublicKey",
|
|
45
|
+
"decryptionFailed": "Decryption failed",
|
|
46
|
+
"verifyRSAKey": "Verify RSA Keys",
|
|
47
|
+
"verifyRSAKeyFailed": "Verify RSA Keys Failed",
|
|
48
|
+
"notVerifying": "Verification failed",
|
|
49
|
+
"mongoServerError": "MongoServerSelectionError: getaddrinfo EAI_AGAIN ({dbHost} is not allow to database connection)",
|
|
50
|
+
"dbUrlParsingError": "Unable to parse {dbHost}:{dbPort} with URL",
|
|
51
|
+
"errorDBHost": "A database host {host} does not allow connection. Please either set the host like this: {localhost} in your .env file",
|
|
52
|
+
"unknownDB": "Database {database} is unknown. Please try to use Database CLI to create your database, or do it manually in your Database Management System",
|
|
53
|
+
"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",
|
|
54
|
+
"badFormat": "Unsupported YAML line format",
|
|
55
|
+
"parsingFailed": "YAML Parsing failed",
|
|
56
|
+
"unsupportedFormat": "Unsupported YAML format",
|
|
57
|
+
"readingError": "Error reading YAML file",
|
|
58
|
+
"invalidRequest": "Invalid request",
|
|
59
|
+
"moduleNotLoaded": "The following module paths are not loaded: {notLoadedPaths}",
|
|
60
|
+
"serverRouteNotExist": "This route : http://{host}:{port} do not exist.",
|
|
61
|
+
"webServer": "Web server",
|
|
62
|
+
"listening": "listening",
|
|
63
|
+
"webHost": "host",
|
|
64
|
+
"badHost": "bad host",
|
|
65
|
+
"hostNotFound": "not found",
|
|
66
|
+
"errorHostUrl": "The host and port are not define, please define them in .env",
|
|
67
|
+
"badPort": "bad port",
|
|
68
|
+
"errorPort": "The port is not correct. Please define a right port with number port.",
|
|
69
|
+
"errorHost": "The host can't be empty or blank. Please define a string host in .env",
|
|
70
|
+
"serverStart": "Server start",
|
|
71
|
+
"serverStartError": "Server start error",
|
|
72
|
+
"processExitCode": "Process will exit with code: {code}",
|
|
73
|
+
"beforeExit": "BeforeExit",
|
|
74
|
+
"processBeforeExit": "process before exit",
|
|
75
|
+
"childProcessDiscon": "Child process disconnected",
|
|
76
|
+
"processDiscon": "process disconnected",
|
|
77
|
+
"disconnected": "Disconnected",
|
|
78
|
+
"completed": "completed",
|
|
79
|
+
"finishingProcessWell": "The process finished as expected and everything is ok",
|
|
80
|
+
"serverStopped": "[OK] The server shutting down",
|
|
81
|
+
"somethingWentWrong": "Something went wrong",
|
|
82
|
+
"genErrors": "General Errors",
|
|
83
|
+
"exited": "Exited",
|
|
84
|
+
"incorrectCmd": "Incorrect using of shell commands",
|
|
85
|
+
"misuseShell": "Misuse of shell builtins",
|
|
86
|
+
"cmdNotExecutable": "The command is found but is not executable (e.g., trying to execute a directory)",
|
|
87
|
+
"cmdNotFound": "Command not found",
|
|
88
|
+
"cmdNotFoundInSystemPath": "The command was not found in the system's PATH or is misspelled",
|
|
89
|
+
"argInvalid": "Invalid argument",
|
|
90
|
+
"scriptEndedManuallyByCtrlC": "Indicates that the script was manually terminated by the user using the Control-C (SIGINT) signal",
|
|
91
|
+
"processEndedBySIGKILL": "Indicates that the process was terminated by a SIGKILL signal, possibly due to an out-of-memory situation",
|
|
92
|
+
"scriptEnded": "Script terminated",
|
|
93
|
+
"accessProcessIllegally": "Indicates that the process accessed an illegal memory address (segfault)",
|
|
94
|
+
"defaultSegment": "Segmentation fault",
|
|
95
|
+
"processReceivedSigtermSignal": "Indicates that the process received a SIGTERM signal to terminate",
|
|
96
|
+
"processReceived": "process received a SIGTERM",
|
|
97
|
+
"exitCode": "An exit code that is outside the allowable range (0-255 for Unix-like systems)",
|
|
98
|
+
"outRange": "out of range",
|
|
99
|
+
"errorOccurring": "Error is occurring",
|
|
100
|
+
"errors": "errors",
|
|
101
|
+
"promiseRejectionHandled": "Promise rejection is handled at : {promise}",
|
|
102
|
+
"rejectionPromise": "rejection promise",
|
|
103
|
+
"uncaughtExceptionHandled": "uncaught exception handled",
|
|
104
|
+
"unhandledRejectionAtPromise": "Unhandled Rejection at: Promise {promise} -- reason {reason}",
|
|
105
|
+
"unhandledRejection": "Unhandled rejection",
|
|
106
|
+
"processGotMsg": "process got message {message}",
|
|
107
|
+
"msgException": "message exception",
|
|
108
|
+
"promiseReason": "{promise} -- {reason}",
|
|
109
|
+
"multipleResolvesDetected": "Multiple resolves detected : {type}",
|
|
110
|
+
"serverWebStopped": "The Web server has been stopped !",
|
|
111
|
+
"okSuccess": "[ OK ] Success",
|
|
112
|
+
"processPIDReceivedSignal": "Process ${process.pid} received a SIGTERM signal : {signal}",
|
|
113
|
+
"serverClosed": "Server is closed",
|
|
114
|
+
"allProcessStopped": "All processes are stopped",
|
|
115
|
+
"serverDroppedCon": "The server dropped new connections",
|
|
116
|
+
"serverMaxCon": "Server maxConnection",
|
|
117
|
+
"internalServerError": "Internal Server Error",
|
|
118
|
+
"resStatusNotFunc": "res.status is not a function",
|
|
119
|
+
"respndNotFunc": "response not Function",
|
|
120
|
+
"expressErrorHandlingMiddleware": "Express error-handling middleware",
|
|
121
|
+
"expressError": "Express error",
|
|
122
|
+
"serverRunning": "The server is running in",
|
|
123
|
+
"okServerListening": "[OK] Web server listening",
|
|
124
|
+
"webServerUseNodeVersion": "The Web server is using Node.js version",
|
|
125
|
+
"startupTime": "Startup time:",
|
|
126
|
+
"totalMemory": "Resident Set Size - total memory allocated for the process execution :",
|
|
127
|
+
"memoryUsedDuringExecution": "Actual memory used during the execution :",
|
|
128
|
+
"memoryUsedByUser": "Memory usage by user :",
|
|
129
|
+
"memoryUsedBySystem": "Memory usage by system :"
|
|
130
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"erBadDbError": "ER_BAD_DB_ERROR",
|
|
3
|
+
"erAccessDeniedError": "ER_ACCESS_DENIED_ERROR",
|
|
4
|
+
"erNotSupportedAuthMode": "ER_NOT_SUPPORTED_AUTH_MODE",
|
|
5
|
+
"eAiAgain": "EAI_AGAIN",
|
|
6
|
+
"dbConnection": "DataBase connection",
|
|
7
|
+
"dbConnectionClosed": "MySQL connection is closed",
|
|
8
|
+
"mysqlErrorCon": "MysqlError connection",
|
|
9
|
+
"mySQLError": "MysqlError",
|
|
10
|
+
"mySqlCloseConnection": "MySql close connection",
|
|
11
|
+
"mongoConnectionSuccess": "Connection to database is successfully.",
|
|
12
|
+
"mongoDBConnectionChecker": "MongoDB Connection Checker",
|
|
13
|
+
"mongoConnection": "connection",
|
|
14
|
+
"mongoDBAuthentication": "authentication",
|
|
15
|
+
"mongoDBConnection": "MongoDB connection",
|
|
16
|
+
"mongoDBAuthenticationFailed": "failed",
|
|
17
|
+
"mongoDBUnableParsingUrl": "unable to parse",
|
|
18
|
+
"mongoDBConnectionUrl": "url",
|
|
19
|
+
"mongoDBServerSelection": "MongoServer selection error",
|
|
20
|
+
"mongoDBServer": "MongoServer",
|
|
21
|
+
"mongoDBConnectionError": "connection error",
|
|
22
|
+
"mongoDBError": "error",
|
|
23
|
+
"mongoDBAuthenticationError": "Authentication failed, be sure the credentials is correct.",
|
|
24
|
+
"postgresDBConnectionChecker": "PostgresDB Connection Checker",
|
|
25
|
+
"postgresConnection": "connection",
|
|
26
|
+
"postgresConnectionSuccess": "Connection to database is successfully.",
|
|
27
|
+
"postgresSuccessConn": "Postgres client Connection",
|
|
28
|
+
"postgresClosingConnSuccess": "Postgres client is close connection.",
|
|
29
|
+
"postgresEndClientRejection": "Postgres client end rejected",
|
|
30
|
+
"postgresClientError": "Postgres client error",
|
|
31
|
+
"postgresEndRejection": "End rejected",
|
|
32
|
+
"postgresConnError": "Postgres connection error",
|
|
33
|
+
"postgresException": "Exception",
|
|
34
|
+
"rsaKeyNotFound": "RSA key provided is not found.",
|
|
35
|
+
"encryptionWithPrivateKeyFailed": "Encryption With PrivateKey",
|
|
36
|
+
"encryptionFailed": "Encryption failed",
|
|
37
|
+
"verifyExistingKey": "Verify Existing Key",
|
|
38
|
+
"signatureRSAKeyFailed": "Signature verification failed.",
|
|
39
|
+
"signatureRSAKeysError": "Signature RSA Keys Error",
|
|
40
|
+
"errorDecryption": "Error decryption with private key",
|
|
41
|
+
"errorNameNotVerifyingRSAKey": "Error Verify RSA Key",
|
|
42
|
+
"decryptionWithPublicKeyFailed": "Decryption With PublicKey",
|
|
43
|
+
"decryptionFailed": "Decryption failed",
|
|
44
|
+
"verifyRSAKey": "Verify RSA Keys",
|
|
45
|
+
"verifyRSAKeyFailed": "Verify RSA Keys Failed",
|
|
46
|
+
"notVerifying": "Verification failed",
|
|
47
|
+
"mongoServerError": "MongoServerSelectionError: getaddrinfo EAI_AGAIN ({dbHost} is not allow to database connection)",
|
|
48
|
+
"dbUrlParsingError": "Unable to parse ${dbHost}:${dbPort} with URL"
|
|
49
|
+
}
|