@candlerip/shared 0.0.4 → 0.0.11
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/environment/create-env-file.sh +11 -15
- package/devops/eslint/eslint.base.config.js +26 -0
- package/devops/eslint/eslint.sh +4 -4
- package/devops/npm/publish-to-npm.sh +5 -6
- package/devops/prettier/{config.js → prettier.base.config.js} +1 -1
- package/devops/prettier/prettier.sh +4 -4
- package/devops/typescript/tsc-build.sh +1 -1
- package/devops/typescript/tsc-watch.sh +1 -1
- package/devops/typescript/tsconfig.base.json +1 -2
- package/package.json +13 -29
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/service/index.d.ts +1 -0
- package/src/service/index.js +1 -0
- package/src/service/service-name/constants.d.ts +1 -0
- package/src/service/service-name/constants.js +1 -0
- package/src/service/service-name/domains.d.ts +2 -0
- package/src/service/service-name/index.d.ts +2 -0
- package/src/service/service-name/index.js +2 -0
- package/devops/publish-package.sh +0 -12
- package/dist/backend/environment/env-file/index.d.ts +0 -1
- package/dist/backend/environment/env-file/index.js +0 -1
- package/dist/backend/environment/env-file/utils/index.d.ts +0 -1
- package/dist/backend/environment/env-file/utils/index.js +0 -1
- package/dist/backend/environment/env-file/utils/load-env-file/index.d.ts +0 -2
- package/dist/backend/environment/env-file/utils/load-env-file/index.js +0 -47
- package/dist/backend/environment/env-file/utils/load-env-file/type.d.ts +0 -4
- package/dist/backend/environment/env-file/utils/load-env-file/type.js +0 -1
- package/dist/backend/environment/index.d.ts +0 -1
- package/dist/backend/environment/index.js +0 -1
- package/dist/common/environment/environment-mode/configs.d.ts +0 -1
- package/dist/common/environment/environment-mode/configs.js +0 -1
- package/dist/common/environment/environment-mode/domains.d.ts +0 -2
- package/dist/common/environment/environment-mode/index.d.ts +0 -3
- package/dist/common/environment/environment-mode/index.js +0 -3
- package/dist/common/environment/environment-mode/type-guards/index.d.ts +0 -3
- package/dist/common/environment/environment-mode/type-guards/index.js +0 -3
- package/dist/common/environment/environment-mode/type-guards/is-development.d.ts +0 -1
- package/dist/common/environment/environment-mode/type-guards/is-development.js +0 -1
- package/dist/common/environment/environment-mode/type-guards/is-environment-mode.d.ts +0 -2
- package/dist/common/environment/environment-mode/type-guards/is-environment-mode.js +0 -2
- package/dist/common/environment/environment-mode/type-guards/is-production.d.ts +0 -1
- package/dist/common/environment/environment-mode/type-guards/is-production.js +0 -1
- package/dist/common/environment/environment-variables/domains.d.ts +0 -18
- package/dist/common/environment/environment-variables/domains.js +0 -1
- package/dist/common/environment/environment-variables/index.d.ts +0 -2
- package/dist/common/environment/environment-variables/index.js +0 -2
- package/dist/common/environment/environment-variables/singletons/index.d.ts +0 -8
- package/dist/common/environment/environment-variables/singletons/index.js +0 -20
- package/dist/common/environment/environment-variables/singletons/type.d.ts +0 -6
- package/dist/common/environment/environment-variables/singletons/type.js +0 -1
- package/dist/common/environment/index.d.ts +0 -2
- package/dist/common/environment/index.js +0 -2
- package/dist/common/error/domains.d.ts +0 -13
- package/dist/common/error/domains.js +0 -1
- package/dist/common/error/index.d.ts +0 -3
- package/dist/common/error/index.js +0 -3
- package/dist/common/error/utils/compose-error/index.d.ts +0 -2
- package/dist/common/error/utils/compose-error/index.js +0 -7
- package/dist/common/error/utils/compose-error/type.d.ts +0 -2
- package/dist/common/error/utils/compose-error/type.js +0 -1
- package/dist/common/error/utils/console-error/index.d.ts +0 -2
- package/dist/common/error/utils/console-error/index.js +0 -12
- package/dist/common/error/utils/console-error/type.d.ts +0 -2
- package/dist/common/error/utils/console-error/type.js +0 -1
- package/dist/common/error/utils/index.d.ts +0 -2
- package/dist/common/error/utils/index.js +0 -2
- package/dist/common/error/workers/index.d.ts +0 -2
- package/dist/common/error/workers/index.js +0 -32
- package/dist/common/error/workers/type.d.ts +0 -19
- package/dist/common/error/workers/type.js +0 -1
- package/dist/common/helpers/index.d.ts +0 -2
- package/dist/common/helpers/index.js +0 -2
- package/dist/common/helpers/reveal-all-object-props/index.d.ts +0 -2
- package/dist/common/helpers/reveal-all-object-props/index.js +0 -13
- package/dist/common/helpers/reveal-all-object-props/type.d.ts +0 -1
- package/dist/common/helpers/reveal-all-object-props/type.js +0 -1
- package/dist/common/helpers/stringify/index.d.ts +0 -2
- package/dist/common/helpers/stringify/index.js +0 -3
- package/dist/common/helpers/stringify/type.d.ts +0 -1
- package/dist/common/helpers/stringify/type.js +0 -1
- package/dist/common/index.d.ts +0 -5
- package/dist/common/index.js +0 -5
- package/dist/common/service/index.d.ts +0 -1
- package/dist/common/service/index.js +0 -1
- package/dist/common/service/singletons/index.d.ts +0 -5
- package/dist/common/service/singletons/index.js +0 -11
- package/dist/common/service/singletons/type.d.ts +0 -2
- package/dist/common/service/singletons/type.js +0 -1
- package/dist/common/type/array/index.d.ts +0 -1
- package/dist/common/type/array/index.js +0 -1
- package/dist/common/type/array/type-guards.d.ts +0 -1
- package/dist/common/type/array/type-guards.js +0 -9
- package/dist/common/type/index.d.ts +0 -3
- package/dist/common/type/index.js +0 -3
- package/dist/common/type/null/index.d.ts +0 -1
- package/dist/common/type/null/index.js +0 -1
- package/dist/common/type/null/type-guards.d.ts +0 -1
- package/dist/common/type/null/type-guards.js +0 -1
- package/dist/common/type/object/index.d.ts +0 -1
- package/dist/common/type/object/index.js +0 -1
- package/dist/common/type/object/type-guards.d.ts +0 -1
- package/dist/common/type/object/type-guards.js +0 -11
- package/dist/devops/eslint/configs.d.ts +0 -2
- package/dist/devops/eslint/configs.js +0 -8
- package/dist/devops/eslint/index.d.ts +0 -2
- package/dist/devops/eslint/index.js +0 -2
- package/dist/devops/eslint/utils/compose-eslint-config/index.d.ts +0 -2
- package/dist/devops/eslint/utils/compose-eslint-config/index.js +0 -20
- package/dist/devops/eslint/utils/compose-eslint-config/type.d.ts +0 -4
- package/dist/devops/eslint/utils/compose-eslint-config/type.js +0 -1
- package/dist/devops/eslint/utils/index.d.ts +0 -1
- package/dist/devops/eslint/utils/index.js +0 -1
- package/dist/devops/index.d.ts +0 -1
- package/dist/devops/index.js +0 -1
- package/src/backend/environment/env-file/index.ts +0 -1
- package/src/backend/environment/env-file/utils/index.ts +0 -1
- package/src/backend/environment/env-file/utils/load-env-file/index.ts +0 -53
- package/src/backend/environment/env-file/utils/load-env-file/type.ts +0 -5
- package/src/backend/environment/index.ts +0 -1
- package/src/common/environment/environment-mode/configs.ts +0 -1
- package/src/common/environment/environment-mode/domains.ts +0 -3
- package/src/common/environment/environment-mode/index.ts +0 -5
- package/src/common/environment/environment-mode/type-guards/index.ts +0 -5
- package/src/common/environment/environment-mode/type-guards/is-development.ts +0 -1
- package/src/common/environment/environment-mode/type-guards/is-environment-mode.ts +0 -4
- package/src/common/environment/environment-mode/type-guards/is-production.ts +0 -1
- package/src/common/environment/environment-variables/domains.ts +0 -19
- package/src/common/environment/environment-variables/index.ts +0 -3
- package/src/common/environment/environment-variables/singletons/index.ts +0 -29
- package/src/common/environment/environment-variables/singletons/type.ts +0 -11
- package/src/common/environment/index.ts +0 -3
- package/src/common/error/domains.ts +0 -8
- package/src/common/error/index.ts +0 -5
- package/src/common/error/utils/compose-error/index.ts +0 -9
- package/src/common/error/utils/compose-error/type.ts +0 -3
- package/src/common/error/utils/console-error/index.ts +0 -18
- package/src/common/error/utils/console-error/type.ts +0 -3
- package/src/common/error/utils/index.ts +0 -3
- package/src/common/error/workers/index.ts +0 -41
- package/src/common/error/workers/type.ts +0 -21
- package/src/common/helpers/index.ts +0 -3
- package/src/common/helpers/reveal-all-object-props/index.ts +0 -16
- package/src/common/helpers/reveal-all-object-props/type.ts +0 -1
- package/src/common/helpers/stringify/index.ts +0 -5
- package/src/common/helpers/stringify/type.ts +0 -1
- package/src/common/index.ts +0 -9
- package/src/common/service/index.ts +0 -1
- package/src/common/service/singletons/index.ts +0 -16
- package/src/common/service/singletons/type.ts +0 -3
- package/src/common/type/array/index.ts +0 -1
- package/src/common/type/array/type-guards.ts +0 -11
- package/src/common/type/index.ts +0 -5
- package/src/common/type/null/index.ts +0 -1
- package/src/common/type/null/type-guards.ts +0 -1
- package/src/common/type/object/index.ts +0 -1
- package/src/common/type/object/type-guards.ts +0 -12
- package/src/devops/eslint/configs.ts +0 -10
- package/src/devops/eslint/index.ts +0 -3
- package/src/devops/eslint/utils/compose-eslint-config/index.ts +0 -29
- package/src/devops/eslint/utils/compose-eslint-config/type.ts +0 -3
- package/src/devops/eslint/utils/index.ts +0 -1
- package/src/devops/index.ts +0 -1
- /package/{dist/common/environment/environment-mode → src/service/service-name}/domains.js +0 -0
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
#!/bin/bash
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
2
|
set -e
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
NAMES_ARRAY[0]="${ARRAY[@]:0:10}"
|
|
7
|
-
NAMES_ARRAY[1]="${ARRAY[@]:10:20}"
|
|
8
|
-
NAMES_ARRAY[2]="${ARRAY[@]:20:30}"
|
|
4
|
+
PARAM_NAMES=(${1//,/ })
|
|
9
5
|
|
|
10
6
|
ENVS=()
|
|
11
|
-
for
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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")
|
|
20
16
|
done
|
|
21
17
|
|
|
22
18
|
if [[ $2 ]]
|
|
@@ -0,0 +1,26 @@
|
|
|
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
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
2
|
-
set -e
|
|
3
|
-
|
|
4
|
-
npx eslint .
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
npx eslint .
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
#!/bin/bash
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
2
|
set -e
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
npm config set //registry.npmjs.org/:_authToken $NPM_ACCESS_TOKEN
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
cp -r devops dist
|
|
7
|
+
cp package.json dist
|
|
7
8
|
|
|
8
|
-
npm
|
|
9
|
-
|
|
10
|
-
npm publish . --access=public
|
|
9
|
+
npm publish ./dist --access=public
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
2
|
-
set -e
|
|
3
|
-
|
|
4
|
-
npx prettier . --write
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
npx prettier . --write
|
package/package.json
CHANGED
|
@@ -1,43 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@candlerip/shared",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": "=22.19.0"
|
|
7
7
|
},
|
|
8
|
-
"
|
|
9
|
-
"devops",
|
|
10
|
-
"dist",
|
|
11
|
-
"src",
|
|
12
|
-
"package-lock.json",
|
|
13
|
-
"package.json"
|
|
14
|
-
],
|
|
8
|
+
"main": "dist/src/index.js",
|
|
15
9
|
"bin": {
|
|
16
|
-
"crs-
|
|
17
|
-
"crs-
|
|
18
|
-
"crs-
|
|
19
|
-
"crs-tsc-
|
|
20
|
-
|
|
21
|
-
"exports": {
|
|
22
|
-
"./backend/environment": "./dist/backend/environment/index.js",
|
|
23
|
-
"./common": "./dist/common/index.js",
|
|
24
|
-
"./devops": "./dist/devops/index.js"
|
|
10
|
+
"crs-create-env-file": "./devops/environment/create-env-file.sh",
|
|
11
|
+
"crs-eslint": "./devops/eslint/eslint.sh",
|
|
12
|
+
"crs-prettier": "./devops/prettier/prettier.sh",
|
|
13
|
+
"crs-tsc-build": "./devops/typescript/tsc-build.sh",
|
|
14
|
+
"crs-tsc-watch": "./devops/typescript/tsc-watch.sh"
|
|
25
15
|
},
|
|
26
16
|
"scripts": {
|
|
27
|
-
"
|
|
28
|
-
"publish-package": "sh ./devops/publish-package.sh",
|
|
29
|
-
"start": "sh ./devops/typescript/tsc-watch.sh"
|
|
17
|
+
"dev": "sh ./devops/typescript/tsc-watch.sh"
|
|
30
18
|
},
|
|
31
19
|
"dependencies": {
|
|
32
|
-
"eslint": "^9.
|
|
33
|
-
"globals": "^16.
|
|
34
|
-
"
|
|
35
|
-
"prettier": "^3.6.2",
|
|
20
|
+
"eslint": "^9.28.0",
|
|
21
|
+
"globals": "^16.2.0",
|
|
22
|
+
"prettier": "^3.5.3",
|
|
36
23
|
"tsc-alias": "^1.8.16",
|
|
37
|
-
"typescript": "^5.
|
|
38
|
-
"typescript-eslint": "^8.
|
|
39
|
-
},
|
|
40
|
-
"devDependencies": {
|
|
41
|
-
"@types/node": "^24.3.1"
|
|
24
|
+
"typescript": "^5.8.3",
|
|
25
|
+
"typescript-eslint": "^8.33.1"
|
|
42
26
|
}
|
|
43
27
|
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './service/index.js';
|
package/src/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './service/index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './service-name/index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './service-name/index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SERVICE_NAMES: readonly ["cache-service", "environment-service"];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const SERVICE_NAMES = ['cache-service', 'environment-service'];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './utils/index.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './utils/index.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './load-env-file/index.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './load-env-file/index.js';
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import { ErrorWorker } from '../../../../../common/index.js';
|
|
3
|
-
export const loadEnvFile = (environmentMode) => {
|
|
4
|
-
const { composeError } = ErrorWorker({ info: { environmentMode } });
|
|
5
|
-
let fileName = '.env';
|
|
6
|
-
if (environmentMode) {
|
|
7
|
-
fileName += `.${environmentMode}`;
|
|
8
|
-
}
|
|
9
|
-
const parsed = {};
|
|
10
|
-
try {
|
|
11
|
-
const file = fs.readFileSync(fileName, 'utf-8');
|
|
12
|
-
file.split('\n').forEach((fileLine) => {
|
|
13
|
-
if (fileLine.length === 0) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
const envVar = fileLine.split('=');
|
|
17
|
-
parsed[`${envVar[0]}`] = envVar[1];
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
catch (err) {
|
|
21
|
-
return {
|
|
22
|
-
error: composeError(`Error loading ${fileName}`, {
|
|
23
|
-
info: {
|
|
24
|
-
err,
|
|
25
|
-
fileName,
|
|
26
|
-
},
|
|
27
|
-
}),
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
-
const data = {};
|
|
32
|
-
Object.keys(parsed).forEach((key) => {
|
|
33
|
-
const parsedItem = parsed[key];
|
|
34
|
-
if (['false', 'true'].includes(parsedItem)) {
|
|
35
|
-
data[key] = Boolean(parsedItem === 'true');
|
|
36
|
-
}
|
|
37
|
-
else if (!Number.isNaN(parseInt(parsedItem))) {
|
|
38
|
-
data[key] = parseInt(parsedItem);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
data[key] = parsedItem;
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
return {
|
|
45
|
-
data,
|
|
46
|
-
};
|
|
47
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { EnvironmentMode, EnvironmentVariables, TError } from '../../../../../common/index.js';
|
|
2
|
-
export type LoadEnvFile = <T extends Array<keyof EnvironmentVariables> = never>(environmentMode?: EnvironmentMode) => TError<{
|
|
3
|
-
[K in T[number]]: EnvironmentVariables[K];
|
|
4
|
-
}>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './env-file/index.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './env-file/index.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const ENVIRONMENT_MODES: readonly ["development", "production"];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const ENVIRONMENT_MODES = ['development', 'production'];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isDevelopment: (data?: unknown) => data is "development";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const isDevelopment = (data) => data === 'development';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isProduction: (data?: unknown) => data is "production";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const isProduction = (data) => data === 'production';
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { EnvironmentMode } from '../environment-mode/index.js';
|
|
2
|
-
export type EnvironmentVariables = {
|
|
3
|
-
APP_NAME: string;
|
|
4
|
-
AWS_REGION: string;
|
|
5
|
-
AWS_S3_IMAGES_BUCKET_NAME: string;
|
|
6
|
-
CACHE_SERVICE_PORT: string;
|
|
7
|
-
CACHE_ENABLED: boolean;
|
|
8
|
-
DATABASE_URL: string;
|
|
9
|
-
DOMAIN_NAME: string;
|
|
10
|
-
FRONTEND_URL: string;
|
|
11
|
-
LOGGER_SERVICE_PORT: string;
|
|
12
|
-
MOBILE_APP_URL: string;
|
|
13
|
-
NODE_ENV: EnvironmentMode;
|
|
14
|
-
RABBITMQ_URL: string;
|
|
15
|
-
REDIS_PWD: string;
|
|
16
|
-
REDIS_URL: string;
|
|
17
|
-
REDIS_URL_APP: string;
|
|
18
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { isDevelopment as isDev, isProduction as isProd } from '../../environment-mode/index.js';
|
|
2
|
-
export const EnvironmentVariablesSingleton = (() => {
|
|
3
|
-
let _envs;
|
|
4
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
|
-
const getEnv = (name) => _envs[name];
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
|
-
const getEnvs = (names) => names.reduce((acc, curr) => ({ ...acc, [`${curr}`]: _envs[curr] }), {});
|
|
8
|
-
const init = (envs) => {
|
|
9
|
-
_envs = envs;
|
|
10
|
-
};
|
|
11
|
-
const isDevelopment = () => isDev(_envs.NODE_ENV);
|
|
12
|
-
const isProduction = () => isProd(_envs.NODE_ENV);
|
|
13
|
-
return {
|
|
14
|
-
getEnv,
|
|
15
|
-
getEnvs,
|
|
16
|
-
init,
|
|
17
|
-
isDevelopment,
|
|
18
|
-
isProduction,
|
|
19
|
-
};
|
|
20
|
-
})();
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { EnvironmentVariables } from '../domains.js';
|
|
2
|
-
export type GetEnv = <T extends keyof EnvironmentVariables = never>(name: T) => EnvironmentVariables[T];
|
|
3
|
-
export type GetEnvs = <T extends keyof EnvironmentVariables = never>(names: T[]) => Pick<EnvironmentVariables, T>;
|
|
4
|
-
export type Init = (envs: Partial<EnvironmentVariables>) => void;
|
|
5
|
-
export type IsDevelopment = () => boolean;
|
|
6
|
-
export type IsProduction = () => boolean;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { stringify } from '../../../helpers/index.js';
|
|
2
|
-
export const consoleError = (error) => {
|
|
3
|
-
const { id, info, message, serviceName } = error;
|
|
4
|
-
let msg = `ERROR: ${message} (ID) ${id}`;
|
|
5
|
-
if (serviceName) {
|
|
6
|
-
msg += ` (SERVICE-NAME) ${serviceName}`;
|
|
7
|
-
}
|
|
8
|
-
if (info) {
|
|
9
|
-
msg += ` (INFO) ${stringify(info)}`;
|
|
10
|
-
}
|
|
11
|
-
console.error(msg);
|
|
12
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -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 } from '../domains.js';
|
|
2
|
-
export type ErrorWorkerType = (props?: {
|
|
3
|
-
message?: string;
|
|
4
|
-
info?: Record<string, unknown>;
|
|
5
|
-
}) => {
|
|
6
|
-
addErrorInfo: AddErrorInfo;
|
|
7
|
-
addErrorMessage: AddErrorMessage;
|
|
8
|
-
composeError: ComposeError;
|
|
9
|
-
getError: GetError;
|
|
10
|
-
resetError: ResetError;
|
|
11
|
-
};
|
|
12
|
-
export type _ComposeInfo = (info?: Record<string, unknown>) => void;
|
|
13
|
-
export type AddErrorInfo = (info: Record<string, unknown>) => void;
|
|
14
|
-
export type AddErrorMessage = (message: string) => void;
|
|
15
|
-
export type ComposeError = (message: string, info?: Record<string, unknown>) => Error;
|
|
16
|
-
export type GetError = () => {
|
|
17
|
-
error: Error;
|
|
18
|
-
} | undefined;
|
|
19
|
-
export type ResetError = () => void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { isObject } from '../../type/index.js';
|
|
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
|
-
};
|