Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/?q=database&page=245&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=database

Returns an array of strings in format "username" or "username/projectName"

Found 10131 results for "database"(5001ms)

ssscQuizadmin.http.ts8 matches

@allUpdated 2 months ago
12const TABLE_NAME = 'sssc_quiz_submissions_v1'; // Must match the table name in index.http.ts
13
14// Database initialization - ensure table exists
15async function initDatabase() {
16 await sqlite.execute(`CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (
17 id INTEGER PRIMARY KEY AUTOINCREMENT,
33}
34
35// Initialize database on startup
36await initDatabase();
37
38// Main admin dashboard route
94 <body>
95 <div style="padding: 2rem; text-align: center;">
96 <h1>⚠️ Database Error</h1>
97 <p>Unable to load dashboard data. Please check if the database is initialized.</p>
98 <a href="/" style="color: #4361ee;">← Back to Quiz</a>
99 </div>
204});
205
206// Debug endpoint to check database contents
207app.get("/api/debug", async c => {
208 try {
527 <p>Total Submissions: <strong>${total}</strong></p>
528 <p style="font-size: 0.9rem; opacity: 0.8;">
529 <a href="/api/debug" style="color: rgba(255,255,255,0.8); text-decoration: none;">🔍 Debug Database</a>
530 </p>
531 </div>

ssscQuizREADME.md9 matches

@allUpdated 2 months ago
10- **Personality Analysis**: Advanced algorithm determining primary social archetype
11- **Email Delivery**: Automated email with detailed results and insights
12- **Data Persistence**: All submissions stored in SQLite database
13
14### Enhanced Features
61- **Backend**: Hono web framework on Deno
62- **Frontend**: React 18 with TypeScript
63- **Database**: Val Town SQLite
64- **Email**: Val Town email service
65- **Styling**: CSS with custom properties and responsive design
91- Primary HTTP val that users visit
92- Hono web server with comprehensive error handling
93- SQLite database with optimized schema and indexing
94- Enhanced email system with HTML/text templates
95- API endpoints for quiz submission and analytics
107### Backend (Hono)
108- RESTful API with proper error handling
109- SQLite database with structured schema and indexes
110- Email automation with professional HTML templates
111- Admin analytics with real-time data
120- Progressive enhancement
121
122### Database Schema
123```sql
124CREATE TABLE sssc_quiz_submissions (
180
181- **Email Validation**: Client and server-side validation
182- **Data Sanitization**: All inputs sanitized before database storage
183- **Privacy Focused**: No tracking beyond essential quiz functionality
184- **Secure Storage**: Encrypted database storage through Val Town
185
186## 🚀 Deployment
1901. **Main Application**: `index.http.ts` - Primary entry point users visit
1912. **Admin Dashboard**: `admin.http.ts` - Analytics and data management
1923. **Database**: Automatic SQLite initialization with proper indexing
1934. **Email**: Enhanced email service with HTML templates following Val Town standards
1945. **Frontend**: Served as static files with mobile-responsive design
254- **Efficient Rendering**: Optimized React components
255- **CSS Optimization**: Custom properties and efficient selectors
256- **Database Queries**: Indexed and optimized queries
257
258

ssscQuizindex.http.ts9 matches

@allUpdated 2 months ago
13});
14
15// Database setup following Val Town standards
16const TABLE_NAME = 'sssc_quiz_submissions_v1'; // Must match admin.http.ts table name
17
18// Initialize database with Val Town best practices
19async function initDatabase() {
20 await sqlite.execute(`CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (
21 id INTEGER PRIMARY KEY AUTOINCREMENT,
37}
38
39// Initialize database on startup
40await initDatabase();
41
42// Serve static files
86 const ipHash = forwarded ? await hashIP(forwarded.split(',')[0].trim()) : '';
87
88 console.log("Storing in database...");
89 console.log("Table name:", TABLE_NAME);
90 console.log("Data to insert:", {
96 });
97
98 // Store in database following Val Town patterns
99 const insertResult = await sqlite.execute(
100 `INSERT INTO ${TABLE_NAME} (
113 ]
114 );
115 console.log("Database insert successful, result:", insertResult);
116
117 // Verify the insert worked
200app.get("/api/test-insert", async c => {
201 try {
202 console.log("Testing database insert...");
203
204 const testEmail = `test${Date.now()}@example.com`;

ssscQuizconfig.ts2 matches

@allUpdated 2 months ago
37 },
38
39 // Database configuration
40 database: {
41 tableName: "sssc_quiz_submissions_v1",
42 enableIndexes: true
11});
12
13app.get("/clear-databases", async (c) => {
14 return c.html(`
15 <h1>Clear Databases</h1>
16 <p>This will clear the databases for the bot.</p>
17 <form method="post" action="/clear-databases">
18 <input type="text" name="token" placeholder="Token" />
19 <button type="submit">Clear Databases</button>
20 </form>
21 <p>The password is ${Deno.env.get("ADMIN_TOKEN")}</p>
23});
24
25// Clear databases endpoint
26app.post("/clear-databases", async (c) => {
27 const body = await c.req.parseBody();
28 const token = body["token"];
32 }
33
34 // clear the databases
35 await sqlite.execute(`DELETE FROM ${LangChainTables.checkpoints}`);
36 await sqlite.execute(`DELETE FROM ${LangChainTables.checkpoint_writes}`);
37
38 return c.json({ message: "Databases cleared" });
39});
40
40 await ctx.reply(`✅ Successfully joined room with secret: ${roomSecret}`);
41 } catch (dbError) {
42 console.error("Database error in join command:", dbError);
43 await ctx.reply("❌ Error joining room. Please try again.");
44 }
74 await ctx.reply(`✅ Successfully left room with secret: ${roomSecret}`);
75 } catch (dbError) {
76 console.error("Database error in leave command:", dbError);
77 await ctx.reply("❌ Error leaving room. Please try again.");
78 }

Workflow2main.tsx2 matches

@svcUpdated 2 months ago
45 await new Promise(res => setTimeout(res, getRandomInt(200, 400)));
46 const possibleLogs = [
47 `ERROR: Connection to database 'pg-primary-01' on host ${serviceName}-db-host timed out.`,
48 `WARN: High memory pressure detected on service '${serviceName}'. Throttling new connections.`,
49 `ERROR: Failed to acquire lock 'payment_processing_lock' for service ${serviceName}.`,
170async function safetyCheckerAgent(acp: ACP): Promise<ACP> {
171 const { remediation_plan } = acp.payload.content;
172 const dangerousCommands = ["reboot", "rm -rf", "shutdown", "DROP DATABASE", "DELETE FROM"];
173
174 const unsafeStep = remediation_plan.find(step =>

town-hallREADME.md2 matches

@stevekrouseUpdated 2 months ago
16- Supports both general attendee registration and speaker applications
17- Collects attendee interests and preferences for event content
18- SQLite database storage for all submissions
19- Email notifications for new submissions
20- Mobile-responsive design
69- Copy the entire list to clipboard with one click
70
71## Database Schema
72
73```sql

MiniAppStarterApp.tsx5 matches

@moeUpdated 2 months ago
16 { name: "Farcaster SDK", path: "/" },
17 { name: "Haptics", path: "/haptics" },
18 { name: "Database", path: "/db" },
19 { name: "About", path: "/about" },
20 ];
39 <Route path="/" element={<FarcasterMiniApp />} />
40 <Route path="/haptics" element={<CustomHaptics />} />
41 <Route path="/db" element={<Database />} />
42 <Route path="/about" element={<About />} />
43 <Route path="/neynar" element={<Neynar />} />
55 <div className="">✷ Hono + React + Tailwind</div>
56 <div className="">✷ React Router + React Query</div>
57 <div className="">✷ Built-in database (blob storage)</div>
58 <div className="">✷ Farcaster mini app manifest + webhook + embed metadata</div>
59 <div className="">✷ Farcaster notifications (storing tokens, sending recurring notifications, ...)</div>
71}
72
73function Database() {
74 const queryFn = () => fetch("/api/counter/get").then((r) => r.json());
75 const { data, refetch } = useQuery({ queryKey: ["counter"], queryFn });
76 return (
77 <Section className="flex flex-col items-start gap-3 m-5">
78 {/* <h2 className="font-semibold">Database Example</h2> */}
79 <div className="">Counter value: {data}</div>
80 <Button variant="outline" onClick={() => fetch("/api/counter/increment").then(refetch)}>

reactHonoExampleREADME.md2 matches

@gwoods22Updated 2 months ago
4
5* `index.ts` - this is the **entrypoint** for this whole project
6* `database/` - this contains the code for interfacing with the app's SQLite database table
7
8## Hono
26## CRUD API Routes
27
28This app has two CRUD API routes: for reading and inserting into the messages table. They both speak JSON, which is standard. They import their functions from `/backend/database/queries.ts`. These routes are called from the React app to refresh and update data.
29
30## Errors

customer-database-setup2 file matches

@stevenvapiUpdated 2 months ago

prDatabase

@pdwUpdated 2 months ago