2
3export default async function(req: Request): Promise<Response> {
4 const markdown = await fetch(import.meta.resolve("./README.md")).then(res => res.text());
5 const url = new URL(req.url);
6
140});
141
142export default app.fetch;
140});
141
142export default app.fetch;
2export async function importFile(path: string) {
3 const url = new URL(path, import.meta.url);
4 const res = await fetch(url, { redirect: "follow" });
5 if (!res.ok) return null;
6 return await res.text();
20
21 try {
22 const response = await fetch("/chat", {
23 method: "POST",
24 headers: { "Content-Type": "application/json" },
51
52 useEffect(() => {
53 fetchState();
54 }, []);
55
56 /**
57 * Fetches the current state from the server
58 */
59 const fetchState = async () => {
60 setIsLoading(true);
61 setError(null);
62 try {
63 const response = await fetch("/api/state");
64 if (!response.ok) throw new Error("Failed to fetch state");
65 const data = await response.json();
66 setState(data);
80 setError(null);
81 try {
82 const response = await fetch("/api/state", {
83 method: "POST",
84 headers: { "Content-Type": "application/json" },
86 });
87 if (!response.ok) throw new Error("Failed to update state");
88 await fetchState();
89 } catch (err) {
90 setError(err.message);
565 if (webhookUrl) {
566 try {
567 await fetch(webhookUrl, {
568 method: "POST",
569 headers: { "Content-Type": "application/json" },
7countPath(app);
8
9export default app.fetch;
10const TABLE_NAME = `${KEY}_versions_v1`;
11
12async function fetchContent(url: string) {
13 const response = await fetch(url);
14 return await response.text();
15}
30
31 for (const url of URLS) {
32 const content = await fetchContent(url);
33 const latestVersion = await sqlite.execute(
34 `SELECT blob_key FROM ${TABLE_NAME} WHERE url = ? ORDER BY timestamp DESC LIMIT 1`,
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export async function getWeather(location: string): Promise<WeatherResponse> {
4 return fetchJSON(`https://wttr.in/${location}?format=j1`);
5}
6
11const supabase = createClient(supabaseUrl, supabaseKey)
12
13// Disable prefetch as it is not supported for "Transaction" pool mode
14export const client = postgres(connectionString, { prepare: false })