21
22// This is the entry point for HTTP vals
23export default app.fetch;
24
46 files={project.data?.files}
47 branchId={branchId}
48 refetch={project.refetch}
49 />
50 </>
56 files,
57 branchId,
58 refetch,
59}: {
60 project: any;
61 files: any[];
62 branchId: string;
63 refetch: () => void;
64}) {
65 const { token, anthropicApiKey } = useAuth();
93 if (!messages?.length) return;
94 let last = messages.at(-1);
95 if (shouldRefetch(last)) {
96 refetch();
97 }
98 }, [messages]);
177}
178
179function shouldRefetch (message) {
180 for (let i = 0; i < message?.parts?.length; i++) {
181 let part = message.parts[i];
184 case "str_replace_editor":
185 if (part.toolInvocation?.args?.command === "create") {
186 // console.log("REFETCH (create)");
187 return true;
188 }
190 case "delete_file":
191 case "change_val_type":
192 // console.log("REFETCH (change type or delete)");
193 return true;
194 }
33 return;
34 }
35 branches.refetch();
36 if (res?.branch?.id) {
37 navigate(`/chat/${projectId}/branch/${res.branch.id}`);
17
18 try {
19 const response = await fetch(proxyRequest);
20 return new Response(response.body, {
21 status: response.status,
46 </div>
47 )
48 : <div className="text-2xl mt-2.5">Unable to fetch weather data</div>}
49 </Content>
50 <Footer />
1import fetchWithCache from "./fetchWithCache.ts";
2
3export type WEATHER_FORECAST = {
39
40 // Cache for 30 minutes
41 const data: WEATHER_FORECAST = await fetchWithCache(apiUrl, cacheKey, 30).then((res) => res.json());
42 return new Response(JSON.stringify(data), {
43 headers: {
1import fetchWithCache from "./fetchWithCache.ts";
2
3const GUARDIAN_API_KEY = Deno.env.get("GUARDIAN_API_KEY");
25 const cacheKey = `guardian_headlines_${size}`;
26
27 const data = await fetchWithCache(apiUrl, cacheKey).then((res) => res.json());
28 return new Response(JSON.stringify(data), {
29 headers: {
46 <h3 class="text-xl pb-2">Example frame previews</h3>
47 <p>
48 Frames data is fetched, cached, and displayed with val.town, then fetched and rendered on an e-ink
49 display.
50 </p>
32 ))
33 )
34 : <div className="text-2xl mt-2.5">Unable to fetch data</div>}
35 </ul>
36 </Content>
1import fetchWithCache from "./fetchWithCache.ts";
2
3export type HEMOLOG_TREATMENT = {
22 const cacheKey = "hemolog-recent-treatments";
23
24 const data: HEMOLOG_TREATMENT[] = await fetchWithCache(apiUrl, cacheKey).then((res) => res.json());
25 return new Response(JSON.stringify(data), {
26 headers: {