Hacker News new | ask | show | jobs
by illuminant 697 days ago
The way I like to do it:

- use a config library (or write your own) it should read the settings.config from the root home folder.

- This library should also read settings.local.config (or equivalent.) make a git IGNORE rule for the settings.local.config so you would put credentials here and they won't be checked in to the repo.

- This local config should be read and merged into the base config by your config library (deep merge).

- Further, I like to pull additional config from the DB (for user level settings.) the fs is necessary for bootstrapping into the DB, which then may load additional preferences.

- This config format should be whatever you're comfortable with, JSON , YAML, TOML, .py/js, etc. your stack will have its own selection (and behavior) for config libraries.

And now, make sure that config is loaded and made available at the earliest point in code, and everyone can use it EASILY.

You could have this stashed into a user or system cache which your tools can then spy on to see what settings are available whichever place in code.

Settings, access control, preferences, etc. can all fit this format.

By using the git excluded '.local.' layer you can ensure API keys are never checked into git.

1 comments

* root home folder; that's the application home, one level ABOVE whatever passes for web root. This file should not be accessible to anyone outside of the application.