New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

unleash-express

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unleash-express

express helper for unleash

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

unleash-express

Build Status

unleash-client that helps persisting feature toggle results over Express.js

Prerequisite

You will need express and cookie-parser:

const express = require('express');
const app = express();
app.use(cookieParser());

Configuration

const { initialize } = require('unleash-client');
const unleash = initialize(...);
const { UnleashExpress } = require('unleash-express');
const unleashExpress = new UnleashExpress(unleash, options);

Available options:

  • cookieName (string): The name of the cookie to persist the result values of each feature toggle. Defaults to 'unleash'
  • cookieOptions (object): Additionl options for the cookie like expires or maxAge. No default.

Usage

1. Use the middleware

app.use(cookieParser());
app.use(unleashExpress.middleware()); // This will allow reading/setting the cookies

2. Flip the coin

Ask unleash-client for the value of a feature as usual by using getVariant.

// In your feature.controller.js
req.unleash.getVariant('feature', ...);

You can also check alternatives or features that are enabled by using isEnabled.

// In your controller
req.unleash.isEnabled('alternative');

3. Reuse the result along the pipeline

Peek the persisted results:

req.unleash.results['feature']; // Variant object or null

Acknowledgment

Inspired by fflip-express

FAQs

Package last updated on 05 Sep 2019

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc