Simple feature flags management for hapi.js
$ npm install hapi-features
To use this plugin just load it into your hapi.js server.
Pass it your feature flags as the options property. It will add the plugins.features
property to every request object.
server.register({
register: index,
options: {"feature_a":true, "feature_b":false}
}, function(err) {});
To update features while the server is running call the updateFeatures(features)
methods
server.methods.updateFeatures({"new_conf": true});
{
"feature_a": true,
"feature_b": false
}
{
"feature_a": true,
"feature_b": false
}
{
"feature_a": true,
"feature_b": false,
"true_dep_a": {
"active": true,
"required": [
"feature_a"
]
},
"false_dep_a": {
"active": false,
"required": [
"feature_a"
]
},
"true_dep_b": {
"active": true,
"required": [
"feature_b"
]
},
"false_dep_b": {
"active": false,
"required": [
"feature_b"
]
},
"true_dep_ab": {
"active": true,
"required": [
"feature_a",
"feature_b"
]
},
"false_dep_ab": {
"active": false,
"required": [
"feature_a",
"feature_b"
]
}
}
{
"feature_a": true,
"feature_b": false,
"true_dep_a": true,
"false_dep_a": false,
"true_dep_b": false,
"false_dep_b": false,
"true_dep_ab": false,
"false_dep_ab": false
}
{
"feature_a": true,
"feature_b": false,
"true_dep_a": {
"active": true,
"required": [
"feature_a"
]
},
"true_dep_b": {
"active": true,
"required": [
"feature_b"
]
},
"a_dep_a": {
"active": true,
"required": [
"feature_a",
"true_dep_a"
]
},
"a_dep_b": {
"active": true,
"required": [
"feature_a",
"true_dep_b"
]
}
}
{
"feature_a": true,
"feature_b": false,
"true_dep_a": true,
"true_dep_b": false,
"a_dep_a": true,
"a_dep_b": false
}