Unleash is an Open source feature flagging solution with built-in javascript which can help you create and manage feature toggles using REST API's.
*For Windows 11 with WSL enabled.
Install Docker
Keep in mind to enable WSL when installing Docker
Setup Unleash Server
git clone https://github.com/Unleash/unleash-docker.git
cd unleash-docker
docker compose up -d
Open Unleash UI Console in the browser: http://localhost:4242/
default credentials: admin unleash4all
Create Feature Flag
Create Unleash Server Token
You'll need to add it to the small app below
customHeaders: { Authorization: 'TOKEN' },
Install NodeJS
sudo apt install curl
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
source ~/.bashrc
nvm ls-remote
nvm install 18.18.2 (put the version you need)
npm install unleash-client
Create NodeJS small app
const { initialize } = require('unleash-client');
console.log('Starting ....');
const unleash = initialize({
url: 'http://localhost:4242/api',
appName: 'my-node-name',
customHeaders: { Authorization: '*:development.ce816607696cadd45123c06ff16a69e252546e5899c5349e081250e4' },
});
console.log('Reading ');
// Unleash SDK has now fresh state from the unleash-api
const isEnabled = unleash.isEnabled('AwesomeFeature',);
console.log('IsEnabled: '+isEnabled);
setInterval(() => {
let result=unleash.isEnabled('AwesomeFeature');
console.log('IsEnabled: '+result);
}, 1000);
Testing Feature Flagging
start your app:
node unleash-client-setup.js
you'll in the terminal running:
IsEnabled: false
IsEnabled: false
IsEnabled: false
IsEnabled: false
IsEnabled: false
IsEnabled: false
Комментариев нет:
Отправить комментарий