@candlerip/shared 0.0.22 → 0.0.40
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/devops/cdk/cdk-deploy.sh +4 -4
- package/devops/docker/publish-to-docker-hub.sh +7 -7
- package/devops/environment/create-env-file.sh +0 -0
- package/devops/eslint/eslint.sh +4 -4
- package/devops/prettier/prettier.sh +4 -4
- package/package.json +36 -30
- package/src/devops/env-file/create-env-file/convert-environment-variable-name-to-ssm-parameter-name/index.d.ts +2 -0
- package/src/devops/env-file/create-env-file/convert-environment-variable-name-to-ssm-parameter-name/index.js +8 -0
- package/src/devops/env-file/create-env-file/convert-environment-variable-name-to-ssm-parameter-name/types.d.ts +2 -0
- package/src/devops/env-file/create-env-file/domains.d.ts +6 -0
- package/src/devops/env-file/create-env-file/domains.js +1 -0
- package/src/devops/env-file/create-env-file/index.d.ts +2 -0
- package/src/devops/env-file/create-env-file/index.js +41 -0
- package/src/devops/env-file/create-env-file/types.d.ts +6 -0
- package/src/devops/env-file/create-env-file/types.js +1 -0
- package/src/devops/env-file/create-env-file/validate-parameters/index.d.ts +2 -0
- package/src/devops/env-file/create-env-file/validate-parameters/index.js +52 -0
- package/src/devops/env-file/create-env-file/validate-parameters/types.d.ts +8 -0
- package/src/devops/env-file/create-env-file/validate-parameters/types.js +1 -0
- package/src/devops/env-file/index.d.ts +1 -0
- package/src/devops/env-file/index.js +1 -0
- package/src/devops/index.d.ts +1 -0
- package/src/devops/index.js +1 -0
- package/src/environment/environment-mode/domains.d.ts +1 -1
- package/src/environment/environment-mode/index.d.ts +3 -3
- package/src/environment/environment-mode/index.js +3 -3
- package/src/environment/environment-mode/type-guards/index.d.ts +3 -3
- package/src/environment/environment-mode/type-guards/index.js +3 -3
- package/src/environment/environment-mode/type-guards/is-environment-mode.d.ts +1 -1
- package/src/environment/environment-mode/type-guards/is-environment-mode.js +1 -1
- package/src/environment/environment-variable-name/constants.d.ts +2 -0
- package/src/environment/environment-variable-name/constants.js +28 -0
- package/src/environment/environment-variable-name/domains.d.ts +2 -2
- package/src/environment/environment-variable-name/index.d.ts +3 -1
- package/src/environment/environment-variable-name/index.js +3 -1
- package/src/environment/environment-variable-name/type-guards.d.ts +2 -0
- package/src/environment/environment-variable-name/type-guards.js +2 -0
- package/src/environment/environment-variables/domains.d.ts +2 -4
- package/src/environment/environment-variables/index.d.ts +1 -1
- package/src/environment/environment-variables/index.js +1 -1
- package/src/environment/index.d.ts +3 -3
- package/src/environment/index.js +3 -3
- package/src/error/domains.d.ts +14 -0
- package/src/error/domains.js +1 -0
- package/src/error/index.d.ts +3 -0
- package/src/error/index.js +3 -0
- package/src/error/utils/compose-error/index.d.ts +2 -0
- package/src/error/utils/compose-error/index.js +5 -0
- package/src/error/utils/compose-error/type.d.ts +2 -0
- package/src/error/utils/compose-error/type.js +1 -0
- package/src/error/utils/console-error/index.d.ts +2 -0
- package/src/error/utils/console-error/index.js +9 -0
- package/src/error/utils/console-error/type.d.ts +2 -0
- package/src/error/utils/console-error/type.js +1 -0
- package/src/error/utils/index.d.ts +2 -0
- package/src/error/utils/index.js +2 -0
- package/src/error/workers/index.d.ts +2 -0
- package/src/error/workers/index.js +32 -0
- package/src/error/workers/type.d.ts +19 -0
- package/src/error/workers/type.js +1 -0
- package/src/helpers/index.d.ts +2 -0
- package/src/helpers/index.js +2 -0
- package/src/helpers/reveal-all-object-props/index.d.ts +2 -0
- package/src/helpers/reveal-all-object-props/index.js +13 -0
- package/src/helpers/reveal-all-object-props/type.d.ts +1 -0
- package/src/helpers/reveal-all-object-props/type.js +1 -0
- package/src/helpers/stringify/index.d.ts +2 -0
- package/src/helpers/stringify/index.js +3 -0
- package/src/helpers/stringify/type.d.ts +1 -0
- package/src/helpers/stringify/type.js +1 -0
- package/src/index.d.ts +5 -2
- package/src/index.js +5 -2
- package/src/service/index.d.ts +2 -2
- package/src/service/index.js +2 -2
- package/src/service/service-environment-variable-names/constants.d.ts +2 -0
- package/src/service/service-environment-variable-names/constants.js +5 -0
- package/src/service/service-environment-variable-names/index.d.ts +1 -0
- package/src/service/service-environment-variable-names/index.js +1 -0
- package/src/service/{service-environment-variables → service-environment-variable-names}/type.d.ts +2 -2
- package/src/service/service-environment-variable-names/type.js +1 -0
- package/src/service/service-name/domains.d.ts +1 -1
- package/src/service/service-name/index.d.ts +3 -2
- package/src/service/service-name/index.js +3 -2
- package/src/service/service-name/type-guards.d.ts +2 -0
- package/src/service/service-name/type-guards.js +2 -0
- package/src/type/array/index.d.ts +1 -0
- package/src/type/array/index.js +1 -0
- package/src/type/array/type-guards.d.ts +1 -0
- package/src/type/array/type-guards.js +9 -0
- package/src/type/index.d.ts +4 -0
- package/src/type/index.js +4 -0
- package/src/type/null/index.d.ts +1 -0
- package/src/type/null/index.js +1 -0
- package/src/type/null/type-guards.d.ts +1 -0
- package/src/type/null/type-guards.js +1 -0
- package/src/type/object/index.d.ts +1 -0
- package/src/type/object/index.js +1 -0
- package/src/type/object/type-guards.d.ts +1 -0
- package/src/type/object/type-guards.js +11 -0
- package/src/type/string/index.d.ts +1 -0
- package/src/type/string/index.js +1 -0
- package/src/type/string/type-guards.d.ts +1 -0
- package/src/type/string/type-guards.js +1 -0
- package/src/service/service-environment-variables/constants.d.ts +0 -2
- package/src/service/service-environment-variables/constants.js +0 -5
- package/src/service/service-environment-variables/index.d.ts +0 -1
- package/src/service/service-environment-variables/index.js +0 -1
- /package/src/{service/service-environment-variables/type.js → devops/env-file/create-env-file/convert-environment-variable-name-to-ssm-parameter-name/types.js} +0 -0
package/devops/cdk/cdk-deploy.sh
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env sh
|
|
2
|
-
set -e
|
|
3
|
-
|
|
4
|
-
cdk deploy --require-approval never
|
|
1
|
+
#!/usr/bin/env sh
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
cdk deploy --require-approval never
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
#!/usr/bin/env sh
|
|
2
|
-
|
|
3
|
-
DOCKERFILE=${2:-"Dockerfile"}
|
|
4
|
-
|
|
5
|
-
echo "$DOCKER_ACCESS_TOKEN" | docker login -u $DOCKER_USERNAME --password-stdin
|
|
6
|
-
docker build -f $DOCKERFILE -t reveszimre/$1 .
|
|
7
|
-
docker push reveszimre/$1
|
|
1
|
+
#!/usr/bin/env sh
|
|
2
|
+
|
|
3
|
+
DOCKERFILE=${2:-"Dockerfile"}
|
|
4
|
+
|
|
5
|
+
echo "$DOCKER_ACCESS_TOKEN" | docker login -u $DOCKER_USERNAME --password-stdin
|
|
6
|
+
docker build -f $DOCKERFILE -t reveszimre/$1 .
|
|
7
|
+
docker push reveszimre/$1
|
|
File without changes
|
package/devops/eslint/eslint.sh
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env sh
|
|
2
|
-
set -e
|
|
3
|
-
|
|
4
|
-
npx eslint .
|
|
1
|
+
#!/usr/bin/env sh
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
npx eslint .
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env sh
|
|
2
|
-
set -e
|
|
3
|
-
|
|
4
|
-
npx prettier . --write
|
|
1
|
+
#!/usr/bin/env sh
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
npx prettier . --write
|
package/package.json
CHANGED
|
@@ -1,30 +1,36 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@candlerip/shared",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"engines": {
|
|
6
|
-
"node": "=22.19.0"
|
|
7
|
-
},
|
|
8
|
-
"main": "src/index.js",
|
|
9
|
-
"bin": {
|
|
10
|
-
"crs-cdk-deploy": "devops/cdk/cdk-deploy.sh",
|
|
11
|
-
"crs-create-env-file": "devops/
|
|
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"
|
|
18
|
-
},
|
|
19
|
-
"scripts": {
|
|
20
|
-
"dev": "sh ./devops/typescript/tsc-watch.sh"
|
|
21
|
-
},
|
|
22
|
-
"dependencies": {
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"typescript
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@candlerip/shared",
|
|
3
|
+
"version": "0.0.40",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"engines": {
|
|
6
|
+
"node": "=22.19.0"
|
|
7
|
+
},
|
|
8
|
+
"main": "src/index.js",
|
|
9
|
+
"bin": {
|
|
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"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"dev": "sh ./devops/typescript/tsc-watch.sh"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@aws-sdk/client-ssm": "^3.917.0",
|
|
24
|
+
"eslint": "^9.28.0",
|
|
25
|
+
"globals": "^16.2.0",
|
|
26
|
+
"prettier": "^3.5.3",
|
|
27
|
+
"tsc-alias": "^1.8.16",
|
|
28
|
+
"typescript": "^5.8.3",
|
|
29
|
+
"typescript-eslint": "^8.33.1",
|
|
30
|
+
"yargs": "^18.0.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/node": "^24.9.1",
|
|
34
|
+
"@types/yargs": "^17.0.34"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MODE_INDEPENDENT_ENVIRONMENT_VARIABLE_NAMES } from '../../../../environment';
|
|
2
|
+
export const convertEnvironmentVariableNameToSsmParameterName = (environmentVariableName, environmentMode) => {
|
|
3
|
+
let parameterName = environmentVariableName;
|
|
4
|
+
if (!MODE_INDEPENDENT_ENVIRONMENT_VARIABLE_NAMES.includes(environmentVariableName)) {
|
|
5
|
+
parameterName = `${parameterName}_${environmentMode.toUpperCase()}`;
|
|
6
|
+
}
|
|
7
|
+
return parameterName.replace('AWS', 'AMAZONWEBSERVICES');
|
|
8
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { SERVICE_ENVIRONMENT_VARIABLE_NAMES } from '../../../service';
|
|
3
|
+
import { SSMClient, GetParametersCommand } from '@aws-sdk/client-ssm';
|
|
4
|
+
import * as fs from 'fs';
|
|
5
|
+
import { isEnvironmentMode } from '../../../environment';
|
|
6
|
+
import { validateParameters } from './validate-parameters';
|
|
7
|
+
import { convertEnvironmentVariableNameToSsmParameterName } from './convert-environment-variable-name-to-ssm-parameter-name';
|
|
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
|
+
}));
|
|
25
|
+
parameterNames.forEach((parameterName) => {
|
|
26
|
+
let envName = parameterName.replace('AMAZONWEBSERVICES', 'AWS');
|
|
27
|
+
const parts = envName.split('_');
|
|
28
|
+
const lastPart = parts.pop()?.toLowerCase();
|
|
29
|
+
if (isEnvironmentMode(lastPart)) {
|
|
30
|
+
envName = parts.join('_');
|
|
31
|
+
}
|
|
32
|
+
const value = response.Parameters?.find((p) => p.Name === envName)?.Value;
|
|
33
|
+
environmentVariables[envName] = value;
|
|
34
|
+
});
|
|
35
|
+
fs.writeFileSync(fileName, environmentVariableName
|
|
36
|
+
? Object.values(environmentVariables)[0]
|
|
37
|
+
: Object.entries(environmentVariables)
|
|
38
|
+
.map(([k, v]) => `${k}=${v}`)
|
|
39
|
+
.join('\n'), 'utf8');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { isServiceName } from '../../../../service';
|
|
2
|
+
import yargs from 'yargs';
|
|
3
|
+
import { hideBin } from 'yargs/helpers';
|
|
4
|
+
import { isString } from '../../../../type';
|
|
5
|
+
import { consoleError, ErrorWorker } from '../../../../error';
|
|
6
|
+
import { isEnvironmentMode, isEnvironmentVariableName } from '../../../../environment';
|
|
7
|
+
export const validateParameters = () => {
|
|
8
|
+
const argv = yargs(hideBin(process.argv)).parse();
|
|
9
|
+
const environmentMode = 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
|
+
if (!isEnvironmentMode(environmentMode)) {
|
|
23
|
+
consoleError(composeError('Invalid environment-mode parameter'));
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
if (!environmentVariableNameArg && !serviceNameArg) {
|
|
27
|
+
consoleError(composeError('Missing environment-variable-name or service-name parameter'));
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
let environmentVariableName;
|
|
31
|
+
if (environmentVariableNameArg) {
|
|
32
|
+
if (!isEnvironmentVariableName(environmentVariableNameArg)) {
|
|
33
|
+
consoleError(composeError('Invalid environment-variable-name parameter'));
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
environmentVariableName = environmentVariableNameArg;
|
|
37
|
+
}
|
|
38
|
+
let serviceName;
|
|
39
|
+
if (serviceNameArg) {
|
|
40
|
+
if (!isServiceName(serviceNameArg)) {
|
|
41
|
+
consoleError(composeError('Invalid service-name parameter'));
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
serviceName = serviceNameArg;
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
environmentMode,
|
|
48
|
+
environmentVariableName,
|
|
49
|
+
fileName,
|
|
50
|
+
serviceName,
|
|
51
|
+
};
|
|
52
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ServiceName } from '../../../../service';
|
|
2
|
+
import { EnvironmentMode, EnvironmentVariableName } from '../../../../environment';
|
|
3
|
+
export type ValidateParameters = () => {
|
|
4
|
+
environmentMode: EnvironmentMode;
|
|
5
|
+
environmentVariableName?: EnvironmentVariableName;
|
|
6
|
+
fileName: string;
|
|
7
|
+
serviceName?: ServiceName;
|
|
8
|
+
} | void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './create-env-file';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './create-env-file';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './env-file';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './env-file';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ENVIRONMENT_MODES } from './constants
|
|
1
|
+
import { ENVIRONMENT_MODES } from './constants';
|
|
2
2
|
export type EnvironmentMode = (typeof ENVIRONMENT_MODES)[number];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './constants
|
|
2
|
-
export * from './domains
|
|
3
|
-
export * from './type-guards
|
|
1
|
+
export * from './constants';
|
|
2
|
+
export * from './domains';
|
|
3
|
+
export * from './type-guards';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './constants
|
|
2
|
-
export * from './domains
|
|
3
|
-
export * from './type-guards
|
|
1
|
+
export * from './constants';
|
|
2
|
+
export * from './domains';
|
|
3
|
+
export * from './type-guards';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './is-development
|
|
2
|
-
export * from './is-environment-mode
|
|
3
|
-
export * from './is-production
|
|
1
|
+
export * from './is-development';
|
|
2
|
+
export * from './is-environment-mode';
|
|
3
|
+
export * from './is-production';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './is-development
|
|
2
|
-
export * from './is-environment-mode
|
|
3
|
-
export * from './is-production
|
|
1
|
+
export * from './is-development';
|
|
2
|
+
export * from './is-environment-mode';
|
|
3
|
+
export * from './is-production';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { EnvironmentMode } from '../domains
|
|
1
|
+
import { EnvironmentMode } from '../domains';
|
|
2
2
|
export declare const isEnvironmentMode: (data?: unknown) => data is EnvironmentMode;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ENVIRONMENT_MODES } from '../constants
|
|
1
|
+
import { ENVIRONMENT_MODES } from '../constants';
|
|
2
2
|
export const isEnvironmentMode = (data) => ENVIRONMENT_MODES.some((it) => data === it);
|
|
@@ -0,0 +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", "LOGGER_SERVICE_PORT", "MOBILE_APP_URL", "NODE_ENV", "RABBITMQ_URL", "REDIS_PWD", "REDIS_URL", "REDIS_URL_APP", "SSL_PRIVATE_KEY"];
|
|
2
|
+
export declare const MODE_INDEPENDENT_ENVIRONMENT_VARIABLE_NAMES: readonly ["APP_NAME", "APP_PORT", "AWS_REGION", "CACHE_SERVICE_PORT", "DOMAIN_NAME", "LOGGER_SERVICE_PORT", "REDIS_PWD", "SSL_PRIVATE_KEY"];
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const ENVIRONMENT_VARIABLE_NAMES = [
|
|
2
|
+
'APP_NAME',
|
|
3
|
+
'APP_PORT',
|
|
4
|
+
'AWS_REGION',
|
|
5
|
+
'AWS_S3_IMAGES_BUCKET_NAME',
|
|
6
|
+
'CACHE_SERVICE_PORT',
|
|
7
|
+
'DATABASE_URL',
|
|
8
|
+
'DOMAIN_NAME',
|
|
9
|
+
'FRONTEND_URL',
|
|
10
|
+
'LOGGER_SERVICE_PORT',
|
|
11
|
+
'MOBILE_APP_URL',
|
|
12
|
+
'NODE_ENV',
|
|
13
|
+
'RABBITMQ_URL',
|
|
14
|
+
'REDIS_PWD',
|
|
15
|
+
'REDIS_URL',
|
|
16
|
+
'REDIS_URL_APP',
|
|
17
|
+
'SSL_PRIVATE_KEY',
|
|
18
|
+
];
|
|
19
|
+
export const MODE_INDEPENDENT_ENVIRONMENT_VARIABLE_NAMES = [
|
|
20
|
+
'APP_NAME',
|
|
21
|
+
'APP_PORT',
|
|
22
|
+
'AWS_REGION',
|
|
23
|
+
'CACHE_SERVICE_PORT',
|
|
24
|
+
'DOMAIN_NAME',
|
|
25
|
+
'LOGGER_SERVICE_PORT',
|
|
26
|
+
'REDIS_PWD',
|
|
27
|
+
'SSL_PRIVATE_KEY',
|
|
28
|
+
];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export type EnvironmentVariableName =
|
|
1
|
+
import { ENVIRONMENT_VARIABLE_NAMES } from './constants';
|
|
2
|
+
export type EnvironmentVariableName = (typeof ENVIRONMENT_VARIABLE_NAMES)[number];
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { EnvironmentMode } from '../environment-mode
|
|
2
|
-
export type
|
|
1
|
+
import { EnvironmentMode } from '../environment-mode';
|
|
2
|
+
export type EnvironmentVariables = {
|
|
3
3
|
APP_NAME: string;
|
|
4
4
|
APP_PORT: number;
|
|
5
5
|
AWS_REGION: string;
|
|
6
6
|
AWS_S3_IMAGES_BUCKET_NAME: string;
|
|
7
7
|
CACHE_SERVICE_PORT: number;
|
|
8
|
-
CACHE_ENABLED: boolean;
|
|
9
8
|
DATABASE_URL: string;
|
|
10
9
|
DOMAIN_NAME: string;
|
|
11
|
-
EC2_IP_ADDRESS: string;
|
|
12
10
|
FRONTEND_URL: string;
|
|
13
11
|
LOGGER_SERVICE_PORT: number;
|
|
14
12
|
MOBILE_APP_URL: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './domains
|
|
1
|
+
export * from './domains';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './domains
|
|
1
|
+
export * from './domains';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './environment-mode
|
|
2
|
-
export * from './environment-variable-name
|
|
3
|
-
export * from './environment-variables
|
|
1
|
+
export * from './environment-mode';
|
|
2
|
+
export * from './environment-variable-name';
|
|
3
|
+
export * from './environment-variables';
|
package/src/environment/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './environment-mode
|
|
2
|
-
export * from './environment-variable-name
|
|
3
|
-
export * from './environment-variables
|
|
1
|
+
export * from './environment-mode';
|
|
2
|
+
export * from './environment-variable-name';
|
|
3
|
+
export * from './environment-variables';
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { composeError as composeErrorFunc } from '../utils';
|
|
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
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Error, ErrorInfo, ErrorMessage } from '../domains';
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { isObject } from '../../type';
|
|
2
|
+
export const revealAllObjectProps = (obj) => {
|
|
3
|
+
const newObj = {};
|
|
4
|
+
Object.getOwnPropertyNames(obj).forEach((key) => {
|
|
5
|
+
if (isObject(obj[key])) {
|
|
6
|
+
newObj[key] = revealAllObjectProps(obj[key]);
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
newObj[key] = obj[key];
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
return newObj;
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type RevealAllObjectProps = (obj: Record<string, unknown>) => Record<string, unknown>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Stringify = (obj: unknown) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
package/src/service/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './service-environment-
|
|
2
|
-
export * from './service-name
|
|
1
|
+
export * from './service-environment-variable-names';
|
|
2
|
+
export * from './service-name';
|
package/src/service/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './service-environment-
|
|
2
|
-
export * from './service-name
|
|
1
|
+
export * from './service-environment-variable-names';
|
|
2
|
+
export * from './service-name';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './constants';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './constants';
|
package/src/service/{service-environment-variables → service-environment-variable-names}/type.d.ts
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EnvironmentVariableName } from 'src/environment';
|
|
2
|
-
import { ServiceName } from '../service-name
|
|
3
|
-
export type
|
|
2
|
+
import { ServiceName } from '../service-name';
|
|
3
|
+
export type ServiceEnvironmentVariableNames = {
|
|
4
4
|
[key in ServiceName]: EnvironmentVariableName[];
|
|
5
5
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { SERVICE_NAMES } from './constants
|
|
1
|
+
import { SERVICE_NAMES } from './constants';
|
|
2
2
|
export type ServiceName = (typeof SERVICE_NAMES)[number];
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export * from './constants
|
|
2
|
-
export * from './domains
|
|
1
|
+
export * from './constants';
|
|
2
|
+
export * from './domains';
|
|
3
|
+
export * from './type-guards';
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export * from './constants
|
|
2
|
-
export * from './domains
|
|
1
|
+
export * from './constants';
|
|
2
|
+
export * from './domains';
|
|
3
|
+
export * from './type-guards';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './type-guards';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './type-guards';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isArray: <T>(data?: unknown, typeGuard?: (data?: unknown) => data is T) => data is T[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './type-guards';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './type-guards';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isNull: (data?: unknown) => data is null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const isNull = (data) => data === null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './type-guards';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './type-guards';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isObject: (data?: unknown) => data is Record<string, unknown>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './type-guards';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './type-guards';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isString: (data?: unknown) => data is string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const isString = (data) => typeof data === 'string';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './constants.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './constants.js';
|