7const app = new Hono();
89// Initialize database (if needed)
10const db = getDb('template');
1112// Create schema if needed
13app.use('*', async (c, next) => {
14// Uncomment and modify if you need database tables
15/*
16await db.execute(`
7const app = new Hono();
89// Initialize database
10const db = getDb('notes');
1160}
61
62// Get notes from database
63const result = await db.execute(
64'SELECT id, title, content, created_at, updated_at FROM {{table}} WHERE email = ? ORDER BY updated_at DESC',
1/**
2* Shared database utilities
3* Each app can choose to use this or manage its own database operations
4*/
56import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
78// Base key for database tables to avoid conflicts
9const KEY_PREFIX = 'charbuild';
1011/**
12* Creates a database interface for a specific app
13* @param {string} appName - The name of the app (used for table prefixing)
14* @param {number} schemaVersion - The schema version for the app
15* @returns {Object} Database interface object
16*/
17export function getDb(appName, schemaVersion = 1) {
queryParamsNotEncodedRepromain.tsx9 matches
5const respWithoutError = await vt.projects.files.retrieve(
6"3fed38fa-00e9-11f0-99ff-569c3dd06744",
7"backend%2Fdatabase%2Fmigrations.ts", // <-- URI encoded
8{ limit: 10, offset: 0 },
9);
14const respWithError = await vt.projects.files.retrieve(
15"3fed38fa-00e9-11f0-99ff-569c3dd06744",
16"backend/database/migrations.ts", // <-- not URI encoded
17{ limit: 10, offset: 0 },
18);
28// id: "412a62a6-00e9-11f0-bbde-569c3dd06744",
29// parentId: "ba51ef61-14d6-4805-b94b-9d6c8b42e4e9",
30// path: "backend/database/migrations.ts",
31// version: 27,
32// updatedAt: "2025-03-14T19:26:35.553Z",
33// type: "script",
34// links: {
35// self: "https://api.val.town/v1/projects/3fed38fa-00e9-11f0-99ff-569c3dd06744/files/backend/database/migrations.ts",
36// html: "https://www.val.town/x/shouser/project_updates_webhook/code/backend/database/migrations.ts",
37// module: "https://esm.town/v/shouser/project_updates_webhook/backend/database/migrations.ts"
38// }
39// }
40// ],
41// links: {
42// self: "https://api.val.town/v1/projects/3fed38fa-00e9-11f0-99ff-569c3dd06744/files/backend%2Fdatabase%2Fmigrations.ts?limit=10&offset=0"
43// }
44// }
45// Not URI encoding causes error: Error: 404 Route GET:/v1/projects/3fed38fa-00e9-11f0-99ff-569c3dd06744/files/backend/database/migrations.ts?limit=10&offset=0 not found
46// at Function.generate (file:///opt/render/.cache/deno/npm/registry.npmjs.org/@valtown/sdk/0.36.0/error.mjs:45:20)
47// at ValTown.makeStatusError (file:///opt/render/.cache/deno/npm/registry.npmjs.org/@valtown/sdk/0.36.0/core.mjs:272:25)
57// },
58// error: {
59// message: "Route GET:/v1/projects/3fed38fa-00e9-11f0-99ff-569c3dd06744/files/backend/database/migrations.ts?limit=10&offset=0 not found",
60// error: "Not Found",
61// statusCode: 404
charlieMultiappindex.ts5 matches
2import { MainLayout } from '../../layouts/MainLayout';
3import { AppConfig, AppContext } from '../registry';
4import { initAppDatabase } from '../../utils/db';
5import { sqlite } from "https://esm.town/v/std/sqlite";
680`;
8182// Setup database schema
83const SCHEMA = `
84CREATE TABLE IF NOT EXISTS questie_quests (
92`;
9394// Initialize the database
95initAppDatabase('questie', SCHEMA);
9697// Questie app handler
115const status = formData.get('status') || 'pending';
116
117// Save the new quest to database
118await sqlite.execute(
119`INSERT INTO questie_quests (email, title, description, status) VALUES (?, ?, ?, ?)`,
charlieMultiappDetail.ts1 match
89export async function QuestieDetail({ email, questId }: QuestieDetailProps) {
10// Fetch quest details from the database
11let quest = null;
12
charlieMultiappList.ts1 match
78export async function QuestieList({ email }: QuestieListProps) {
9// Fetch quests from the database
10let quests = [];
11try {
charlieMultiappdb.ts4 matches
1import { sqlite } from "https://esm.town/v/std/sqlite";
23// Helper function to initialize an app's database
4export async function initAppDatabase(appName: string, schema: string) {
5try {
6await sqlite.execute(schema);
7console.log(`Initialized database schema for ${appName}`);
8return true;
9} catch (error) {
10console.error(`Error initializing database for ${appName}:`, error);
11return false;
12}
cerebras_coderindex2 matches
1import { generateCode } from "./backend/generate-code";
2import { createTables } from "./database/migrations";
3import { createProject, getCode, getNextVersionNumber, insertVersion } from "./database/queries";
45async function servePublicFile(path: string): Promise<Response> {
invitationTrackerDbmain.tsx1 match
4const SCHEMA_VERSION = 1;
56// Initialize the database
7async function initDB() {
8await sqlite.execute(`