@takaro/config
v0.0.15
Published
An opinionated config handler
Downloads
341
Readme
@takaro/config
An opinionated config manager based on node-convict
Usage
import { Config, IBaseConfig } from '@takaro/config';
interface IExampleConfig extends IBaseConfig {
test: string;
}
// This is a schema from convict
const exampleSchema = {
test: {
doc: 'Test value',
format: String,
default: 'test',
env: 'TAKARO_TEST'
}
};
const config = new Config<IExampleConfig>([exampleSchema]);
// ---
config.load({ test: 1 });
// Error! 'test' should be a string
config.validate();
// ---
config.load({ test: 'Hello world' });
config.get('test') // 'Hello world'