Skip to content

Instantly share code, notes, and snippets.

@gabrielstuff
Last active March 14, 2017 10:04
Show Gist options
  • Save gabrielstuff/f3b8343a35e2ed69316cbca633a7f647 to your computer and use it in GitHub Desktop.
Save gabrielstuff/f3b8343a35e2ed69316cbca633a7f647 to your computer and use it in GitHub Desktop.
๐Ÿ“š A description of what should include a setting module loader

Setting loader

The setting loader is a module that allows to load settings in the form of a JSON. This JSON file can include various parameters. We call them settings.

The settings should be overridable in the following levels :

  • default settings in a setting folder, in a JSON file. We might use HJSON
  • override settings loaded depending on the ENV : production / staging / development ย This overriding should take the following form : load(settings/settings.${ENV}.json) if load(settings/settings.${ENV}.json) fail, tries load(settings/${ENV}.json) else tries load(settings/settings.json)
  • override based on the default path where a setting can be found (inspired from rc):
  • override base on a file input : providing a --settings option then this setting file should be loaded. If the setting file can not be found or parsing is wrong, a warning should be thrown and the other setting should be loaded
@gabrielstuff
Copy link
Author

Looks like https://github.com/indexzero/nconf is doing exactly what we need. Except from the HJSON part. Need to test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment