title: Proper way to parse environment variables
body: <p>I am using <a href="https://github.com/lorenwest/node-config" rel="noreferrer">node-config</a> in basically all my projects and most of the time I come across the problem of parsing booleans and numbers which are set as environment variables.</p>
  
  <p>E.g.</p>
  
  <blockquote>
    <p>default.js</p>
  </blockquote>
  
  <pre class="lang-js prettyprint-override"><code>module.exports = { 
      myNumber = 10,
      myBool = true
  }
  </code></pre>
  
  <blockquote>
    <p>custom-environment-variables.js</p>
  </blockquote>
  
  <pre class="lang-js prettyprint-override"><code>module.exports = { 
      myNumber = "MY_NUMBER",
      myBool = "MY_BOOL"
  }
  </code></pre>
  
  <p>Now, the obvious problem is that if I override the default values with custom values set as environment variables they will be a string value instead of a number or boolean value. So now, to make sure in my code that the types are correct. I always have to do type conversion and for booleans use a proper library e.g. <a href="https://www.npmjs.com/package/yn" rel="noreferrer">yn</a>. The problem is I have to do this conversion every time I use <code>config.get()</code> for example <code>+config.get("myNumber")</code> or <code>yn(config.get("myBool"))</code>.</p>
  
  <p>Is there a better and more elegant way to do this? </p>
  
  <p>One solution I see would be to add a type property to an environment variable as it is done <a href="https://github.com/lorenwest/node-config/wiki/Environment-Variables#custom-environment-variables" rel="noreferrer">here</a> with format. This would allow to do something like this...</p>
  
  <blockquote>
    <p>custom-environment-variables.js</p>
  </blockquote>
  
  <pre class="lang-js prettyprint-override"><code>module.exports = { 
      myNumber = {
          name: "MY_NUMBER",
          type: "number"
      },
      myBool = {
          name: "MY_BOOL",
          type: "boolean"
      }
  }
  </code></pre>
  
  <p><code>node-config</code> would handle the type conversions and there would be no need to do it all the time in the code when getting it. Of course there would be the requirement to implement a proper parser for booleans but those already exist and could be used here.</p>