44});
4546export default app.fetch;
react-router-hono-starterroutes.tsx2 matches
3import { useLoaderData, Link, Outlet } from "https://esm.sh/react-router@7";
45// provide the full URL so that both the client and server can fetch
6const API_URL = "https://react-router-hono.val.run/api";
77071async function catsLoader () {
72const data = await fetch(API_URL)
73.then(res => res.json());
74return data;
1213The routes are defined in `routes` and can include data loading and actions.
14The `/about` route includes a loader that fetches data from the `/api` route, which returns a JSON response.
15The About page uses the `useLoaderData` hook to render the data from the loader in the page.
16
1/** @jsxImportSource npm:hono@3/jsx */
2import { modifyFetchHandler as codeOnValTownBanner } from "https://esm.town/v/andreterron/codeOnValTown";
3import { passwordAuth } from "https://esm.town/v/pomdtr/password_auth";
4import { Hono } from "npm:hono@3";
121122export default codeOnValTownBanner(
123passwordAuth(app.fetch, { verifyPassword: verifyToken }),
124);
Jobchatappchat.ts2 matches
11return c.json(messages);
12} catch (error) {
13console.error("Error fetching chat messages:", error);
14return c.json({ error: "Failed to fetch chat messages" }, 500);
15}
16});
Jobchatappapp.js16 matches
115116// Job Listings
117const fetchJobs = async () => {
118try {
119const response = await fetch('/api/jobs');
120if (!response.ok) throw new Error('Failed to fetch jobs');
121
122const jobs = await response.json();
123renderJobs(jobs);
124} catch (error) {
125console.error('Error fetching jobs:', error);
126jobListings.innerHTML = '<li class="px-4 py-4 sm:px-6 text-center text-red-500">Failed to load job listings</li>';
127}
169
170try {
171const response = await fetch('/api/jobs', {
172method: 'POST',
173headers: {
184// Clear form and refresh job listings
185jobForm.reset();
186fetchJobs();
187
188// Show success message
195196// Chat functionality
197const fetchChatMessages = async () => {
198try {
199const response = await fetch('/api/chat');
200if (!response.ok) throw new Error('Failed to fetch chat messages');
201
202const messages = await response.json();
203renderChatMessages(messages.reverse()); // Reverse to show oldest first
204} catch (error) {
205console.error('Error fetching chat messages:', error);
206chatMessages.innerHTML = '<div class="text-center text-red-500">Failed to load chat messages</div>';
207}
260
261try {
262const response = await fetch('/api/chat', {
263method: 'POST',
264headers: {
278// Clear input and refresh messages
279chatInput.value = '';
280fetchChatMessages();
281} catch (error) {
282console.error('Error sending message:', error);
311const startPolling = () => {
312// Poll for new jobs every 30 seconds
313setInterval(fetchJobs, 30000);
314
315// Poll for new chat messages every 5 seconds
316setInterval(fetchChatMessages, 5000);
317};
318321setViewSourceLink();
322loadUsername();
323fetchJobs();
324fetchChatMessages();
325startPolling();
326
Jobchatappindex.ts1 match
4546// Export the Hono app for HTTP vals
47export default app.fetch;
vectorsroutes.tsx2 matches
3import { useLoaderData, Link, Outlet } from "https://esm.sh/react-router@7";
45// provide the full URL so that both the client and server can fetch
6const API_URL = "https://react-router-hono.val.run/api";
77071async function catsLoader () {
72const data = await fetch(API_URL)
73.then(res => res.json());
74return data;
Jobchatappjobs.ts2 matches
10return c.json(jobPostings);
11} catch (error) {
12console.error("Error fetching jobs:", error);
13return c.json({ error: "Failed to fetch job postings" }, 500);
14}
15});
2122/* ── helper: pull one page synchronously ── */
23async function fetchPage(offset: number) {
24const query = `
25SELECT
35`;
3637const res = await fetch(
38`${POSTHOG_HOST}/api/projects/${POSTHOG_PROJECT_ID}/query/`,
39{
6364for (let page = 0; page < MAX_PAGES; page++) {
65const rows = await fetchPage(page * PAGE_LIMIT);
66if (rows.length === 0) break;
67