13 const navLinks = [
14 { name: "Farcaster SDK", path: "/" },
15 { name: "Database", path: "/db" },
16 { name: "About", path: "/about" },
17 ];
35 <Routes>
36 <Route path="/" element={<FarcasterMiniApp />} />
37 <Route path="/db" element={<Database />} />
38 <Route path="/about" element={<About />} />
39 <Route path="/neynar" element={<Neynar />} />
50 <div className="">✷ Hono + React + Tailwind</div>
51 <div className="">✷ React Router + React Query</div>
52 <div className="">✷ Built-in database (blob storage)</div>
53 <div className="">✷ Farcaster mini app manifest + webhook + embed metadata</div>
54 <div className="">✷ Farcaster notifications (storing tokens, sending recurring notifications, ...)</div>
66}
67
68function Database() {
69 const queryFn = () => fetch("/api/counter/get").then((r) => r.json());
70 const { data, refetch } = useQuery({ queryKey: ["counter"], queryFn });
71 return (
72 <Section className="flex flex-col items-start gap-3 m-5">
73 {/* <h2 className="font-semibold">Database Example</h2> */}
74 <div className="">Counter value: {data}</div>
75 <Button variant="outline" onClick={() => fetch("/api/counter/increment").then(refetch)}>
19export async function createMeetingPage(data: MeetingPageData): Promise<string> {
20 const notionApiKey = Deno.env.get("NOTION_API_KEY");
21 const databaseId = Deno.env.get("NOTION_DATABASE_ID");
22
23 if (!notionApiKey || !databaseId) {
24 throw new Error("Missing Notion API credentials in environment variables");
25 }
50 // Prepare the content for the Notion page
51 const pageContent = {
52 parent: { database_id: databaseId },
53 properties: {
54 title: {
19export async function createMeetingPage(data: MeetingPageData): Promise<string> {
20 const notionApiKey = Deno.env.get("NOTION_API_KEY");
21 const databaseId = Deno.env.get("NOTION_DATABASE_ID");
22
23 if (!notionApiKey || !databaseId) {
24 throw new Error("Missing Notion API credentials in environment variables");
25 }
50 // Prepare the content for the Notion page
51 const pageContent = {
52 parent: { database_id: databaseId },
53 properties: {
54 title: {
46 }
47
48 // Now it's time to upload things to database and blob storage
49 // First, add to database, and get the ID
50 const id = await sqlite.execute(
51 `INSERT INTO ${TABLE_NAME} (title, data, type, time) VALUES ($title, $data, $type, CURRENT_TIMESTAMP)`,
263 `);
264 } catch (error) {
265 console.error("Database initialization error:", error);
266 return new Response(`Database error: ${error.message}`, { status: 500 });
267 }
268
202 `);
203 } catch (error) {
204 console.error("Database initialization error:", error);
205 return new Response(`Database error: ${error.message}`, { status: 500 });
206 }
207
64 const { blob } = await import("https://esm.town/v/std/blob");
65
66 // Unique key for this val's database tables
67 const KEY = "AI_generated_Pictures";
68 const SCHEMA_VERSION = 1;
1import { serveFile } from "https://esm.town/v/std/utils/index.ts";
2import { generateCode } from "./backend/generate-code.ts";
3import { createTables } from "./database/migrations.ts";
4import { createProject, getCode, getNextVersionNumber, insertVersion } from "./database/queries.ts";
5
6await createTables();
1209 throw new Error("Notion API token not found");
1210 }
1211 const databaseId = "16e2c190bff080fd9ea8d2a8c21548b0";
1212
1213 // Use database query with filter instead of direct page fetch
1214 const response = await fetch(`https://api.notion.com/v1/databases/${databaseId}/query`, {
1215 method: "POST",
1216 headers: {
1247
1248 if (!response.ok) {
1249 throw new Error(`Failed to query Notion database: ${response.statusText}`);
1250 }
1251
379];
380
381// Insert memories into the database
382async function insertDemoMemories() {
383 try {
420 await insertDemoMemories();
421
422 console.log("Demo database successfully populated!");
423 return "Demo database successfully populated!";
424 } catch (error) {
425 console.error("Error populating demo database:", error);
426 throw error;
427 }