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/$%7Burl%7D?q=database&page=1&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 7799 results for "database"(1360ms)

cardamomindex.ts10 matches

@connnollyโ€ขUpdated 1 hour ago
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { readFile, serveFile } from "https://esm.town/v/std/utils/index.ts";
3import { runMigrations } from "./database/migrations.ts";
4import recipesApp from "./routes/recipes.ts";
5import parseApp from "./routes/parse.ts";
13});
14
15// Initialize database on startup
16let dbInitialized = false;
17async function initializeDatabase() {
18 if (!dbInitialized) {
19 try {
20 await runMigrations();
21 dbInitialized = true;
22 console.log('Database initialized successfully');
23 } catch (error) {
24 console.error('Failed to initialize database:', error);
25 throw error;
26 }
31app.get('/api/health', async (c) => {
32 try {
33 await initializeDatabase();
34 return c.json({ status: 'ok', timestamp: new Date().toISOString() });
35 } catch (error) {
40// Test endpoint for debugging delete operations
41app.get('/api/test-delete', async (c) => {
42 await initializeDatabase();
43 return c.json({ message: 'Delete test endpoint - check logs for database operations' });
44});
45
53app.get("/shared/*", c => serveFile(c.req.path, import.meta.url));
54
55// Serve main HTML page with database initialization
56app.get("/", async (c) => {
57 try {
58 await initializeDatabase();
59 let html = await readFile("/frontend/index.html", import.meta.url);
60

luciaMagicLinkStarterREADME.md1 match

@shapedlinesโ€ขUpdated 3 hours ago
25## Technical Implementation
26
27- **Database**:[Val Town SQLite](https://docs.val.town/std/sqlite/) for storing users, sessions, and magic link tokens
28- **Frontend**: React with Tailwind CSS
29- **Backend**: Hono.js for API routes and middleware

luciaMagicLinkStartermagic-links.ts2 matches

@shapedlinesโ€ขUpdated 3 hours ago
59 const tokenHash = hashToken(token);
60
61 // Get the token from the database using its hash
62 const { rows } = await sqlite.execute(
63 `SELECT email, expires_at FROM ${MAGIC_LINKS_TABLE} WHERE id = ?`,
66
67 if (rows.length === 0) {
68 console.log("Did not find magic link token in database");
69 return { valid: false };
70 }

luciaMagicLinkStarterindex.ts1 match

@shapedlinesโ€ขUpdated 3 hours ago
3import { Hono } from "npm:hono";
4import { authMiddleware } from "./auth.ts";
5import { USER_TABLE } from "./database/schema.ts";
6
7const app = new Hono();

luciaMagicLinkStarterauth.ts2 matches

@shapedlinesโ€ขUpdated 3 hours ago
1import { getCookie, setCookie } from "npm:hono/cookie";
2import { createMiddleware } from "npm:hono/factory";
3import { createMagicLinkToken, sendMagicLinkEmail, validateMagicLinkToken } from "./database/magic-links.ts";
4import { createSession, generateSessionToken, invalidateSession, validateSessionToken } from "./database/sessions.ts";
5
6export const authMiddleware = createMiddleware(async (c, next) => {

cardamomshopping-lists.ts1 match

@connnollyโ€ขUpdated 4 hours ago
7 updateShoppingListItem,
8 deleteShoppingList
9} from "../database/queries.ts";
10
11const app = new Hono();

cardamomqueries.ts2 matches

@connnollyโ€ขUpdated 5 hours ago
39 if (!recipeId) {
40 console.error('Failed to get recipe ID from insert result:', recipeResult);
41 throw new Error('Failed to create recipe: no ID returned from database');
42 }
43
47 if (isNaN(numericRecipeId) || numericRecipeId <= 0) {
48 console.error('Recipe ID is not a valid number:', recipeId);
49 throw new Error('Failed to create recipe: invalid ID returned from database');
50 }
51

cardamommigrations.ts3 matches

@connnollyโ€ขUpdated 5 hours ago
7
8export async function runMigrations() {
9 console.log('Running database migrations...');
10
11 try {
90 `);
91
92 console.log('Database migrations completed successfully');
93 } catch (error) {
94 console.error('Database migration failed:', error);
95 throw error;
96 }

cardamomREADME.md13 matches

@connnollyโ€ขUpdated 5 hours ago
29- **Frontend**: React 18.2.0 with TypeScript, TailwindCSS
30- **Backend**: Hono API framework with TypeScript
31- **Database**: SQLite with normalized schema (recipes + ingredients tables)
32- **AI**: OpenAI GPT-4o-mini for intelligent recipe parsing
33- **File Processing**:
40```
41โ”œโ”€โ”€ backend/
42โ”‚ โ”œโ”€โ”€ database/
43โ”‚ โ”‚ โ”œโ”€โ”€ migrations.ts # Database schema
44โ”‚ โ”‚ โ””โ”€โ”€ queries.ts # Database operations
45โ”‚ โ”œโ”€โ”€ routes/
46โ”‚ โ”‚ โ”œโ”€โ”€ recipes.ts # Recipe CRUD operations
955. **Manage**: View, search, filter, edit, or delete saved recipes
96
97## Database Schema
98
99The app uses a normalized SQLite database with two main tables:
100
101### Recipes Table (`recipes_v1`)
143### Backend Architecture
144- Hono-based REST API with TypeScript
145- Normalized database design with proper foreign key relationships
146- Comprehensive error handling and validation
147- Database migrations with versioned table names
148- Performance optimizations with database indexes
149
150## Development Setup
163### File Structure Notes
164- **Static Files**: Served via Val Town's utility functions (`serveFile`, `readFile`)
165- **Database**: SQLite with automatic table creation on startup
166- **Error Handling**: Client-side error catching enabled via Val Town's error capture script
167
168### Development Workflow
1691. **Database Changes**: Update table names (e.g., `_v1` โ†’ `_v2`) when modifying schemas
1702. **Testing**: Use built-in test endpoints and browser developer tools
1713. **Debugging**: Check Val Town logs for server-side issues
177- **PDF Parsing Fails**: Ensure PDF contains readable text (not scanned images)
178- **Image Upload Issues**: Verify image is properly base64 encoded
179- **Database Errors**: Check if migrations ran successfully on startup
180- **OpenAI Errors**: Verify API quota and model availability
181
182### Debug Endpoints
183- `GET /api/health` - Check if API is responding
184- `GET /api/test-delete` - Test database delete operations
185- Browser console logs for client-side debugging
186- Server logs in Val Town interface for backend issues

cardamomval-town.mdc2 matches

@connnollyโ€ขUpdated 5 hours ago
179```
180โ”œโ”€โ”€ backend/
181โ”‚ โ”œโ”€โ”€ database/
182โ”‚ โ”‚ โ”œโ”€โ”€ migrations.ts # Schema definitions
183โ”‚ โ”‚ โ”œโ”€โ”€ queries.ts # DB query functions
239 ```
240
241### Database Patterns
242- Run migrations on startup or comment out for performance
243- Change table names when modifying schemas rather than altering

bookmarksDatabase

@s3thiโ€ขUpdated 4 months ago

sqLiteDatabase1 file match

@ideofunkโ€ขUpdated 7 months ago