1.2.3 • Published 11 years ago

embedded-config v1.2.3

Weekly downloads
1
License
MIT
Repository
github
Last release
11 years ago

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
1.2.3

11 years ago

1.2.2

11 years ago

1.1.2

11 years ago

1.1.1

11 years ago

1.0.1

11 years ago

1.0.0

11 years ago