Code
HTTP
import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo?v=26";
import { Statement } from "https://esm.town/v/postpostscript/sqliteBuilder";
import { sqliteDump } from "https://esm.town/v/postpostscript/sqliteDump";
import { createSqlite } from "https://esm.town/v/postpostscript/sqliteWasm";
import type { InStatement } from "https://esm.town/v/std/sqlite";
import { createServer } from "https://esm.town/v/vladimyr/sqliteServer";
import { toHonoHandler } from "https://esm.town/v/vladimyr/toHonoHandler";
import { type ResultSet } from "npm:@libsql/client";
import { Hono } from "npm:hono";
import ky from "npm:ky";
const dumped = {
tables: ["authIdExampleComments_comment"],
subset: {
authIdExampleComments_comment:
Statement`SELECT * FROM authIdExampleComments_comment WHERE username = "postpostscript"`,
},
};
const sqliteServer = createServer(async () => {
const dump = await sqliteDump(dumped);
const sqlite = createSqlite();
sqlite.batch(dump);
return sqlite;
});
const app = new Hono();
app.post("/execute", toHonoHandler(sqliteServer.handleExecute));
app.post("/batch", toHonoHandler(sqliteServer.handleBatch));
export default app.fetch;
export const { httpEndpoint: ENDPOINT } = extractValInfo(import.meta.url);
export const sqlitePublic = {
execute,
batch,
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
vladimyr-sqlitepublic.web.val.run
Updated: March 8, 2024