@openfeature/config-cat-provider
Advanced tools
Comparing version 0.7.1 to 0.7.2
{ | ||
"name": "@openfeature/config-cat-provider", | ||
"version": "0.7.1", | ||
"version": "0.7.2", | ||
"scripts": { | ||
@@ -10,3 +10,3 @@ "publish-if-not-exists": "cp $NPM_CONFIG_USERCONFIG .npmrc && if [ \"$(npm show $npm_package_name@$npm_package_version version)\" = \"$(npm run current-version -s)\" ]; then echo 'already published, skipping'; else npm publish --access public; fi", | ||
"@openfeature/server-sdk": "^1.13.5", | ||
"configcat-node": "^11.0.0" | ||
"configcat-node": "^11.3.1" | ||
}, | ||
@@ -25,5 +25,6 @@ "exports": { | ||
"@openfeature/config-cat-core": "0.1.0", | ||
"configcat-common": "9.3.0", | ||
"configcat-js-ssr": "8.4.1" | ||
"configcat-common": "9.3.1", | ||
"configcat-js-ssr": "8.4.3", | ||
"events": "3.3.0" | ||
} | ||
} |
# ConfigCat Provider | ||
This provider is an implementation for [ConfigCat](https://configcat.com) a managed feature flag service. | ||
This is an OpenFeature provider implementation for using [ConfigCat](https://configcat.com), a managed feature flag service in Node.js applications. | ||
@@ -17,3 +17,3 @@ ## Installation | ||
The minimum required version of `configcat-node` currently is `11.0.0`. | ||
The minimum required version of `configcat-node` currently is `11.3.1`. | ||
@@ -35,18 +35,34 @@ ``` | ||
```javascript | ||
import { OpenFeature } from "@openfeature/server-sdk"; | ||
import { ConfigCatProvider } from '@openfeature/config-cat-provider'; | ||
// Create and set the provider. | ||
const provider = ConfigCatProvider.create('<sdk_key>'); | ||
OpenFeature.setProvider(provider); | ||
await OpenFeature.setProviderAndWait(provider); | ||
// Obtain a client instance and evaluate feature flags. | ||
const client = OpenFeature.getClient(); | ||
const value = await client.getBooleanValue('isAwesomeFeatureEnabled', false); | ||
console.log(`isAwesomeFeatureEnabled: ${value}`); | ||
// On application shutdown, clean up the OpenFeature provider and the underlying ConfigCat client. | ||
await OpenFeature.clearProviders(); | ||
``` | ||
### Example using different polling options and a setupHook | ||
### Example using a different polling mode and custom configuration | ||
```javascript | ||
import { OpenFeature } from "@openfeature/server-sdk"; | ||
import { ConfigCatProvider } from '@openfeature/config-cat-provider'; | ||
import { createConsoleLogger, LogLevel, PollingMode } from 'configcat-node'; | ||
// Create and set the provider. | ||
const provider = ConfigCatProvider.create('<sdk_key>', PollingMode.LazyLoad, { | ||
logger: createConsoleLogger(LogLevel.Info), | ||
setupHooks: (hooks) => hooks.on('clientReady', () => console.log('Client is ready!')), | ||
}); | ||
await OpenFeature.setProviderAndWait(provider); | ||
OpenFeature.setProvider(provider); | ||
// ... | ||
``` | ||
@@ -56,5 +72,5 @@ | ||
The OpenFeature Evaluation Context is mapped to the [ConfigCat user object](https://configcat.com/docs/advanced/user-object/). | ||
The OpenFeature Evaluation Context is mapped to the [ConfigCat User Object](https://configcat.com/docs/advanced/user-object/). | ||
The [ConfigCat user object](https://configcat.com/docs/advanced/user-object/) has three known attributes, | ||
The [ConfigCat User Object](https://configcat.com/docs/advanced/user-object/) has three predefined attributes, | ||
and allows for additional attributes. | ||
@@ -61,0 +77,0 @@ The following shows how the attributes are mapped: |
32201
154
6
+ Addedevents@3.3.0
+ Addedconfigcat-js-ssr@8.4.3(transitive)
+ Addedevents@3.3.0(transitive)
Updatedconfigcat-common@9.3.1
Updatedconfigcat-js-ssr@8.4.3