@impargo/configurator
v1.0.1
Published
Loads all yaml files under `config` directory in the root folder, validates them against a schema, and then returns them if they're valid. Otherwise logs an error and exits the process with error code 1.
Downloads
4
Keywords
Readme
Configurator
Loads all yaml files under config
directory in the root folder, validates them against a schema, and then returns them if they're valid. Otherwise logs an error and exits the process with error code 1.
Schema
Schema validation currently supports the following values:
- Objects
- Arrays
- Numbers
- Strings
- Booleans
Example
import { parse, schema } from 'configurator'
const parsed = parse(schema.object({
config: schema.object({
PORT: schema.number(),
}),
secrets: schema.object({
MONGO_URL: schema.string(),
}),
}))
console.log(parsed)
// {
// config: {
// port: 123
// },
// secrets: {
// MONGO_URL: "mongodb://server.mongodb.net/db"
// }
// }