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);
1import { blob } from "https://esm.town/v/std/blob?v=12";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3import { msDay } from "https://esm.town/v/stevekrouse/msDay";
4import { msHour } from "https://esm.town/v/stevekrouse/msHour";
25lon: number;
26}) => {
27const { results } = await fetchJSON(
28`${BASE_URL}/v3/locations?`
29+ new URLSearchParams({
50export async function openAqNowcastAQI(location) {
51const sensorID = location.sensors.find(s => s.parameter.name === "pm25").id;
52const data = await fetchJSON(
53`${BASE_URL}/v3/sensors/${sensorID}/measurements?`
54+ new URLSearchParams({
3export default async function(req: Request): Promise<Response> {
4const url = new URL(req.url);
5return fetch(TARGET_URL + url.pathname + url.search, {
6headers: {
7"X-API-Key": Deno.env.get("OpenAQ_API_KEY") as string,
aqinominatim.ts2 matches
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
23export function nominatimSearch(params: Search): Promise<Place[]> {
4return fetchJSON(
5"https://nominatim.openstreetmap.org/search?"
6+ new URLSearchParams({
6263useEffect(() => {
64const fetchYCCompanies = async () => {
65const storedCompanies = localStorage.getItem("ycCompanies");
66if (storedCompanies) {
69setDebugInfo(prevInfo => prevInfo + `\nLoaded ${companies.length} companies from localStorage`);
70} else {
71const response = await fetch("/companies.json");
72const companies = await response.json();
73setYcCompanies(companies);
74localStorage.setItem("ycCompanies", JSON.stringify(companies));
75setDebugInfo(prevInfo =>
76prevInfo + `\nFetched ${companies.length} companies from server and stored in localStorage`
77);
78}
79};
80fetchYCCompanies();
81}, []);
82226227export default async function server(request: Request): Promise<Response> {
228const companies = await fetch("https://stevekrouse-yc_database.web.val.run").then(res => res.json());
229const url = new URL(request.url);
230if (url.pathname === "/companies.json") {
2import { cleanupOldAggregatedEntries } from "./cleanup"; // For manual trigger
3import { initializeAggregatorDB } from "./db"; // Make sure DB is initialized
4import { fetchAndStoreNewCreations } from "./fetchAndStore"; // For manual trigger
5import { serveFrontend } from "./frontend";
6import { generateRSSFeed } from "./generateRSS";
15console.log(`[${new Date().toISOString()}] Request: ${req.method} ${path}`);
1617// Add CORS headers - useful if you ever want to fetch feed via JS
18const corsHeaders = {
19"Access-Control-Allow-Origin": "*",
49case "/_update":
50console.log("Manual update triggered.");
51const fetchRes = await fetchAndStoreNewCreations();
52const cleanupRes = await cleanupOldAggregatedEntries();
53response = Response.json({ ok: true, fetch: fetchRes, cleanup: cleanupRes }, { headers: corsHeaders });
54break;
55
3// Use a distinct table name for this aggregator instance
4export const AGGREGATOR_TABLE_NAME = "pondiverse_rss_aggregator_v2"; // Incremented version
5export const UPSTREAM_PONDIVERSE_URL = "https://pondiverse.com"; // URL for linking, not fetching
67export async function initializeAggregatorDB() {
FeedPondgenerateRSS.js2 matches
27try {
28const results = await sqlite.execute({
29// Fetch recent items, ordered by original creation time
30sql: `SELECT title, type, creation_time, image_url, link
31FROM ${AGGREGATOR_TABLE_NAME}
54}
55} catch (error) {
56console.error("Error fetching items for RSS feed:", error);
57// Optionally add an error item to the feed
58itemsXml = `