@technician/env-config-source
A config source for accessing environment variables.
This package provides the EnvConfigSource
for use with the Technician config manager.
Installation
npm i @technician/env-config-source
This package is compatible with Node 10 LTS and up.
Usage Examples
The Basics
import {Technician, DefaultInterpreters} from 'technician';
import {EnvConfigSource} from '@technician/env-config-source'
const technician = new Technician(DefaultInterpreters.asText('utf8'));
technician.addSource(new EnvConfigSource());
await technician.read('MY_ENV_VAR');
Overriding Another Source With Environment Variables
import {Technician, DefaultInterpreters} from 'technician';
import {EnvConfigSource} from '@technician/env-config-source';
import {FSConfigSource} from '@technician/fs-config-source';
const technician = new Technician(DefaultInterperters.asBuffer(), {
cacheRespectsPriority: true,
defaultCacheLength: 1000 * 60 * 60;
});
const envSource = new EnvConfigSource();
const filesystemSource = new FSConfigSource('/etc/ssl/certs');
technician.addSource([
{
source: envSource,
priority: 1,
cacheFor: -1
},
filesystemSource
]);
technician.alias('ssl_cert', ['SSL_CERT', 'mysite.crt']);
const value = await technician.read('ssl_cert');
Contributions
Contributions and pull requests are always welcome. Please be sure your code passes all existing tests and linting.
Pull requests with full code coverage are strongly encouraged.
License
Apache-2.0