https://github.com/wingify/vwo-openfeature-provider-node
Openfeature Provider for VWO Node SDK
https://github.com/wingify/vwo-openfeature-provider-node
Last synced: about 1 month ago
JSON representation
Openfeature Provider for VWO Node SDK
- Host: GitHub
- URL: https://github.com/wingify/vwo-openfeature-provider-node
- Owner: wingify
- License: apache-2.0
- Created: 2024-05-02T07:00:08.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-05-03T13:13:03.000Z (about 1 year ago)
- Last Synced: 2025-04-21T03:19:46.208Z (about 2 months ago)
- Language: TypeScript
- Homepage: https://developers.vwo.com/v2/docs/node-openfeature-provider
- Size: 18.6 KB
- Stars: 10
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
## VWO Openfeature Provider Node
[](https://www.npmjs.com/package/vwo-openfeature-provider-node)
[](http://www.apache.org/licenses/LICENSE-2.0)### Requirements
- Node 10+
### Installation
```bash
# via npm
npm install vwo-openfeature-provider-node --save# via yarn
yarn add vwo-openfeature-provider-node
```### Example
```javascript
const OpenFeature = require('@openfeature/server-sdk').OpenFeature;
const VWOProvider = require('vwo-openfeature-provider-node').VWOProvider;
const vwo = require('vwo-fme-node-sdk');async function start() {
const vwoClient = await vwo.init({
sdkKey: '',
accountId: ''
});
const context = {
user: {
id: 'unique-user-id',
},
};const provider = new VWOProvider(vwoClient);
OpenFeature.setProvider(provider);const newClient = OpenFeature.getClient();
newClient.setContext(context);console.log(
'BOOLEAN',
await newClient.getBooleanValue(
'unique-feature-key',
false,
Object.assign({}, context, { key: 'boolean_variable' }),
),
); //pass 'key' if you want to fetch value of a specific variable. Otherwise it will return feature on/off
console.log(
'STRING',
await newClient.getStringValue('unique-feature-key', '', Object.assign({}, context, { key: 'string-variable' })),
); //will return undefined without key
console.log(
'NUMERIC',
await newClient.getNumberValue('unique-feature-key', 10, Object.assign({}, context, { key: 'number-variable' })),
); //will return undefined without key
console.log(
'FLOAT',
await newClient.getNumberValue('unique-feature-key', 10.0, Object.assign({}, context, { key: 'float-variable' })),
); //will return undefined without key
console.log(
'JSON',
await newClient.getObjectValue('unique-feature-key', {}, Object.assign({}, context, { key: 'json-variable' })),
); //pass 'key' if you want to fetch value of a specific variable of type JSON. Otherwise it will return all the variables.
}start();
```### Scripts
1. Build - it will compile typescript and create minified version too
```
yarn run build
```2. Compile - convert typescript into javascript
```
yarn run tsc
```3. Prettier - beautify code
```
yarn run prettier
```4. Uglify - minify javascript code after compilation
```
yarn run uglify
```### Contributing
Please go through our [contributing guidelines](https://github.com/wingify/vwo-openfeature-provider-node/blob/master/CONTRIBUTING.md)
### Code of Conduct
[Code of Conduct](https://github.com/wingify/vwo-openfeature-provider-node/blob/master/CODE_OF_CONDUCT.md)
### License
[Apache License, Version 2.0](https://github.com/wingify/vwo-openfeature-provider-node/blob/master/LICENSE)
Copyright 2024 Wingify Software Pvt. Ltd.