flips-client
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

A simple nodejs lib for handling feature flags through typescript decorators. Define the flags by remote url (json response), inline, or environment variables.

Install

$ npm install flips-client --save

Usage

import Flips, { FlipsConfig } from 'flips-client'

const flipped = new Flips(<FlipsConfig>{json: {features: [{feature:"hello", switchedOn: true}]}})

//...

class App {
  @flipped.on("hello")
  works (input): any {
    return input;
  }
  
  @flipped.on("bye")
  wontwork (input): any {
    return input;
  }
}

const app = new App();

console.log(app.works("Yay"));      // logs "Yay"
console.log(app.wontwork("Sorry"))  // logs "false"

//...

Or in js

As the decorators are not available use the by function

var Flips = require("flips-client").default;

const flipped = new Flips({json: {features: [{feature:"hello", switchedOn: true}]}});

console.log("true => ", flipped.by("hello"))
console.log("false => ", flipped.by("not"))

Dependents (0)

Package Sidebar

Install

npm i flips-client

Weekly Downloads

2

Version

1.0.2

License

ISC

Unpacked Size

7.34 kB

Total Files

6

Last publish

Collaborators

  • mcraa