hapi-ff

1.0.1 • Public • Published

hapi-ff

Feature flags for Hapi.js

Installation

npm install hapi-ff

Usage

Register the plugin and pass an options object with your feature flags. Simple features accept boolean values. Features with dependencies are objects with a boolean property 'active' and a 'dependencies' array. Feature flags can also be functions, that accept the request object and the entire features object itself, giving access to checking for other flags.

hapi-ff can be run in persistent in dynamic mode (default). In dynamic mode function feature flags have access to the request object and features are resolved on each incoming request. In persistent mode feature flags are set only once when registering the plugin and when running the update server function ('ffUpdate'). Function feature flags do not have access to the request object in persistent mode.

  • Persistent mode is helpful if your feature flags are request independent and need only be updated sporadically.
  • Dynamic mode is helpful if feature flags are request-dependent. For instance when using a url query object to set a flag.

Example Configuration

server.register({
  register: require('hapi-ff'),
  options: {
    persistent: false,
    features: {
      'feature_1': true,
      'feature_2': {
        active: true,
        dependencies: ['feature_1']
      },
      'feature_3': (request, features) => {
        return !!request.params.id && features.feature_1
      }
    }
  }
});

Readme

Keywords

Package Sidebar

Install

npm i hapi-ff

Weekly Downloads

0

Version

1.0.1

License

MIT

Last publish

Collaborators

  • gattermeier