@candlerip/shared3 0.0.30 → 0.0.32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. package/package.json +1 -1
  2. package/src/environment/env-file/utils/load-env-file/index.js +8 -6
  3. package/src/environment/env-file/utils/load-env-file/types.d.ts +1 -3
  4. package/src/environment/environment-variable-name/domains/index.d.ts +2 -0
  5. package/src/environment/environment-variable-name/domains/index.js +1 -0
  6. package/src/environment/environment-variable-name/index.d.ts +1 -0
  7. package/src/environment/environment-variable-name/index.js +1 -0
  8. package/src/environment/environment-variables/configs/environment-variables/index.d.ts +15 -0
  9. package/src/environment/environment-variables/configs/environment-variables/index.js +15 -0
  10. package/src/environment/environment-variables/configs/index.d.ts +2 -0
  11. package/src/environment/environment-variables/configs/index.js +2 -0
  12. package/src/environment/environment-variables/configs/number-environment-variables/index.d.ts +1 -0
  13. package/src/environment/environment-variables/configs/number-environment-variables/index.js +2 -0
  14. package/src/environment/environment-variables/domains/index.d.ts +6 -15
  15. package/src/environment/environment-variables/workers/environment-variables-worker/index.js +2 -2
  16. package/src/environment/environment-variables/workers/environment-variables-worker/types.d.ts +1 -1
  17. package/src/environment/index.d.ts +1 -0
  18. package/src/environment/index.js +1 -0
  19. package/src/project/project-config/configs/backend-init-project-config-names/index.d.ts +1 -0
  20. package/src/project/project-config/configs/backend-init-project-config-names/index.js +1 -0
  21. package/src/project/project-config/configs/backend-project-config-names/index.d.ts +1 -0
  22. package/src/project/project-config/configs/backend-project-config-names/index.js +7 -0
  23. package/src/project/project-config/configs/cache-service-project-config-names/index.d.ts +1 -0
  24. package/src/project/project-config/configs/cache-service-project-config-names/index.js +1 -0
  25. package/src/project/project-config/configs/dictionary-service-project-config-names/index.d.ts +1 -0
  26. package/src/project/project-config/configs/dictionary-service-project-config-names/index.js +1 -0
  27. package/src/project/project-config/configs/images-init-project-config-names/index.d.ts +1 -0
  28. package/src/project/project-config/configs/images-init-project-config-names/index.js +1 -0
  29. package/src/project/project-config/configs/images-project-config-names/index.d.ts +1 -0
  30. package/src/project/project-config/configs/images-project-config-names/index.js +1 -0
  31. package/src/project/project-config/configs/index.d.ts +9 -0
  32. package/src/project/project-config/configs/index.js +9 -0
  33. package/src/project/project-config/configs/logger-service-project-config-names/index.d.ts +1 -0
  34. package/src/project/project-config/configs/logger-service-project-config-names/index.js +1 -0
  35. package/src/project/project-config/configs/rabbitmq-project-config-names/index.d.ts +1 -0
  36. package/src/project/project-config/configs/rabbitmq-project-config-names/index.js +1 -0
  37. package/src/project/project-config/configs/redis-project-config-names/index.d.ts +1 -0
  38. package/src/project/project-config/configs/redis-project-config-names/index.js +1 -0
  39. package/src/project/project-config/domains/backend-init-project-config/index.d.ts +2 -1
  40. package/src/project/project-config/domains/backend-project-config/index.d.ts +2 -1
  41. package/src/project/project-config/domains/cache-service-project-config/index.d.ts +2 -1
  42. package/src/project/project-config/domains/dictionary-service-poject-config/index.d.ts +2 -1
  43. package/src/project/project-config/domains/images-init-project-config/index.d.ts +2 -1
  44. package/src/project/project-config/domains/images-project-config/index.d.ts +2 -1
  45. package/src/project/project-config/domains/index.d.ts +2 -0
  46. package/src/project/project-config/domains/index.js +2 -0
  47. package/src/project/project-config/domains/logger-service-project-config/index.d.ts +2 -1
  48. package/src/project/project-config/domains/rabbitmq-project-config/index.d.ts +2 -1
  49. package/src/project/project-config/domains/redis-project-config/index.d.ts +2 -1
  50. package/src/project/project-config/index.d.ts +1 -0
  51. package/src/project/project-config/index.js +1 -0
  52. package/src/type/domains/index.d.ts +5 -0
  53. package/src/type/domains/index.js +1 -0
  54. package/src/type/index.d.ts +1 -0
  55. package/src/type/index.js +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@candlerip/shared3",
