@launchdarkly/cloudflare-server-sdk 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +22 -14
- package/dist/cjs/package.json +1 -1
- package/dist/esm/package.json +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to the LaunchDarkly SDK for Cloudflare Workers will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org).
|
|
4
4
|
|
|
5
|
+
### Dependencies
|
|
6
|
+
|
|
7
|
+
* The following workspace dependencies were updated
|
|
8
|
+
* dependencies
|
|
9
|
+
* @launchdarkly/js-server-sdk-common-edge bumped from 0.0.2 to 0.0.3
|
|
10
|
+
|
|
5
11
|
## [0.0.2](https://github.com/launchdarkly/js-core/compare/cloudflare-server-sdk-v0.0.1...cloudflare-server-sdk-v0.0.2) (2023-04-20)
|
|
6
12
|
|
|
7
13
|
|
package/README.md
CHANGED
|
@@ -8,20 +8,13 @@ This library supports using Cloudflare [Workers KV](https://developers.cloudflar
|
|
|
8
8
|
|
|
9
9
|
For more information, see the [SDK features guide](https://docs.launchdarkly.com/sdk/features/storing-data).
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Install
|
|
12
12
|
|
|
13
13
|
```shell
|
|
14
14
|
npm i @launchdarkly/cloudflare-server-sdk
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
```shell
|
|
20
|
-
yarn add @launchdarkly/cloudflare-server-sdk
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
In `wrangler.toml` in your worker project turn on the Node.js compatibility flag.
|
|
24
|
-
This allows the SDK to use `node:events`:
|
|
17
|
+
Then turn on the Node.js compatibility flag in your `wrangler.toml`. This allows the SDK to use `node:events`:
|
|
25
18
|
|
|
26
19
|
```toml
|
|
27
20
|
compatibility_flags = [ "nodejs_compat" ]
|
|
@@ -29,15 +22,30 @@ compatibility_flags = [ "nodejs_compat" ]
|
|
|
29
22
|
|
|
30
23
|
## Quickstart
|
|
31
24
|
|
|
32
|
-
Initialize the ldClient with the [Cloudflare KV namespace](https://developers.cloudflare.com/workers/runtime-apis/kv#kv-bindings)
|
|
25
|
+
Initialize the ldClient with your client side sdk key and the [Cloudflare KV namespace](https://developers.cloudflare.com/workers/runtime-apis/kv#kv-bindings):
|
|
33
26
|
|
|
34
27
|
```typescript
|
|
35
|
-
import { init } from '@launchdarkly/cloudflare-server-sdk';
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
import { init as initLD } from '@launchdarkly/cloudflare-server-sdk';
|
|
29
|
+
|
|
30
|
+
export default {
|
|
31
|
+
async fetch(request: Request, env: Bindings): Promise<Response> {
|
|
32
|
+
const sdkKey = 'test-sdk-key';
|
|
33
|
+
const flagKey = 'testFlag1';
|
|
34
|
+
const context = { kind: 'user', key: 'test-user-key-1' };
|
|
35
|
+
|
|
36
|
+
// init the ldClient, wait and finally evaluate
|
|
37
|
+
const client = initLD(sdkKey, env.LD_KV);
|
|
38
|
+
await client.waitForInitialization();
|
|
39
|
+
const flagValue = await client.variation(flagKey, context, false);
|
|
40
|
+
|
|
41
|
+
return new Response(`${flagKey}: ${flagValue}`);
|
|
42
|
+
},
|
|
43
|
+
};
|
|
38
44
|
```
|
|
39
45
|
|
|
40
|
-
|
|
46
|
+
See the full [example app](https://github.com/launchdarkly/js-core/tree/main/packages/sdk/cloudflare/example).
|
|
47
|
+
|
|
48
|
+
Read the [complete reference guide for this SDK](https://docs.launchdarkly.com/sdk/server-side/cloudflare).
|
|
41
49
|
|
|
42
50
|
## Developing this SDK
|
|
43
51
|
|
package/dist/cjs/package.json
CHANGED
package/dist/esm/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@launchdarkly/cloudflare-server-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Cloudflare LaunchDarkly SDK",
|
|
5
5
|
"packageManager": "yarn@3.4.1",
|
|
6
6
|
"keywords": [
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@cloudflare/workers-types": "^4.20230321.0",
|
|
34
|
-
"@launchdarkly/js-server-sdk-common-edge": "0.0.
|
|
34
|
+
"@launchdarkly/js-server-sdk-common-edge": "0.0.3",
|
|
35
35
|
"crypto-js": "^4.1.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|