@candlerip/shared3 0.0.25 → 0.0.27
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +2 -1
- package/src/environment/env-file/index.d.ts +1 -0
- package/src/environment/env-file/index.js +1 -0
- package/src/environment/env-file/utils/index.d.ts +1 -0
- package/src/environment/env-file/utils/index.js +1 -0
- package/src/environment/env-file/utils/load-env-file/index.d.ts +2 -0
- package/src/environment/env-file/utils/load-env-file/index.js +26 -0
- package/src/environment/env-file/utils/load-env-file/types.d.ts +9 -0
- package/src/environment/env-file/utils/load-env-file/types.js +1 -0
- package/src/environment/environment-variables/domains/index.d.ts +1 -0
- package/src/environment/environment-variables/index.d.ts +1 -0
- package/src/environment/environment-variables/index.js +1 -0
- package/src/environment/environment-variables/workers/environment-variables-worker/index.d.ts +2 -0
- package/src/environment/environment-variables/workers/environment-variables-worker/index.js +20 -0
- package/src/environment/environment-variables/workers/environment-variables-worker/types.d.ts +9 -0
- package/src/environment/environment-variables/workers/environment-variables-worker/types.js +1 -0
- package/src/environment/environment-variables/workers/index.d.ts +1 -0
- package/src/environment/environment-variables/workers/index.js +1 -0
- package/src/environment/index.d.ts +1 -0
- package/src/environment/index.js +1 -0
- package/src/project/project-config/domains/backend-project-config/index.d.ts +1 -1
- package/src/project/project-name/configs/index.d.ts +1 -1
- package/src/project/project-name/configs/index.js +1 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@candlerip/shared3",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.27",
|
4
4
|
"type": "module",
|
5
5
|
"main": "src/index.js",
|
6
6
|
"bin": {
|
@@ -22,6 +22,7 @@
|
|
22
22
|
},
|
23
23
|
"dependencies": {
|
24
24
|
"@types/node": "^22.5.5",
|
25
|
+
"dotenv": "^16.4.5",
|
25
26
|
"eslint": "^8.57.0",
|
26
27
|
"globals": "^15.9.0",
|
27
28
|
"prettier": "^3.3.2",
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './utils/index.js';
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './utils/index.js';
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './load-env-file/index.js';
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './load-env-file/index.js';
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import * as dotenv from 'dotenv';
|
2
|
+
export const loadEnvFile = (environmentMode, options) => {
|
3
|
+
const props = { environmentMode, options };
|
4
|
+
const integers = options?.integers;
|
5
|
+
const fileName = `.env.${environmentMode}`;
|
6
|
+
const envFile = dotenv.config({ path: `./${fileName}` });
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
8
|
+
const { error, parsed } = envFile;
|
9
|
+
if (error || !parsed) {
|
10
|
+
return {
|
11
|
+
customError: {
|
12
|
+
info: {
|
13
|
+
error,
|
14
|
+
},
|
15
|
+
message: `Error loading ${fileName}`,
|
16
|
+
props,
|
17
|
+
},
|
18
|
+
};
|
19
|
+
}
|
20
|
+
if (integers) {
|
21
|
+
integers.forEach((it) => (parsed[it] = parseInt(parsed[it])));
|
22
|
+
}
|
23
|
+
return {
|
24
|
+
data: parsed,
|
25
|
+
};
|
26
|
+
};
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { CustomError } from '../../../../error/index.js';
|
2
|
+
import { EnvironmentMode } from '../../../environment-mode/index.js';
|
3
|
+
export type LoadEnvFile = <T extends Record<string, unknown>>(environmentMode: EnvironmentMode, options?: {
|
4
|
+
integers?: string[];
|
5
|
+
}) => {
|
6
|
+
data: T;
|
7
|
+
} | {
|
8
|
+
customError: CustomError;
|
9
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { loadEnvFile } from '../../../env-file/index.js';
|
2
|
+
export const EnvironmentVariablesWorker = (() => {
|
3
|
+
let envs;
|
4
|
+
const getEnvs = () => envs;
|
5
|
+
const init = () => {
|
6
|
+
const ENVIRONMENT_MODE = process.env.ENVIRONMENT_MODE;
|
7
|
+
const resp = loadEnvFile(ENVIRONMENT_MODE);
|
8
|
+
if ('customError' in resp) {
|
9
|
+
return resp;
|
10
|
+
}
|
11
|
+
envs = {
|
12
|
+
...resp.data,
|
13
|
+
ENVIRONMENT_MODE,
|
14
|
+
};
|
15
|
+
};
|
16
|
+
return {
|
17
|
+
getEnvs,
|
18
|
+
init,
|
19
|
+
};
|
20
|
+
})();
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './environment-variables-worker/index.js';
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './environment-variables-worker/index.js';
|
package/src/environment/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
import { EnvironmentVariables } from '../../../../environment/index.js';
|
2
|
-
export type BackendProjectConfig = Pick<EnvironmentVariables, 'CACHE_SERVICE_PORT' | 'REDIS_PORT'>;
|
2
|
+
export type BackendProjectConfig = Pick<EnvironmentVariables, 'CACHE_SERVICE_PORT' | 'LOGGER_SERVICE_PORT' | 'REDIS_PORT'>;
|
@@ -1 +1 @@
|
|
1
|
-
export declare const PROJECT_NAMES: readonly ["backend-init", "backend", "cache-service", "dictionary-service", "config", "images", "images-init", "logger", "redis", "shared", "shared-aws", "shared-backend"];
|
1
|
+
export declare const PROJECT_NAMES: readonly ["backend-init", "backend", "cache-service", "dictionary-service", "config", "images", "images-init", "logger-service", "redis", "shared", "shared-aws", "shared-backend"];
|