Skip to content

[MAINT] readme modified #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,97 @@ To sign up, https://app.harness.io/auth/#/signup/

## Getting Started

### Setup

```npm install @harness/ff-nodejs-server-sdk```

### Import the package (CommonJS)

```
const { Client } = require('ff-nodejs-server-sdk');
```

### Import the package (ES modules)

```
import { Client } from 'ff-nodejs-server-sdk';
```

### Initialize

This is the most simple way to initialize SDK using only a server type key
```
const client = new Client('your server type SDK key');
```

Advanced initialization can be done using options
```
const client = new Client('your server type SDK key', {
enableStream: false
});
```

### Define a target
```
const target = {
identifier: 'harness',
name: 'Harness',
attributes: {}
};
```

### Evaluate the flag with default value set to false
```
const value = client.boolVariation('test', target, false);
```

### Shutting down SDK
```
client.close();
```

### Avaialable public methods
```
const value = client.boolVariation('test', target, false);
const value = client.stringVariation('test', target, 'BLACK');
const value = client.numberVariation('test', target, 1);
const value = client.jsonVariation('test', target, {});
```

### Avaialable options

```
baseUrl: string;
eventsUrl: string;
pollInterval: number;
eventsSyncInterval: number;
enableStream: boolean;
enableAnalytics: boolean;
cache: KeyValueStore;
store: KeyValueStore;
logger: Logger;
```

## Singleton example

```
import CfClient from 'ff-nodejs-server-sdk';

CfClient.init('your server type SDK key');

const FLAG_KEY = 'test_bool';
const target = {
identifier: 'harness',
name: 'Harness',
attributes: {}
};
const defaultValue = false;

setInterval(() => {
const value = CfClient.boolVariation(FLAG_KEY, target, defaultValue);
console.log("Evaluation for flag test and target none: ", value);
}, 10000);
```
## License

Licensed under the APLv2.
Expand Down
3 changes: 1 addition & 2 deletions example/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const pkg = require('ff-nodejs-server-sdk');
const { Client } = pkg;
const { Client } = require('ff-nodejs-server-sdk');

const client = new Client('1c100d25-4c3f-487b-b198-3b3d01df5794');

Expand Down
1 change: 0 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export interface Options {
baseUrl?: string;
eventsUrl?: string;
pollInterval?: number;
persistInterval?: number;
eventsSyncInterval?: number;
enableStream?: boolean;
enableAnalytics?: boolean;
Expand Down