Fork me on GitHub

confab-features v0.0.2

Runtime feature gating for confab applications

Contents


features (definition)

Extends the configuration with a list of enabled features.

var confab = require('confab');
var features = require('confab-features');

var config = confab([
  features([
    {
      key: 'new_campaign',
      description: 'A switch to flip'
    },
    'new_ui' // equivalent to `{ key: 'new_ui }`
  ])
]);

Run the app with features set by either a previous transformation or environment overrides:

$ CONFIG_FEATURES_NEW_UI=true \
  node app.js

Then, inside the app, retrieve the feature configurations from a processed confab config:

if (config.features.new_ui) {
  renderNewUi();
}
else {
  renderLegacyUi();
}

The set of all defined features can be retrieved by invoking config.features directly:

config.features().forEach(function (feature) {
  console.log(feature.key, feature.description);
});

Arguments

Type Name Description
Array<String|Feature> keys a list of features or feature keys
Object userOpts optional overrides for the `configKey` (default: `"features"`) and strict validation (default: `true`)