22
23 try {
24 const response = await fetch("/auth/magic-link", {
25 method: "POST",
26 headers: {
77});
78
79// HTTP vals expect an exported "fetch handler"
80// This is how you "run the server" in Val Town with Hono
81export default app.fetch;
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});
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});
23 return c.json({ success: true, data: result });
24 } catch (error) {
25 console.error('Error fetching shopping lists:', error);
26 return c.json({ success: false, error: 'Failed to fetch shopping lists' }, 500);
27 }
28});
40 setState(prev => ({ ...prev, loading: true, error: null }));
41 try {
42 const response = await fetch('/api/recipes');
43 const data = await response.json();
44
68 setState(prev => ({ ...prev, loading: true, error: null }));
69 try {
70 const response = await fetch('/api/shopping-lists');
71 const data = await response.json();
72
50 const handleDelete = async (recipeId: number) => {
51 try {
52 const response = await fetch(`/api/recipes/${recipeId}`, {
53 method: 'DELETE'
54 });
16 setLoading(true);
17 try {
18 const response = await fetch(`/api/shopping-lists/items/${itemId}`, {
19 method: 'PUT',
20 headers: {
47 setLoading(true);
48 try {
49 const response = await fetch(`/api/shopping-lists/${shoppingList.id}`, {
50 method: 'DELETE',
51 });
42
43 try {
44 const response = await fetch('/api/shopping-lists', {
45 method: 'POST',
46 headers: {
131- **PDF**: Uses `unpdf` library for text extraction
132- **Images**: Leverages OpenAI Vision API for OCR
133- **URLs**: Fetches and parses HTML content
134- **Text**: Direct text processing
135
166 const { content: url } = await c.req.json() as ParseRequest;
167
168 // Fetch the webpage content
169 const response = await fetch(url);
170 if (!response.ok) {
171 return c.json({ success: false, error: "Failed to fetch URL" } as ParseResponse);
172 }
173