1.3.1 • Published 4 years ago
@splytech-io/config v1.3.1
config
this package includes following npm packages
config
js-yaml
joi
Interface
new Config(rules: any, path?: string)
Sample usage
# config/default.yml
healthz:
port: 7020
Full configuration
import { Config, J } from '@splytech-io/config';
interface Schema {
healthz: {
port: number;
};
}
const config = new Config<Schema>({
healthz: {
port: J.number(),
},
});
// throws an error if configuration is invalid
config.validate();
console.log(config.get().healthz.port); // - 7020
Partial configuration
import { Config, J } from '@splytech-io/config';
interface Schema {
port: number;
}
const rules = {
port: J.number(),
};
const config = new Config<Schema>(rules, 'healthz')
.validate()
.get();
console.log(config.port); // - 7020