268* SQLite schema initialization
269*/
270async function initializeDatabase() {
271const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
272const SCHEMA_VERSION = 1;
338console.log(`Path: ${path}`);
339340// Initialize database
341const { sqlite, SCHEMA_VERSION, tablePrefix } = await initializeDatabase();
342343// Update user record if logged in
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> {
47- Server-side rendering for fast initial page loads
48- LastLogin for secure Google authentication
49- SQLite database for persistent storage
50- Tailwind-inspired CSS for clean, modern styling
51- Responsive design that works on all device sizes
charBuildIdeaScaledb.ts3 matches
1// Database access functions for IdeaScale
2import { DB_KEY, Idea, IdeasResponse, Tag } from "./config";
34// Initialize database schema
5export async function initDatabase(sqlite) {
6await sqlite.execute(`
7CREATE TABLE IF NOT EXISTS ${DB_KEY}_ideas (
charBuildIdeaScaleconfig.ts1 match
7parentLinkText: "โ char.build",
89// Database config
10schemaVersion: 1,
11dbKeyPrefix: "ideascale",
10โโโ core/ # Shared functionality
11โ โโโ header.js # Shared header component with auth
12โ โโโ db.js # Database utilities
13โ โโโ registry.js # App registry for routing
14โโโ apps/ # Individual applications
56- **Consistent Header**: All apps share the same header with navigation
57- **Independent Styling**: Each app can have its own unique UI/UX
58- **Database Integration**: Built-in SQLite functionality with table prefixing for isolation
5960## Design Philosophy
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