Skip to content

Commit bfc30ba

Browse files
authored
Most basic open feature provider for node. (#1)
1 parent 01ee2a8 commit bfc30ba

16 files changed

+873
-0
lines changed

.eslintrc.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module.exports = {
2+
env: {
3+
node: true,
4+
},
5+
extends: [
6+
'airbnb-base',
7+
'airbnb-typescript/base'
8+
],
9+
parser: '@typescript-eslint/parser',
10+
parserOptions: {
11+
project: './tsconfig.eslint.json'
12+
},
13+
plugins: [
14+
'@typescript-eslint',
15+
],
16+
ignorePatterns: ["**/dist/**"],
17+
rules: {
18+
},
19+
};

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package-lock.json
2+
dist/
3+
node_modules/
4+
coverage/

CONTRIBUTING.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Contributing to the LaunchDarkly OpenFeature provider for the Server-Side SDK for Node.js
2+
3+
LaunchDarkly has published an [SDK contributor's guide](https://docs.launchdarkly.com/sdk/concepts/contributors-guide) that provides a detailed explanation of how our SDKs work. See below for additional information on how to contribute to this provider.
4+
5+
## Submitting bug reports and feature requests
6+
7+
The LaunchDarkly SDK team monitors the [issue tracker](https://github.com/launchdarkly/open-feature-node/issues) in the provider repository. Bug reports and feature requests specific to this provider should be filed in this issue tracker. The SDK team will respond to all newly filed issues within two business days.
8+
9+
## Submitting pull requests
10+
11+
We encourage pull requests and other contributions from the community. Before submitting pull requests, ensure that all temporary or unintended code is removed. Don't worry about adding reviewers to the pull request; the LaunchDarkly SDK team will add themselves. The SDK team will acknowledge all pull requests within two business days.
12+
13+
## Build instructions
14+
15+
### Prerequisites
16+
17+
The project should be built and tested against the lowest compatible version, Node 16. It uses `npm`, which is bundled in all supported versions of Node.
18+
19+
### Setup
20+
21+
To install project dependencies, from the project root directory:
22+
23+
```
24+
npm install
25+
```
26+
27+
### Testing
28+
29+
To run all unit tests:
30+
31+
```
32+
npm test
33+
```

LICENSE.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2022 Catamorphic, Co.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# LaunchDarkly OpenFeature provider for the Server-Side SDK for Node.js
2+
3+
This provider allows for using LaunchDarkly with the OpenFeature Node SDK.
4+
5+
This provider is designed primarily for use in multi-user systems such as web servers and applications. It follows the server-side LaunchDarkly model for multi-user contexts. It is not intended for use in desktop and embedded systems applications.
6+
7+
# LaunchDarkly overview
8+
9+
[LaunchDarkly](https://www.launchdarkly.com) is a feature management platform that serves over 100 billion feature flags daily to help teams build better software, faster. [Get started](https://docs.launchdarkly.com/home/getting-started) using LaunchDarkly today!
10+
11+
[![Twitter Follow](https://img.shields.io/twitter/follow/launchdarkly.svg?style=social&label=Follow&maxAge=2592000)](https://twitter.com/intent/follow?screen_name=launchdarkly)
12+
13+
## Supported Node versions
14+
15+
This version of the LaunchDarkly OpenFeature provider is compatible with Node.js versions 16 and above.
16+
17+
## Getting started
18+
19+
### Installation
20+
21+
```
22+
npm install @openfeature/nodejs-sdk
23+
npm install launchdarkly-node-server-sdk
24+
npm install @launchdarkly/open-feature-node
25+
```
26+
27+
### Usage
28+
```
29+
import { OpenFeature } from '@openfeature/nodejs-sdk';
30+
import { init } from 'launchdarkly-node-server-sdk';
31+
import { LaunchDarklyProvider } from 'open-feature-node';
32+
33+
34+
const ldClient = init('<your-sdk-key>');
35+
await ldClient.waitForInitialization();
36+
OpenFeature.setProvider(new LaunchDarklyProvider(ldClient));
37+
const client = OpenFeature.getClient();
38+
const value = await client.getBooleanValue('app-enabled', false, {targetingKey: 'my-key'});
39+
```
40+
41+
Refer to the [SDK reference guide](https://docs.launchdarkly.com/sdk/server-side/node-js) for instructions on getting started with using the SDK.
42+
43+
## OpenFeature Specific Considerations
44+
45+
When evaluating an `LDUser` with the LaunchDarkly Node SDK a string `key` attribute would normally be required. When using OpenFeature the `targetingKey` attribute should be used instead of `key`. If a `key` attribute is provided in the `EvaluationContext`, then it will be discarded in favor of `targetingKey`. If a `targetingKey` is not provided, or if the `EvaluationContext` is omitted entirely, then the `defaultValue` will be returned from OpenFeature evaluation methods.
46+
47+
Other fields normally included in an `LDUser` may be added to the `EvaluationContext`. Any `custom` attributes can
48+
be added to the top level of the evaluation context, and they will operate as if they were `custom` attributes on an `LDUser`. Attributes which are typically top level on an `LDUser` should be of the same types that are specified for
49+
an `LDUser` or they will not operate as intended.
50+
51+
If a top level `custom` attribute is defined on the `EvaluationContext`, then that will be a `custom` attribute inside `custom` for an `LDUser`.
52+
53+
If a custom attribute is provided, whose value is an object, then that attribute will be discarded.
54+
55+
## Learn more
56+
57+
Check out our [documentation](http://docs.launchdarkly.com) for in-depth instructions on configuring and using LaunchDarkly. You can also head straight to the [complete reference guide for this SDK](https://docs.launchdarkly.com/sdk/server-side/node-js).
58+
59+
The authoritative description of all properties and methods is in the [TypeScript documentation](https://launchdarkly.github.io/node-server-sdk/).
60+
61+
## Contributing
62+
63+
We encourage pull requests and other contributions from the community. Check out our [contributing guidelines](CONTRIBUTING.md) for instructions on how to contribute to this SDK.
64+
65+
## About LaunchDarkly
66+
67+
* LaunchDarkly is a continuous delivery platform that provides feature flags as a service and allows developers to iterate quickly and safely. We allow you to easily flag your features and manage them from the LaunchDarkly dashboard. With LaunchDarkly, you can:
68+
* Roll out a new feature to a subset of your users (like a group of users who opt-in to a beta tester group), gathering feedback and bug reports from real-world use cases.
69+
* Gradually roll out a feature to an increasing percentage of users, and track the effect that the feature has on key metrics (for instance, how likely is a user to complete a purchase if they have feature A versus feature B?).
70+
* Turn off a feature that you realize is causing performance problems in production, without needing to re-deploy, or even restart the application with a changed configuration file.
71+
* Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan). Disable parts of your application to facilitate maintenance, without taking everything offline.
72+
* LaunchDarkly provides feature flag SDKs for a wide variety of languages and technologies. Check out [our documentation](https://docs.launchdarkly.com/sdk) for a complete list.
73+
* Explore LaunchDarkly
74+
* [launchdarkly.com](https://www.launchdarkly.com/ "LaunchDarkly Main Website") for more information
75+
* [docs.launchdarkly.com](https://docs.launchdarkly.com/ "LaunchDarkly Documentation") for our documentation and SDK reference guides
76+
* [apidocs.launchdarkly.com](https://apidocs.launchdarkly.com/ "LaunchDarkly API Documentation") for our API documentation
77+
* [blog.launchdarkly.com](https://blog.launchdarkly.com/ "LaunchDarkly Blog Documentation") for the latest product updates

0 commit comments

Comments
 (0)