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

flipper-js

Package Overview
Dependencies
Maintainers
0
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flipper-js

Flipper-js manage the feature flipping in your application

  • 1.0.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
0
Weekly downloads
 
Created
Source

Flipper-js

Flipper-js manage the feature flipping in your application

Inspired from the GEM Flipper Ruby GEM Flipper

Features

  • CLI management
  • In code management
  • UI management

Installation

npm i flipper-js

Configuration

The configuration is on a json file (features.json) that you have to create on your application :

{
  "features": {
    "feature1": true,
    "feature2": false
  },
  "storage": {
    "type": "local"
  }
}

Storage types are

  • local : use this file (read and write) to manage the feature flipping.
  • redis : use the redis (you provide) to store the feature.

Env vars

  • FLIPPER_API_KEY : the api key used to authenticate interaction with the flipper UI
  • FLIPPER_REDIS_URL : The redis connection url

CLI

The feature flipping could be managed by a CLI

npx flipper-js --help

you have to set the env var FLIPPER_REDIS_URL if you are using the redis storage type.

export FLIPPER_REDIS_URL=redis://user:passxord@redis:6379

Options

-V, --version output the version number -h, --help display help for command

Commands

  • list : List all features and their statuses
  • enable "feature" : Enable a feature
  • disable "feature" : Disable a feature
  • add "feature" : Add a new feature (enabled by default)

In code management

Initialisation

import  path  from  'path'
import { Flipper } from  'flipper-js'

// Init flipper with json config path (optional)
Flipper.init(path.join(__dirname, '../features.json'))

Usage

import { Flipper } from  'flipper-js'

// Check if a feature is enabled
await Flipper.isEnabled('feature1')

// Enabled a feature
await Flipper.enable('feature1')

// Disabled a feature
await Flipper.disable('feature1')

// List all features
await Flipper.list()

UI management

UI management is using an express router

The router is exported and could be included in your app.

Example with Express

import { Flipper, User, FlipperRouter } from  'flipper-js'

Flipper.init()

// Expose /flipper-js on your application
app.use(FlipperRouter.of('express'))

User.addUser(process.env.FLIPPER_USER_LOGIN, process.env.FLIPPER_USER_PASSWORD)
// You can add several users

Other router (Nest.js, Fastify) are coming

To access : launch https://yourserver.com/flipper-js

The connection is the login provided by the addUser method.

Inside the UI, you can simply enable or disabled features.

Keywords

FAQs

Package last updated on 20 Nov 2024

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