41});
42
43export default app.fetch;
21app.get("/health", c => c.json({ status: "ok", timestamp: new Date().toISOString() }));
22
23export default app.fetch;
53
54 try {
55 const response = await fetch('/api/itinerary/generate', {
56 method: 'POST',
57 headers: { 'Content-Type': 'application/json' },
51 try {
52 setState(prev => ({ ...prev, isLoading: true }));
53 const response = await fetch('/api/itinerary');
54 const result = await response.json();
55
87 try {
88 // Check for existing progress
89 const response = await fetch(`/api/itinerary/${itinerary.id}/progress`);
90 const result = await response.json();
91
119
120 try {
121 await fetch(`/api/itinerary/${progress.itineraryId}/progress`, {
122 method: 'POST',
123 headers: { 'Content-Type': 'application/json' },
131 const handleDeleteItinerary = async (id: string) => {
132 try {
133 const response = await fetch(`/api/itinerary/${id}`, {
134 method: 'DELETE'
135 });
42});
43
44// Fetch event - serve from cache when offline
45self.addEventListener('fetch', event => {
46 const { request } = event;
47 const url = new URL(request.url);
50 if (url.pathname.startsWith('/api/')) {
51 event.respondWith(
52 fetch(request)
53 .then(response => {
54 // Cache successful API responses
93 }
94
95 return fetch(request)
96 .then(response => {
97 // Cache successful responses
136 });
137 } catch (error) {
138 console.error('Error fetching itinerary:', error);
139 return c.json<ApiResponse<null>>({
140 success: false,
141 error: 'Failed to fetch itinerary'
142 }, 500);
143 }
152 });
153 } catch (error) {
154 console.error('Error fetching itineraries:', error);
155 return c.json<ApiResponse<null>>({
156 success: false,
157 error: 'Failed to fetch itineraries'
158 }, 500);
159 }
213 });
214 } catch (error) {
215 console.error('Error fetching progress:', error);
216 return c.json<ApiResponse<null>>({
217 success: false,
218 error: 'Failed to fetch progress'
219 }, 500);
220 }
29 if (userId && !processedUsers.has(userId)) {
30 try {
31 // Fetch user data
32 const user = await vt.users.retrieve(userId);
33
45 processedUsers.add(userId);
46 } catch (error) {
47 console.error(`Error fetching user ${userId}:`, error);
48 // Continue with project processing even if user fetch fails
49 }
50 }
884 const searchPattern = `%${searchText}%`;
885
886 // 3. Start all data fetching queries in parallel, regardless of result type
887 // This way we don't wait for counts to finish before starting data queries
888 const fileResultsPromise = withTiming(async () => {
1221 <h3>Try searching for:</h3>
1222 <div className="search-examples">
1223 <a href="?q=fetch" className="example-link">fetch</a>
1224 <a href="?q=api" className="example-link">api</a>
1225 <a href="?q=database" className="example-link">database</a>
1375 <h3>Try searching for:</h3>
1376 <div className="search-examples">
1377 <a href="?q=fetch" className="example-link">fetch</a>
1378 <a href="?q=api" className="example-link">api</a>
1379 <a href="?q=database" className="example-link">database</a>
6 let lastSearchTerm = '';
7 let debounceTimer;
8 let currentRequest = null; // To track the current fetch request
9 let requestCounter = 0; // To identify requests
10 let currentResults = [];
11 let selectedIndex = -1;
12
13 // Function to fetch typeahead results
14 async function fetchTypeahead(query) {
15 if (query.length < 1) {
16 hideResults();
32
33 try {
34 const response = await fetch(\`/typeahead?q=\${encodeURIComponent(query)}\`, { signal });
35 if (!response.ok) throw new Error('Network response was not ok');
36
51 // Ignore abort errors which happen when we cancel the request
52 if (error.name !== 'AbortError') {
53 console.error('Typeahead fetch error:', error);
54 }
55 } finally {
120 // If it's a new query (just one character), search immediately
121 if (query.length === 1) {
122 fetchTypeahead(query);
123 } else {
124 // Otherwise use debounce for better performance during typing
125 debounceTimer = setTimeout(() => {
126 fetchTypeahead(query);
127 }, 200); // Debounce delay
128 }