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/$1?q=api&page=38&format=json

For typeahead suggestions, use the /typeahead endpoint:

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

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

Found 19780 results for "api"(3280ms)

pageApi2 file matches

@mgruel•Updated 1 year ago

myApi1 file match

@dng•Updated 1 year ago

myApi2 file matches

@florian•Updated 1 year ago

myApi1 file match

@rolling_coaster•Updated 1 year ago

myApi1 file match

@bcrummy•Updated 1 year ago

myApi1 file match

@mpsuesser•Updated 1 year ago

myApi1 file match

@genevra•Updated 1 year ago

myApi2 file matches

@tekknolagi•Updated 1 year ago

myApi1 file match

@lazydefi1•Updated 1 year ago

myApi1 file match

@M3RCYAJ•Updated 1 year ago

cardamomindex.ts6 matches

@connnolly•Updated 51 mins ago
29
30// Health check endpoint
31app.get('/api/health', async (c) => {
32 try {
33 await initializeDatabase();
39
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
46// Mount API routes
47app.route('/api/recipes', recipesApp);
48// app.route('/api/parse', parseApp);
49app.route('/api/shopping-lists', shoppingListsApp);
50
51// Serve static files

cardamomshopping-lists.ts19 matches

@connnolly•Updated 51 mins ago
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import type { ShoppingList, ShoppingListItem, CreateShoppingListRequest, ApiResponse } from "../../shared/types.ts";
3import {
4 createShoppingList as dbCreateShoppingList,
17 try {
18 const lists = await getAllShoppingLists();
19 return c.json({ success: true, data: lists } as ApiResponse<ShoppingList[]>);
20 } catch (error) {
21 console.error('Error fetching shopping lists:', error);
22 return c.json({ success: false, error: 'Failed to fetch shopping lists' } as ApiResponse, 500);
23 }
24});
29 const id = parseInt(c.req.param('id'));
30 if (isNaN(id)) {
31 return c.json({ success: false, error: 'Invalid shopping list ID' } as ApiResponse, 400);
32 }
33
34 const list = await getShoppingListById(id);
35 if (!list) {
36 return c.json({ success: false, error: 'Shopping list not found' } as ApiResponse, 404);
37 }
38
39 return c.json({ success: true, data: list } as ApiResponse<ShoppingList>);
40 } catch (error) {
41 console.error('Error fetching shopping list:', error);
42 return c.json({ success: false, error: 'Failed to fetch shopping list' } as ApiResponse, 500);
43 }
44});
53 success: false,
54 error: 'At least one recipe ID is required'
55 } as ApiResponse, 400);
56 }
57
62 success: false,
63 error: 'All recipe IDs must be valid numbers'
64 } as ApiResponse, 400);
65 }
66
74
75 const list = await dbCreateShoppingList(listName, validRecipeIds);
76 return c.json({ success: true, data: list } as ApiResponse<ShoppingList>, 201);
77 } catch (error) {
78 console.error('Error creating shopping list:', error);
79 return c.json({ success: false, error: 'Failed to create shopping list' } as ApiResponse, 500);
80 }
81});
86 const id = parseInt(c.req.param('id'));
87 if (isNaN(id)) {
88 return c.json({ success: false, error: 'Invalid item ID' } as ApiResponse, 400);
89 }
90
93 const success = await updateShoppingListItem(id, updates);
94 if (!success) {
95 return c.json({ success: false, error: 'Item not found or no changes made' } as ApiResponse, 404);
96 }
97
98 return c.json({ success: true, data: { updated: true } } as ApiResponse);
99 } catch (error) {
100 console.error('Error updating shopping list item:', error);
101 return c.json({ success: false, error: 'Failed to update item' } as ApiResponse, 500);
102 }
103});
108 const id = parseInt(c.req.param('id'));
109 if (isNaN(id)) {
110 return c.json({ success: false, error: 'Invalid shopping list ID' } as ApiResponse, 400);
111 }
112
113 const deleted = await deleteShoppingList(id);
114 if (!deleted) {
115 return c.json({ success: false, error: 'Shopping list not found' } as ApiResponse, 404);
116 }
117
118 return c.json({ success: true, data: { deleted: true } } as ApiResponse);
119 } catch (error) {
120 console.error('Error deleting shopping list:', error);
121 return c.json({ success: false, error: 'Failed to delete shopping list' } as ApiResponse, 500);
122 }
123});
apiry
snartapi