@biorate/file-config
v1.76.3
Published
Module for configuring the application using files
Downloads
71
Readme
File Config
Module for configuring the application using files, extends Config base class.
Examples:
In cwd of you app, near package.json, create 2 files:
# config.json
{
"app": "test"
}
# config.debug.json:
{
"title": "My awesome app"
}
import { Core, injectable, inject, container, Types } from '@biorate/inversion';
import { IConfig } from '@biorate/config';
import { FileConfig } from '@biorate/file-config';
@injectable()
class Root extends Core() {
@inject(Types.Config) public config: IConfig;
}
container.bind<IConfig>(Types.Config)
.to(FileConfig)
.inSingletonScope();
container.bind<Root>(Root).toSelf().inSingletonScope();
(async () => {
const root = await container.get(Root).$run();
console.log(root.config.get('package'));
// {
// "name": "file-config-test",
// "version": "0.0.0",
// "description": "Test package.json",
// "keywords": [],
// "author": "llevkin",
// "license": "MIT"
// }
console.log(root.config.get('app')); // test
console.log(root.config.get('title')); // My awesome app
})();
Learn
- Documentation can be found here - docs.
Release History
See the CHANGELOG
License
Copyright (c) 2021-present Leonid Levkin (llevkin)