@idoconfig/provider-envvar
v1.3.5
Published
Provider for idoconfig that reads values from environment variables.
Downloads
3
Maintainers
Readme
Environment Variables Provider
Read values from process.env
and make them accessible through Configuration
Installation & Setup
Add this package to your package.json
npm install --save idoconfig-provider-envvar
Use it!
import { EnvVarConfigurationValueProvider } from "idoconfig-provider-envvar";
// Use it
const envVarProvider = new EnvVarConfigurationValueProvider();
const configuration = new Configuration([envVarProvider]);
const value = configuration.getValue("my-key");
Use with dependency injection
I'm using inversify.io
import Container from "inversify";
import { Configuration, IConfiguration, IConfigurationValueProvider } from "idoconfig";
import { EnvVarConfigurationValueProvider } from "idoconfig-provider-envvar";
const di = new Container({ defaultScope: "Singleton" });
decorate(injectable(), Configuration);
decorate(injectable(), EnvVarConfigurationValueProvider);
di.bind<IConfigurationValueProvider>("ConfigProvider").to(EnvVarConfigurationValueProvider);
di.bind<IConfiguration>("Configuration").to(Configuration);