@thoughtsunificator/config-env

1.0.3 • Public • Published

config-env

Provide a way to inject environment variables into your application.

Getting started

Installing

  • npm install @thoughtsunificator/config-env --save-dev

How does it work?

config-env will create a new object from the config file, env file and process.env.

Order of priority:

  1. process.env
  2. env file
  3. config file

Usage

import config from '@thoughtsunificator/config-env' // assumes ".env.json" and "data/config.json"

or

import { createConfig } from '@thoughtsunificator/config-env'
const config = createConfig(".env.json", "data/config.json")

data/config.json

{
  "SITE_NAME": "FOO"
}

.env.json

{
  "SITE_NAME": "BAR"
}

Within the context of your application:

import config from '@thoughtsunificator/config-env'

console.log(config)
/* outputs:
{
  SITE_NAME: "BAR"
}
*/

Readme

Keywords

none

Package Sidebar

Install

npm i @thoughtsunificator/config-env

Weekly Downloads

12

Version

1.0.3

License

MIT

Unpacked Size

6.49 kB

Total Files

11

Last publish

Collaborators

  • thoughtsunificator