60 }
61
62 // If no initial data, fetch it from the API
63 const demoId = window.__DEMO_ID__ || getDemoIdFromPath();
64 if (demoId && demoId !== 'demo') {
65 try {
66 const response = await fetch(`/api/demo/${demoId}`);
67 const data = await response.json();
68 return {
44});
45
46export default app.fetch;
47
30 // const apiUrl = new URL(c.req.url);
31 // apiUrl.pathname = `/api/demo/${id}`;
32 // const response = await fetch(apiUrl.toString());
33 const page = await getPage(id);
34
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
11
12 constructor() {}
13 async fetch(req: Request): Promise<Response> {
14 if (new URL(req.url).pathname === "/robots.txt") {
15 return new Response("User-agent: *\nDisallow: /");
250const sc = new StaticChess();
251
252export default analyticsHandlerWrapper(sc.fetch.bind(sc));
253
2 const method = c.req.method;
3 const secret = c.req.header("x-api-key"); // sent by Notion webhooks via POST
4 const fetchSite = c.req.header("sec-fetch-site");
5
6 // POSTs from Notion are automation webhooks that carry the x-api-key custom header
9 // for now we can just let GETs through without any auth shim
10 if (
11 (secret && secret !== Deno.env.get("X_API_KEY") || fetchSite && fetchSite !== "same-origin") && method !== "GET"
12 ) {
13 console.log(fetchSite);
14 return c.text("Unauthorized", 401);
15 }
22 });
23
24 const response = await fetch(url, {
25 method: "POST",
26 headers: { "Content-Type": "application/x-www-form-urlencoded" },
22 });
23
24 const response = await fetch(url, {
25 method: "POST",
26 headers: { "Content-Type": "application/x-www-form-urlencoded" },
7
8import { Button, Input, Section, ShareButton, Sheet } from '../components/ui.tsx'
9import { fetchUsersById } from '../util/neynar.ts'
10import { supabase, fetchSpace } from '../util/db.ts'
11
12import {
44 const { id } = useParams()
45
46 const { data: space, isLoading } = useQuery({ queryKey: ['space', id], queryFn: () => fetchSpace(id) })
47
48 const [calling, setCalling] = useState(false)
139
140 const queryFn = () =>
141 fetch(`/api/channels`)
142 .then((r) => r.json())
143 .then((r) => r?.data?.channels?.find((c) => c.channel_name == channel))
146
147 const join = async () => {
148 const response = await fetch(`/api/token?channel=${channel}&uid=${uid}`).then((r) => r.json())
149 console.log('response', response)
150 setToken(response.token)
448 if (!uid) return null
449 if (uid > 2_000_000) return null
450 return await fetchUsersById(`${uid}`).then((users) => users?.[0])
451}
452
479
480 useEffect(() => {
481 fetchSpace(id).then(setSpace)
482
483 const changes = supabase
1export {
2 fetchTranspiledJavaScript,
3 listFiles,
4 readFile,