From 0b284209fa1b7294f4730151818b31592dbe8264 Mon Sep 17 00:00:00 2001
From: Dominik Sigmund <dominik.sigmund@br.de>
Date: Wed, 19 Feb 2020 12:39:11 +0100
Subject: [PATCH] Examples done

---
 README.md                         | 22 ++++++++++++++++++++++
 examples/env/config.defaults.json |  6 ++++++
 examples/env/config.json          |  6 ++++++
 examples/env/index.js             |  3 +++
 examples/env/server.env           |  0
 examples/only-local/config.json   |  6 ++++++
 examples/only-local/index.js      |  3 +++
 7 files changed, 46 insertions(+)
 delete mode 100644 examples/env/server.env
 create mode 100644 examples/only-local/config.json
 create mode 100644 examples/only-local/index.js

diff --git a/README.md b/README.md
index 2dba117..b7208c6 100644
--- a/README.md
+++ b/README.md
@@ -28,6 +28,28 @@ It reads from the following sources, performing a deep merge:
 - config.json
 - config.defaults.json
 
+## Examples
+
+### Only config.defaults.json
+
+`node examples/only-defaults/index.js`
+
+### Only config.json
+
+(Kind of legacy use)
+
+`node examples/only-local/index.js`
+
+### defaults and config.json
+
+`node examples/defaults-overwrite/index.js`
+
+### enviroment variables
+
+(Enviroment set by command to not pollute your machine)
+
+`setting=overwritten-by-env node examples/env/index.js`
+
 ## TODO / Missing
 
 - hashicorp values support: if value == "vault:", treat it as secret
diff --git a/examples/env/config.defaults.json b/examples/env/config.defaults.json
index e69de29..8d6cd81 100644
--- a/examples/env/config.defaults.json
+++ b/examples/env/config.defaults.json
@@ -0,0 +1,6 @@
+{
+  "setting":"value",
+  "another": {
+    "setting":"avalue"
+  }
+}
\ No newline at end of file
diff --git a/examples/env/config.json b/examples/env/config.json
index e69de29..de6fd1f 100644
--- a/examples/env/config.json
+++ b/examples/env/config.json
@@ -0,0 +1,6 @@
+{
+  "setting":"overwritten",
+  "another": {
+    "more":"settings"
+  }
+}
\ No newline at end of file
diff --git a/examples/env/index.js b/examples/env/index.js
index e69de29..798f2f4 100644
--- a/examples/env/index.js
+++ b/examples/env/index.js
@@ -0,0 +1,3 @@
+let config = require('../../index')
+
+console.log(JSON.stringify(config, undefined, 2))
\ No newline at end of file
diff --git a/examples/env/server.env b/examples/env/server.env
deleted file mode 100644
index e69de29..0000000
diff --git a/examples/only-local/config.json b/examples/only-local/config.json
new file mode 100644
index 0000000..8d6cd81
--- /dev/null
+++ b/examples/only-local/config.json
@@ -0,0 +1,6 @@
+{
+  "setting":"value",
+  "another": {
+    "setting":"avalue"
+  }
+}
\ No newline at end of file
diff --git a/examples/only-local/index.js b/examples/only-local/index.js
new file mode 100644
index 0000000..798f2f4
--- /dev/null
+++ b/examples/only-local/index.js
@@ -0,0 +1,3 @@
+let config = require('../../index')
+
+console.log(JSON.stringify(config, undefined, 2))
\ No newline at end of file
-- 
GitLab