Updated from the example https://github.com/cloudflare/workers-rs
A todo list example featuring Turso and Cloudflare worker.
Create a turso database.
turso db create <db-name>
Get the database credentials:
# db url
turso db show --url <db-name>
# authentication token
turso db tokens create <db-name>
Store the credentials inside a .dev.vars
file next to your wrangler.toml:
LIBSQL_CLIENT_URL=
LIBSQL_CLIENT_TOKEN=
npx wrangler dev
Add a new task:
curl "http://localhost:8787/todos" \
-X POST \
-H 'Content-Type: application/json' \
-d '{"task": "Do task m"}'
Get the list of added tasks:
curl "http://localhost:8787/todos"
npx wrangler deploy
curl https://cloudflare-worker-rs-turso.petar-vasilev0727.workers.dev/todos