Read my book

I wrote books about Webpack and React. Check them out!

Friday, June 14, 2013

Node.js - a Collection of Server Configuration Patterns

There are many ways to set up Node.js server configuration. Rather than writing a blog post about the topic and having to maintain that I started a repository that goes through a couple of patterns I have used. During its development I found myself writing yet another module, namely parse-env.

parse-env allows you to support environment variables based on your current configuration scheme as long as it is based on an Object structure. It simply constructs environment variable names using some simple logic and then checks whether they exist or not. This allows you to rely on convention rather than having to define each of those by hand.

This sort of approach is especially valuable in environments, such as Heroku, where you have a limited amount of control over the server. In case of Heroku you are pretty much forced to deal with environment variable based configuration as nobody in their right mind would commit configuration to the repository.

Let me know if I'm missing some vital configuration pattern and I'll look into adding it. Even better, poke me with a pull request and I'll be really happy. :)