Last active
May 22, 2025 11:51
-
-
Save Hiweus/d432c87a0d0b97e327efa3df3a819ab0 to your computer and use it in GitHub Desktop.
libsql docker setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createClient } from "@libsql/client"; | |
import crypto from 'node:crypto' | |
const turso = createClient({ | |
url: "http://127.0.1:8080", | |
authToken: "...JWT generated from private key consult https://gist.github.com/Hiweus/15e2f94fb831b6ee389a4f21c9b460d6", | |
}) | |
await turso.execute("create table if not exists user (id integer primary key autoincrement, name TEXT) strict") | |
for(let i = 0; i < 100; i++) { | |
await turso.execute( | |
"insert into user (name) values (?)", | |
[crypto.randomUUID()] | |
) | |
} | |
while(true) { | |
const { rows } = await turso.execute( | |
"select * from user where id = ? or name = ?", | |
[crypto.randomInt(0, 10000), crypto.randomUUID()] | |
) | |
console.log(rows) | |
await new Promise((resolve) => setTimeout(resolve, 10)) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker run -it -p 8080:8080 \ | |
-e SQLD_AUTH_JWT_KEY_FILE=/app/jwt_public.key \ | |
-e SQLD_DB_PATH=/app/database \ | |
-v ./jwt_public.key:/app/jwt_public.key \ | |
-v ./database:/app/database \ | |
ghcr.io/tursodatabase/libsql-server:41eae61 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment