@launchdarkly/cloudflare-server-sdk 0.0.1 → 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 CHANGED
@@ -2,6 +2,26 @@
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
+
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)
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * semver util import error ([#90](https://github.com/launchdarkly/js-core/issues/90)) ([b70015a](https://github.com/launchdarkly/js-core/commit/b70015a86b460e8cdc3ee4fff8b339955bd95099))
17
+
18
+
19
+ ### Dependencies
20
+
21
+ * The following workspace dependencies were updated
22
+ * dependencies
23
+ * @launchdarkly/js-server-sdk-common-edge bumped from 0.0.1 to 0.0.2
24
+
5
25
  ## 0.0.1 (2023-04-19)
6
26
 
7
27
 
package/README.md CHANGED
@@ -1,36 +1,51 @@
1
1
  # LaunchDarkly Cloudflare SDK
2
2
 
3
- [![NPM][sdk-server-cloudflare-npm-badge]][sdk-server-cloudflare-npm-link]
4
- [![Actions Status][sdk-server-cloudflare-ci-badge]][sdk-server-cloudflare-ci]
5
- [![Documentation](https://img.shields.io/static/v1?label=GitHub+Pages&message=API+reference&color=00add8)](https://launchdarkly.github.io/js-core/packages/sdk/server-cloudflare/docs/)
3
+ [![NPM][sdk-cloudflare-npm-badge]][sdk-cloudflare-npm-link]
4
+ [![Actions Status][sdk-cloudflare-ci-badge]][sdk-cloudflare-ci]
5
+ [![Documentation](https://img.shields.io/static/v1?label=GitHub+Pages&message=API+reference&color=00add8)](https://launchdarkly.github.io/js-core/packages/sdk/cloudflare/docs/)
6
6
 
7
7
  This library supports using Cloudflare [Workers KV](https://developers.cloudflare.com/workers/learning/how-kv-works) to replace the default in-memory feature store of the [LaunchDarkly Node.js SDK](https://github.com/launchdarkly/cloudflare-server-sdk).
8
8
 
9
9
  For more information, see the [SDK features guide](https://docs.launchdarkly.com/sdk/features/storing-data).
10
10
 
11
- ## Installation
11
+ ## Install
12
12
 
13
13
  ```shell
14
14
  npm i @launchdarkly/cloudflare-server-sdk
15
15
  ```
16
16
 
17
- or yarn:
17
+ Then turn on the Node.js compatibility flag in your `wrangler.toml`. This allows the SDK to use `node:events`:
18
18
 
19
- ```shell
20
- yarn add -D @launchdarkly/cloudflare-server-sdk
19
+ ```toml
20
+ compatibility_flags = [ "nodejs_compat" ]
21
21
  ```
22
22
 
23
23
  ## Quickstart
24
24
 
25
- Initialize the ldClient with the [Cloudflare KV namespace](https://developers.cloudflare.com/workers/runtime-apis/kv#kv-bindings) and your client side sdk key:
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):
26
26
 
27
27
  ```typescript
28
- import { init } from '@launchdarkly/cloudflare-server-sdk';
29
-
30
- const ldClient = init(KV_NAMESPACE, 'YOUR CLIENT-SIDE SDK KEY');
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
+ };
31
44
  ```
32
45
 
33
- To learn more, head straight to the [complete reference guide for this SDK](https://docs.launchdarkly.com/sdk/server-side/cloudflare).
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).
34
49
 
35
50
  ## Developing this SDK
36
51
 
@@ -55,3 +70,8 @@ yarn test
55
70
  - [docs.launchdarkly.com](https://docs.launchdarkly.com/ 'LaunchDarkly Documentation') for our documentation and SDK reference guides
56
71
  - [apidocs.launchdarkly.com](https://apidocs.launchdarkly.com/ 'LaunchDarkly API Documentation') for our API documentation
57
72
  - [blog.launchdarkly.com](https://blog.launchdarkly.com/ 'LaunchDarkly Blog Documentation') for the latest product updates
73
+
74
+ [sdk-cloudflare-ci-badge]: https://github.com/launchdarkly/js-core/actions/workflows/cloudflare.yml/badge.svg
75
+ [sdk-cloudflare-ci]: https://github.com/launchdarkly/js-core/actions/workflows/cloudflare.yml
76
+ [sdk-cloudflare-npm-badge]: https://img.shields.io/npm/v/@launchdarkly/cloudflare-server-sdk.svg?style=flat-square
77
+ [sdk-cloudflare-npm-link]: https://www.npmjs.com/package/@launchdarkly/cloudflare-server-sdk
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@launchdarkly/cloudflare-server-sdk",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "type": "commonjs"
5
5
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@launchdarkly/cloudflare-server-sdk",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "type": "module"
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@launchdarkly/cloudflare-server-sdk",
3
- "version": "0.0.1",
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.1",
34
+ "@launchdarkly/js-server-sdk-common-edge": "0.0.3",
35
35
  "crypto-js": "^4.1.1"
36
36
  },
37
37
  "devDependencies": {