1.0.1 • Published 1 year ago

node-env-object v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

node-env-object

Simple node module to convert an .env file to an js object.

Quick start

To be able to process envs from .env file load them first. I prefere the dotenv package from npm.

npm install dotenv https://github.com/kyromoto/node-env-object.git

An example .env:

api.port=300
api.host=0.0.0.0

To use node-env-object you need to integrate it in your application.

import dotenv from "dotenv"
import { getEnv } from "node-env-object"

dotenv.config()

const config = getEnv("api", ".")

This will transform the .env to an js object.

{
    "api" : {
        "port" : 3000,
        "host" : "0.0.0.0"
    }
}