From 1bd0bcaf6e60dc7812785ac40c4d8c5c29afd4a0 Mon Sep 17 00:00:00 2001 From: Mark Stosberg Date: Wed, 19 Nov 2014 08:20:15 -0500 Subject: [PATCH] Update README to mention that get() throws excewptions, and also `config.has()`. Addresses #173. These are important and common details to encounter, and worth mentioning up front. --- History.md | 4 ++++ README.md | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/History.md b/History.md index ad10ec44..3a67c8ed 100644 --- a/History.md +++ b/History.md @@ -1,4 +1,8 @@ + + * Highlight `config.has()` in the README. Use it to check to if a value exists, since `config.get()` + throws exceptions on undefined values. (@markstos) + 1.8.1 / 2014-11-14 ================== diff --git a/README.md b/README.md index abbfc83d..2596dfa0 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,14 @@ The following examples are in JSON format, but configurations can be in other [f 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