Skip to content

Commit 7cc3e2a

Browse files
Drivers page to connect via wss: socket
1 parent 61fa044 commit 7cc3e2a

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

public/drivers.html

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
</head>
99

1010
<body class="p-4">
11-
<h1>SQLite Cloud Driver</h1>
12-
<div class="pb-6">
13-
<a href="https://www.npmjs.com/package/sqlitecloud">npm sqlitecloud</a>
11+
<h1>SQLite Cloud Drivers</h1>
12+
<div class="pb-6 text-sm">
13+
<a href="https://www.npmjs.com/package/@sqlitecloud/drivers">npm add @sqlitecloud/drivers</a>
1414
</div>
1515

1616
<!-- Add the text field and button here -->
1717
<div class="pb-2">
18-
<div class="text-sm w-12">connectionString:</div>
18+
<div class="text-xs w-12">databaseUrl</div>
1919
<input
2020
type="text"
2121
id="connectionStringInput"
@@ -65,7 +65,13 @@ <h2 class="pb-4">Results:</h2>
6565

6666
sendButton.addEventListener('click', () => {
6767
if (!database) {
68-
database = new window.sqlitecloud.Database(connectionString, error => {
68+
// connect via websocket to the gateway on the same server
69+
const connectionConfig = {
70+
gatewayUrl: `${window.location.protocol === 'https:' ? 'wss' : 'ws'}://${window.location.hostname}:4000`,
71+
connectionString
72+
}
73+
74+
database = new window.sqlitecloud.Database(connectionConfig, error => {
6975
if (error) {
7076
database = null
7177
appendMessage(`connection error: ${error}`)

public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ <h2>Messages:</h2>
111111
socket = setupSocket()
112112
}
113113
socket.emit('v1/info', {}, response => {
114-
appendMessage(`info | rss: ${(response.data.rss / 1024 / 1024).toFixed(2)}mb, ${JSON.stringify(response)}`)
114+
appendMessage(`info | heapSize: ${(response.data.memory.heapSize / 1024 / 1024).toFixed(2)}mb, ${JSON.stringify(response)}`)
115115
})
116116
})
117117
</script>

0 commit comments

Comments
 (0)