config
Configuration control for production node deployments
Last updated 2 days ago by lorenwest .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install config 
SYNC missed versions from official npm registry.

Configure your Node.js Applications

NPM   Build Status   release notes

Introduction

Node-config organizes hierarchical configurations for your app deployments.

It lets you define a set of default parameters, and extend them for different deployment environments (development, qa, staging, production, etc.).

Configurations are stored in configuration files within your application, and can be overridden and extended by environment variables, command line parameters, or external sources.

This gives your application a consistent configuration interface shared among a growing list of npm modules also using node-config.

Project Guidelines

  • Simple - Get started fast
  • Powerful - For multi-node enterprise deployment
  • Flexible - Supporting multiple config file formats
  • Lightweight - Small file and memory footprint
  • Predictable - Well tested foundation for module and app developers

Quick Start

The following examples are in JSON format, but configurations can be in other file formats.

Install in your app directory, and edit the default config file.

$ npm install config
$ mkdir config
$ vi config/default.json
{
  // Customer module configs
  "Customer": {
    "dbConfig": {
      "host": "localhost",
      "port": 5984,
      "dbName": "customers"
    },
    "credit": {
      "initialLimit": 100,
      // Set low for development
      "initialDays": 1
    }
  }
}

Edit config overrides for production deployment:

 $ vi config/production.json
{
  "Customer": {
    "dbConfig": {
      "host": "prod-db-server"
    },
    "credit": {
      "initialDays": 30
    }
  }
}

Use configs in your code:

var config = require('config');
//...
var dbConfig = config.get('Customer.dbConfig');
db.connect(dbConfig, ...);

if (config.has('optionalFeature.detail')) {
  var detail = config.get('optionalFeature.detail');
  //...
}

config.get() will throw an exception for undefined keys to help catch typos and missing values. Use config.has() to test if a configuration value is defined.

Start your app server:

$ export NODE_ENV=production
$ node my-app.js

Running in this configuration, the port and dbName elements of dbConfig will come from the default.json file, and the host element will come from the production.json override file.

Articles

Further Information

If you still don't see what you are looking for, here more resources to check:

Contributors

lorenwest markstos elliotttf jfelege leachiM2k josx
enyo arthanzel eheikes diversario th507 Osterjour
nsabovic ScionOfBytes simon-scherzinger axelhzf benkroeger fgheorghe
IvanVergiliev jpwilliams jaylynch jberrisch kgoerlitz bertho-zero
leonardovillela nitzan-shaked robertrossmann roncli superoven wmertens

License

May be freely distributed under the MIT license.

Copyright (c) 2010-2018 Loren West and other contributors

Current Tags

  • 3.0.1                                ...           latest (2 days ago)

98 Versions

  • 3.0.1                                ...           2 days ago
  • 3.0.0                                ...           a month ago
  • 2.0.2                                ...           a month ago
  • 2.0.1                                ...           5 months ago
  • 2.0.0                                ...           5 months ago
  • 1.31.0                                ...           5 months ago
  • 1.30.0                                ...           10 months ago
  • 1.29.4                                ...           10 months ago
  • 1.29.3                                ...           a year ago
  • 1.29.2                                ...           a year ago
  • 1.29.1                                ...           a year ago
  • 1.29.0                                ...           a year ago
  • 1.28.1                                ...           a year ago
  • 1.28.0                                ...           a year ago
  • 1.27.0                                ...           a year ago
  • 1.26.2                                ...           a year ago
  • 1.26.1                                ...           2 years ago
  • 1.25.1                                ...           2 years ago
  • 1.25.0                                ...           2 years ago
  • 1.24.0                                ...           2 years ago
  • 1.23.0                                ...           2 years ago
  • 1.21.0                                ...           3 years ago
  • 1.20.4                                ...           3 years ago
  • 1.20.3                                ...           3 years ago
  • 1.20.2                                ...           3 years ago
  • 1.20.1                                ...           3 years ago
  • 1.20.0                                ...           3 years ago
  • 1.19.0                                ...           3 years ago
  • 1.17.1                                ...           3 years ago
  • 1.17.0                                ...           3 years ago
  • 1.16.0                                ...           3 years ago
  • 1.15.0                                ...           3 years ago
  • 1.14.0                                ...           4 years ago
  • 1.13.0                                ...           4 years ago
  • 1.12.0                                ...           4 years ago
  • 1.11.0                                ...           4 years ago
  • 1.10.0                                ...           4 years ago
  • 1.9.0                                ...           4 years ago
  • 1.8.1                                ...           4 years ago
  • 1.8.0                                ...           4 years ago
  • 1.7.0                                ...           4 years ago
  • 1.6.0                                ...           4 years ago
  • 1.5.0                                ...           4 years ago
  • 1.4.0                                ...           4 years ago
  • 1.3.0                                ...           4 years ago
  • 1.2.4                                ...           4 years ago
  • 1.2.3                                ...           4 years ago
  • 1.2.2                                ...           4 years ago
  • 1.2.1                                ...           4 years ago
  • 1.2.0                                ...           4 years ago
  • 1.1.0                                ...           4 years ago
  • 1.0.2                                ...           4 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
  • 0.4.37                                ...           4 years ago
  • 0.4.36                                ...           5 years ago
  • 0.4.35                                ...           5 years ago
  • 0.4.34                                ...           5 years ago
  • 0.4.33                                ...           5 years ago
  • 0.4.32                                ...           5 years ago
  • 0.4.31                                ...           5 years ago
  • 0.4.30                                ...           5 years ago
  • 0.4.29                                ...           5 years ago
  • 0.4.28                                ...           5 years ago
  • 0.4.27                                ...           6 years ago
  • 0.4.26                                ...           6 years ago
  • 0.4.25                                ...           6 years ago
  • 0.4.24                                ...           6 years ago
  • 0.4.23                                ...           6 years ago
  • 0.4.22                                ...           6 years ago
  • 0.4.21                                ...           6 years ago
  • 0.4.20                                ...           6 years ago
  • 0.4.19                                ...           6 years ago
  • 0.4.18                                ...           6 years ago
  • 0.4.17                                ...           6 years ago
  • 0.4.16                                ...           6 years ago
  • 0.4.15                                ...           7 years ago
  • 0.4.14                                ...           7 years ago
  • 0.4.13                                ...           7 years ago
  • 0.4.12                                ...           7 years ago
  • 0.4.11                                ...           7 years ago
  • 0.4.10                                ...           7 years ago
  • 0.4.9                                ...           7 years ago
  • 0.4.8                                ...           7 years ago
  • 0.4.7                                ...           7 years ago
  • 0.4.6                                ...           7 years ago
  • 0.4.5                                ...           7 years ago
  • 0.4.4                                ...           7 years ago
  • 0.4.3                                ...           7 years ago
  • 0.4.2                                ...           7 years ago
  • 0.4.1                                ...           7 years ago
  • 0.4.0                                ...           7 years ago
  • 0.2.9                                ...           8 years ago
  • 0.2.8                                ...           8 years ago
  • 0.2.7                                ...           8 years ago
  • 0.2.4                                ...           8 years ago
  • 0.2.5                                ...           8 years ago
  • 0.2.3                                ...           8 years ago
Maintainers (2)
Downloads
Today 923
This Week 3,330
This Month 13,515
Last Day 1,364
Last Week 4,928
Last Month 17,596
Dependencies (1)
Dev Dependencies (13)
Dependents (2039)

Copyright 2014 - 2016 © taobao.org |