3
- "version": "0.0.30",
3
+ "version": "0.0.32",
4
4
  "type": "module",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -1,7 +1,7 @@
1
1
  import * as dotenv from 'dotenv';
2
- export const loadEnvFile = (environmentMode, options) => {
3
- const props = { environmentMode, options };
4
- const integers = options?.integers;
2
+ import { NUMBER_ENVIRONMENT_VARIABLES } from '../../../environment-variables/configs/number-environment-variables/index.js';
3
+ export const loadEnvFile = (environmentMode) => {
4
+ const props = { environmentMode };
5
5
  const fileName = `.env.${environmentMode}`;
6
6
  const envFile = dotenv.config({ path: `./${fileName}` });
7
7
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -17,9 +17,11 @@ export const loadEnvFile = (environmentMode, options) => {
17
17
  },
18
18
  };
19
19
  }
20
- if (integers) {
21
- integers.forEach((it) => (parsed[it] = parseInt(parsed[it])));
22
- }
20
+ NUMBER_ENVIRONMENT_VARIABLES.forEach((it) => {
21
+ if (parsed[it]) {
22
+ parsed[it] = parseInt(parsed[it]);
23
+ }
24
+ });
23
25
  return {
24
26
  data: parsed,
25
27
  };
@@ -1,8 +1,6 @@
1
1
  import { CustomError } from '../../../../error/index.js';
2
2
  import { EnvironmentMode } from '../../../environment-mode/index.js';
