24 return fetchCreations(req);
25
26 if (req.method == "POST" && url.pathname == "/updateDatabase")
27 return updateTable(req);
28
1import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
2import { updateTable } from "./database";
3
4export default async function(req: Request): Promise<Response> {
2import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
3
4import { TABLE_NAME } from "./database";
5
6export default async function(req: Request): Promise<Response> {
2import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
3
4import { TABLE_NAME } from "./database";
5
6export default async function(req: Request): Promise<Response> {
5/**
6 * Every Val Town account comes with its own private
7 * [SQLite database](https://www.sqlite.org/) that
8 * is accessible from any of your vals.
9 * ([Docs ↗](https://docs.val.town/std/sqlite))
118
119// adapted from
120// https://github.com/tursodatabase/libsql-client-ts/blob/17dd996b840c950dd22b871adfe4ba0eb4a5ead3/packages/libsql-client/src/sqlite3.ts#L314C1-L337C2
121function rowFromSql(
122 sqlRow: Array<unknown>,
372 const url = new URL(request.url);
373
374 // Initialize database tables
375 await sqlite.execute(`
376 CREATE TABLE IF NOT EXISTS ${KEY}_items_${SCHEMA_VERSION} (
9- The **client-side entrypoint** is `/frontend/index.html`, which in turn imports `/frontend/index.tsx`, which in turn imports the React app from `/frontend/App.tsx`.
10
11[React Hono Example](https://www.val.town/x/stevekrouse/reactHonoExample) is a fuller featured example project, with a SQLite database table, queries, client-side CSS and a favicon, and some shared code that runs on both client and server.
30- [ ] add triggers to sidebar
31- [ ] add upload from SQL, CSV and JSON
32- [ ] add ability to connect to a non-val town Turso database
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable
9- [ ] make it one click to branch off like old jp townie demos
10- [ ] opentownie as a pr bot
11- [ ] give it the ability to see its own client-side and server-side logs by building a middleware that shoves them into a SQL light database date and then give it a tool to access them
12- [ ] do a browser use or screenshot thing to give it access to its own visual output
13- [ ] Have it default to creating a new branch off main
7export const thinkTool = tool({
8 description:
9 "Use the tool to think about something. It will not obtain new information or change the database, but just append the thought to the log. Use it when complex reasoning or some cache memory is needed.",
10 parameters: z.object({
11 thought: z.string().describe("A thought to think about."),