0.0.29 • Published 5 months ago

@vtex/openfeature-featurehub-server v0.0.29

Weekly downloads
-
License
-
Repository
-
Last release
5 months ago

FeatureHub Provider for OpenFeature

This project provides a FeatureHub provider for the OpenFeature SDK. It allows you to use FeatureHub as a feature flag management system with OpenFeature.

Getting Started

Prerequisites

  • Node.js
  • npm or yarn

Installation

  1. Install the dependencies:
npm install @openfeature/featurehub-provider
  1. Create a .env file based on the .env.sample file and fill in your FeatureHub Edge URL and API key:
cp .env.sample .env

Usage

To use the FeatureHub provider in your project, you need to import and set it as the provider for OpenFeature:

import { FeaturehubProvider } from '@openfeature/featurehub-provider';
//or
const { FeaturehubProvider } = require('@openfeature/featurehub-provider');


const provider = new FeaturehubProvider();

You can then use the OpenFeature API to evaluate feature flags:

const context = {
  targetingKey: 'mytargetingKey',
  country: 'Brazil',
  account: 'myaccount'
};

const booleanFlag = await provider.resolveBooleanEvaluation('booleanFlag', true, context);
const stringFlag = await provider.resolveStringEvaluation('stringFlag', 'default', context);
const numberFlag = await provider.resolveNumberEvaluation('numberFlag', 0, context);
const jsonFlag = await provider.resolveObjectEvaluation('jsonFlag', { default: 'value' }, context);

Environment Variables

FEATUREHUB_EDGE_URL: The URL of your FeatureHub Edge. FEATUREHUB_CLIENT_API_KEY: Your FeatureHub client API key. FEATUREHUB_POLLING_INTERVAL (optional): The polling interval for the FeatureHub client (default is 5000ms).