wye-switch
v1.5.0
Published
JSON document-based feature flag management
Downloads
2
Readme
Wye Switch
This adds structure to a JSON-document based feature flag service. It's intended that the file created by this will live in a CDN with a short cache life & is requested by the frontend.
The CLI manipulates a JSON document on the file system.
Installation
npm install -g wye-switch
Add a config block to your package.json
:
{
...
"wye-switch": {
"path": "feature-flags.json"
}
...
}
If you don't supply this the default is a file in the current directory called feature-flags.json
Flag Management Usage
The command line is interactive. Start with these commands:
wye add-flag
wye remove-flag
wye set-default
wye set-user
wye set-group
The "QA" option has special meaning which takes into consideration the sessionStorage
of the user.
Package Usage
Install the module in the application you're going to use it in:
npm install wye-switch
Then construct a WyeSwitch
object:
import WyeSwitch from 'wye-switch'
...
const flags = new WyeSwitch({ ... json from fetching feature-flags.json ... })
const canWeasel = flags.canWeasel('can-weasel', { userId: 'me', group: undefined })
If the value of the flag is QA
it will return a truthy check on the value of sessionStorage['allow-wye-switch-qa']
for the result of isEnabled
.
Fetching the json from feature-flags.json
is left for the user to implement.