Repository navigation
Initializers
Every application or module may require to execute an expression to initialize a part of the app according to the environment.
Initializers can be created in two ways:
initializers is an optional directory for your application or priest module that will hold expressions to be executed by certain environment. Every folder inside corresponds to the target environment.
Examples:
-
initializers/developmentwill contain all the development expressions activated indevelopmentenvironment, this is the default environment but it can be enforced by using NODE_ENV=development. -
initializers/testwill contain all the testing expressions activated intestenvironment when using NODE_ENV=test.
What the runtime does with the expressions of the current initializer directory is decorate them with the 'initialize' attribute when they are loaded.
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 it should be executed.
Example, the following expression will be used as a initializer for "development" and "staging":
{
"name": "MyApp.Dev.Init",
"initialize": ["development", "staging"],
"json": {}
}