Expresser Settings

The settings.default.json file is commented with all Expresser settings. Please check it for detailed instructions.

How to overwrite Expresser settings

You can overwrite settings in 3 different ways:
  • by creating a settings.json file on the root folder of your application.
  • by using the settings.loadFromJson method passing the path to your custom settings file.
  • programmatically on your app code.

Please note that when you call the main expresser.init(), it will automatically look for the settings.json file and use it to override your app settings, so you don't need to do this manually.

Also remember that the Settings class is singleton: if you update a specific setting somewhere, it will reflect on all other parts of your application.

Per-environment settings

In addition to settings.json , Expresser will also look for a settings.NODE_ENV.json file to set per-environment specific settings. That way you can easily create specific settings for different environments (development and production, for example).

Appending custom settings to the Expresser Settings class

You can add as many custom settings as you want and use the Settings class as the main settings repository for your app, as long as you make sure that there are no conflicts between your custom settings keys and the ones used by Expresser. For example you could add the following "theme" block to the settings.json and it will be automatically added to the Settings class:
theme: {
    name: "MyTheme:,
    location: "/mytheme/"
}

The above theme name for example can be accessed via expresser.settings.theme.name .

Resetting to default settings

The settings.reset() method will create a new Settings instance and reset all settings to their default initial state. Custom values set programmatically will be cleared out.

Last edited Feb 12 at 10:05 PM by igoramadas, version 8

Comments

No comments yet.