@candlerip/shared3 0.0.60 → 0.0.62

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@candlerip/shared3",
3
- "version": "0.0.60",
3
+ "version": "0.0.62",
4
4
  "type": "module",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -28,8 +28,5 @@
28
28
  "tsc-alias": "^1.8.10",
29
29
  "typescript": "^5.6.2",
30
30
  "typescript-eslint": "^8.8.0"
31
- },
32
- "dependencies": {
33
- "dotenv": "^16.4.5"
34
31
  }
35
32
  }
@@ -1,13 +1,13 @@
1
1
  export declare const ENVIRONMENT_VARIABLE: {
2
2
  readonly API_GATEWAY_PORT: "number";
3
3
  readonly APP_NAME: "string";
4
+ readonly APP_PORT: "number";
4
5
  readonly AUTHENTICATION_AUDIENCE: "string";
5
6
  readonly AUTHENTICATION_DOMAIN: "string";
6
7
  readonly CACHE_ENABLED: "boolean";
7
8
  readonly CACHE_SERVICE_PORT: "number";
8
9
  readonly DATABASE_URL: "string";
9
10
  readonly DOMAIN_NAME: "string";
10
- readonly FRONTEND_PORT: "number";
11
11
  readonly FRONTEND_URL: "string";
12
12
  readonly LOGGER_SERVICE_PORT: "number";
13
13
  readonly NODE_ENV: "EnvironmentMode";
@@ -1,13 +1,13 @@
1
1
  export const ENVIRONMENT_VARIABLE = {
2
2
  API_GATEWAY_PORT: 'number',
3
3
  APP_NAME: 'string',
4
+ APP_PORT: 'number',
4
5
  AUTHENTICATION_AUDIENCE: 'string',
5
6
  AUTHENTICATION_DOMAIN: 'string',
6
7
  CACHE_ENABLED: 'boolean',
7
8
  CACHE_SERVICE_PORT: 'number',
8
9
  DATABASE_URL: 'string',
9
10
  DOMAIN_NAME: 'string',
10
- FRONTEND_PORT: 'number',
11
11
  FRONTEND_URL: 'string',
12
12
  LOGGER_SERVICE_PORT: 'number',
13
13
  NODE_ENV: 'EnvironmentMode',
@@ -1,12 +1,12 @@
1
1
  export declare const ENVIRONMENT_VARIABLES: {
2
- readonly app: readonly ["DATABASE_URL", "FRONTEND_PORT", "NODE_ENV", "RABBITMQ_URL", "REDIS_PWD", "REDIS_URL", "S3_IMAGES_BUCKET_NAME"];
2
+ readonly app: readonly ["APP_PORT", "DATABASE_URL", "NODE_ENV", "RABBITMQ_URL", "REDIS_PWD", "REDIS_URL", "S3_IMAGES_BUCKET_NAME"];
3
3
  readonly 'cache-service': readonly ["CACHE_ENABLED", "CACHE_SERVICE_PORT", "DATABASE_URL", "NODE_ENV", "RABBITMQ_URL", "REDIS_PWD", "REDIS_URL"];
4
4
  readonly images: readonly ["NODE_ENV", "S3_IMAGES_BUCKET_NAME"];
5
5
  readonly 'images-init': readonly ["FRONTEND_URL", "NODE_ENV", "S3_IMAGES_BUCKET_NAME"];
6
6
  readonly 'logger-service': readonly ["DATABASE_URL", "LOGGER_SERVICE_PORT", "NODE_ENV", "RABBITMQ_URL"];
7
- readonly nginx: readonly ["FRONTEND_PORT", "NODE_ENV"];
7
+ readonly nginx: readonly ["APP_PORT", "NODE_ENV"];
8
8
  readonly rabbitmq: readonly ["RABBITMQ_PORT", "RABBITMQ_MANAGEMENT_PORT", "NODE_ENV", "RABBITMQ_PWD", "RABBITMQ_USER"];
9
9
  readonly redis: readonly ["NODE_ENV", "REDIS_PORT", "REDIS_PWD"];
10
- readonly server: readonly ["API_GATEWAY_PORT", "CACHE_SERVICE_PORT", "FRONTEND_PORT", "LOGGER_SERVICE_PORT", "NODE_ENV", "RABBITMQ_PORT", "RABBITMQ_MANAGEMENT_PORT", "REDIS_PORT"];
10
+ readonly server: readonly ["APP_PORT", "API_GATEWAY_PORT", "CACHE_SERVICE_PORT", "LOGGER_SERVICE_PORT", "NODE_ENV", "RABBITMQ_PORT", "RABBITMQ_MANAGEMENT_PORT", "REDIS_PORT"];
11
11
  readonly 'server-init': readonly ["APP_NAME", "DOMAIN_NAME", "NODE_ENV", "S3_IMAGES_BUCKET_NAME"];
12
12
  };
@@ -1,16 +1,16 @@
1
1
  export const ENVIRONMENT_VARIABLES = {
2
- app: ['DATABASE_URL', 'FRONTEND_PORT', 'NODE_ENV', 'RABBITMQ_URL', 'REDIS_PWD', 'REDIS_URL', 'S3_IMAGES_BUCKET_NAME'],
2
+ app: ['APP_PORT', 'DATABASE_URL', 'NODE_ENV', 'RABBITMQ_URL', 'REDIS_PWD', 'REDIS_URL', 'S3_IMAGES_BUCKET_NAME'],
3
3
  'cache-service': ['CACHE_ENABLED', 'CACHE_SERVICE_PORT', 'DATABASE_URL', 'NODE_ENV', 'RABBITMQ_URL', 'REDIS_PWD', 'REDIS_URL'],
4
4
  images: ['NODE_ENV', 'S3_IMAGES_BUCKET_NAME'],
5
5
  'images-init': ['FRONTEND_URL', 'NODE_ENV', 'S3_IMAGES_BUCKET_NAME'],
6
6
  'logger-service': ['DATABASE_URL', 'LOGGER_SERVICE_PORT', 'NODE_ENV', 'RABBITMQ_URL'],
7
- nginx: ['FRONTEND_PORT', 'NODE_ENV'],
7
+ nginx: ['APP_PORT', 'NODE_ENV'],
8
8
  rabbitmq: ['RABBITMQ_PORT', 'RABBITMQ_MANAGEMENT_PORT', 'NODE_ENV', 'RABBITMQ_PWD', 'RABBITMQ_USER'],
9
9
  redis: ['NODE_ENV', 'REDIS_PORT', 'REDIS_PWD'],
10
10
  server: [
11
+ 'APP_PORT',
11
12
  'API_GATEWAY_PORT',
12
13
  'CACHE_SERVICE_PORT',
13
- 'FRONTEND_PORT',
14
14
  'LOGGER_SERVICE_PORT',
15
15
  'NODE_ENV',
16
16
  'RABBITMQ_PORT',
@@ -1,16 +1,10 @@
1
1
  import { isDevelopment as isDev, isProduction as isProd } from '../../../environment-mode/index.js';
2
- import { loadEnvFile } from '../../../env-file/index.js';
3
2
  export const EnvironmentVariablesSingleton = (() => {
4
3
  const NODE_ENV = process.env.NODE_ENV;
5
- let envs;
6
- const get = () => envs;
7
- const init = (projectName) => {
8
- const resp = loadEnvFile(NODE_ENV, projectName);
9
- if ('customError' in resp) {
10
- return resp;
11
- }
12
- envs = resp.data;
13
- return resp;
4
+ let _envs;
5
+ const get = () => _envs;
6
+ const init = (envs) => {
7
+ _envs = envs;
14
8
  };
15
9
  const isDevelopment = () => isDev(NODE_ENV);
16
10
  const isProduction = () => isProd(NODE_ENV);
@@ -1,4 +1,3 @@
1
- import { CustomError } from '../../../../error/index.js';
2
1
  import { EnvironmentVariables } from '../../domains/index.js';
3
2
  export type IEnvironmentVariablesSingleton = {
4
3
  get: Get;
@@ -7,10 +6,6 @@ export type IEnvironmentVariablesSingleton = {
7
6
  isProduction: IsProduction;
8
7
  };
9
8
  export type Get = <T extends keyof EnvironmentVariables = never>() => EnvironmentVariables[T];
10
- export type Init = <T extends keyof EnvironmentVariables>(projectName: T) => {
11
- data: EnvironmentVariables[T];
12
- } | {
13
- customError: CustomError;
14
- };
9
+ export type Init = <T extends keyof EnvironmentVariables>(envs: EnvironmentVariables[T]) => void;
15
10
  export type IsDevelopment = () => boolean;
16
11
  export type IsProduction = () => boolean;
@@ -1,4 +1,3 @@
1
- export * from './env-file/index.js';
2
1
  export * from './environment-mode/index.js';
3
2
  export * from './environment-variable-name/index.js';
4
3
  export * from './environment-variables/index.js';
@@ -1,4 +1,3 @@
1
- export * from './env-file/index.js';
2
1
  export * from './environment-mode/index.js';
3
2
  export * from './environment-variable-name/index.js';
4
3
  export * from './environment-variables/index.js';
@@ -1 +1 @@
1
- export declare const PROJECT_NAMES: readonly ["app", "cache-service", "config", "images", "images-init", "logger-service", "nginx", "rabbitmq", "redis", "server", "server-init", "shared", "shared-aws", "shared-backend"];
1
+ export declare const PROJECT_NAMES: readonly ["app", "backend", "cache-service", "config", "frontend", "images", "images-init", "logger-service", "nginx", "rabbitmq", "redis", "server", "server-init", "shared", "shared-aws", "shared-backend"];
@@ -1,7 +1,9 @@
1
1
  export const PROJECT_NAMES = [
2
2
  'app',
3
+ 'backend',
3
4
  'cache-service',
4
5
  'config',
6
+ 'frontend',
5
7
  'images',
6
8
  'images-init',
7
9
  'logger-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,8 +0,0 @@
1
- import { CustomError } from '../../../../error/index.js';
2
- import { EnvironmentMode } from '../../../environment-mode/index.js';
3
- import { EnvironmentVariables } from '../../../environment-variables/index.js';
4
- export declare const loadEnvFile: <P extends keyof EnvironmentVariables, D = EnvironmentVariables[P]>(environmentMode: EnvironmentMode, projectName: P) => {
5
- data: D;
6
- } | {
7
- customError: CustomError;
8
- };
@@ -1,29 +0,0 @@
1
- import * as dotenv from 'dotenv';
2
- import { customErrorWorker } from '../../../../error/index.js';
3
- import { ENVIRONMENT_VARIABLES } from '../../../environment-variables/index.js';
4
- import { ENVIRONMENT_VARIABLE } from '../../../environment-variable/index.js';
5
- export const loadEnvFile = (environmentMode, projectName) => {
6
- const { composeCustomError } = customErrorWorker({ environmentMode });
7
- const fileName = `.env.${environmentMode}`;
8
- const envFile = dotenv.config({ path: `./${fileName}` });
9
- const { error: err, parsed } = envFile;
10
- if (err || !parsed) {
11
- return composeCustomError(`Error loading ${fileName}`, { err });
12
- }
13
- const environmentVariables = ENVIRONMENT_VARIABLES[projectName];
14
- return {
15
- data: environmentVariables.reduce((acc, key) => {
16
- const data = {};
17
- if (ENVIRONMENT_VARIABLE[key] === 'boolean') {
18
- data[key] = Boolean(parsed[key] === 'true');
19
- }
20
- else if (ENVIRONMENT_VARIABLE[key] === 'number') {
21
- data[key] = parseInt(parsed[key]);
22
- }
23
- else {
24
- data[key] = parsed[key];
25
- }
26
- return { ...acc, ...data };
27
- }, {}),
28
- };
29
- };