19queries: {
20staleTime: 60 * 1000, // 1 minute
21refetchOnWindowFocus: false,
22},
23},
4142- `GET /` - Serves the React application with initial data
43- `GET /api/messages` - Fetch all messages (JSON)
44- `POST /api/messages` - Create a new message
45- `GET /public/**` - Static assets (CSS, JS, etc.)
tanstackReactHonoExamplequeries.ts5 matches
2import { type Message } from "../../shared/utils.ts";
34// Fetch messages query
5export function useMessages(initialData?: Message[]) {
6return useQuery({
7queryKey: ["messages"],
8queryFn: async () => {
9const response = await fetch("/api/messages");
10if (!response.ok) {
11throw new Error("Failed to fetch messages");
12}
13const data = await response.json();
25return useMutation({
26mutationFn: async (content: string) => {
27const response = await fetch("/api/messages", {
28method: "POST",
29headers: { "Content-Type": "application/json" },
38},
39onSuccess: () => {
40// Invalidate and refetch messages
41queryClient.invalidateQueries({ queryKey: ["messages"] });
42},
tanstackReactHonoExampleindex.ts2 matches
58});
5960// HTTP vals expect an exported "fetch handler"
61// This is how you "run the server" in Val Town with Hono
62export default app.fetch;
91**Individual Record Access:**
92- Implement `com.atproto.sync.getRecord` for external clients
93- Allow other servers/clients to fetch specific check-in records
94- Required for federation and embedding
95
anchorPDSval-town.md3 matches
216217// Inject data to avoid extra round-trips
218const initialData = await fetchInitialData();
219const dataScript = `<script>
220window.__INITIAL_DATA__ = ${JSON.stringify(initialData)};
2662675. **API Design:**
268- `fetch` handler is the entry point for HTTP vals
269- Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`
2702716. **Hono Peculiarities:**
stevensDemosendDailyBrief.ts1 match
135const lastSunday = today.startOf("week").minus({ days: 1 });
136137// Fetch relevant memories using the utility function
138const memories = await getRelevantMemories();
139
stevensDemoNotebookView.tsx12 matches
67const [currentPage, setCurrentPage] = useState(1);
6869const fetchMemories = useCallback(async () => {
70setLoading(true);
71setError(null);
72try {
73const response = await fetch(API_BASE);
74if (!response.ok) {
75throw new Error(`HTTP error! status: ${response.status}`);
78setMemories(data);
79} catch (e) {
80console.error("Failed to fetch memories:", e);
81setError(e.message || "Failed to fetch memories.");
82} finally {
83setLoading(false);
8687useEffect(() => {
88fetchMemories();
89}, [fetchMemories]);
9091const handleAddMemory = async (e: React.FormEvent) => {
100101try {
102const response = await fetch(API_BASE, {
103method: "POST",
104headers: { "Content-Type": "application/json" },
112setNewMemoryTags("");
113setShowAddForm(false);
114await fetchMemories();
115} catch (e) {
116console.error("Failed to add memory:", e);
123124try {
125const response = await fetch(`${API_BASE}/${id}`, {
126method: "DELETE",
127});
129throw new Error(`HTTP error! status: ${response.status}`);
130}
131await fetchMemories();
132} catch (e) {
133console.error("Failed to delete memory:", e);
155156try {
157const response = await fetch(`${API_BASE}/${editingMemory.id}`, {
158method: "PUT",
159headers: { "Content-Type": "application/json" },
164}
165setEditingMemory(null);
166await fetchMemories();
167} catch (e) {
168console.error("Failed to update memory:", e);
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