@oceanum/datamesh 0.5.0 → 0.5.2

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/README.md CHANGED
@@ -28,4 +28,25 @@ const data = await datamesh.query(query);
28
28
  ```
29
29
 
30
30
  [!WARNING]
31
- DO NOT put your Datamesh token directly into browser code. For use in an SPA, you should forward your Datamesh request through a reverse proxy to conceal your token. Read the [library documentation](https://oceanum-js.oceanum.io/datamesh) to learn more.
31
+ DO NOT put your Datamesh token directly into browser code. For use in an SPA, you should forward your Datamesh request through a reverse proxy to conceal your token.
32
+
33
+ ## Using a Datamesh Proxy
34
+
35
+ If you are building a browser application, we recommend using a reverse proxy to keep your Datamesh token secret and to simplify CORS. This package includes an example Cloudflare Worker you can deploy quickly and configure the `Connector` to use.
36
+
37
+ - See the [proxy guide](./proxy/guide.md) for more information.
38
+
39
+ Quick setup:
40
+
41
+ ```ts
42
+ import { Connector } from "@oceanum/datamesh";
43
+
44
+ const PROXY_URL = "https://your-proxy.workers.dev"; // or your own domain
45
+
46
+ const datamesh = new Connector("proxy", {
47
+ service: PROXY_URL,
48
+ gateway: PROXY_URL,
49
+ });
50
+ ```
51
+
52
+ Deploy the example Worker at `proxy/cloudflare/index.js` and add a secret `DATAMESH_TOKEN` with your Datamesh token in the Worker settings.
package/dist/README.md CHANGED
@@ -28,4 +28,25 @@ const data = await datamesh.query(query);
28
28
  ```
29
29
 
30
30
  [!WARNING]
31
- DO NOT put your Datamesh token directly into browser code. For use in an SPA, you should forward your Datamesh request through a reverse proxy to conceal your token. Read the [library documentation](https://oceanum-js.oceanum.io/datamesh) to learn more.
31
+ DO NOT put your Datamesh token directly into browser code. For use in an SPA, you should forward your Datamesh request through a reverse proxy to conceal your token.
32
+
33
+ ## Using a Datamesh Proxy
34
+
35
+ If you are building a browser application, we recommend using a reverse proxy to keep your Datamesh token secret and to simplify CORS. This package includes an example Cloudflare Worker you can deploy quickly and configure the `Connector` to use.
36
+
37
+ - See the [proxy guide](./proxy/guide.md) for more information.
38
+
39
+ Quick setup:
40
+
41
+ ```ts
42
+ import { Connector } from "@oceanum/datamesh";
43
+
44
+ const PROXY_URL = "https://your-proxy.workers.dev"; // or your own domain
45
+
46
+ const datamesh = new Connector("proxy", {
47
+ service: PROXY_URL,
48
+ gateway: PROXY_URL,
49
+ });
50
+ ```
51
+
52
+ Deploy the example Worker at `proxy/cloudflare/index.js` and add a secret `DATAMESH_TOKEN` with your Datamesh token in the Worker settings.