@candlerip/shared3 0.0.37 → 0.0.39
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +1 -1
- package/src/database/domains/error-log/index.d.ts +2 -3
- package/src/environment/env-file/utils/load-env-file/index.js +3 -10
- package/src/environment/environment-variable-name/configs/number-environment-variable-names/index.d.ts +1 -1
- package/src/error/custom-error/domains/index.d.ts +3 -2
- package/src/error/custom-error/index.d.ts +1 -0
- package/src/error/custom-error/index.js +1 -0
- package/src/error/custom-error/utils/console-custom-error/index.js +2 -6
- package/src/error/custom-error/workers/custom-error-worker/index.d.ts +2 -0
- package/src/error/custom-error/workers/custom-error-worker/index.js +29 -0
- package/src/error/custom-error/workers/custom-error-worker/types.d.ts +11 -0
- package/src/error/custom-error/workers/custom-error-worker/types.js +1 -0
- package/src/error/custom-error/workers/index.d.ts +1 -0
- package/src/error/custom-error/workers/index.js +1 -0
package/package.json
CHANGED
@@ -1,21 +1,14 @@
|
|
1
1
|
import * as dotenv from 'dotenv';
|
2
2
|
import { NUMBER_ENVIRONMENT_VARIABLE_NAMES } from '../../../environment-variable-name/index.js';
|
3
|
+
import { CustomErrorWorker } from '../../../../error/index.js';
|
3
4
|
export const loadEnvFile = (environmentMode) => {
|
4
|
-
|
5
|
+
CustomErrorWorker.addInfo({ environmentMode });
|
5
6
|
const fileName = `.env.${environmentMode}`;
|
6
7
|
const envFile = dotenv.config({ path: `./${fileName}` });
|
7
8
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
8
9
|
const { error, parsed } = envFile;
|
9
10
|
if (error || !parsed) {
|
10
|
-
return {
|
11
|
-
customError: {
|
12
|
-
info: {
|
13
|
-
error,
|
14
|
-
},
|
15
|
-
message: `Error loading ${fileName}`,
|
16
|
-
props,
|
17
|
-
},
|
18
|
-
};
|
11
|
+
return CustomErrorWorker.compose(`Error loading ${fileName}`, { error });
|
19
12
|
}
|
20
13
|
NUMBER_ENVIRONMENT_VARIABLE_NAMES.forEach((it) => {
|
21
14
|
if (parsed[it]) {
|
@@ -1 +1 @@
|
|
1
|
-
export declare const NUMBER_ENVIRONMENT_VARIABLE_NAMES: ("
|
1
|
+
export declare const NUMBER_ENVIRONMENT_VARIABLE_NAMES: ("CACHE_SERVICE_PORT" | "LOGGER_SERVICE_PORT" | "RABBITMQ_PORT" | "RABBITMQ_MANAGEMENT_PORT" | "REDIS_PORT" | "APP_NAME" | "DOMAIN_NAME" | "S3_IMAGES_BUCKET_NAME" | "DATABASE_URL" | "REDIS_PWD" | "REDIS_URL" | "DICTIONARY_SERVICE_PORT" | "FRONTEND_URL" | "RABBITMQ_URL" | "RABBITMQ_PWD" | "RABBITMQ_USER")[];
|
@@ -1,12 +1,8 @@
|
|
1
1
|
export const consoleCustomError = (customError) => {
|
2
2
|
console.error('***ERROR***:', customError.message);
|
3
|
-
|
4
|
-
|
5
|
-
}
|
3
|
+
console.error('ID:', customError.id);
|
4
|
+
console.error('PROJECT_NAME:', customError.projectName);
|
6
5
|
if (customError.info) {
|
7
6
|
console.error('INFO:', customError.info);
|
8
7
|
}
|
9
|
-
if (customError.props) {
|
10
|
-
console.error('PROPS:', customError.props);
|
11
|
-
}
|
12
8
|
};
|
@@ -0,0 +1,29 @@
|
|
1
|
+
export const CustomErrorWorker = (() => {
|
2
|
+
let projectName;
|
3
|
+
let info;
|
4
|
+
const addInfo = (infoInput) => {
|
5
|
+
info = {
|
6
|
+
...info,
|
7
|
+
...infoInput,
|
8
|
+
};
|
9
|
+
};
|
10
|
+
const compose = (message, infoInput) => ({
|
11
|
+
customError: {
|
12
|
+
id: Math.random().toString(16).slice(2).toUpperCase(),
|
13
|
+
info: {
|
14
|
+
...info,
|
15
|
+
...infoInput,
|
16
|
+
},
|
17
|
+
message,
|
18
|
+
projectName,
|
19
|
+
},
|
20
|
+
});
|
21
|
+
const init = (projectNameInput) => {
|
22
|
+
projectName = projectNameInput;
|
23
|
+
};
|
24
|
+
return {
|
25
|
+
addInfo,
|
26
|
+
compose,
|
27
|
+
init,
|
28
|
+
};
|
29
|
+
})();
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { CustomError } from '../../domains/index.js';
|
2
|
+
export interface ICustomErrorWorker {
|
3
|
+
addInfo: AddInfo;
|
4
|
+
compose: Compose;
|
5
|
+
init: Init;
|
6
|
+
}
|
7
|
+
export type AddInfo = (props: CustomError['info']) => void;
|
8
|
+
export type Compose = (message: CustomError['message'], info?: CustomError['info']) => {
|
9
|
+
customError: CustomError;
|
10
|
+
};
|
11
|
+
export type Init = (projectName: CustomError['projectName']) => void;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './custom-error-worker/index.js';
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './custom-error-worker/index.js';
|