Socket
Book a DemoInstallSign in
Socket

express-feature-flag

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-feature-flag

Feature Flag system as a Express middleware

0.2.0
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

express-feature-flag

Feature Flag system as an express.js middleware.

Installation

npm install express-feature-flag

Usage

app.use(require('express-feature-flag')({
  contextGenerator: function (req, callback) {
    callback(null, req.session); //do other queries if necessary
    return;
  },

  ruleGenerator: function (callback) {
    queryFeatureFlagDB(function (err, featureFlagRules) {
      if (err) {
        callback(err);
        return;
      }

      var rule, rules, _i, _len;

      rules = {};

      for (_i = 0, _len = featureFlagRules.length; _i < _len; _i++) {
        rule = featureFlagRules[_i];
        rules[rule.name] = parseRuleSpec(rule.rule);
      }

      callback(null, rules);
    })
  }
})); // returns a middleware function

###Middleware Options ####contextGenerator Function(req, callback) [optional] An asynchronous function to generate context which will then be used as an argument to feature flag rules.

If not supplied, context will be req.

####ruleGenerator Function(callback) [required] An asynchronous function to generate rules.

callback's first argument is error and second argument is rules. rules have to be an object whose names are the name of rules and values are functions that takes context and returns boolean.

rules Example:

{
  htmlEmail: function (context) {
    if (context.type === 'admin') {
        return true;
    }
    return false;
  }
}

ToDo

  • Include basic rule spec

Changelog

v0.1.3

  • Added stricter type checking to FeatureFlagCollection

v0.1.0

  • Initial release

Contributors

License

ISC License

Keywords

express

FAQs

Package last updated on 07 Dec 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.