config

WebJar for config

License

License

MIT
Categories

Categories

config Application Layer Libs Configuration
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

config
Last Version

Last Version

3.2.4
Release Date

Release Date

Type

Type

jar
Description

Description

config
WebJar for config
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/lorenwest/node-config

Download config

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/config/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>config</artifactId>
    <version>3.2.4</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/config/
implementation 'org.webjars.npm:config:3.2.4'
// https://jarcasting.com/artifacts/org.webjars.npm/config/
implementation ("org.webjars.npm:config:3.2.4")
'org.webjars.npm:config:jar:3.2.4'
<dependency org="org.webjars.npm" name="config" rev="3.2.4">
  <artifact name="config" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='config', version='3.2.4')
)
libraryDependencies += "org.webjars.npm" % "config" % "3.2.4"
[org.webjars.npm/config "3.2.4"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm : json5 jar [1.0.1,2)

Project Modules

There are no modules declared in this project.

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 cunneen nsabovic BadgerBadgerBadgerBadger simon-scherzinger leonardovillela
axelhzf benkroeger fgheorghe IvanVergiliev jpwilliams jaylynch
jberrisch kgoerlitz bertho-zero nitzan-shaked robertrossmann roncli

License

May be freely distributed under the MIT license.

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

Versions

Version
3.2.4