agatha-proxymain.tsx3 matches
10const manifestBaseUrl = "https://agatha.arch.be/data/json/";
1112async function fetchJson(id: string) {
13const headers = new Headers([
14["referer", "https://agatha.arch.be/"],
15]);
16const url = new URL(manifestBaseUrl + id);
17return fetch(url, { headers })
18.then(resp => resp.json())
19.catch((err) => ({ error: `Could not access item ${id}` }));
31let resp;
32if (requestType === "manifest") {
33resp = await fetchJson(requestParams.join("/"));
34}
35if (resp.error) {
5455// Forward the request to Brave Search API
56const braveResponse = await fetch(`${braveApiUrl}?${braveParams}`, {
57method: 'GET',
58headers: {
564565try {
566const response = await fetch(window.location.pathname + '?format=json', { method: 'POST', headers: { 'Accept': 'application/json'}, body: formData });
567const data = await response.json();
568if (!response.ok) { throw new Error(data?.error || data?.details || response.statusText || \`Server status: \${response.status}\`); }
615616} catch (error) {
617console.error("Fetch Error:", error);
618displayError('errorFetchFailed', { errorMessage: error.message });
619setLoadingState(false);
620}
652// --- Dynamic Imports ---
653const { OpenAI } = await import("https://esm.town/v/std/openai");
654const { fetch } = await import("https://esm.town/v/std/fetch");
655const { PDFExtract } = await import("npm:pdf.js-extract");
656763errorInvalidFile: "Invalid file type. Please upload a {{document_format_accepted | default('PDF')}}.",
764errorFileSize: "File is too large (Max {{max_pdf_size_mb}}MB).",
765errorFetchFailed: "Failed to perform analysis: {{errorMessage}}",
766contactNamePlaceholder: APP_CONFIG.contact_form_placeholders_en.name,
767contactEmailPlaceholder: APP_CONFIG.contact_form_placeholders_en.email,
803errorInvalidFile: "Tipo de archivo inválido. Por favor, suba un {{document_format_accepted | default('PDF')}}.",
804errorFileSize: "El archivo es demasiado grande (Máx {{max_pdf_size_mb}}MB).",
805errorFetchFailed: "Falló la realización del análisis: {{errorMessage}}",
806contactNamePlaceholder: APP_CONFIG.contact_form_placeholders_es.name,
807contactEmailPlaceholder: APP_CONFIG.contact_form_placeholders_es.email,
872}
873try {
874const response = await fetch(ref.potentialUrl, { method: "HEAD", redirect: "follow", timeout: 5000 });
875ref.traversalStatus = response.ok ? "success" : "failed";
876if (!response.ok) ref.error = `Status ${response.status}`;
877} catch (e) {
878ref.traversalStatus = "failed";
879ref.error = e.name === "AbortError" || e.message.includes("timed out") ? "Timeout" : "Fetch Error";
880}
881return ref;
904docText = await extractPdfTextNative(buffer, input.documentFile.name, log);
905} else if (input.documentUrl) {
906log.push({ agent: ingestAgent, type: "input", message: `Fetching content from URL: ${input.documentUrl}` });
907try {
908const response = await fetch(input.documentUrl);
909if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
910docText = await response.text();
911log.push({ agent: ingestAgent, type: "result", message: `Fetched ${docText.length} characters.` });
912} catch (e) {
913log.push({ agent: ingestAgent, type: "error", message: `Failed to fetch URL: ${e.message}. Halting.` });
914}
915} else if (input.documentText) {
241
242// Use BinList.net free API (no API key required)
243const response = await fetch(`https://lookup.binlist.net/${cleanBin}`);
244
245if (!response.ok) {
294app.get("/api/marketplace/products", async c => {
295try {
296// In a real application, this would fetch from a database
297const products = [
298{
365});
366} catch (error) {
367return c.json({ error: "Failed to fetch products" }, 500);
368}
369});
373const id = c.req.param("id");
374
375// In a real application, this would fetch from a database
376const products = [
377{
418});
419} catch (error) {
420return c.json({ error: "Failed to fetch product" }, 500);
421}
422});
449});
450451export default app.fetch;
shitty-leaderboardindex.ts10 matches
41}, []);
4243// Fetch leaderboard data
44const fetchLeaderboard = async () => {
45if (!instanceId) return;
4648setIsLoading(true);
49
50// Fetch chores and history in parallel with cache-busting
51const timestamp = Date.now();
52const [choresResponse, historyResponse] = await Promise.all([
53fetch(`/api/${instanceId}/chores?_t=${timestamp}`),
54fetch(`/api/${instanceId}/history?_t=${timestamp}`),
55]);
5657if (!choresResponse.ok || !historyResponse.ok) {
58throw new Error("Failed to fetch data");
59}
60126setIsLoading(false);
127} catch (err) {
128console.error("Error fetching leaderboard:", err);
129setError("Failed to load leaderboard data");
130setIsLoading(false);
132};
133134// Initial fetch and polling
135useEffect(() => {
136if (!instanceId) return;
137138fetchLeaderboard();
139140// Poll every 30 seconds for real-time updates
141const interval = setInterval(fetchLeaderboard, 30000);
142143return () => clearInterval(interval);
send-transcriptsmain.tsx1 match
176});
177178export default app.fetch;
176}
177178console.log(`Fetching fresh data from OpenAI for: "${plantName}"`);
179// If not cached, fetch from OpenAI
180const prompt =
181`Please provide detailed information about the plant "${plantName}" in the following JSON format. Be specific and accurate:
261}
262} catch (error) {
263console.error("Error fetching plant information:", error);
264return c.json({
265error: "Failed to fetch plant information",
266details: error instanceof Error ? error.message : "Unknown error",
267}, 500);
390});
391392export default app.fetch; // This is the entry point for HTTP vals
orbiterHealthmonitor3 matches
10async function notifySlack(message: string) {
11try {
12await fetch(WEBHOOK_URL, {
13method: "POST",
14headers: {
29const start = performance.now();
30try {
31const res = await fetch(url);
32end = performance.now();
33status = res.status;
40} catch (e) {
41end = performance.now();
42reason = `couldn't fetch: ${e}`;
43ok = false;
44console.log(`Website down (${url}): ${reason} (${end - start}ms)`);
57});
5859export default instrument(app, { libraryDebugMode: true }).fetch;
60