ec

embedded-config

Node configuration file loader with integrated environment variables.

Showing:

Popularity

Downloads/wk

7

GitHub Stars

0

Maintenance

Last Commit

7yrs ago

Contributors

0

Package

Dependencies

1

Size (min+gzip)

8.6KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

node-embedded-config

Node configuration file loader with integrated environment variables. embedded-config

Introduction

Embedded-config lets you define a default configuration and optionally overwrite them in different deployment environments (development, staging, production, etc).

The JSON configuration files allow for inclusion of environment variables using the following syntax in string values:

{
  "db": "{MONGODB_URI}"
}

Here, MONGODB_URI is an environment variable in the server and its value will be replaced into the configuration when the file is loaded.

Usage

Create the config folder in your application directory and create the default configuration file.
$ mkdir config
$ vi config/default.json

{
  "db": "{MYSQL_CONNECTION_URI}",
  "secret_key": "1234567890"
}
Values in your configuration file based on NODE_ENV will be deeply merged into the default configuration.
$vi config/development.json

{
    "db": "localhost"
}
Use the configuration in your code (config is a simple JavaScript object).
var config = require('embedded-config');
...
var db = mysql.connect(config.db);
...
Start the server.
$ NODE_ENV=development node index.js

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100