1.3.1 • Published 1 year ago
alliage-parameters-loader v1.3.1
Alliage Parameters Loader
Provides a generic configuration file to store any parameters we could need to configure our application.
Dependencies
Installation
yarn add alliage-parameters-loader
With npm
npm install alliage-parameters-loader
Registration
If you have already installed alliage-module-installer you just have to run the following command:
$(npm bin)/alliage-scripts install alliage-parameters-loader
Otherwise, update your alliage-modules.json
file to add this at the bottom:
{
// ... other modules
"alliage-parameters-loader": {
"module": "alliage-parameters-loader",
"deps": [
"alliage-lifecycle",
"alliage-di",
"alliage-module-installer",
"alliage-config-loader"
],
"envs": [],
}
}
Usage
Once installed, a new file located in config/parameters.yaml
should be available.
The format of this file is totally free.
For example we could have something like that:
# config/parameters.yaml
webserver:
host: 127.0.0.1
port: 8080
credentials:
username: thehumblejester
password: '411!463|20(|(5'
Then, everything would be available as a dependency of any service as in the following example:
import { AbstractLifeCycleAwareModule } from 'alliage-lifecycle/module';
import { INIT_EVENTS, RUN_EVENTS } from 'alliage-lifecycle/events';
import { parameter } from 'alliage-di/dependencies';
import { MyService } from './MyService';
export = class MyModule extends AbstractLifeCycleAwareModule {
// ...
registerServices(serviceContainer) {
serviceContainer.registerService('my_service', MyService, [
parameter('parameters.webserver.host'),
parameter('parameters.webserver.port'),
parameter('parameters.webserver.credentials'),
]);
}
}
1.3.1-beta.0
1 year ago
1.3.0-beta.2
1 year ago
1.3.0-beta.5
1 year ago
1.3.1
1 year ago
1.3.0
1 year ago
1.2.0-pre1
3 years ago
1.1.1
4 years ago
1.1.0
4 years ago
1.0.0
4 years ago
0.0.1
4 years ago