🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

feature-flipper

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

feature-flipper

Another feature flipping module

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

Feature-Flipper

standard-readme compliant XO code styleBuild StatusCoverage Status

Another feature flipper module

TODO: Fill out this long description.

Table of Contents

Install

npm install --save feature-flipper

Usage

const Flipper = require('feature-flipper');
const flip = new Flipper();

// Lets add a feature
flip.set('somefeature', false);

// Use the set method to change the status of a feature
flip.set('somefeature', true);

// To check if a feature is enabled
console.log( flip.isEnabled('somefeature') ); // true

// To flip the status of the feature
flip.flip('somefeature')
console.log( flip.isEnabled('somefeature') ); // false

// To remove the feature
flip.remove('somefeature');

// If you have your feature set in a seperate json object / file you can load them in
const featureSet = {
	somefeature: true,
	someOtherFeature: false
};
flip.load(featureSet);
console.log( flip.isEnabled('someOtherFeature') ); // false

API

TODO: Fill out API specification.

Middleware

This module can be used to enable/disable endpoints in your restify/express like http server with a middleware like the following.

function flipMW(feature) {
	return function(req, res, next) {
		if(flip.isEnabled(feature)) {
			return next();
		} else {
			return res.send(403);
		}
	}
}

server.get('/somefeature', [
	flipMW('somefeature'),
	(req, res, next) => {
		res.send('somefeature endpoint');
		return next();
	}
]);

Maintainers

@rolfkoenders

Contribute

PRs accepted.

Small note: If editing the README, please conform to the standard-readme specification.

License

MIT © 2017 Rolf Koenders

FAQs

Package last updated on 20 Aug 2017

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