dittoenv
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

DittoEnv

DittoEnv is a simple Node.js library for managing environment variables in your application. It reads variables from a .env file and provides easy-to-use methods for accessing them.

Features

  • Reads a .env file from the current working directory
  • Provides get and getOr methods for easy access to environment variables
  • Falls back to process.env if a key is not found in the .env file

Installation

npm install dittoenv

Usage

  1. Import the Library
import DittoEnv from 'dittoenv';
  1. Create an instance
const env = new DittoEnv();

Use the get method to retrieve the value of an environment variable:

const port = env.get('PORT');

The get method will throw an error if the requested key is not found in the .env file or process.env.

Use the getOr method to retrieve the value of an environment variable or return an alternate value if the key is not found:

const port = env.getOr('PORT', 3000);

License

This project is licensed under the MIT License.

Package Sidebar

Install

npm i dittoenv

Weekly Downloads

4

Version

0.0.1

License

MIT

Unpacked Size

4.83 kB

Total Files

7

Last publish

Collaborators

  • mofax