Skip to content
Johan Hernandez edited this page Nov 23, 2011 · 2 revisions

Every application or module may require to execute an expression to initialize a part of the app according to the current environment.

Initializers can be created in two ways: By using initializers Directory or the initialize attribute.

The initializers Directory

initializers is an optional directory for your application or fire.js module that will contain expressions to be executed automatically for specific environments. Every folder inside corresponds to the target environment.

Examples:

  1. initializers/development will contain all the development expressions activated in development environment, this is the default environment but it can be enforced by using NODE_ENV=development.

  2. initializers/test will contain all the testing expressions activated in test environment when using NODE_ENV=test.

All the expressions of those directories will be decorated with the 'initialize' attribute when they are exported to the runtime.

The "initialize" attribute.

You can also specify which expressions are used to initialize the environment by using the initialize attribute in your expressions without including the expression in any initializer directory. The attribute will accept an array with all the environment names in which the expression will act as a initializer.

Example, the following expression will be used as a initializer for "development" and "staging":

{
    "name": "MyApp.Dev.Init",
    "initialize": ["development", "staging"],
    "json": {}
}