# Configuration Management

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

{% code title="app/configs/facebook.js" %}

```javascript
module.exports = {
  api_key: 'api key goes here'
};
```

{% endcode %}

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

{% code title="app/controllers/facebook.js" %}

```javascript
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;
  }
});
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://blueprint.onehilltech.com/developer-guide/managing-configurations.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
