@candlerip/shared3 0.0.42 → 0.0.44
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 +11 -6
- package/src/environment/environment-variable-name/configs/boolean-environment-variable-names/index.d.ts +1 -0
- package/src/environment/environment-variable-name/configs/boolean-environment-variable-names/index.js +2 -0
- package/src/environment/environment-variable-name/configs/index.d.ts +1 -0
- package/src/environment/environment-variable-name/configs/index.js +1 -0
- package/src/environment/environment-variable-name/configs/number-environment-variable-names/index.d.ts +1 -1
- package/src/environment/environment-variables/configs/index.d.ts +4 -0
- package/src/environment/environment-variables/configs/index.js +4 -0
- package/src/error/custom-error/workers/custom-error-worker/index.d.ts +2 -2
- package/src/error/custom-error/workers/custom-error-worker/index.js +1 -1
- package/src/error/custom-error/workers/custom-error-worker/types.d.ts +2 -1
- package/src/helper/index.d.ts +1 -0
- package/src/helper/index.js +1 -0
- package/src/helper/promise-all/index.d.ts +12 -0
- package/src/helper/promise-all/index.js +24 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/project/project-config/configs/project-config/index.d.ts +4 -1
- package/src/project/project-config/configs/project-config/index.js +14 -1
package/package.json
CHANGED
@@ -1,20 +1,25 @@
|
|
1
1
|
import * as dotenv from 'dotenv';
|
2
|
-
import { NUMBER_ENVIRONMENT_VARIABLE_NAMES } from '../../../environment-variable-name/index.js';
|
3
|
-
import {
|
2
|
+
import { BOOLEAN_ENVIRONMENT_VARIABLE_NAMES, NUMBER_ENVIRONMENT_VARIABLE_NAMES } from '../../../environment-variable-name/index.js';
|
3
|
+
import { customErrorWorker } from '../../../../error/index.js';
|
4
4
|
export const loadEnvFile = (environmentMode) => {
|
5
|
-
const { composeCustomError } =
|
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
|
9
|
-
const { error, parsed } = envFile;
|
10
|
-
if (
|
11
|
-
return composeCustomError(`Error loading ${fileName}`, {
|
9
|
+
const { error: err, parsed } = envFile;
|
10
|
+
if (err || !parsed) {
|
11
|
+
return composeCustomError(`Error loading ${fileName}`, { err });
|
12
12
|
}
|
13
13
|
NUMBER_ENVIRONMENT_VARIABLE_NAMES.forEach((it) => {
|
14
14
|
if (parsed[it]) {
|
15
15
|
parsed[it] = parseInt(parsed[it]);
|
16
16
|
}
|
17
17
|
});
|
18
|
+
BOOLEAN_ENVIRONMENT_VARIABLE_NAMES.forEach((it) => {
|
19
|
+
if (parsed[it]) {
|
20
|
+
parsed[it] = Boolean(parsed[it] === 'true');
|
21
|
+
}
|
22
|
+
});
|
18
23
|
return {
|
19
24
|
data: parsed,
|
20
25
|
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const BOOLEAN_ENVIRONMENT_VARIABLE_NAMES: ("API_GATEWAY_PORT" | "AUTHENTICATION_AUDIENCE" | "AUTHENTICATION_DOMAIN" | "CACHE_ENABLED" | "DATABASE_URL" | "FRONTEND_URL" | "REDIS_PWD" | "REDIS_URL" | "S3_IMAGES_BUCKET_NAME" | "CACHE_SERVICE_PORT" | "LOGGER_SERVICE_PORT" | "RABBITMQ_PORT" | "RABBITMQ_MANAGEMENT_PORT" | "REDIS_PORT" | "APP_NAME" | "DOMAIN_NAME" | "RABBITMQ_URL" | "DICTIONARY_SERVICE_PORT" | "RABBITMQ_PWD" | "RABBITMQ_USER")[];
|
@@ -1 +1 @@
|
|
1
|
-
export declare const NUMBER_ENVIRONMENT_VARIABLE_NAMES: ("
|
1
|
+
export declare const NUMBER_ENVIRONMENT_VARIABLE_NAMES: ("API_GATEWAY_PORT" | "AUTHENTICATION_AUDIENCE" | "AUTHENTICATION_DOMAIN" | "CACHE_ENABLED" | "DATABASE_URL" | "FRONTEND_URL" | "REDIS_PWD" | "REDIS_URL" | "S3_IMAGES_BUCKET_NAME" | "CACHE_SERVICE_PORT" | "LOGGER_SERVICE_PORT" | "RABBITMQ_PORT" | "RABBITMQ_MANAGEMENT_PORT" | "REDIS_PORT" | "APP_NAME" | "DOMAIN_NAME" | "RABBITMQ_URL" | "DICTIONARY_SERVICE_PORT" | "RABBITMQ_PWD" | "RABBITMQ_USER")[];
|
@@ -1,5 +1,9 @@
|
|
1
1
|
export declare const ENVIRONMENT_VARIABLES: {
|
2
|
+
readonly API_GATEWAY_PORT: "number";
|
2
3
|
readonly APP_NAME: "string";
|
4
|
+
readonly AUTHENTICATION_AUDIENCE: "string";
|
5
|
+
readonly AUTHENTICATION_DOMAIN: "string";
|
6
|
+
readonly CACHE_ENABLED: "boolean";
|
3
7
|
readonly CACHE_SERVICE_PORT: "number";
|
4
8
|
readonly DATABASE_URL: "string";
|
5
9
|
readonly DICTIONARY_SERVICE_PORT: "number";
|
@@ -1,5 +1,9 @@
|
|
1
1
|
export const ENVIRONMENT_VARIABLES = {
|
2
|
+
API_GATEWAY_PORT: 'number',
|
2
3
|
APP_NAME: 'string',
|
4
|
+
AUTHENTICATION_AUDIENCE: 'string',
|
5
|
+
AUTHENTICATION_DOMAIN: 'string',
|
6
|
+
CACHE_ENABLED: 'boolean',
|
3
7
|
CACHE_SERVICE_PORT: 'number',
|
4
8
|
DATABASE_URL: 'string',
|
5
9
|
DICTIONARY_SERVICE_PORT: 'number',
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import {
|
2
|
-
export declare const
|
1
|
+
import { CustomErrorWorker } from './types.js';
|
2
|
+
export declare const customErrorWorker: CustomErrorWorker;
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { CustomError } from '../../domains/index.js';
|
2
|
-
export type
|
2
|
+
export type CustomErrorWorker = (info?: CustomError['info']) => ICustomErrorWorker;
|
3
|
+
export type ICustomErrorWorker = {
|
3
4
|
addInfo: AddInfo;
|
4
5
|
composeCustomError: ComposeCustomError;
|
5
6
|
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './promise-all/index.js';
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './promise-all/index.js';
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { CustomError } from '../../error/index.js';
|
2
|
+
export declare const promiseAll: <T>(promises: Promise<{
|
3
|
+
customError: CustomError;
|
4
|
+
} | {
|
5
|
+
data: unknown;
|
6
|
+
}>[], keys?: string[]) => Promise<{
|
7
|
+
customErrors: {
|
8
|
+
customError: CustomError;
|
9
|
+
}[];
|
10
|
+
} | {
|
11
|
+
data: T;
|
12
|
+
}>;
|
@@ -0,0 +1,24 @@
|
|
1
|
+
export const promiseAll = async (promises, keys) => {
|
2
|
+
const resp = await Promise.all(promises);
|
3
|
+
const customErrors = resp.filter((it) => 'customError' in it);
|
4
|
+
const values = resp.filter((it) => 'data' in it).map((it) => it.data);
|
5
|
+
if (customErrors.length > 0) {
|
6
|
+
return { customErrors };
|
7
|
+
}
|
8
|
+
if (!keys) {
|
9
|
+
let data = {};
|
10
|
+
values.forEach((it) => {
|
11
|
+
data = Object.assign(data, it);
|
12
|
+
});
|
13
|
+
return {
|
14
|
+
data: data,
|
15
|
+
};
|
16
|
+
}
|
17
|
+
const data = {};
|
18
|
+
values.forEach((it, i) => {
|
19
|
+
data[keys[i]] = it;
|
20
|
+
});
|
21
|
+
return {
|
22
|
+
data: data,
|
23
|
+
};
|
24
|
+
};
|
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
export declare const PROJECT_CONFIG: {
|
2
|
+
readonly 'api-gateway-project-config': {
|
3
|
+
readonly environmentVariableNames: readonly ["API_GATEWAY_PORT", "AUTHENTICATION_AUDIENCE", "AUTHENTICATION_DOMAIN", "CACHE_ENABLED", "DATABASE_URL", "FRONTEND_URL", "REDIS_PWD", "REDIS_URL", "S3_IMAGES_BUCKET_NAME"];
|
4
|
+
};
|
2
5
|
readonly 'backend-project-config': {
|
3
6
|
readonly environmentVariableNames: readonly ["CACHE_SERVICE_PORT", "LOGGER_SERVICE_PORT", "RABBITMQ_PORT", "RABBITMQ_MANAGEMENT_PORT", "REDIS_PORT"];
|
4
7
|
};
|
@@ -6,7 +9,7 @@ export declare const PROJECT_CONFIG: {
|
|
6
9
|
readonly environmentVariableNames: readonly ["APP_NAME", "DOMAIN_NAME", "S3_IMAGES_BUCKET_NAME"];
|
7
10
|
};
|
8
11
|
readonly 'cache-service-project-config': {
|
9
|
-
readonly environmentVariableNames: readonly ["CACHE_SERVICE_PORT", "DATABASE_URL", "REDIS_PWD", "REDIS_URL"];
|
12
|
+
readonly environmentVariableNames: readonly ["CACHE_SERVICE_PORT", "DATABASE_URL", "RABBITMQ_URL", "REDIS_PWD", "REDIS_URL"];
|
10
13
|
};
|
11
14
|
readonly 'dictionary-service-project-config': {
|
12
15
|
readonly environmentVariableNames: readonly ["DICTIONARY_SERVICE_PORT"];
|
@@ -1,4 +1,17 @@
|
|
1
1
|
export const PROJECT_CONFIG = {
|
2
|
+
'api-gateway-project-config': {
|
3
|
+
environmentVariableNames: [
|
4
|
+
'API_GATEWAY_PORT',
|
5
|
+
'AUTHENTICATION_AUDIENCE',
|
6
|
+
'AUTHENTICATION_DOMAIN',
|
7
|
+
'CACHE_ENABLED',
|
8
|
+
'DATABASE_URL',
|
9
|
+
'FRONTEND_URL',
|
10
|
+
'REDIS_PWD',
|
11
|
+
'REDIS_URL',
|
12
|
+
'S3_IMAGES_BUCKET_NAME',
|
13
|
+
],
|
14
|
+
},
|
2
15
|
'backend-project-config': {
|
3
16
|
environmentVariableNames: ['CACHE_SERVICE_PORT', 'LOGGER_SERVICE_PORT', 'RABBITMQ_PORT', 'RABBITMQ_MANAGEMENT_PORT', 'REDIS_PORT'],
|
4
17
|
},
|
@@ -6,7 +19,7 @@ export const PROJECT_CONFIG = {
|
|
6
19
|
environmentVariableNames: ['APP_NAME', 'DOMAIN_NAME', 'S3_IMAGES_BUCKET_NAME'],
|
7
20
|
},
|
8
21
|
'cache-service-project-config': {
|
9
|
-
environmentVariableNames: ['CACHE_SERVICE_PORT', 'DATABASE_URL', 'REDIS_PWD', 'REDIS_URL'],
|
22
|
+
environmentVariableNames: ['CACHE_SERVICE_PORT', 'DATABASE_URL', 'RABBITMQ_URL', 'REDIS_PWD', 'REDIS_URL'],
|
10
23
|
},
|
11
24
|
'dictionary-service-project-config': {
|
12
25
|
environmentVariableNames: ['DICTIONARY_SERVICE_PORT'],
|