3
- export type LoadEnvFile = <T extends Record<string, unknown>>(environmentMode: EnvironmentMode, options?: {
4
- integers?: string[];
5
- }) => {
3
+ export type LoadEnvFile = <T extends Record<string, unknown>>(environmentMode: EnvironmentMode) => {
6
4
  data: T;
7
5
  } | {
8
6
  customError: CustomError;
@@ -0,0 +1,2 @@
1
+ import { ENVIRONMENT_VARIABLES } from '../../environment-variables/configs/index.js';
2
+ export type EnvironmentVariableName = keyof typeof ENVIRONMENT_VARIABLES;
@@ -0,0 +1 @@
1
+ export * from './domains/index.js';
@@ -0,0 +1 @@
1
+ export * from './domains/index.js';
@@ -0,0 +1,15 @@
1
+ export declare const ENVIRONMENT_VARIABLES: {
2
+ readonly APP_NAME: "string";
3
+ readonly CACHE_SERVICE_PORT: "number";
4
+ readonly DATABASE_URL: "string";
5
+ readonly DICTIONARY_SERVICE_PORT: "number";
6
+ readonly DOMAIN_NAME: "string";
7
+ readonly FRONTEND_URL: "string";
8
+ readonly LOGGER_SERVICE_PORT: "number";
9
+ readonly RABBITMQ_PORT: "number";
10
+ readonly RABBITMQ_MANAGEMENT_PORT: "number";
11
+ readonly REDIS_PORT: "number";
12
+ readonly REDIS_PWD: "string";
13
+ readonly REDIS_URL: "string";
14
+ readonly S3_IMAGES_BUCKET_NAME: "string";
15
+ };
@@ -0,0 +1,15 @@
1
+ export const ENVIRONMENT_VARIABLES = {
2
+ APP_NAME: 'string',
3
+ CACHE_SERVICE_PORT: 'number',
4
+ DATABASE_URL: 'string',
5
+ DICTIONARY_SERVICE_PORT: 'number',
6
+ DOMAIN_NAME: 'string',
7
+ FRONTEND_URL: 'string',
8
+ LOGGER_SERVICE_PORT: 'number',
9
+ RABBITMQ_PORT: 'number',
10
+ RABBITMQ_MANAGEMENT_PORT: 'number',
11
+ REDIS_PORT: 'number',
12
+ REDIS_PWD: 'string',
13
+ REDIS_URL: 'string',
14
+ S3_IMAGES_BUCKET_NAME: 'string',
15
+ };
@@ -0,0 +1,2 @@
1
+ export * from './environment-variables/index.js';
2
+ export * from './number-environment-variables/index.js';
@@ -0,0 +1,2 @@
1
+ export * from './environment-variables/index.js';
2
+ export * from './number-environment-variables/index.js';
@@ -0,0 +1 @@
1
+ export declare const NUMBER_ENVIRONMENT_VARIABLES: ("APP_NAME" | "CACHE_SERVICE_PORT" | "DATABASE_URL" | "DICTIONARY_SERVICE_PORT" | "DOMAIN_NAME" | "FRONTEND_URL" | "LOGGER_SERVICE_PORT" | "RABBITMQ_PORT" | "RABBITMQ_MANAGEMENT_PORT" | "REDIS_PORT" | "REDIS_PWD" | "REDIS_URL" | "S3_IMAGES_BUCKET_NAME")[];
@@ -0,0 +1,2 @@
1
+ import { ENVIRONMENT_VARIABLES } from '../environment-variables/index.js';
2
+ export const NUMBER_ENVIRONMENT_VARIABLES = Object.keys(ENVIRONMENT_VARIABLES).filter((it) => ENVIRONMENT_VARIABLES[it] === 'number');
@@ -1,15 +1,6 @@
1
- export interface EnvironmentVariables {
2
- APP_NAME: string;
3
- CACHE_SERVICE_PORT: number;
4
- DATABASE_URL: string;
5
- DICTIONARY_SERVICE_PORT: number;
6
- DOMAIN_NAME: string;
7
- FRONTEND_URL: string;
8
- LOGGER_SERVICE_PORT: number;
9
- RABBITMQ_PORT: number;
10
- RABBITMQ_MANAGEMENT_PORT: number;
11
- REDIS_PORT: number;
12
- REDIS_PWD: string;
13
- REDIS_URL: string;
14
- S3_IMAGES_BUCKET_NAME: string;
15
- }
1
+ import { TypeMap } from '../../../type/index.js';
2
+ import { EnvironmentVariableName } from '../../environment-variable-name/domains/index.js';
3
+ import { ENVIRONMENT_VARIABLES } from '../configs/index.js';
4
+ export type EnvironmentVariables = {
5
+ [key in EnvironmentVariableName]: TypeMap[(typeof ENVIRONMENT_VARIABLES)[key]];
6
+ };
@@ -2,9 +2,9 @@ import { loadEnvFile } from '../../../env-file/index.js';
2
2
  export const EnvironmentVariablesWorker = (() => {
3
3
  let envs;
4
4
  const get = () => envs;
5
- const init = (integers) => {
5
+ const init = () => {
6
6
  const ENVIRONMENT_MODE = process.env.ENVIRONMENT_MODE;
7
- const resp = loadEnvFile(ENVIRONMENT_MODE, { integers });
7
+ const resp = loadEnvFile(ENVIRONMENT_MODE);
8
8
  if ('customError' in resp) {
9
9
  return resp;
10
10
  }
@@ -4,6 +4,6 @@ export type IEnvironmentVariablesWorker = {
4
4
  init: Init;
5
5
  };
6
6
  export type Get = <T = never>() => T;
7
- export type Init = (integers?: string[]) => undefined | {
7
+ export type Init = () => undefined | {
8
8
  customError: CustomError;
9
9
  };
@@ -1,3 +1,4 @@
1
1
  export * from './env-file/index.js';
2
2
  export * from './environment-mode/index.js';
3
+ export * from './environment-variable-name/index.js';
3
4
  export * from './environment-variables/index.js';
@@ -1,3 +1,4 @@
1
1
  export * from './env-file/index.js';
2
2
  export * from './environment-mode/index.js';
3
+ export * from './environment-variable-name/index.js';
3
4
  export * from './environment-variables/index.js';
@@ -0,0 +1 @@
1
+ export declare const BACKEND_INIT_PROJECT_CONFIG_NAMES: readonly ["APP_NAME", "DOMAIN_NAME", "S3_IMAGES_BUCKET_NAME"];
@@ -0,0 +1 @@
1
+ export const BACKEND_INIT_PROJECT_CONFIG_NAMES = ['APP_NAME', 'DOMAIN_NAME', 'S3_IMAGES_BUCKET_NAME'];
@@ -0,0 +1 @@
1
+ export declare const BACKEND_PROJECT_CONFIG_NAMES: readonly ["CACHE_SERVICE_PORT", "LOGGER_SERVICE_PORT", "RABBITMQ_PORT", "RABBITMQ_MANAGEMENT_PORT", "REDIS_PORT"];
@@ -0,0 +1,7 @@
1
+ export const BACKEND_PROJECT_CONFIG_NAMES = [
2
+ 'CACHE_SERVICE_PORT',
3
+ 'LOGGER_SERVICE_PORT',
4
+ 'RABBITMQ_PORT',
5
+ 'RABBITMQ_MANAGEMENT_PORT',
6
+ 'REDIS_PORT',
7
+ ];
@@ -0,0 +1 @@
1
+ export declare const CACHE_SERVICE_PROJECT_CONFIG_NAMES: readonly ["CACHE_SERVICE_PORT", "DATABASE_URL", "REDIS_PWD", "REDIS_URL"];
@@ -0,0 +1 @@
1
+ export const CACHE_SERVICE_PROJECT_CONFIG_NAMES = ['CACHE_SERVICE_PORT', 'DATABASE_URL', 'REDIS_PWD', 'REDIS_URL'];
@@ -0,0 +1 @@
1
+ export declare const DICTIONARY_SERVICE_PROJECT_CONFIG_NAMES: readonly ["DICTIONARY_SERVICE_PORT"];
@@ -0,0 +1 @@
1
+ export const DICTIONARY_SERVICE_PROJECT_CONFIG_NAMES = ['DICTIONARY_SERVICE_PORT'];
@@ -0,0 +1 @@
1
+ export declare const IMAGES_INIT_PROJECT_CONFIG_NAMES: readonly ["FRONTEND_URL", "S3_IMAGES_BUCKET_NAME"];
@@ -0,0 +1 @@
1
+ export const IMAGES_INIT_PROJECT_CONFIG_NAMES = ['FRONTEND_URL', 'S3_IMAGES_BUCKET_NAME'];
@@ -0,0 +1 @@
1
+ export declare const IMAGES_PROJECT_CONFIG_NAMES: readonly ["S3_IMAGES_BUCKET_NAME"];
@@ -0,0 +1 @@
1
+ export const IMAGES_PROJECT_CONFIG_NAMES = ['S3_IMAGES_BUCKET_NAME'];
@@ -0,0 +1,9 @@
1
+ export * from './backend-init-project-config-names/index.js';
2
+ export * from './backend-project-config-names/index.js';
3
+ export * from './cache-service-project-config-names/index.js';
4
+ export * from './dictionary-service-project-config-names/index.js';
5
+ export * from './images-init-project-config-names/index.js';
6
+ export * from './images-project-config-names/index.js';
7
+ export * from './logger-service-project-config-names/index.js';
8
+ export * from './rabbitmq-project-config-names/index.js';
9
+ export * from './redis-project-config-names/index.js';
@@ -0,0 +1,9 @@
1
+ export * from './backend-init-project-config-names/index.js';
2
+ export * from './backend-project-config-names/index.js';
3
+ export * from './cache-service-project-config-names/index.js';
4
+ export * from './dictionary-service-project-config-names/index.js';
5
+ export * from './images-init-project-config-names/index.js';
6
+ export * from './images-project-config-names/index.js';
7
+ export * from './logger-service-project-config-names/index.js';
8
+ export * from './rabbitmq-project-config-names/index.js';
9
+ export * from './redis-project-config-names/index.js';
@@ -0,0 +1 @@
1
+ export declare const LOGGER_SERVICE_PROJECT_CONFIG_NAMES: readonly ["DATABASE_URL", "LOGGER_SERVICE_PORT"];
@@ -0,0 +1 @@
1
+ export const LOGGER_SERVICE_PROJECT_CONFIG_NAMES = ['DATABASE_URL', 'LOGGER_SERVICE_PORT'];
@@ -0,0 +1 @@
1
+ export declare const RABBITMQ_PROJECT_CONFIG_NAMES: readonly ["RABBITMQ_PORT", "RABBITMQ_MANAGEMENT_PORT"];
@@ -0,0 +1 @@
1
+ export const RABBITMQ_PROJECT_CONFIG_NAMES = ['RABBITMQ_PORT', 'RABBITMQ_MANAGEMENT_PORT'];
@@ -0,0 +1 @@
1
+ export declare const REDIS_PROJECT_CONFIG_NAMES: readonly ["REDIS_PORT", "REDIS_PWD"];
@@ -0,0 +1 @@
1
+ export const REDIS_PROJECT_CONFIG_NAMES = ['REDIS_PORT', 'REDIS_PWD'];
@@ -1,2 +1,3 @@
1
1
  import { EnvironmentVariables } from '../../../../environment/index.js';
2
- export type BackendInitProjectConfig = Pick<EnvironmentVariables, 'APP_NAME' | 'DOMAIN_NAME' | 'S3_IMAGES_BUCKET_NAME'>;
2
+ import { BACKEND_INIT_PROJECT_CONFIG_NAMES } from '../../configs/index.js';
3
+ export type BackendInitProjectConfig = Pick<EnvironmentVariables, (typeof BACKEND_INIT_PROJECT_CONFIG_NAMES)[number]>;
@@ -1,2 +1,3 @@
1
1
  import { EnvironmentVariables } from '../../../../environment/index.js';
2
- export type BackendProjectConfig = Pick<EnvironmentVariables, 'CACHE_SERVICE_PORT' | 'LOGGER_SERVICE_PORT' | 'RABBITMQ_PORT' | 'RABBITMQ_MANAGEMENT_PORT' | 'REDIS_PORT'>;
2
+ import { BACKEND_PROJECT_CONFIG_NAMES } from '../../configs/index.js';
3
+ export type BackendProjectConfig = Pick<EnvironmentVariables, (typeof BACKEND_PROJECT_CONFIG_NAMES)[number]>;
@@ -1,2 +1,3 @@
1
1
  import { EnvironmentVariables } from '../../../../environment/index.js';
2
- export type CacheServiceProjectConfig = Pick<EnvironmentVariables, 'CACHE_SERVICE_PORT' | 'DATABASE_URL' | 'REDIS_PWD' | 'REDIS_URL'>;
2
+ import { CACHE_SERVICE_PROJECT_CONFIG_NAMES } from '../../configs/index.js';
3
+ export type CacheServiceProjectConfig = Pick<EnvironmentVariables, (typeof CACHE_SERVICE_PROJECT_CONFIG_NAMES)[number]>;
@@ -1,2 +1,3 @@
1
1
  import { EnvironmentVariables } from '../../../../environment/index.js';
2
- export type DictionaryServiceProjectConfig = Pick<EnvironmentVariables, 'DICTIONARY_SERVICE_PORT'>;
2
+ import { DICTIONARY_SERVICE_PROJECT_CONFIG_NAMES } from '../../configs/index.js';
3
+ export type DictionaryServiceProjectConfig = Pick<EnvironmentVariables, (typeof DICTIONARY_SERVICE_PROJECT_CONFIG_NAMES)[number]>;
@@ -1,2 +1,3 @@
1
1
  import { EnvironmentVariables } from '../../../../environment/index.js';
2
- export type ImagesInitProjectConfig = Pick<EnvironmentVariables, 'FRONTEND_URL' | 'S3_IMAGES_BUCKET_NAME'>;
2
+ import { IMAGES_INIT_PROJECT_CONFIG_NAMES } from '../../configs/index.js';
3
+ export type ImagesInitProjectConfig = Pick<EnvironmentVariables, (typeof IMAGES_INIT_PROJECT_CONFIG_NAMES)[number]>;
@@ -1,2 +1,3 @@
1
1
  import { EnvironmentVariables } from '../../../../environment/index.js';
2
- export type ImagesProjectConfig = Pick<EnvironmentVariables, 'S3_IMAGES_BUCKET_NAME'>;
2
+ import { IMAGES_PROJECT_CONFIG_NAMES } from '../../configs/index.js';
3
+ export type ImagesProjectConfig = Pick<EnvironmentVariables, (typeof IMAGES_PROJECT_CONFIG_NAMES)[number]>;
@@ -2,6 +2,8 @@ export * from './backend-project-config/index.js';
2
2
  export * from './backend-init-project-config/index.js';
3
3
  export * from './cache-service-project-config/index.js';
4
4
  export * from './dictionary-service-poject-config/index.js';
5
+ export * from './images-project-config/index.js';
6
+ export * from './images-init-project-config/index.js';
5
7
  export * from './logger-service-project-config/index.js';
6
8
  export * from './project-config-map/index.js';
7
9
  export * from './rabbitmq-project-config/index.js';
@@ -2,6 +2,8 @@ export * from './backend-project-config/index.js';
2
2
  export * from './backend-init-project-config/index.js';
3
3
  export * from './cache-service-project-config/index.js';
4
4
  export * from './dictionary-service-poject-config/index.js';
5
+ export * from './images-project-config/index.js';
6
+ export * from './images-init-project-config/index.js';
5
7
  export * from './logger-service-project-config/index.js';
6
8
  export * from './project-config-map/index.js';
7
9
  export * from './rabbitmq-project-config/index.js';
@@ -1,2 +1,3 @@
1
1
  import { EnvironmentVariables } from '../../../../environment/index.js';
2
- export type LoggerServiceProjectConfig = Pick<EnvironmentVariables, 'DATABASE_URL' | 'LOGGER_SERVICE_PORT'>;
2
+ import { LOGGER_SERVICE_PROJECT_CONFIG_NAMES } from '../../configs/index.js';
3
+ export type LoggerServiceProjectConfig = Pick<EnvironmentVariables, (typeof LOGGER_SERVICE_PROJECT_CONFIG_NAMES)[number]>;
@@ -1,2 +1,3 @@
1
1
  import { EnvironmentVariables } from '../../../../environment/index.js';
2
- export type RabbitmqProjectConfig = Pick<EnvironmentVariables, 'RABBITMQ_PORT' | 'RABBITMQ_MANAGEMENT_PORT'>;
2
+ import { RABBITMQ_PROJECT_CONFIG_NAMES } from '../../configs/index.js';
3
+ export type RabbitmqProjectConfig = Pick<EnvironmentVariables, (typeof RABBITMQ_PROJECT_CONFIG_NAMES)[number]>;
@@ -1,2 +1,3 @@
1
1
  import { EnvironmentVariables } from '../../../../environment/index.js';
2
- export type RedisProjectConfig = Pick<EnvironmentVariables, 'REDIS_PORT' | 'REDIS_PWD'>;
2
+ import { REDIS_PROJECT_CONFIG_NAMES } from '../../configs/index.js';
3
+ export type RedisProjectConfig = Pick<EnvironmentVariables, (typeof REDIS_PROJECT_CONFIG_NAMES)[number]>;
@@ -1 +1,2 @@
1
+ export * from './configs/index.js';
1
2
  export * from './domains/index.js';
@@ -1 +1,2 @@
1
+ export * from './configs/index.js';
1
2
  export * from './domains/index.js';
@@ -0,0 +1,5 @@
1
+ export interface TypeMap {
2
+ boolean: boolean;
3
+ number: number;
4
+ string: string;
5
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1,2 @@
1
+ export * from './domains/index.js';
1
2
  export * from './type-guards/index.js';
package/src/type/index.js CHANGED
@@ -1 +1,2 @@
1
+ export * from './domains/index.js';
1
2
  export * from './type-guards/index.js';