@launchdarkly/cloudflare-server-sdk 0.0.2 → 0.0.4
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 +13 -0
- package/README.md +33 -17
- 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,19 @@
|
|
|
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.4](https://github.com/launchdarkly/js-core/compare/cloudflare-server-sdk-v0.0.3...cloudflare-server-sdk-v0.0.4) (2023-04-26)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* Improve readme. ([50d8556](https://github.com/launchdarkly/js-core/commit/50d85561c5f7577e1ecdc64f919d753c5df66b39))
|
|
17
|
+
|
|
5
18
|
## [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
19
|
|
|
7
20
|
|
package/README.md
CHANGED
|
@@ -2,26 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
[![NPM][sdk-cloudflare-npm-badge]][sdk-cloudflare-npm-link]
|
|
4
4
|
[![Actions Status][sdk-cloudflare-ci-badge]][sdk-cloudflare-ci]
|
|
5
|
-
[![Documentation]
|
|
5
|
+
[![Documentation][sdk-cloudflare-ghp-badge]][sdk-cloudflare-ghp-link]
|
|
6
|
+
[![NPM][sdk-cloudflare-dm-badge]][sdk-cloudflare-npm-link]
|
|
7
|
+
[![NPM][sdk-cloudflare-dt-badge]][sdk-cloudflare-npm-link]
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
The LaunchDarkly Cloudflare SDK is designed primarily for use in multi-user Cloudflare workers. It follows the server-side LaunchDarkly model for multi-user contexts. It is not intended for use in desktop and embedded systems applications.
|
|
8
10
|
|
|
9
|
-
For more information, see the [
|
|
11
|
+
For more information, see the [complete reference guide for this SDK](https://docs.launchdarkly.com/sdk/server-side/cloudflare).
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
This SDK is a beta version and should not be considered ready for production use while this message is visible.
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
npm i @launchdarkly/cloudflare-server-sdk
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
or yarn:
|
|
15
|
+
## Install
|
|
18
16
|
|
|
19
17
|
```shell
|
|
20
|
-
|
|
18
|
+
npm i @launchdarkly/cloudflare-server-sdk
|
|
21
19
|
```
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
This allows the SDK to use `node:events`:
|
|
21
|
+
Then turn on the Node.js compatibility flag in your `wrangler.toml`. This allows the SDK to use `node:events`:
|
|
25
22
|
|
|
26
23
|
```toml
|
|
27
24
|
compatibility_flags = [ "nodejs_compat" ]
|
|
@@ -29,15 +26,30 @@ compatibility_flags = [ "nodejs_compat" ]
|
|
|
29
26
|
|
|
30
27
|
## Quickstart
|
|
31
28
|
|
|
32
|
-
Initialize the ldClient with the [Cloudflare KV namespace](https://developers.cloudflare.com/workers/runtime-apis/kv#kv-bindings)
|
|
29
|
+
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
30
|
|
|
34
31
|
```typescript
|
|
35
|
-
import { init } from '@launchdarkly/cloudflare-server-sdk';
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
import { init as initLD } from '@launchdarkly/cloudflare-server-sdk';
|
|
33
|
+
|
|
34
|
+
export default {
|
|
35
|
+
async fetch(request: Request, env: Bindings): Promise<Response> {
|
|
36
|
+
const sdkKey = 'test-sdk-key';
|
|
37
|
+
const flagKey = 'testFlag1';
|
|
38
|
+
const context = { kind: 'user', key: 'test-user-key-1' };
|
|
39
|
+
|
|
40
|
+
// init the ldClient, wait and finally evaluate
|
|
41
|
+
const client = initLD(sdkKey, env.LD_KV);
|
|
42
|
+
await client.waitForInitialization();
|
|
43
|
+
const flagValue = await client.variation(flagKey, context, false);
|
|
44
|
+
|
|
45
|
+
return new Response(`${flagKey}: ${flagValue}`);
|
|
46
|
+
},
|
|
47
|
+
};
|
|
38
48
|
```
|
|
39
49
|
|
|
40
|
-
|
|
50
|
+
See the full [example app](https://github.com/launchdarkly/js-core/tree/main/packages/sdk/cloudflare/example).
|
|
51
|
+
|
|
52
|
+
Read the [complete reference guide for this SDK](https://docs.launchdarkly.com/sdk/server-side/cloudflare).
|
|
41
53
|
|
|
42
54
|
## Developing this SDK
|
|
43
55
|
|
|
@@ -67,3 +79,7 @@ yarn test
|
|
|
67
79
|
[sdk-cloudflare-ci]: https://github.com/launchdarkly/js-core/actions/workflows/cloudflare.yml
|
|
68
80
|
[sdk-cloudflare-npm-badge]: https://img.shields.io/npm/v/@launchdarkly/cloudflare-server-sdk.svg?style=flat-square
|
|
69
81
|
[sdk-cloudflare-npm-link]: https://www.npmjs.com/package/@launchdarkly/cloudflare-server-sdk
|
|
82
|
+
[sdk-cloudflare-ghp-badge]: https://img.shields.io/static/v1?label=GitHub+Pages&message=API+reference&color=00add8
|
|
83
|
+
[sdk-cloudflare-ghp-link]: https://launchdarkly.github.io/js-core/packages/sdk/cloudflare/docs/
|
|
84
|
+
[sdk-cloudflare-dm-badge]: https://img.shields.io/npm/dm/@launchdarkly/cloudflare-server-sdk.svg?style=flat-square
|
|
85
|
+
[sdk-cloudflare-dt-badge]: https://img.shields.io/npm/dt/@launchdarkly/cloudflare-server-sdk.svg?style=flat-square
|
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.4",
|
|
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": {
|