@candlerip/shared 0.0.47 → 0.0.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -17
- package/src/common/custom-error/domains.d.ts +14 -0
- package/src/common/custom-error/utils/compose-custom-error/index.d.ts +2 -0
- package/src/{error/utils/compose-error → common/custom-error/utils/compose-custom-error}/index.js +1 -1
- package/src/common/custom-error/utils/compose-custom-error/type.d.ts +2 -0
- package/src/common/custom-error/utils/console-custom-error/index.d.ts +2 -0
- package/src/{error/utils/console-error → common/custom-error/utils/console-custom-error}/index.js +1 -1
- package/src/common/custom-error/utils/console-custom-error/type.d.ts +2 -0
- package/src/common/custom-error/utils/index.d.ts +2 -0
- package/src/common/custom-error/utils/index.js +2 -0
- package/src/common/custom-error/workers/index.d.ts +2 -0
- package/src/common/custom-error/workers/index.js +32 -0
- package/src/common/custom-error/workers/type.d.ts +19 -0
- package/src/{environment → common/environment}/environment-variable-name/constants.d.ts +1 -1
- package/src/{environment → common/environment}/environment-variable-name/constants.js +0 -1
- package/src/{environment → common/environment}/environment-variables/domains.d.ts +0 -1
- package/src/{environment → common/environment}/index.d.ts +0 -1
- package/src/{environment → common/environment}/index.js +0 -1
- package/src/{index.d.ts → common/index.d.ts} +1 -1
- package/src/{index.js → common/index.js} +1 -1
- package/src/common/service/index.d.ts +1 -0
- package/src/common/service/index.js +1 -0
- package/src/{service → common/service}/service-name/constants.d.ts +1 -1
- package/src/common/service/service-name/constants.js +1 -0
- package/devops/cdk/cdk-deploy.sh +0 -4
- package/devops/docker/publish-to-docker-hub.sh +0 -7
- package/devops/environment/create-env-file.sh +0 -25
- package/devops/eslint/eslint.base.config.js +0 -26
- package/devops/eslint/eslint.sh +0 -4
- package/devops/npm/publish-to-npm-registry.sh +0 -15
- package/devops/prettier/prettier.base.config.js +0 -7
- package/devops/prettier/prettier.sh +0 -4
- package/devops/typescript/tsc-build.sh +0 -6
- package/devops/typescript/tsc-watch.sh +0 -5
- package/devops/typescript/tsconfig.base.json +0 -17
- package/src/devops/env-file/create-env-file/convert-environment-variable-name-to-ssm-parameter-name/index.d.ts +0 -2
- package/src/devops/env-file/create-env-file/convert-environment-variable-name-to-ssm-parameter-name/index.js +0 -8
- package/src/devops/env-file/create-env-file/convert-environment-variable-name-to-ssm-parameter-name/types.d.ts +0 -2
- package/src/devops/env-file/create-env-file/convert-environment-variable-name-to-ssm-parameter-name/types.js +0 -1
- package/src/devops/env-file/create-env-file/index.d.ts +0 -2
- package/src/devops/env-file/create-env-file/index.js +0 -42
- package/src/devops/env-file/create-env-file/types.d.ts +0 -6
- package/src/devops/env-file/create-env-file/types.js +0 -1
- package/src/devops/env-file/create-env-file/validate-parameters/index.d.ts +0 -2
- package/src/devops/env-file/create-env-file/validate-parameters/index.js +0 -56
- package/src/devops/env-file/create-env-file/validate-parameters/types.d.ts +0 -8
- package/src/devops/env-file/create-env-file/validate-parameters/types.js +0 -1
- package/src/devops/env-file/index.d.ts +0 -1
- package/src/devops/env-file/index.js +0 -1
- package/src/devops/index.d.ts +0 -1
- package/src/devops/index.js +0 -1
- package/src/error/domains.d.ts +0 -14
- package/src/error/utils/compose-error/index.d.ts +0 -2
- package/src/error/utils/compose-error/type.d.ts +0 -2
- package/src/error/utils/console-error/index.d.ts +0 -2
- package/src/error/utils/console-error/type.d.ts +0 -2
- package/src/error/utils/index.d.ts +0 -2
- package/src/error/utils/index.js +0 -2
- package/src/error/workers/index.d.ts +0 -2
- package/src/error/workers/index.js +0 -32
- package/src/error/workers/type.d.ts +0 -19
- package/src/service/index.d.ts +0 -2
- package/src/service/index.js +0 -2
- package/src/service/service-environment-variable-names/constants.d.ts +0 -2
- package/src/service/service-environment-variable-names/constants.js +0 -17
- package/src/service/service-environment-variable-names/index.d.ts +0 -1
- package/src/service/service-environment-variable-names/index.js +0 -1
- package/src/service/service-environment-variable-names/type.d.ts +0 -5
- package/src/service/service-environment-variable-names/type.js +0 -1
- package/src/service/service-name/constants.js +0 -1
- /package/src/{environment/environment-mode → common/custom-error}/domains.js +0 -0
- /package/src/{error → common/custom-error}/index.d.ts +0 -0
- /package/src/{error → common/custom-error}/index.js +0 -0
- /package/src/{error/utils/compose-error → common/custom-error/utils/compose-custom-error}/type.js +0 -0
- /package/src/{error/utils/console-error → common/custom-error/utils/console-custom-error}/type.js +0 -0
- /package/src/{error → common/custom-error}/workers/type.js +0 -0
- /package/src/{environment → common/environment}/environment-mode/constants.d.ts +0 -0
- /package/src/{environment → common/environment}/environment-mode/constants.js +0 -0
- /package/src/{environment → common/environment}/environment-mode/domains.d.ts +0 -0
- /package/src/{environment/environment-variable-name → common/environment/environment-mode}/domains.js +0 -0
- /package/src/{environment → common/environment}/environment-mode/index.d.ts +0 -0
- /package/src/{environment → common/environment}/environment-mode/index.js +0 -0
- /package/src/{environment → common/environment}/environment-mode/type-guards/index.d.ts +0 -0
- /package/src/{environment → common/environment}/environment-mode/type-guards/index.js +0 -0
- /package/src/{environment → common/environment}/environment-mode/type-guards/is-development.d.ts +0 -0
- /package/src/{environment → common/environment}/environment-mode/type-guards/is-development.js +0 -0
- /package/src/{environment → common/environment}/environment-mode/type-guards/is-environment-mode.d.ts +0 -0
- /package/src/{environment → common/environment}/environment-mode/type-guards/is-environment-mode.js +0 -0
- /package/src/{environment → common/environment}/environment-mode/type-guards/is-production.d.ts +0 -0
- /package/src/{environment → common/environment}/environment-mode/type-guards/is-production.js +0 -0
- /package/src/{environment → common/environment}/environment-variable-name/domains.d.ts +0 -0
- /package/src/{environment/environment-variables → common/environment/environment-variable-name}/domains.js +0 -0
- /package/src/{environment → common/environment}/environment-variable-name/index.d.ts +0 -0
- /package/src/{environment → common/environment}/environment-variable-name/index.js +0 -0
- /package/src/{environment → common/environment}/environment-variable-name/type-guards.d.ts +0 -0
- /package/src/{environment → common/environment}/environment-variable-name/type-guards.js +0 -0
- /package/src/{error → common/environment/environment-variables}/domains.js +0 -0
- /package/src/{environment → common/environment}/environment-variables/index.d.ts +0 -0
- /package/src/{environment → common/environment}/environment-variables/index.js +0 -0
- /package/src/{helpers → common/helpers}/index.d.ts +0 -0
- /package/src/{helpers → common/helpers}/index.js +0 -0
- /package/src/{helpers → common/helpers}/reveal-all-object-props/index.d.ts +0 -0
- /package/src/{helpers → common/helpers}/reveal-all-object-props/index.js +0 -0
- /package/src/{helpers → common/helpers}/reveal-all-object-props/type.d.ts +0 -0
- /package/src/{helpers → common/helpers}/reveal-all-object-props/type.js +0 -0
- /package/src/{helpers → common/helpers}/stringify/index.d.ts +0 -0
- /package/src/{helpers → common/helpers}/stringify/index.js +0 -0
- /package/src/{helpers → common/helpers}/stringify/type.d.ts +0 -0
- /package/src/{helpers → common/helpers}/stringify/type.js +0 -0
- /package/src/{service → common/service}/service-name/domains.d.ts +0 -0
- /package/src/{service → common/service}/service-name/domains.js +0 -0
- /package/src/{service → common/service}/service-name/index.d.ts +0 -0
- /package/src/{service → common/service}/service-name/index.js +0 -0
- /package/src/{service → common/service}/service-name/type-guards.d.ts +0 -0
- /package/src/{service → common/service}/service-name/type-guards.js +0 -0
- /package/src/{type → common/type}/array/index.d.ts +0 -0
- /package/src/{type → common/type}/array/index.js +0 -0
- /package/src/{type → common/type}/array/type-guards.d.ts +0 -0
- /package/src/{type → common/type}/array/type-guards.js +0 -0
- /package/src/{type → common/type}/index.d.ts +0 -0
- /package/src/{type → common/type}/index.js +0 -0
- /package/src/{type → common/type}/null/index.d.ts +0 -0
- /package/src/{type → common/type}/null/index.js +0 -0
- /package/src/{type → common/type}/null/type-guards.d.ts +0 -0
- /package/src/{type → common/type}/null/type-guards.js +0 -0
- /package/src/{type → common/type}/object/index.d.ts +0 -0
- /package/src/{type → common/type}/object/index.js +0 -0
- /package/src/{type → common/type}/object/type-guards.d.ts +0 -0
- /package/src/{type → common/type}/object/type-guards.js +0 -0
- /package/src/{type → common/type}/string/index.d.ts +0 -0
- /package/src/{type → common/type}/string/index.js +0 -0
- /package/src/{type → common/type}/string/type-guards.d.ts +0 -0
- /package/src/{type → common/type}/string/type-guards.js +0 -0
package/package.json
CHANGED
|
@@ -1,36 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@candlerip/shared",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.59",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": "=22.19.0"
|
|
7
7
|
},
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
"crs-cdk-deploy": "devops/cdk/cdk-deploy.sh",
|
|
11
|
-
"crs-create-env-file": "src/devops/env-file/create-env-file/index.js",
|
|
12
|
-
"crs-publish-to-docker-hub": "./devops/docker/publish-to-docker-hub.sh",
|
|
13
|
-
"crs-eslint": "devops/eslint/eslint.sh",
|
|
14
|
-
"crs-publish-to-npm-registry": "devops/npm/publish-to-npm-registry.sh",
|
|
15
|
-
"crs-prettier": "devops/prettier/prettier.sh",
|
|
16
|
-
"crs-tsc-build": "devops/typescript/tsc-build.sh",
|
|
17
|
-
"crs-tsc-watch": "devops/typescript/tsc-watch.sh"
|
|
8
|
+
"exports": {
|
|
9
|
+
"./common": "./dist/common/index.js"
|
|
18
10
|
},
|
|
19
11
|
"scripts": {
|
|
20
|
-
"dev": "
|
|
12
|
+
"dev": "crs-tsc-watch"
|
|
21
13
|
},
|
|
22
14
|
"dependencies": {
|
|
23
|
-
"@aws-sdk/client-ssm": "^3.917.0",
|
|
24
15
|
"eslint": "^9.28.0",
|
|
25
|
-
"globals": "^16.2.0",
|
|
26
16
|
"prettier": "^3.5.3",
|
|
27
17
|
"tsc-alias": "^1.8.16",
|
|
28
18
|
"typescript": "^5.8.3",
|
|
29
|
-
"typescript-eslint": "^8.33.1"
|
|
30
|
-
"yargs": "^18.0.0"
|
|
19
|
+
"typescript-eslint": "^8.33.1"
|
|
31
20
|
},
|
|
32
21
|
"devDependencies": {
|
|
22
|
+
"@candlerip/shared-devops": "^0.0.50",
|
|
33
23
|
"@types/node": "^24.9.1",
|
|
34
|
-
"
|
|
24
|
+
"globals": "^16.4.0"
|
|
35
25
|
}
|
|
36
26
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface CustomError {
|
|
2
|
+
id: string;
|
|
3
|
+
info?: CustomErrorInfo;
|
|
4
|
+
message: CustomErrorMessage;
|
|
5
|
+
}
|
|
6
|
+
export type CustomErrorInfo = Record<string, unknown>;
|
|
7
|
+
export type CustomErrorMessage = string;
|
|
8
|
+
export type TCustomError<T = never> = {
|
|
9
|
+
data: T;
|
|
10
|
+
error?: never;
|
|
11
|
+
} | {
|
|
12
|
+
error: CustomError;
|
|
13
|
+
data?: never;
|
|
14
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { composeCustomError as composeCustomErrorFunc } from '../utils/index.js';
|
|
2
|
+
export const CustomErrorWorker = (props) => {
|
|
3
|
+
let _error = props ? composeCustomErrorFunc(props.message, props.info) : undefined;
|
|
4
|
+
const _composeInfo = (info) => {
|
|
5
|
+
if (_error) {
|
|
6
|
+
_error.info = {
|
|
7
|
+
..._error.info,
|
|
8
|
+
...info,
|
|
9
|
+
};
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
_error = composeCustomErrorFunc(undefined, info);
|
|
13
|
+
};
|
|
14
|
+
const addCustomErrorInfo = (info) => {
|
|
15
|
+
_composeInfo(info);
|
|
16
|
+
};
|
|
17
|
+
const addCustomErrorMessage = (message) => {
|
|
18
|
+
_error = composeCustomErrorFunc(message);
|
|
19
|
+
};
|
|
20
|
+
const composeCustomError = (message, info) => composeCustomErrorFunc(message, info ?? _error?.info);
|
|
21
|
+
const getCustomError = () => (_error ? { error: _error } : undefined);
|
|
22
|
+
const resetCustomError = () => {
|
|
23
|
+
_error = undefined;
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
addCustomErrorInfo,
|
|
27
|
+
addCustomErrorMessage,
|
|
28
|
+
composeCustomError,
|
|
29
|
+
getCustomError,
|
|
30
|
+
resetCustomError,
|
|
31
|
+
};
|
|
32
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CustomError, CustomErrorInfo, CustomErrorMessage } from '../domains.js';
|
|
2
|
+
export type CustomErrorWorkerType = (props?: {
|
|
3
|
+
message?: CustomErrorMessage;
|
|
4
|
+
info?: CustomErrorInfo;
|
|
5
|
+
}) => {
|
|
6
|
+
addCustomErrorInfo: AddCustomErrorInfo;
|
|
7
|
+
addCustomErrorMessage: AddCustomErrorMessage;
|
|
8
|
+
composeCustomError: ComposeCustomError;
|
|
9
|
+
getCustomError: GetCustomError;
|
|
10
|
+
resetCustomError: ResetCustomError;
|
|
11
|
+
};
|
|
12
|
+
export type _ComposeInfo = (info?: CustomErrorInfo) => void;
|
|
13
|
+
export type AddCustomErrorInfo = (info: CustomErrorInfo) => void;
|
|
14
|
+
export type AddCustomErrorMessage = (message: CustomErrorMessage) => void;
|
|
15
|
+
export type ComposeCustomError = (message: CustomErrorMessage, info?: CustomErrorInfo) => CustomError;
|
|
16
|
+
export type GetCustomError = () => {
|
|
17
|
+
error: CustomError;
|
|
18
|
+
} | undefined;
|
|
19
|
+
export type ResetCustomError = () => void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const ENVIRONMENT_VARIABLE_NAMES: readonly ["APP_NAME", "APP_PORT", "AWS_REGION", "AWS_S3_IMAGES_BUCKET_NAME", "CACHE_SERVICE_PORT", "DATABASE_URL", "DOMAIN_NAME", "FRONTEND_URL", "
|
|
1
|
+
export declare const ENVIRONMENT_VARIABLE_NAMES: readonly ["APP_NAME", "APP_PORT", "AWS_REGION", "AWS_S3_IMAGES_BUCKET_NAME", "CACHE_SERVICE_PORT", "DATABASE_URL", "DOMAIN_NAME", "FRONTEND_URL", "MOBILE_APP_URL", "NODE_ENV", "RABBITMQ_MANAGEMENT_PORT", "RABBITMQ_PORT", "RABBITMQ_PWD", "RABBITMQ_USER", "RABBITMQ_URL", "REDIS_PORT", "REDIS_PWD", "REDIS_URL", "REDIS_URL_APP", "SSL_PRIVATE_KEY"];
|
|
2
2
|
export declare const MODE_DEPENDENT_ENVIRONMENT_VARIABLE_NAMES: readonly ["DATABASE_URL"];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './service-name/index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './service-name/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SERVICE_NAMES: readonly ["cache-service", "
|
|
1
|
+
export declare const SERVICE_NAMES: readonly ["cache-service", "nginx", "redis", "server"];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const SERVICE_NAMES = ['cache-service', 'nginx', 'redis', 'server'];
|
package/devops/cdk/cdk-deploy.sh
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env sh
|
|
2
|
-
set -e
|
|
3
|
-
|
|
4
|
-
PARAM_NAMES=(${1//,/ })
|
|
5
|
-
|
|
6
|
-
ENVS=()
|
|
7
|
-
for ((i=0; i<${#PARAM_NAMES[@]}; i+=10)); do
|
|
8
|
-
chunk=("${PARAM_NAMES[@]:i:10}")
|
|
9
|
-
|
|
10
|
-
PARAMS=$(aws ssm get-parameters --names "${chunk[@]}" --output text --query "Parameters[*].{Name:Name,Value:Value}" --with-decryption | sed -E 's/\s+/=/g')
|
|
11
|
-
|
|
12
|
-
PARAMS1="${PARAMS[@]//_DEVELOPMENT/}"
|
|
13
|
-
PARAMS2="${PARAMS1[@]//_PRODUCTION/}"
|
|
14
|
-
PARAMS3="${PARAMS2[@]//AMAZONWEBSERVICES/AWS}"
|
|
15
|
-
ENVS+=("$PARAMS3")
|
|
16
|
-
done
|
|
17
|
-
|
|
18
|
-
if [[ $2 ]]
|
|
19
|
-
then
|
|
20
|
-
FILENAME=".env.$2"
|
|
21
|
-
else
|
|
22
|
-
FILENAME=".env"
|
|
23
|
-
fi
|
|
24
|
-
|
|
25
|
-
printf "%s\n" "${ENVS[@]}" > $FILENAME
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import js from '@eslint/js';
|
|
2
|
-
import ts from 'typescript-eslint';
|
|
3
|
-
import globals from 'globals';
|
|
4
|
-
|
|
5
|
-
export default (projectConfig) =>
|
|
6
|
-
ts.config(
|
|
7
|
-
js.configs.recommended,
|
|
8
|
-
...ts.configs.recommended,
|
|
9
|
-
{
|
|
10
|
-
ignores: ['.next', 'cdk.out', 'dist', 'temp'],
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
languageOptions: {
|
|
14
|
-
globals: {
|
|
15
|
-
...globals.browser,
|
|
16
|
-
...globals.node,
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
rules: {
|
|
22
|
-
'no-console': [2, { allow: ['error', 'info'] }],
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
...(projectConfig ?? []),
|
|
26
|
-
);
|
package/devops/eslint/eslint.sh
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env sh
|
|
2
|
-
set -e
|
|
3
|
-
|
|
4
|
-
npm config set //registry.npmjs.org/:_authToken $NPM_ACCESS_TOKEN
|
|
5
|
-
|
|
6
|
-
ls -al
|
|
7
|
-
cat package.json
|
|
8
|
-
cat ~/.npmrc
|
|
9
|
-
|
|
10
|
-
if [ -d "devops" ]; then
|
|
11
|
-
cp -r devops dist
|
|
12
|
-
fi
|
|
13
|
-
cp package.json dist
|
|
14
|
-
|
|
15
|
-
npm publish ./dist --access public
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"declaration": true,
|
|
4
|
-
"esModuleInterop": true,
|
|
5
|
-
"module": "ES2022",
|
|
6
|
-
"moduleResolution": "bundler",
|
|
7
|
-
"outDir": "${configDir}/dist",
|
|
8
|
-
"rootDir": "${configDir}/src",
|
|
9
|
-
"skipLibCheck": true,
|
|
10
|
-
"strict": true,
|
|
11
|
-
"target": "ES2022"
|
|
12
|
-
},
|
|
13
|
-
"tsc-alias": {
|
|
14
|
-
"verbose": false,
|
|
15
|
-
"resolveFullPaths": true
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { MODE_DEPENDENT_ENVIRONMENT_VARIABLE_NAMES } from '../../../../environment/index.js';
|
|
2
|
-
export const convertEnvironmentVariableNameToSsmParameterName = (environmentVariableName, environmentMode) => {
|
|
3
|
-
let parameterName = environmentVariableName;
|
|
4
|
-
if (MODE_DEPENDENT_ENVIRONMENT_VARIABLE_NAMES.includes(environmentVariableName)) {
|
|
5
|
-
parameterName = `${environmentVariableName}_${environmentMode?.toUpperCase()}`;
|
|
6
|
-
}
|
|
7
|
-
return parameterName.replace('AWS', 'AMAZONWEBSERVICES');
|
|
8
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { SERVICE_ENVIRONMENT_VARIABLE_NAMES } from '../../../service/index.js';
|
|
3
|
-
import { SSMClient, GetParametersCommand } from '@aws-sdk/client-ssm';
|
|
4
|
-
import * as fs from 'fs';
|
|
5
|
-
import { isEnvironmentMode } from '../../../environment/index.js';
|
|
6
|
-
import { validateParameters } from './validate-parameters/index.js';
|
|
7
|
-
import { convertEnvironmentVariableNameToSsmParameterName } from './convert-environment-variable-name-to-ssm-parameter-name/index.js';
|
|
8
|
-
const parameters = validateParameters();
|
|
9
|
-
if (parameters) {
|
|
10
|
-
const { environmentMode, environmentVariableName, fileName, serviceName } = parameters;
|
|
11
|
-
const ssmClient = new SSMClient();
|
|
12
|
-
let parameterNames = [];
|
|
13
|
-
if (environmentVariableName) {
|
|
14
|
-
parameterNames = [convertEnvironmentVariableNameToSsmParameterName(environmentVariableName, environmentMode)];
|
|
15
|
-
}
|
|
16
|
-
else if (serviceName) {
|
|
17
|
-
const envNames = SERVICE_ENVIRONMENT_VARIABLE_NAMES[serviceName];
|
|
18
|
-
parameterNames = envNames.map((envName) => convertEnvironmentVariableNameToSsmParameterName(envName, environmentMode));
|
|
19
|
-
}
|
|
20
|
-
const environmentVariables = {};
|
|
21
|
-
for (let i = 0; i < parameterNames.length; i += 10) {
|
|
22
|
-
const response = await ssmClient.send(new GetParametersCommand({
|
|
23
|
-
Names: parameterNames.slice(i, i + 10),
|
|
24
|
-
WithDecryption: true,
|
|
25
|
-
}));
|
|
26
|
-
parameterNames.forEach((parameterName) => {
|
|
27
|
-
let envName = parameterName.replace('AMAZONWEBSERVICES', 'AWS');
|
|
28
|
-
const parts = envName.split('_');
|
|
29
|
-
const lastPart = parts.pop()?.toLowerCase();
|
|
30
|
-
if (isEnvironmentMode(lastPart)) {
|
|
31
|
-
envName = parts.join('_');
|
|
32
|
-
}
|
|
33
|
-
const value = response.Parameters?.find((p) => p.Name === parameterName)?.Value;
|
|
34
|
-
environmentVariables[envName] = value;
|
|
35
|
-
});
|
|
36
|
-
fs.writeFileSync(fileName, environmentVariableName
|
|
37
|
-
? Object.values(environmentVariables)[0]
|
|
38
|
-
: Object.entries(environmentVariables)
|
|
39
|
-
.map(([k, v]) => `${k}=${v}`)
|
|
40
|
-
.join('\n'), 'utf8');
|
|
41
|
-
}
|
|
42
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { isServiceName } from '../../../../service/index.js';
|
|
2
|
-
import yargs from 'yargs';
|
|
3
|
-
import { hideBin } from 'yargs/helpers';
|
|
4
|
-
import { isString } from '../../../../type/index.js';
|
|
5
|
-
import { consoleError, ErrorWorker } from '../../../../error/index.js';
|
|
6
|
-
import { isEnvironmentMode, isEnvironmentVariableName } from '../../../../environment/index.js';
|
|
7
|
-
export const validateParameters = () => {
|
|
8
|
-
const argv = yargs(hideBin(process.argv)).parse();
|
|
9
|
-
const environmentModeArg = argv['environment-mode'];
|
|
10
|
-
const environmentVariableNameArg = argv['environment-variable-name'];
|
|
11
|
-
const serviceNameArg = argv['service-name'];
|
|
12
|
-
const fileName = argv['file-name'];
|
|
13
|
-
const { composeError } = ErrorWorker({
|
|
14
|
-
info: {
|
|
15
|
-
args: process.argv,
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
if (!isString(fileName)) {
|
|
19
|
-
consoleError(composeError('Invalid or missing file-name parameter'));
|
|
20
|
-
process.exit(1);
|
|
21
|
-
}
|
|
22
|
-
let environmentMode;
|
|
23
|
-
if (environmentModeArg) {
|
|
24
|
-
if (!isEnvironmentMode(environmentModeArg)) {
|
|
25
|
-
consoleError(composeError('Invalid environment-mode parameter'));
|
|
26
|
-
process.exit(1);
|
|
27
|
-
}
|
|
28
|
-
environmentMode = environmentModeArg;
|
|
29
|
-
}
|
|
30
|
-
if (!environmentVariableNameArg && !serviceNameArg) {
|
|
31
|
-
consoleError(composeError('Missing environment-variable-name or service-name parameter'));
|
|
32
|
-
process.exit(1);
|
|
33
|
-
}
|
|
34
|
-
let environmentVariableName;
|
|
35
|
-
if (environmentVariableNameArg) {
|
|
36
|
-
if (!isEnvironmentVariableName(environmentVariableNameArg)) {
|
|
37
|
-
consoleError(composeError('Invalid environment-variable-name parameter'));
|
|
38
|
-
process.exit(1);
|
|
39
|
-
}
|
|
40
|
-
environmentVariableName = environmentVariableNameArg;
|
|
41
|
-
}
|
|
42
|
-
let serviceName;
|
|
43
|
-
if (serviceNameArg) {
|
|
44
|
-
if (!isServiceName(serviceNameArg)) {
|
|
45
|
-
consoleError(composeError('Invalid service-name parameter'));
|
|
46
|
-
process.exit(1);
|
|
47
|
-
}
|
|
48
|
-
serviceName = serviceNameArg;
|
|
49
|
-
}
|
|
50
|
-
return {
|
|
51
|
-
environmentMode,
|
|
52
|
-
environmentVariableName,
|
|
53
|
-
fileName,
|
|
54
|
-
serviceName,
|
|
55
|
-
};
|
|
56
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ServiceName } from '../../../../service/index.js';
|
|
2
|
-
import { EnvironmentMode, EnvironmentVariableName } from '../../../../environment/index.js';
|
|
3
|
-
export type ValidateParameters = () => {
|
|
4
|
-
environmentMode?: EnvironmentMode;
|
|
5
|
-
environmentVariableName?: EnvironmentVariableName;
|
|
6
|
-
fileName: string;
|
|
7
|
-
serviceName?: ServiceName;
|
|
8
|
-
} | void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './create-env-file/index.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './create-env-file/index.js';
|
package/src/devops/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './env-file/index.js';
|
package/src/devops/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './env-file/index.js';
|
package/src/error/domains.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export interface Error {
|
|
2
|
-
id: string;
|
|
3
|
-
info?: ErrorInfo;
|
|
4
|
-
message: ErrorMessage;
|
|
5
|
-
}
|
|
6
|
-
export type ErrorInfo = Record<string, unknown>;
|
|
7
|
-
export type ErrorMessage = string;
|
|
8
|
-
export type TError<T = never> = {
|
|
9
|
-
data: T;
|
|
10
|
-
error?: never;
|
|
11
|
-
} | {
|
|
12
|
-
error: Error;
|
|
13
|
-
data?: never;
|
|
14
|
-
};
|
package/src/error/utils/index.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { composeError as composeErrorFunc } from '../utils/index.js';
|
|
2
|
-
export const ErrorWorker = (props) => {
|
|
3
|
-
let _error = props ? composeErrorFunc(props.message, props.info) : undefined;
|
|
4
|
-
const _composeInfo = (info) => {
|
|
5
|
-
if (_error) {
|
|
6
|
-
_error.info = {
|
|
7
|
-
..._error.info,
|
|
8
|
-
...info,
|
|
9
|
-
};
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
_error = composeErrorFunc(undefined, info);
|
|
13
|
-
};
|
|
14
|
-
const addErrorInfo = (info) => {
|
|
15
|
-
_composeInfo(info);
|
|
16
|
-
};
|
|
17
|
-
const addErrorMessage = (message) => {
|
|
18
|
-
_error = composeErrorFunc(message);
|
|
19
|
-
};
|
|
20
|
-
const composeError = (message, info) => composeErrorFunc(message, info ?? _error?.info);
|
|
21
|
-
const getError = () => (_error ? { error: _error } : undefined);
|
|
22
|
-
const resetError = () => {
|
|
23
|
-
_error = undefined;
|
|
24
|
-
};
|
|
25
|
-
return {
|
|
26
|
-
addErrorInfo,
|
|
27
|
-
addErrorMessage,
|
|
28
|
-
composeError,
|
|
29
|
-
getError,
|
|
30
|
-
resetError,
|
|
31
|
-
};
|
|
32
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Error, ErrorInfo, ErrorMessage } from '../domains.js';
|
|
2
|
-
export type ErrorWorkerType = (props?: {
|
|
3
|
-
message?: ErrorMessage;
|
|
4
|
-
info?: ErrorInfo;
|
|
5
|
-
}) => {
|
|
6
|
-
addErrorInfo: AddErrorInfo;
|
|
7
|
-
addErrorMessage: AddErrorMessage;
|
|
8
|
-
composeError: ComposeError;
|
|
9
|
-
getError: GetError;
|
|
10
|
-
resetError: ResetError;
|
|
11
|
-
};
|
|
12
|
-
export type _ComposeInfo = (info?: ErrorInfo) => void;
|
|
13
|
-
export type AddErrorInfo = (info: ErrorInfo) => void;
|
|
14
|
-
export type AddErrorMessage = (message: ErrorMessage) => void;
|
|
15
|
-
export type ComposeError = (message: ErrorMessage, info?: ErrorInfo) => Error;
|
|
16
|
-
export type GetError = () => {
|
|
17
|
-
error: Error;
|
|
18
|
-
} | undefined;
|
|
19
|
-
export type ResetError = () => void;
|
package/src/service/index.d.ts
DELETED
package/src/service/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export const SERVICE_ENVIRONMENT_VARIABLE_NAMES = {
|
|
2
|
-
'cache-service': ['APP_NAME'],
|
|
3
|
-
nginx: ['APP_PORT'],
|
|
4
|
-
'logger-service': ['DATABASE_URL', 'LOGGER_SERVICE_PORT'],
|
|
5
|
-
rabbitmq: ['RABBITMQ_MANAGEMENT_PORT', 'RABBITMQ_PORT', 'RABBITMQ_PWD', 'RABBITMQ_USER'],
|
|
6
|
-
redis: ['REDIS_PORT', 'REDIS_PWD'],
|
|
7
|
-
server: [
|
|
8
|
-
'APP_PORT',
|
|
9
|
-
'CACHE_SERVICE_PORT',
|
|
10
|
-
'LOGGER_SERVICE_PORT',
|
|
11
|
-
'RABBITMQ_MANAGEMENT_PORT',
|
|
12
|
-
'RABBITMQ_PORT',
|
|
13
|
-
'RABBITMQ_PWD',
|
|
14
|
-
'RABBITMQ_USER',
|
|
15
|
-
'REDIS_PORT',
|
|
16
|
-
],
|
|
17
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './constants.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './constants.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const SERVICE_NAMES = ['cache-service', 'logger-service', 'nginx', 'rabbitmq', 'redis', 'server'];
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/src/{error/utils/compose-error → common/custom-error/utils/compose-custom-error}/type.js
RENAMED
|
File without changes
|
/package/src/{error/utils/console-error → common/custom-error/utils/console-custom-error}/type.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/src/{environment → common/environment}/environment-mode/type-guards/is-development.d.ts
RENAMED
|
File without changes
|
/package/src/{environment → common/environment}/environment-mode/type-guards/is-development.js
RENAMED
|
File without changes
|
|
File without changes
|
/package/src/{environment → common/environment}/environment-mode/type-guards/is-environment-mode.js
RENAMED
|
File without changes
|
/package/src/{environment → common/environment}/environment-mode/type-guards/is-production.d.ts
RENAMED
|
File without changes
|
/package/src/{environment → common/environment}/environment-mode/type-guards/is-production.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|