1.0.2 • Published 9 months ago

is-env-service v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
9 months ago

Node Environment Service Package

This package provides a structured and centralized way to store and manage environment constants (both names and paths) for different environments (e.g., Development, Testing, CI, Production). It also includes a utility function getEnvPath() that returns the correct path for the .env file based on the provided NODE_ENV value.

Features

  • Centralized Environment Constants: Defines environment names and paths for different environments such as:
  • Development: Default .env
    • Test: Custom .env.test
    • CI: Custom .env.ci
    • Production: Custom .env.production
    • Utility Function for Path Resolution: Provides a utility function getEnvPath() that dynamically returns the correct path for the environment configuration file based on the current NODE_ENV.

Installation

npm install is-env-service

Usage

1. init

import { getEnvPath } from 'is-env-service';
import dotenv from 'dotenv';

// default setup
dotenv.config();

const NODE_ENV = process.env.NODE_ENV;
if (!NODE_ENV) {
  throw new NotFoundError({
    resource: 'NODE_ENV',
  });
}
const path = getEnvPath(NODE_ENV);
dotenv.config({ path });

2. Get ENV constants values

import { ENV } from 'is-env-service';

ENV.TEST.NAME; // 'test'
ENV.DEV.PATH; // .env
1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago