578
579 // just launch it, don't wait for the result
580 // const taskRunResponse = await fetch(`${URL}/taskrun`, {
581 const taskRunResponse = fetch(`${URL}/taskrun`, {
582 method: 'POST',
583 headers: {
674}
675
676export default app.fetch;
677export { ModelProvider, modelProvider, ai, test };
678
9 const endpoint = supabaseUrl + query;
10
11 const response = await fetch(endpoint, {
12 headers: {
13 "Authorization":
7
8import { Button, Input, Section, ShareButton } from '../components/ui.tsx'
9import { fetchUsersById } from '../util/neynar.ts'
10import { supabase } from '../util/db.ts'
11
39function Spaces() {
40 const queryFn = async () => {
41 const agoraChannels = await fetch(`/api/channels`)
42 .then((r) => r.json())
43 .then((r) => r?.data?.channels)
145 }
146
147 fetch("/api/voicenotes", {
148 method: "POST",
149 body: formData,
14
15 useEffect(() => {
16 fetchVoiceNote();
17 }, [voiceNoteId]);
18
19 const fetchVoiceNote = async () => {
20 try {
21 setLoading(true);
22 const response = await fetch(`/api/voicenotes/${voiceNoteId}`);
23 const data = await response.json();
24
32 } catch (err) {
33 setError("Failed to load voice message");
34 console.error("Error fetching voice message:", err);
35 } finally {
36 setLoading(false);
9
10 useEffect(() => {
11 fetchVoiceNotes();
12 }, []);
13
14 const fetchVoiceNotes = async () => {
15 try {
16 setLoading(true);
17 const response = await fetch("/api/voicenotes");
18 const data = await response.json();
19
21 setVoiceNotes(data.voiceNotes || []);
22 } else {
23 setError(data.error || "Failed to fetch voice messages");
24 }
25 } catch (err) {
26 setError("Failed to load voice messages");
27 console.error("Error fetching voice messages:", err);
28 } finally {
29 setLoading(false);
120
121 try {
122 const response = await fetch(`/api/voicenotes/${voiceNoteId}`, {
123 method: "DELETE",
124 });
160 <p className="text-red-600 mb-4">{error}</p>
161 <button
162 onClick={fetchVoiceNotes}
163 className="px-6 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700"
164 >
177 </h2>
178 <button
179 onClick={fetchVoiceNotes}
180 className="px-4 py-2 bg-gray-100 text-gray-700 rounded-md hover:bg-gray-200 text-sm"
181 >
24 return c.json({ success: true, voiceNotes });
25 } catch (error) {
26 console.error("Error fetching voice notes:", error);
27 return c.json({ success: true, voiceNotes: [] });
28 }
97 return c.json({ success: true, voiceNote });
98 } catch (error) {
99 console.error("Error fetching voice note:", error);
100 return c.json({ success: false, error: "Failed to fetch voice note" }, 500);
101 }
102});
21 try {
22 const url = `${this.baseUrl}${endpoint}`;
23 const response = await fetch(url, {
24 headers: {
25 'Content-Type': 'application/json',
59 async streamChatMessage(request: ChatRequest): Promise<Response> {
60 const url = `${this.baseUrl}/chat/stream`;
61 const response = await fetch(url, {
62 method: 'POST',
63 headers: {
97
98 const handleStreamingResponse = async (content: string, assistantMessageId: string) => {
99 const response = await fetch('/api/chat/stream', {
100 method: 'POST',
101 headers: {
187
188 const handleNonStreamingResponse = async (content: string, assistantMessageId: string) => {
189 const response = await fetch('/api/chat', {
190 method: 'POST',
191 headers: {
66});
67
68// Fetch event - handle requests
69self.addEventListener('fetch', (event) => {
70 const { request } = event;
71 const url = new URL(request.url);
116 }
117
118 const networkResponse = await fetch(request);
119
120 // Cache successful responses
146async function handleAPIRequest(request) {
147 try {
148 const networkResponse = await fetch(request);
149
150 // Cache successful GET requests for health checks
187async function handleNavigationRequest(request) {
188 try {
189 const networkResponse = await fetch(request);
190 return networkResponse;
191 } catch (error) {
228async function handleDynamicRequest(request) {
229 try {
230 const networkResponse = await fetch(request);
231
232 // Cache successful responses