@candlerip/shared3 0.0.24 → 0.0.26
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/environment-variables/domains/index.d.ts +2 -1
- 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-config/domains/cache-service-project-config/index.d.ts +1 -1
- package/src/project/project-config/domains/logger-service-project-config/index.d.ts +2 -0
- package/src/project/project-config/domains/logger-service-project-config/index.js +1 -0
- package/src/project/project-config/domains/project-config-map/index.d.ts +2 -1
- package/src/project/project-config-name/configs/index.d.ts +1 -1
- package/src/project/project-config-name/configs/index.js +1 -1
- package/src/project/project-name/configs/index.d.ts +1 -1
- package/src/project/project-name/configs/index.js +1 -1
- package/src/project/project-config/domains/logger-project-config/index.d.ts +0 -2
- /package/src/{project/project-config/domains/logger-project-config/index.js → environment/env-file/utils/load-env-file/types.js} +0 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@candlerip/shared3",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.26",
|
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> = never>(environmentMode: EnvironmentMode, options?: {
|
4
|
+
integers?: string[];
|
5
|
+
}) => {
|
6
|
+
data: T;
|
7
|
+
} | {
|
8
|
+
customError: CustomError;
|
9
|
+
};
|
@@ -3,10 +3,11 @@ export interface EnvironmentVariables {
|
|
3
3
|
REDIS_PORT: number;
|
4
4
|
REDIS_PWD: string;
|
5
5
|
CACHE_SERVICE_PORT: number;
|
6
|
-
CACHE_URL: string;
|
7
6
|
DATABASE_URL: string;
|
8
7
|
DICTIONARY_SERVICE_PORT: number;
|
9
8
|
DOMAIN_NAME: string;
|
10
9
|
FRONTEND_URL: string;
|
10
|
+
LOGGER_SERVICE_PORT: string;
|
11
|
+
REDIS_URL: string;
|
11
12
|
S3_IMAGES_BUCKET_NAME: string;
|
12
13
|
}
|
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,2 +1,2 @@
|
|
1
1
|
import { EnvironmentVariables } from '../../../../environment/index.js';
|
2
|
-
export type CacheServiceProjectConfig = Pick<EnvironmentVariables, 'CACHE_SERVICE_PORT' | 'DATABASE_URL' | 'REDIS_PWD' | '
|
2
|
+
export type CacheServiceProjectConfig = Pick<EnvironmentVariables, 'CACHE_SERVICE_PORT' | 'DATABASE_URL' | 'REDIS_PWD' | 'REDIS_URL'>;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -4,6 +4,7 @@ import { CacheServiceProjectConfig } from '../cache-service-project-config/index
|
|
4
4
|
import { DictionaryServiceProjectConfig } from '../dictionary-service-poject-config/index.js';
|
5
5
|
import { ImagesInitProjectConfig } from '../images-init-project-config/index.js';
|
6
6
|
import { ImagesProjectConfig } from '../images-project-config/index.js';
|
7
|
+
import { LoggerServiceProjectConfig } from '../logger-service-project-config/index.js';
|
7
8
|
import { RedisProjectConfig } from '../redis-project-config/index.js';
|
8
9
|
export type ProjectConfigMap = {
|
9
10
|
'backend-project-config': BackendProjectConfig;
|
@@ -12,6 +13,6 @@ export type ProjectConfigMap = {
|
|
12
13
|
'dictionary-service-project-config': DictionaryServiceProjectConfig;
|
13
14
|
'images-project-config': ImagesProjectConfig;
|
14
15
|
'images-init-project-config': ImagesInitProjectConfig;
|
15
|
-
'logger-project-config':
|
16
|
+
'logger-service-project-config': LoggerServiceProjectConfig;
|
16
17
|
'redis-project-config': RedisProjectConfig;
|
17
18
|
};
|
@@ -1 +1 @@
|
|
1
|
-
export declare const PROJECT_CONFIG_NAMES: readonly ["backend-init-project-config", "backend-project-config", "cache-service-project-config", "dictionary-service-project-config", "images-project-config", "images-init-project-config", "logger-project-config", "redis-project-config"];
|
1
|
+
export declare const PROJECT_CONFIG_NAMES: readonly ["backend-init-project-config", "backend-project-config", "cache-service-project-config", "dictionary-service-project-config", "images-project-config", "images-init-project-config", "logger-service-project-config", "redis-project-config"];
|
@@ -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"];
|