Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/featbit/openfeature-provider-node-server
A OpenFeature provider implementation for the FeatBit node SDK
https://github.com/featbit/openfeature-provider-node-server
Last synced: 4 days ago
JSON representation
A OpenFeature provider implementation for the FeatBit node SDK
- Host: GitHub
- URL: https://github.com/featbit/openfeature-provider-node-server
- Owner: featbit
- License: mit
- Created: 2023-12-28T06:54:56.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-09T14:11:12.000Z (12 months ago)
- Last Synced: 2024-12-09T01:48:53.460Z (26 days ago)
- Language: TypeScript
- Size: 169 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FeatBit OpenFeature provider for Node.js SDK
## Introduction
This is the OpenFeature provider for the [Node.js Server-Side SDK](https://github.com/featbit/featbit-node-server-sdk) for the 100% open-source feature flags management platform [FeatBit](https://github.com/featbit/featbit).
The FeatBit OpenFeature provider is designed primarily for use in multi-user systems such as web servers and applications. It is not intended for use in desktop and embedded systems applications.
## Supported Node versions
This version of the FeatBit OpenFeature provider is compatible with Node.js versions 16 and above.
## Getting started
### Installation
```bash
npm install @openfeature/server-sdk
npm install @featbit/node-server-sdk
npm install @featbit/openfeature-provider-node-server
```### Quick start
```js
import { OpenFeature, ProviderEvents } from '@openfeature/server-sdk';
import { FbProvider } from '@featbit/openfeature-provider-node-server';const provider = new FbProvider({
sdkKey: '',
streamingUri: '',
eventsUri: ''
});OpenFeature.setProvider(provider);
// If you need access to the FbClient, then you can use provider.getClient()
// Evaluations before the provider indicates it is ready may get default values with a
// CLIENT_NOT_READY reason.
OpenFeature.addHandler(ProviderEvents.Ready, (eventDetails) => {
console.log(`Changed ${eventDetails.flagsChanged}`);
});// The FeatBit provider supports the ProviderEvents.ConfigurationChanged event.
// The provider will emit this event for any flag key that may have changed (each event will contain
// a single key in the `flagsChanged` field).
OpenFeature.addHandler(ProviderEvents.ConfigurationChanged, async (eventDetails) => {
const client = OpenFeature.getClient();
const value = await client.getBooleanValue('ff1', false, {targetingKey: 'my-key'});
console.log({...eventDetails, value});
});// (async () => {
// // When the FeatBit provider is closed it will flush the events on the FbClient instance.
// // This can be useful for short lived processes.
// await OpenFeature.close();
// })();
```