mralanlee / suede

A node environment configuration handler that sets environment variables based on environment, inspired by dotenv

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Suede

Suede is a module, inspired by dotenv, for loading environment variables from a suede.env.json file into process.env. The difference is that you must declare the environment for the imported function so that it could do a lookup in the JSON file to load any required environment variables.

Install

npm install suede or yarn add suede

Create a suede.env.json file and add specific variables needed in JSON relative to the root property.

Example:

{
    "test": {
        "DATABASE": "mongodb://localhost:27017/test",
        "BACKEND_ENDPOINT": "http://localhost:3000/"
    },
    "qa": {
        "DATABASE": "mongodb://localhost:27017/test",
        "BACKEND_ENDPOINT": "http://localhost:3000/"
    },
    "production": {
        "DATABASE": "mongodb://localhost:27017/test",
        "BACKEND_ENDPOINT": "http://localhost:3000/"
    }
}

It's that simple.

const mongoose = require('mongoose')
const suede = require('suede')

suede('test')
mongoose.connect(process.env.DATABASE)

Reason

The reason for building another environment variable manager is to help manage multiple environments and to simplify testing

About

A node environment configuration handler that sets environment variables based on environment, inspired by dotenv


Languages

Language:JavaScript 88.4%Language:HCL 11.6%