Blueprint
Search…
Configuration Management
Learn how to define configurations

Introduction

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.
app/configs/facebook.js
1
module.exports = {
2
api_key: 'api key goes here'
3
};
Copied!

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:..
app/controllers/facebook.js
1
const {Controller} = require ('@onhilltech/blueprint');
2
3
module.exports = Controller.extend ({
4
apiKey: null,
5
6
init () {
7
this._super.call (this, ...arguments);
8
const config = this.app.lookup ('config:facebook');
9
this.apiKey = config.apiKey;
10
}
11
});
Copied!
Last modified 3yr ago