LearnersGuild / idm

identity management service
MIT License
2 stars 24 forks source link

Improve config management #91

Closed jeffreywescott closed 8 years ago

jeffreywescott commented 8 years ago

BACKGROUND

When it comes to app configuration, the terms development and production are overloaded, especially in a repo containing client- and server-side application code.

Often, development and production are simply used as friendly names for the general environment in which an app is running. For example, a server app might be deployed to and run on a remote testing environment named the "development" env. Other common environment names in simple deployment schemes are test, staging and local.

Other times, development and production are used to refer to "modes" of app execution, particularly on the client side. For example, they might be used to suggest whether or not an app should be optimized for performance and security or allowed to contain hooks and other helpers for debugging.

These changes aim to make it easier to manage configuration both for different modes of app execution and for different app environments.

OBJECTIVES

SUGGESTED SOLUTIONS

I've found node-config extremely useful.

It lets you specify environment-specific variables along with a default config and automatically merges the env-specific (whatever file matches the current NODE_ENV -- e.g. config/development.js) and default configs together.

What I usually do is set up a config module that not only contains hard-coded non-sensitive values but that also wraps sensitive env-based variables (such as those set in process.env).

Then, the entire app only has to look to the config module to get whatever config it needs. No more hardcoded string comparisons or checking for process.env.foo.

Recommending for all of our JS apps.

jeffreywescott commented 8 years ago

Duplicated from https://github.com/LearnersGuild/game/issues/116 so we can track the work needed in different repos.

heyheyjp commented 8 years ago

Heroku vars updated for lg-idm app.