Skip to content

Commit f12ba2f

Browse files
committed
chore: add readme
1 parent 2aa298c commit f12ba2f

File tree

2 files changed

+71
-3
lines changed

2 files changed

+71
-3
lines changed

.github/component_owners.yml

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ components:
3030
- markphelps
3131
libs/providers/flipt-web:
3232
- markphelps
33+
libs/providers/unleash:
34+
- albertilagan
3335
libs/providers/unleash-web:
3436
- jarebudev
3537

libs/providers/unleash/README.md

+69-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,81 @@
11
# unleash Provider
22

3+
## About this provider
4+
5+
This provider is a community-developed implementation for Unleash which uses the official [Node Server-side SDK](https://docs.getunleash.io/reference/sdks/node).
6+
7+
### Concepts
8+
9+
- Boolean evaluation gets feature enabled status.
10+
- String, Number, and Object evaluation gets feature variant value.
11+
- Object evaluation should be used for JSON/CSV payloads in variants.
12+
313
## Installation
414

15+
```shell
16+
$ npm install @openfeature/unleash-provider @openfeature/server-sdk
517
```
6-
$ npm install @openfeature/unleash-provider
18+
19+
## Usage
20+
21+
To initialize the OpenFeature client with Unleash, you can use the following code snippets:
22+
23+
### Initialization
24+
25+
```ts
26+
import { UnleashProvider } from '@openfeature/unleash-provider';
27+
28+
const provider = new UnleashProvider({
29+
url: 'https://YOUR-API-URL',
30+
appName: 'your app',
31+
customHeaders: { Authorization: 'your api key' },
32+
});
33+
34+
await OpenFeature.setProviderAndWait(provider);
735
```
836

9-
## Building
37+
### Available Constructor Configuration Options
38+
39+
Unleash has a variety of configuration options that can be provided to the `UnleashProvider` constructor.
40+
41+
Please refer to the options described in the official [Node Server-side SDK](https://docs.getunleash.io/reference/sdks/node).
42+
43+
### After initialization
44+
45+
After the provider gets initialized, you can start evaluations of feature flags like so:
46+
47+
```ts
48+
// Get the client
49+
const client = await OpenFeature.getClient();
50+
51+
// You can now use the client to evaluate your flags
52+
const details = client.getBooleanValue('my-feature', false);
53+
```
54+
55+
The static evaluation context can be changed if needed
56+
57+
```ts
58+
const evaluationCtx: EvaluationContext = {
59+
usedId: 'theuser',
60+
currentTime: 'time',
61+
sessionId: 'theSessionId',
62+
remoteAddress: 'theRemoteAddress',
63+
environment: 'theEnvironment',
64+
appName: 'theAppName',
65+
aCustomProperty: 'itsValue',
66+
anotherCustomProperty: 'somethingForIt',
67+
};
68+
69+
// changes the static evaluation context for OpenFeature
70+
await OpenFeature.setContext(evaluationCtx);
71+
```
72+
73+
## Contribute
74+
75+
### Building
1076

1177
Run `nx package providers-unleash` to build the library.
1278

13-
## Running unit tests
79+
### Running unit tests
1480

1581
Run `nx test providers-unleash` to execute the unit tests via [Jest](https://jestjs.io).

0 commit comments

Comments
 (0)