stevensDemoindex.ts2 matches
135));
136137// HTTP vals expect an exported "fetch handler"
138export default app.fetch;
stevensDemo.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
stevensDemoApp.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);
68return rateLimitService.executeWithRateLimit(routeKey, async () => {
69console.log(`🔄 Sending request to ${url}`);
70const response = await fetch(url, {
71...options,
72headers,
2829console.log(`🔄 Sending request to ${url}`);
30const response = await fetch(url, {
31...options,
32headers,
luciaMagicLinkStarterindex.ts2 matches
24});
2526// HTTP vals expect an exported "fetch handler"
27// This is how you "run the server" in Val Town with Hono
28export default app.fetch;
66return rateLimitService.executeWithRateLimit(routeKey, async () => {
67console.log(`🔄 Sending request to ${url}`);
68const response = await fetch(url, {
69...options,
70headers,
109const token = Deno.env.get("DISCORD_BOT_TOKEN");
110111const response = await fetch(url, {
112method: "PUT",
113headers: {
crypto-geminiscript.tsx11 matches
2// Make sure to set the COINGECKO_API_KEY environment variable in Val Town
34import { fetch } from "npm:undici"; // Use undici for fetch in Node.js environment
56interface CoinGeckoMarketCoin {
57const FNG_API_URL = "https://api.alternative.me/fng/?limit=1";
5859async function fetchFromApi<T>(url: string, isCoinGecko: boolean = true): Promise<T | null> {
60const headers: HeadersInit = {};
61if (isCoinGecko && COINGECKO_API_KEY) {
6566try {
67const response = await fetch(url, { headers });
68if (!response.ok) {
69const errorText = await response.text();
73return await response.json() as T;
74} catch (error) {
75console.error(`Network or Fetch Error for ${url}: `, error);
76return null;
77}
100topCoinsData,
101] = await Promise.all([
102fetchFromApi<CoinGeckoMarketCoin[]>(`${COINGECKO_API_BASE}/coins/markets?vs_currency=usd&ids=bitcoin`),
103fetchFromApi<CoinGeckoChartData>(
104`${COINGECKO_API_BASE}/coins/bitcoin/market_chart?vs_currency=usd&days=30&interval=daily`,
105),
106fetchFromApi<FearAndGreedData>(FNG_API_URL, false), // false for isCoinGecko
107fetchFromApi<CoinGeckoGlobalData>(`${COINGECKO_API_BASE}/global`),
108fetchFromApi<CoinGeckoMarketCoin[]>(
109`${COINGECKO_API_BASE}/coins/markets?vs_currency=usd&order=market_cap_desc&per_page=10&page=1&sparkline=true&price_change_percentage=7d`,
110),
124});
125} catch (error) {
126console.error("Error fetching dashboard data:", error);
127return new Response(JSON.stringify({ error: "Failed to fetch dashboard data" }), {
128headers: { ...corsHeaders, "Content-Type": "application/json" },
129status: 500,
dood-redirectmain.tsx1 match
16});
1718export default app.fetch;
mastodon-pogodanew-file-2457.tsx4 matches
1const mastodonToken = Deno.env.get("MASTODON_ACCESS_TOKEN");
23import { fetchText } from "https://esm.town/v/stevekrouse/fetchText?v=6";
4import { load } from "npm:cheerio";
56async function mastodonWeatherMap() {
7const html = await fetchText("https://www.bankier.pl//gielda/notowania/indeksy-gpw"); // Przykład linku do strony z ETF-ami
8const $ = load(html);
936const status = await mastodonWeatherMap();
3738const html = await fetchText(
39"https://www.bankier.pl//gielda/notowania/indeksy-gpw",
40);
47console.log("lol");
4849await fetch(`https://mastodon.social/api/v1/statuses`, {
50method: "POST",
51headers: {