Blueprint
  • Blueprint Developer Guide
  • Quick Start
    • Getting Started
    • My First Application
      • Creating Your Application
      • Controllers
      • Routers & Routes
      • Services
      • Resources & Resource Controllers
      • Validating & Sanitizing Input
      • Unit Testing Your Application
      • Policies
  • Developer Guide
    • The Object Model
      • Introduction
      • Classes and Instances
      • Computed Properties
      • Aggregated Properties
      • Mixins
    • Routers and Controllers
      • Introduction
      • Routers
      • Controllers
      • Resources
    • Models
    • The Server
    • Policy Framework
    • Services
    • Messaging Framework
    • Configuration Management
    • Application and Resources
      • Lookup Operation
      • Views
      • Assets
    • Blueprint Modules
    • Blueprint Cluster
      • What is a Blueprint Cluster?
      • Running a Blueprint Cluster
      • Technical Details
    • Testing Framework
    • Command-line Interface (Coming Soon)
Powered by GitBook
On this page
  • Introduction
  • Defining a Configuration
  • Accessing the Configuration
  1. Developer Guide

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
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:..

app/controllers/facebook.js
const {Controller} = require ('@onhilltech/blueprint');

module.exports = Controller.extend ({
  apiKey: null,
  
  init () {
    this._super.call (this, ...arguments);
    const config = this.app.lookup ('config:facebook');
    this.apiKey = config.apiKey;
  }
});
PreviousMessaging FrameworkNextApplication and Resources

Last updated 7 years ago