@candlerip/shared3 0.0.25 → 0.0.26

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.25",
3
+ "version": "0.0.26",
4
4
  "type": "module",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -22,6 +22,7 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@types/node": "^22.5.5",
25
+ "dotenv": "^16.4.5",
25
26
  "eslint": "^8.57.0",
26
27
  "globals": "^15.9.0",
27
28
  "prettier": "^3.3.2",
@@ -0,0 +1 @@
1
+ export * from './utils/index.js';
@@ -0,0 +1 @@
1
+ export * from './utils/index.js';
@@ -0,0 +1 @@
1
+ export * from './load-env-file/index.js';
@@ -0,0 +1 @@
1
+ export * from './load-env-file/index.js';
@@ -0,0 +1,2 @@
1
+ import { LoadEnvFile } from './types.js';
2
+ export declare const loadEnvFile: LoadEnvFile;
@@ -0,0 +1,26 @@
1
+ import * as dotenv from 'dotenv';
2
+ export const loadEnvFile = (environmentMode, options) => {
3
+ const props = { environmentMode, options };
4
+ const integers = options?.integers;
5
+ const fileName = `.env.${environmentMode}`;
6
+ const envFile = dotenv.config({ path: `./${fileName}` });
7
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
+ const { error, parsed } = envFile;
9
+ if (error || !parsed) {
10
+ return {
11
+ customError: {
12
+ info: {
13
+ error,
14
+ },
15
+ message: `Error loading ${fileName}`,
16
+ props,
17
+ },
18
+ };
19
+ }
20
+ if (integers) {
21
+ integers.forEach((it) => (parsed[it] = parseInt(parsed[it])));
22
+ }
23
+ return {
24
+ data: parsed,
25
+ };
26
+ };
@@ -0,0 +1,9 @@
1
+ import { CustomError } from '../../../../error/index.js';
2
+ import { EnvironmentMode } from '../../../environment-mode/index.js';
3
+ export type LoadEnvFile = <T extends Record<string, unknown> = never>(environmentMode: EnvironmentMode, options?: {
4
+ integers?: string[];
5
+ }) => {
6
+ data: T;
7
+ } | {
8
+ customError: CustomError;
9
+ };
@@ -7,6 +7,7 @@ export interface EnvironmentVariables {
7
7
  DICTIONARY_SERVICE_PORT: number;
8
8
  DOMAIN_NAME: string;
9
9
  FRONTEND_URL: string;
10
+ LOGGER_SERVICE_PORT: string;
10
11
  REDIS_URL: string;
11
12
  S3_IMAGES_BUCKET_NAME: string;
12
13
  }
@@ -1,2 +1,3 @@
1
+ export * from './env-file/index.js';
1
2
  export * from './environment-mode/index.js';
2
3
  export * from './environment-variables/index.js';
@@ -1,2 +1,3 @@
1
+ export * from './env-file/index.js';
1
2
  export * from './environment-mode/index.js';
2
3
  export * from './environment-variables/index.js';
@@ -1,2 +1,2 @@
1
1
  import { EnvironmentVariables } from '../../../../environment/index.js';
2
- export type BackendProjectConfig = Pick<EnvironmentVariables, 'CACHE_SERVICE_PORT' | 'REDIS_PORT'>;
2
+ export type BackendProjectConfig = Pick<EnvironmentVariables, 'CACHE_SERVICE_PORT' | 'LOGGER_SERVICE_PORT' | 'REDIS_PORT'>;
@@ -1 +1 @@
1
- export declare const PROJECT_NAMES: readonly ["backend-init", "backend", "cache-service", "dictionary-service", "config", "images", "images-init", "logger", "redis", "shared", "shared-aws", "shared-backend"];
1
+ export declare const PROJECT_NAMES: readonly ["backend-init", "backend", "cache-service", "dictionary-service", "config", "images", "images-init", "logger-service", "redis", "shared", "shared-aws", "shared-backend"];
@@ -6,7 +6,7 @@ export const PROJECT_NAMES = [
6
6
  'config',
7
7
  'images',
8
8
  'images-init',
9
- 'logger',
9
+ 'logger-service',
10
10
  'redis',
11
11
  'shared',
12
12
  'shared-aws',