Configuration Management

Last updated 7 months ago

Learn how to define configurations


Configurations define property values used by the application to configure its behavior.

All configurations are located in app/configs directory. Environment-specific configurations (e.g., NODE_ENV=production) must reside in the env subdirectory and named after the target environment (e.g., app/configs/env/production). Environment-specific configurations overwrite the values in general-purpose configuration files.

Defining a Configuration

Define a configuration by exporting an object from the configuration file.

module.exports = {
api_key: 'api key goes here'

Accessing the Configuration

You access the configuration by looking it using the blueprint.lookup() method. Because application configuration are the first resource loaded, it is safe to lookup a configuration at any time within in the servers lifetime. For example, the code snippet below shows how to access the Facebook API key from the configuration above:..

const {Controller} = require ('@onhilltech/blueprint');
module.exports = Controller.extend ({
apiKey: null,
init () { (this, ...arguments);
const config = ('config:facebook');
this.apiKey = config.apiKey;