Skip to content

Commit 320a845

Browse files
committed
Add example for configuring an explicit ProxyAgent.
1 parent 8896df1 commit 320a845

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

demos/example-node/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
BACKEND=http://localhost:6060
22
SYNC_SERVICE=http://localhost:8080
33
POWERSYNC_TOKEN=
4+
POWERSYNC_DEBUG=1

demos/example-node/src/main.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,24 @@ const main = async () => {
3333
});
3434
console.log(await db.get('SELECT powersync_rs_version();'));
3535

36-
await db.connect(new DemoConnector(), { connectionMethod: SyncStreamConnectionMethod.HTTP });
36+
await db.connect(new DemoConnector(), {
37+
connectionMethod: SyncStreamConnectionMethod.WEB_SOCKET
38+
});
39+
// Example using a proxy agent for more control over the connection:
40+
// const proxyAgent = new (await import('undici')).ProxyAgent({
41+
// uri: 'http://localhost:8080',
42+
// requestTls: {
43+
// ca: '<CA for the service>'
44+
// },
45+
// proxyTls: {
46+
// ca: '<CA for the proxy>'
47+
// }
48+
// });
49+
// await db.connect(new DemoConnector(), {
50+
// connectionMethod: SyncStreamConnectionMethod.WEB_SOCKET,
51+
// dispatcher: proxyAgent
52+
// });
53+
3754
await db.waitForFirstSync();
3855
console.log('First sync complete!');
3956

0 commit comments

Comments
 (0)