stevens-openaiindex.ts2 matches
135));
136137// HTTP vals expect an exported "fetch handler"
138export default app.fetch;
stevens-openai.cursorrules5 matches
163```
1641655. **fetchTranspiledJavaScript** - Fetch and transpile TypeScript to JavaScript:
166```ts
167const jsCode = await fetchTranspiledJavaScript("https://esm.town/v/username/project/path/to/file.ts");
168```
169242243// Inject data to avoid extra round-trips
244const initialData = await fetchInitialData();
245const dataScript = `<script>
246window.__INITIAL_DATA__ = ${JSON.stringify(initialData)};
3003015. **API Design:**
302- `fetch` handler is the entry point for HTTP vals
303- Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`
304- Properly handle CORS if needed for external access
stevens-openaiApp.tsx17 matches
82const [cookieAndTeaMode, setCookieAndTeaMode] = useState(false);
8384// Fetch images from backend instead of blob storage directly
85useEffect(() => {
86// Set default background color in case image doesn't load
89}
9091// Fetch avatar image
92fetch("/api/images/stevens.jpg")
93.then((response) => {
94if (response.ok) return response.blob();
103});
104105// Fetch wood background
106fetch("/api/images/wood.jpg")
107.then((response) => {
108if (response.ok) return response.blob();
129}, []);
130131const fetchMemories = useCallback(async () => {
132setLoading(true);
133setError(null);
134try {
135const response = await fetch(API_BASE);
136if (!response.ok) {
137throw new Error(`HTTP error! status: ${response.status}`);
154}
155} catch (e) {
156console.error("Failed to fetch memories:", e);
157setError(e.message || "Failed to fetch memories.");
158} finally {
159setLoading(false);
162163useEffect(() => {
164fetchMemories();
165}, [fetchMemories]);
166167const handleAddMemory = async (e: React.FormEvent) => {
176177try {
178const response = await fetch(API_BASE, {
179method: "POST",
180headers: { "Content-Type": "application/json" },
188setNewMemoryTags("");
189setShowAddForm(false);
190await fetchMemories();
191} catch (e) {
192console.error("Failed to add memory:", e);
199200try {
201const response = await fetch(`${API_BASE}/${id}`, {
202method: "DELETE",
203});
205throw new Error(`HTTP error! status: ${response.status}`);
206}
207await fetchMemories();
208} catch (e) {
209console.error("Failed to delete memory:", e);
231232try {
233const response = await fetch(`${API_BASE}/${editingMemory.id}`, {
234method: "PUT",
235headers: { "Content-Type": "application/json" },
240}
241setEditingMemory(null);
242await fetchMemories();
243} catch (e) {
244console.error("Failed to update memory:", e);
9});
1011// Fetch the weather image directly
12const weatherImageUrl = "https://wttr.in/buelach_q_1pq.png";
13const weatherResponse = await fetch(weatherImageUrl);
1415if (!weatherResponse.ok) {
16console.error(`Failed to fetch weather image: ${weatherResponse.status}`);
17return new Response(`Error fetching weather data: ${weatherResponse.status}`, { status: 500 });
18}
192930// Send to Capacities API with JSON
31const capacitiesResponse = await fetch("https://api.capacities.io/save-to-daily-note", {
32method: "POST",
33headers: {
FarcasterMiniAppStoreneynar.ts16 matches
2// const baseUrl = "https://api.neynar.com/v2/farcaster/";
34export async function fetchNeynarGet(path: string) {
5const res = await fetch(baseUrl + encodeURIComponent(path), {
6method: "GET",
7headers: {
15}
1617export async function fetchNeynarGetPages(path: string, pages: number, dataKey: string) {
18let data: any = [];
19let cursor = "";
20let pagesLeft = pages;
21while (true) {
22const res = await fetchNeynarGet(`${path}&cursor=${cursor}`);
23data = [...data, ...res[dataKey]];
24cursor = res?.next?.cursor;
35//////////
3637export function fetchUser(username: string) {
38return fetchNeynarGet(`user/by_username?username=${username}`).then(r => r.user);
39}
40export function fetchUsersById(fids: string) {
41return fetchNeynarGet(`user/bulk?fids=${fids}`).then(r => r.users);
42}
4344export function fetchUserFeed(fid: number) {
45return fetchNeynarGet(
46`feed?feed_type=filter&filter_type=fids&fids=${fid}&with_recasts=false&with_replies=false&limit=100&cursor=`,
47).then(r => r.casts);
48}
4950export function fetchChannel(channelId: string) {
51return fetchNeynarGet(`channel?id=${channelId}`).then(r => r.channel);
52}
5354export function fetchChannelFeed(channelId: string) {
55return fetchNeynarGet(
56`feed/channels?channel_ids=${channelId}&with_recasts=false&limit=100`,
57).then(r => r.casts);
58}
5960export function fetchChannelsFeed(channelIds: array) {
61return fetchNeynarGet(
62`feed/channels?channel_ids=${channelIds.join(",")}&with_recasts=false&limit=100`,
63).then(r => r.casts);
FarcasterMiniAppStoreneynar.ts4 matches
5};
67export const fetchGet = async (path: string) => {
8return await fetch("https://api.neynar.com/v2/farcaster/" + path, {
9method: "GET",
10headers: headers,
12};
1314export const fetchPost = async (path: string, body: any) => {
15return await fetch("https://api.neynar.com/v2/farcaster/" + path, {
16method: "POST",
17headers: headers,
FarcasterMiniAppStoreindex.tsx5 matches
4import { embedMetadata, handleFarcasterEndpoints, iconUrl, name } from "./farcaster.ts";
5import { handleImageEndpoints } from "./image.tsx";
6import { fetchGet as fetchNeynarGet } from "./neynar.ts";
78const app = new Hono();
1920app.get("/api/miniapps", async (c) => {
21const response = await fetch(`https://client.warpcast.com/v1/top-frameapps?limit=100`).then(r => r.json()).then(r =>
22r?.result?.frames
23);
28const url = new URL(c.req.url);
29const path = url.searchParams.get("path");
30const response = await fetchNeynarGet(path).then(r => r.json());
31return c.json(response);
32});
73});
7475// HTTP vals expect an exported "fetch handler"
76// This is how you "run the server" in Val Town with Hono
77export default app.fetch;
FarcasterMiniAppStoreimage.tsx2 matches
82const fontPromises = fontsConfig.map(async (font) => {
83const fontUrl = "https://cdn.jsdelivr.net/npm/@tamagui/font-inter@1.108.3/otf/" + font.fontFile;
84const fontArrayBuf = await fetch(fontUrl).then((res) => res.arrayBuffer());
85return { name: font.name, data: fontArrayBuf, weight: font.weight };
86});
93// const api = `https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/svg/${code.toLowerCase()}.svg`
94const api = `https://cdn.jsdelivr.net/gh/shuding/fluentui-emoji-unicode/assets/${code.toLowerCase()}_color.svg`;
95return fetch(api).then((r) => r.text());
96};
97
FarcasterMiniAppStoreHome.tsx4 matches
67import { Button, Input, Section, ShareButton } from "../components/ui.tsx";
8import { fetchNeynarGet, fetchNeynarGetPages, fetchUsersById } from "../util/neynar.ts";
9import { useQuery } from "../util/useQuery.ts";
1038function MiniApps() {
39const { data: miniapps } = useQuery(["miniapps"], async () => {
40// return await fetch(`/api/miniapps`).then(r => r.json()).then(r => r);
41// return await fetchNeynarGet(`frame/catalog?limit=100`).then(r => r.frames);
42return await fetchNeynarGetPages(`frame/catalog?limit=100`, 4, "frames").then(r => r.frames);
43});
44
8990async function sendFarcasterNotification(payload: any) {
91return await fetch("https://api.warpcast.com/v1/frame-notifications", {
92method: "POST",
93headers: { "Content-Type": "application/json" },