dotenv-getter
v1.1.1
Published
Provide a global env() function to get environment variables
Downloads
1
Readme
dotenv-getter
Simply provides a global env() function to get environment variables, instead of process.env.CONSTANT
Installation
Use the node package manager to install dotenv-getter.
npm install dotenv-getter
Usage
// configures dotenv and sets global env() helper
import "dotenv-getter"
// get your .env constant
const appKey = env('APP_KEY')
// provide a default value
const appEnv = env('APP_ENV', 'production')
Flexible
When preloading dotenv from the command line, like when using import statements (checkout the dotenv docs for more info)
$ node -r dotenv/config your_script.js
Set only global env() helper
import "dotenv-getter/helper"
Manually configure dotenv or use the parse() function
// imports dotenv and sets global env() helper
import { config, parse } from 'dotenv-getter/dotenv'
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.