
Security News
PHP Foundation Says Chainguard Broke Security Embargo Ahead of Emergency Patches
The PHP Foundation says Chainguard broke a security embargo ahead of critical RCE patches, as leaks disrupted the coordinated release.
feature-bouncer
Advanced tools
A simple feature toggle library with persistance in Redis, built for Express. You can use it for feature gating, AB testing, etc.
NOTE: This is a very early development version, use at your own risk. Contributions welcome.
If you want a mature solution, these two stood out for me while researching:
AB testing
import * as express from 'express';
import * as Redis from 'redis';
import { FeatureBouncer, PercentageOfRequestsCheck } from 'feature-bouncer';
const app = express();
const redis = new Redis();
// Initialize FeatureBouncer
const bouncer = new FeatureBouncer({
store: redis,
features: {
example: {
// 50-50 AB testing
checks: {
'fiftyPercent': PercentageOfRequestsCheck(50),
},
// Manual override by passing in a `?abtest=show` query string
overrides: {
'cheatCode': QueryStringCheck('abtest', 'show'),
}
},
}
});
// Apply middleware
app.use(bouncer.middleware);
app.get('/', async (_: any, res: any) => {
const check = await bouncer.get('example');
res.send(check ? "You passed!" : "You didn't pass :(");
});
app.listen(3000, () => console.log('listening to port 3000'));
FeatureBouncer.constructor(params: {
store: any,
features: IMap<FeatureToggle>,
getContext?: ((request: express.Request) => IFeaturesContext) | undefined,
options?: IFeatureBouncerOptions
})
getContext such that you make extra data available to the checkers (user id, country, etc.)debug key is available (see debug() function).FeatureBouncer.middleware(
request: express.Request,
response: express.Response,
next: express.NextFunction
)
Pass to app.use() or to app.get() in order to initialize the context data, needed by the feature checkers.
Usage:
app.use(bouncer.middleware);
// or
app.get('/yourRoute', bouncer.middleware, () => {})
async FeatureBouncer.getX(name: string): Promise<boolean>
async FeatureBouncer.get(name: string): Promise<boolean>
example). Returns a Promise containing the result of the check. getX() can throw, get() will just return false if there's an error.FeatureBouncer.debug()
If you passed { debug: true } for options in the constructor, this will return an object showing you the results for each individual checks. Checks bail early, so if it hits false before finishing all of the checks, you won't see them all in here.
This library contains a few general, but the idea is that you should build your own for anything particular to your project.
The type for the check functions is:
type Check = ((
idx: string,
context: IFeaturesContext
) => Promise<[string, boolean]>);
The string in the return tuple should almost always be the idx that you receive as a parameter. This is used for debugging (see debug() method above).
MIT © Claudiu Ceia
FAQs
A simple feature toggle library for Express
We found that feature-bouncer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.

Security News
The PHP Foundation says Chainguard broke a security embargo ahead of critical RCE patches, as leaks disrupted the coordinated release.

Security News
PHP releases emergency patches for two critical RCE vulnerabilities as agencies urge organizations to take unpatched sites offline.

Threat Research
/Security News
A supply chain attack compromised LiteLLM 1.107.0 on PyPI and Docker, spreading malware that steals cloud credentials, developer secrets, and AI provider keys.