@biorate/file-config
TypeScript icon, indicating that this package has built-in type declarations

1.65.4 • Public • Published

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

MIT

Copyright (c) 2021-present Leonid Levkin (llevkin)

Readme

Keywords

none

Package Sidebar

Install

npm i @biorate/file-config

Weekly Downloads

0

Version

1.65.4

License

MIT

Unpacked Size

156 kB

Total Files

35

Last publish

Collaborators

  • llevkin