0.0.1 • Published 3 years ago
dittoenv v0.0.1
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
.envfile from the current working directory - Provides
getandgetOrmethods for easy access to environment variables - Falls back to
process.envif a key is not found in the .env file
Installation
npm install dittoenvUsage
- Import the Library
import DittoEnv from 'dittoenv';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.