@candlerip/shared3 0.0.41 → 0.0.42
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +1 -1
- package/src/environment/env-file/utils/load-env-file/index.js +1 -2
- package/src/error/custom-error/workers/custom-error-worker/index.js +20 -29
- package/src/error/custom-error/workers/custom-error-worker/types.d.ts +4 -10
- package/src/project/index.d.ts +1 -0
- package/src/project/index.js +1 -0
- package/src/project/singletons/index.d.ts +1 -0
- package/src/project/singletons/index.js +1 -0
- package/src/project/singletons/project-singleton/index.d.ts +2 -0
- package/src/project/singletons/project-singleton/index.js +11 -0
- package/src/project/singletons/project-singleton/types.d.ts +7 -0
- package/src/project/singletons/project-singleton/types.js +1 -0
package/package.json
CHANGED
@@ -2,7 +2,7 @@ import * as dotenv from 'dotenv';
|
|
2
2
|
import { NUMBER_ENVIRONMENT_VARIABLE_NAMES } from '../../../environment-variable-name/index.js';
|
3
3
|
import { CustomErrorWorker } from '../../../../error/index.js';
|
4
4
|
export const loadEnvFile = (environmentMode) => {
|
5
|
-
const { composeCustomError } = CustomErrorWorker
|
5
|
+
const { composeCustomError } = CustomErrorWorker({ environmentMode });
|
6
6
|
const fileName = `.env.${environmentMode}`;
|
7
7
|
const envFile = dotenv.config({ path: `./${fileName}` });
|
8
8
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
@@ -19,4 +19,3 @@ export const loadEnvFile = (environmentMode) => {
|
|
19
19
|
data: parsed,
|
20
20
|
};
|
21
21
|
};
|
22
|
-
loadEnvFile('development');
|
@@ -1,34 +1,25 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
info
|
1
|
+
import { ProjectSingleton } from '../../../../project/index.js';
|
2
|
+
export const CustomErrorWorker = (infoInput) => {
|
3
|
+
let info = infoInput;
|
4
|
+
const addInfo = (infoInput) => {
|
5
|
+
info = {
|
6
|
+
...info,
|
7
|
+
...infoInput,
|
8
|
+
};
|
9
|
+
};
|
10
|
+
const composeCustomError = (message, infoInput) => ({
|
11
|
+
customError: {
|
12
|
+
id: Math.random().toString(16).slice(2).toUpperCase(),
|
13
|
+
info: {
|
7
14
|
...info,
|
8
15
|
...infoInput,
|
9
|
-
};
|
10
|
-
};
|
11
|
-
const composeCustomError = (message, infoInput) => ({
|
12
|
-
customError: {
|
13
|
-
id: Math.random().toString(16).slice(2).toUpperCase(),
|
14
|
-
info: {
|
15
|
-
...info,
|
16
|
-
...infoInput,
|
17
|
-
},
|
18
|
-
message,
|
19
|
-
projectName,
|
20
16
|
},
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
};
|
26
|
-
};
|
27
|
-
const init = (projectNameInput) => {
|
28
|
-
projectName = projectNameInput;
|
29
|
-
};
|
17
|
+
message,
|
18
|
+
projectName: ProjectSingleton.getProjectName(),
|
19
|
+
},
|
20
|
+
});
|
30
21
|
return {
|
31
|
-
|
32
|
-
|
22
|
+
addInfo,
|
23
|
+
composeCustomError,
|
33
24
|
};
|
34
|
-
}
|
25
|
+
};
|
@@ -1,15 +1,9 @@
|
|
1
1
|
import { CustomError } from '../../domains/index.js';
|
2
|
-
export
|
3
|
-
|
4
|
-
|
5
|
-
}
|
2
|
+
export type ICustomErrorWorker = (info: CustomError['info']) => {
|
3
|
+
addInfo: AddInfo;
|
4
|
+
composeCustomError: ComposeCustomError;
|
5
|
+
};
|
6
6
|
export type AddInfo = (props: CustomError['info']) => void;
|
7
7
|
export type ComposeCustomError = (message: CustomError['message'], info?: CustomError['info']) => {
|
8
8
|
customError: CustomError;
|
9
9
|
};
|
10
|
-
export type GetInstance = (info: CustomError['info']) => CustomErrorWorkerInstance;
|
11
|
-
export type Init = (projectName: CustomError['projectName']) => void;
|
12
|
-
export type CustomErrorWorkerInstance = {
|
13
|
-
addInfo: AddInfo;
|
14
|
-
composeCustomError: ComposeCustomError;
|
15
|
-
};
|
package/src/project/index.d.ts
CHANGED
package/src/project/index.js
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
export * from './project-singleton/index.js';
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './project-singleton/index.js';
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|