config
Configuration control for production node deployments
Last updated 12 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:

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

if (config.has('optionalFeature.detail')) {
  const 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 are some more resources to check:

Contributors

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

License

May be freely distributed under the MIT license.

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

Current Tags

  • 3.2.5                                ...           latest (12 days ago)

105 Versions

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

Copyright 2014 - 2016 © taobao.org |