Skip to content

Instantly share code, notes, and snippets.

@Hiweus
Last active May 22, 2025 11:51
Show Gist options
  • Save Hiweus/d432c87a0d0b97e327efa3df3a819ab0 to your computer and use it in GitHub Desktop.
Save Hiweus/d432c87a0d0b97e327efa3df3a819ab0 to your computer and use it in GitHub Desktop.

Revisions

  1. Hiweus revised this gist May 22, 2025. 1 changed file with 26 additions and 0 deletions.
    26 changes: 26 additions & 0 deletions consume.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    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))
    }
  2. Hiweus created this gist May 22, 2025.
    6 changes: 6 additions & 0 deletions run.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    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