This project is a configuration management tool for HackMD.
It inspired by node-config.
@hackmd/config is a tool to manage mass configuration source, such as config file, environment, or docker secret.
We use config-provider to load difference config source. The config-provider is a plugin for @hackmd/config.
- You must setup which config type and config loaded order in your
package.json
{
"name": "example-project",
"dependencies": {
"@hackmd/config": "0.0.1-alpha.1"
},
"config": {
"type": "./config/type.js",
"reader": [
"file:./config/default.js",
"env:APP"
]
}
}
- Define your config type
module.exports = {
host: String,
port: Number,
db: {
host: String,
port: String,
user: String,
pass: String,
},
allowHost: Array
}
- initialize
@hackmd/config
before your program
const config = require('@hackmd/config')
await config.buildAsync()
main();
- in your program, you can use
require('@hackmd/config').getConfig()
to get your config object