1// Import drizzle deps with npm: specifier because exports don't get picked up properly by typescript when using esm.sh
2import { drizzle, type LibSQLDatabase } from "npm:drizzle-orm@0.39.3/libsql";
3import { and, eq, desc, relations, sql } from "npm:drizzle-orm@0.39.3";
4import { integer, sqliteTable, text } from "npm:drizzle-orm@0.39.3/sqlite-core";
5
6export { drizzle };
7export type { LibSQLDatabase };
8export { and, eq, desc, relations, sql };
9export { integer, sqliteTable, text };
1import { generateCode } from "./backend/generate-code";
2import { createTables } from "./database/migrations";
3import { createProject, getCode, getNextVersionNumber, insertVersion } from "./database/queries";
4
5async function servePublicFile(path: string): Promise<Response> {
1import { generateCode } from "./backend/generate-code";
2import { createTables } from "./database/migrations";
3import { createProject, getCode, getNextVersionNumber, insertVersion } from "./database/queries";
4
5async function servePublicFile(path: string): Promise<Response> {
7The **client-side entrypoint** is `/frontend/index.html`, which in turn imports `/frontend/index.tsx`, which in turn imports the React app from `/frontend/components/App.tsx`.
8
9[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.
7The **client-side entrypoint** is `/frontend/index.html`, which in turn imports `/frontend/index.tsx`, which in turn imports the React app from `/frontend/components/App.tsx`.
8
9[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.
1import { generateCode } from "./backend/generate-code";
2import { createTables } from "./database/migrations";
3import { createProject, getCode, getNextVersionNumber, insertVersion } from "./database/queries";
4
5async function servePublicFile(path: string): Promise<Response> {
13 todayHits = hits.todayHits;
14 } catch (e) {
15 console.log("Caught database error: ", e);
16 }
17 return new Response(
5import ValTown from "npm:@valtown/sdk";
6import SocialData from "../sdk/index.ts";
7import { setupDatabase, USAGE_TABLE } from "./database.ts";
8import { searchTwitterRoute } from "./routes/search.ts";
9
14
15// Uncomment this if you're forking this project:
16// await setupDatabase()
17
18// https://socialdata.gitbook.io/docs/pricing
5import ValTown from "npm:@valtown/sdk";
6import SocialData from "../sdk/index.ts";
7import { setupDatabase, USAGE_TABLE } from "./database.ts";
8import { searchTwitterRoute } from "./routes/search.ts";
9
14
15// Uncomment this if you're forking this project:
16// await setupDatabase()
17
18// https://socialdata.gitbook.io/docs/pricing
3export const USAGE_TABLE = "socialDataProxy_usage_2";
4
5export async function setupDatabase() {
6 await sqlite.execute(`
7 CREATE TABLE IF NOT EXISTS ${USAGE_TABLE} (