1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { runValAPIAuth } from "https://esm.town/v/stevekrouse/runValAPIAuth";
// grab the types off turso's client without importing it
let tursoImport = () => import("https://esm.sh/@libsql/client/web");
type createClient = Awaited<ReturnType<typeof tursoImport>>["createClient"];
export function turso(keys, handle?) {
let val = "@std.tursoAPI";
let f = (method) => (...args) =>
runValAPIAuth({
val,
args: [method, args],
keys,
handle,
});
return {
execute: f("execute") as ReturnType<createClient>["execute"],
batch: f("batch") as ReturnType<createClient>["batch"],
transaction: f("transaction") as ReturnType<createClient>["transaction"],
};
}
export const endpoint = function(req, res) {
res.end("hello, world!");
};