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);
TracesStreammain.ts1 match
45setInterval(
6() => fetch("https://wolf--266a00ae4c8c11f0a9af76b3cceeab13.web.val.run"),
71_000,
8);
4const videoFeed = "https://www.youtube.com/feeds/videos.xml?channel_id=UC3TpyhwXdKXh_TcBC27QQaw";
5export async function parseFeedFromUrl(url: string) {
6const response = await fetch(url);
7const xml = await response.text();
8const feed = await parseFeed(xml);
266
267// Inject data to avoid extra round-trips
268const initialData = await fetchInitialData();
269const dataScript = `<script>
270window.__INITIAL_DATA__ = ${JSON.stringify(initialData)};
3623635. **API Design:**
364- `fetch` handler is the entry point for HTTP vals
365- Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`
366367
bluesky-jaws-1975main.tsx1 match
127// load script file
128// You cannot read files from the file system in Val Town. LOL!
129const resp = await fetch("https://www.val.town/x/cheersderek/bluesky-jaws-1975/code/jaws-1975.txt");
130const text = await resp.text();
131console.log(text);
vtEditorFiles-fixvaltown.mdc3 matches
221222// Inject data to avoid extra round-trips
223const initialData = await fetchInitialData();
224const dataScript = `<script>
225window.__INITIAL_DATA__ = ${JSON.stringify(initialData)};
2682695. **API Design:**
270- `fetch` handler is the entry point for HTTP vals
271- Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`
2722736. **Hono Peculiarities:**
GIthubProfileindex.tsx6 matches
339</div>
340<div className="mt-4 p-3 bg-blue-50 rounded-lg text-sm text-blue-800">
341<strong>💡 API Information:</strong> This data is fetched from GitHub's REST API v3.
342The APIs used are: <code>/users/{`{username}`}</code>, <code>/users/{`{username}`}/repos</code>,
343and <code>/users/{`{username}`}/events/public</code>.
354const [error, setError] = useState<string>('');
355356const fetchProfile = async (searchUsername: string) => {
357if (!searchUsername.trim()) return;
358362363try {
364const response = await fetch(`/api/user/${encodeURIComponent(searchUsername.trim())}`);
365const data = await response.json();
366367if (!response.ok) {
368throw new Error(data.error || 'Failed to fetch profile');
369}
370379const handleSubmit = (e: React.FormEvent) => {
380e.preventDefault();
381fetchProfile(username);
382};
383384// Load a default profile on mount
385useEffect(() => {
386fetchProfile('octocat');
387}, []);
388
GIthubProfileindex.ts12 matches
7677// Helper function to make GitHub API requests
78async function fetchGitHubAPI(endpoint: string): Promise<any> {
79const headers: Record<string, string> = {
80'Accept': 'application/vnd.github.v3+json',
88}
8990const response = await fetch(`https://api.github.com${endpoint}`, {
91headers
92});
111}
112113// API endpoint to fetch GitHub user profile data
114app.get("/api/user/:username", async c => {
115try {
120}
121122// Fetch user data
123const userResponse = await fetchGitHubAPI(`/users/${username}`);
124
125// Fetch user's repositories (latest 10, sorted by updated)
126const reposResponse = await fetchGitHubAPI(`/users/${username}/repos?sort=updated&per_page=10`);
127
128// Fetch user's recent public events (latest 10)
129const eventsResponse = await fetchGitHubAPI(`/users/${username}/events/public?per_page=10`);
130131const profileData: GitHubProfileData = {
142return c.json(profileData);
143} catch (error) {
144console.error("Error fetching GitHub data:", error);
145
146// If it's a rate limit error and the user is 'octocat', return demo data
150
151return c.json({
152error: error instanceof Error ? error.message : "Failed to fetch GitHub data"
153}, 500);
154}
252});
253254export default app.fetch;