3.3.11 • Published 3 months ago

config v3.3.11

Weekly downloads
668,376
License
MIT
Repository
github
Last release
3 months ago

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

License

May be freely distributed under the MIT license.

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

@amtekcorp/cms2-lib-common-expresswao@sprucelabs/spruce-skill@determinacy/interfacecomposer-commonsomryst-api@bitrabbit/nuls-jsrepositorycodegencreateviewwebchat-backendplatform-orderstargeting-helpernuggets-creditsgamiphy-service-coregamiphy-auth-node@coffeekraken/monorepo@vilellaj/wet-umbrellaservice-configuration@everreal/file-storage-client@everreal/notifications-clientsp-server-initializereasypost-queue-ebmultisoft-teams-imogc-api@prima/prima-database@prima/prima-cacheixl-omnicron-apollo-serverbiapp-loggerextension-chromemid-config-toolsinx-serverpt.config.connectsudoku-apirubato-commonmailmessagequeuecodeberry-data-mininglivita-socket-serverlivita-socketio-serverstrelka-mag-redactor4leaflabs-api-proxymativetransactions-users-database@domain-group/transactions-users-db-modelstutorideer-notifications-apirevma@antsomi/core-servicesfoundry-keystore-test@sample-vst/apiarticles-searcherluna-plutoospoon-merchantpurascents-scripts@sample-vst/desktop-wrapperadmin-mongo-forkmhsid-v2@fulldivevr/config-remotenode-red-contrib-storage-motebus@motebus/fbuilder@ikangxu/i5ting_tocrelay-restmrcp_clientnero-common-utilitiessupermario-clisuper-mario-clijailhouse-mail-daemongizconnection-apikn-vehiclespivvot-common-api-libibl-metadata-errors-lambda@nestwealth/service-buskvssk-mern-appgithub-star-cli2enigma-p2pmern-app-kvsskipg-turnkey-sdkreach-ad-analyserbatch-processing-servicewm-email-v3hoserver-frameworkcirplus-frontend@everreal/ftp-clientcube-go-database-migrations@ibm-gpn/gpn-configkit-krangtingz-libplastics@shealtiel/socket-bridge@nodetraveller/mapmaker@nodetraveller/lumberjackmarkable-middle-layer-sku-api@nodetraveller/beancounterlimecraft-adminetp.common.kidaccessvendor-enquiry-api@deboxsoft/lb-module-farm-management-server@deboxsoft/webpackchromecast-dbus@deboxsoft/devel-react@wong-bejo/api
3.3.11

3 months ago

3.3.10

3 months ago

3.3.9

1 year ago

3.3.8

2 years ago

3.3.7

2 years ago

3.3.6

3 years ago

3.3.4

3 years ago

3.3.3

3 years ago

3.3.2

4 years ago

3.3.1

4 years ago

3.3.0

4 years ago

3.2.6

4 years ago

3.2.5

4 years ago

3.2.4

4 years ago

3.2.3

5 years ago

3.2.2

5 years ago

3.2.1

5 years ago

3.2.0

5 years ago

3.1.0

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.0.2

5 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.31.0

6 years ago

1.30.0

6 years ago

1.29.4

6 years ago

1.29.3

6 years ago

1.29.2

6 years ago

1.29.1

6 years ago

1.29.0

6 years ago

1.28.1

6 years ago

1.28.0

6 years ago

1.27.0

7 years ago

1.26.2

7 years ago

1.26.1

7 years ago

1.25.1

7 years ago

1.25.0

7 years ago

1.24.0

7 years ago

1.23.0

7 years ago

1.21.0

8 years ago

1.20.4

8 years ago

1.20.3

8 years ago

1.20.2

8 years ago

1.20.1

8 years ago

1.20.0

8 years ago

1.19.0

8 years ago

1.17.1

8 years ago

1.17.0

8 years ago

1.16.0

9 years ago

1.15.0

9 years ago

1.14.0

9 years ago

1.13.0

9 years ago

1.12.0

9 years ago

1.11.0

9 years ago

1.10.0

9 years ago

1.9.0

9 years ago

1.8.1

9 years ago

1.8.2

9 years ago

1.8.0

9 years ago

1.7.0

9 years ago

1.6.0

10 years ago

1.5.0

10 years ago

1.4.0

10 years ago

1.3.0

10 years ago

1.2.4

10 years ago

1.2.3

10 years ago

1.2.2

10 years ago

1.2.1

10 years ago

1.2.0

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.4.37

10 years ago

0.4.36

10 years ago

0.4.35

10 years ago

0.4.34

10 years ago

0.4.33

10 years ago

0.4.32

11 years ago

0.4.31

11 years ago

0.4.30

11 years ago

0.4.29

11 years ago

0.4.28

11 years ago

0.4.27

11 years ago

0.4.26

11 years ago

0.4.25

11 years ago

0.4.24

11 years ago

0.4.23

11 years ago

0.4.22

11 years ago

0.4.21

11 years ago

0.4.20

11 years ago

0.4.19

11 years ago

0.4.18

11 years ago

0.4.17

12 years ago

0.4.16

12 years ago

0.4.15

12 years ago

0.4.14

12 years ago

0.4.13

12 years ago

0.4.12

12 years ago

0.4.11

12 years ago

0.4.10

12 years ago

0.4.9

12 years ago

0.4.8

12 years ago

0.4.7

12 years ago

0.4.6

12 years ago

0.4.5

12 years ago

0.4.4

12 years ago

0.4.3

13 years ago

0.4.2

13 years ago

0.4.1

13 years ago

0.4.0

13 years ago

0.2.9

13 years ago

0.2.8

13 years ago

0.2.7

13 years ago

0.2.5

13 years ago

0.2.4

13 years ago

0.2.3

13 years ago