1.1.0 • Published 2 years ago

underflag-http v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

HTTP Provider

This is a HTTP provider for underflag (feature flag/feature toggle) than help your app to load the features from a json object or an array of json object from web. You can get easly from the Github json file, AWS S3 or a Rest API with custom token too.

Install

Using npm:

npm install underflag underflag-http

Using yarn:

yarn add underflag underflag-http

How to use

Import the underflag and prepare to load data provider

import { Underflag } from "underflag";
import { HttpDataProvider } from "underflag-http";

const dataProvider = new HttpDataProvider({ 
    url: 'http://localhost:3000/features' 
});
const underflag = new Underflag({ dataProvider });
if (await underflag.isOn("feature")) {
    // ...
}

Important: The url need return a json object or an array of json object

Eg. json object:

{
    "feature": true
}

Eg. array of json object:

[
    {
        "key": "feature",
        "value": true
    }
]

If you need getting data from nested field like:

{
    "data": [
        {
            "key": "feature",
            "value": true
        }
    ]
}

You can setting the path of the field:

const dataProvider = new HttpDataProvider({
    url: 'http://localhost:3000/features',
    nestedField: 'data'
});

The nestedField option use lodash.get, know more about lodash.get on https://lodash.com/docs#get

Know more on underflag npm page

License

MIT

1.1.0

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago