26 if (userId && !processedUsers.has(userId)) {
27 try {
28 // Fetch user data
29 const user = await vt.users.retrieve(userId);
30
42 processedUsers.add(userId);
43 } catch (error) {
44 console.error(`Error fetching user ${userId}:`, error);
45 // Continue with project processing even if user fetch fails
46 }
47 }
83 * @param page Page number
84 * @param pageSize Number of results per page
85 * @param fetchData Whether to fetch the full data for each result
86 */
87export async function searchDocs(
89 page: number = 1,
90 pageSize: number = 10,
91 fetchData: boolean = true
92): Promise<{
93 results: DocSearchResult[];
105
106 // If we don't need the full data, just return the count
107 if (!fetchData) {
108 return { results: [], totalResults: unfilteredResultCount };
109 }
112 const paginatedResults = results.slice(startIndex, endIndex);
113
114 // Fetch all result data in parallel
115 const dataPromises = paginatedResults.map(result => result.data());
116 const resultDataArray = await Promise.all(dataPromises);
37 "integrity": "sha512-OF8fFQSkbL7vJY9rfuegK1R7sPgQ6kFMkDamiEccNUvieQ+3urzfDFI616oPl8V7T9zRmnTkSjMOImYCAVRVuw==",
38 "dependencies": [
39 "@libsql/isomorphic-fetch",
40 "@libsql/isomorphic-ws",
41 "js-base64",
42 "node-fetch@3.3.2"
43 ]
44 },
45 "@libsql/isomorphic-fetch@0.3.1": {
46 "integrity": "sha512-6kK3SUK5Uu56zPq/Las620n5aS9xJq+jMBcNSOmjhNf/MUvdyji4vrMTqD7ptY7/4/CAVEAYDeotUz60LNQHtw=="
47 },
71 "integrity": "sha512-kTPhdZyTQxB+2wpiRcFWrDcejc4JI6tkPuS7UZCG4l6Zvc5kU/gGQ/ozvHTh1XR5tS+UlfAfGuPajjzQjCiHCw=="
72 },
73 "@types/node-fetch@2.6.12": {
74 "integrity": "sha512-8nneRWKCg3rMtF69nLQJnOYUcbafYeFSjqkw3jCRLsqkWFlHaoQrr5mXmofFGOx3DKn7UfmBMyov8ySvLRVldA==",
75 "dependencies": [
106 "dependencies": [
107 "@types/node@18.19.87",
108 "@types/node-fetch",
109 "abort-controller",
110 "agentkeepalive",
111 "form-data-encoder",
112 "formdata-node",
113 "node-fetch@2.7.0"
114 ]
115 },
118 "dependencies": [
119 "@types/node@18.19.87",
120 "@types/node-fetch",
121 "abort-controller",
122 "agentkeepalive",
123 "form-data-encoder",
124 "formdata-node",
125 "node-fetch@2.7.0"
126 ]
127 },
198 "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ=="
199 },
200 "fetch-blob@3.2.0": {
201 "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==",
202 "dependencies": [
227 "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==",
228 "dependencies": [
229 "fetch-blob"
230 ]
231 },
314 "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ=="
315 },
316 "node-fetch@2.7.0": {
317 "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
318 "dependencies": [
320 ]
321 },
322 "node-fetch@3.3.2": {
323 "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==",
324 "dependencies": [
325 "data-uri-to-buffer",
326 "fetch-blob",
327 "formdata-polyfill"
328 ]
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 () => {
239
240 // Inject data to avoid extra round-trips
241 const initialData = await fetchInitialData();
242 const dataScript = `<script>
243 window.__INITIAL_DATA__ = ${JSON.stringify(initialData)};
286
2875. **API Design:**
288 - `fetch` handler is the entry point for HTTP vals
289 - Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`
290
291
1240 <h3>Try searching for:</h3>
1241 <div className="search-examples">
1242 <a href="?q=fetch" className="example-link">fetch</a>
1243 <a href="?q=api" className="example-link">api</a>
1244 <a href="?q=database" className="example-link">database</a>
1395 <h3>Try searching for:</h3>
1396 <div className="search-examples">
1397 <a href="?q=fetch" className="example-link">fetch</a>
1398 <a href="?q=api" className="example-link">api</a>
1399 <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 }
43 e.preventDefault()
44 const form = e.currentTarget as HTMLFormElement
45 const res = await fetch(form.action || window.location.href, {
46 method: form.method || "POST",
47 body: new FormData(form),
129
130export default async function (req: Request): Promise<Response> {
131 return await app.fetch(req);
132}
133
30
31 // Make request to Hume API to get access token
32 const response = await fetch("https://api.hume.ai/oauth2-cc/token", {
33 method: "POST",
34 headers: {