reactHonoStarterindex.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;
expSumOfTheDaymain.tsx2 matches
8081React.useEffect(() => {
82const fetchSvg = () => {
83const month = currentDate.getMonth() + 1;
84const date = currentDate.getDate();
88};
8990fetchSvg();
9192const timer = setInterval(() => {
58});
5960export default app.fetch;
5const iiifBaseUrl = "https://data.4tu.nl/iiif/v3/";
67async function fetchJson(url: string, token: string | null = null) {
8const headers = new Headers();
9if (token) {
10headers.append("Authorization", `token ${token}`);
11}
12return fetch(url, { headers }).then(resp => resp.ok ? resp.json() : null);
13}
1471}
72const token = params.get("token");
73const metadata = await fetchJson((token ? privateApiUrl : publicApiUrl) + "/" + datasetUuid, token);
74// return Response.json(metadata);
75if (!metadata) {
78const images = await Promise.all(
79metadata.files.map((i: any) =>
80fetchJson(iiifBaseUrl + i.uuid + "/info.json").then(resp => resp ? { ...resp, meta: i } : null)
81),
82);
aBeautifulMindindex.ts2 matches
21});
2223// HTTP vals expect an exported "fetch handler"
24// This is how you "run the server" in Val Town with Hono
25export default app.fetch;
twitterAlertmain.tsx3 matches
89useEffect(() => {
10// Fetch initial balance when component loads
11fetch('/balance')
12.then(response => response.json())
13.then(data => setBalance(data.balance));
16const handleClick = async () => {
17try {
18const response = await fetch('/earn', { method: 'POST' });
19const data = await response.json();
20setBalance(data.balance);
dailySlackRoundupmain.tsx2 matches
1import { fetch } from "https://esm.town/v/std/fetch";
2import { getDayName } from "https://esm.town/v/stevekrouse/getDayName?v=2";
3import process from "node:process";
45export const dailySlackRoundup = (async () => {
6const res = await fetch(process.env.BRAINBOT_WEBHOOK_URL, {
7method: "POST",
8body: JSON.stringify({
blob_adminmain.tsx23 matches
234const [isDragging, setIsDragging] = useState(false);
235236const fetchBlobs = useCallback(async () => {
237setLoading(true);
238try {
239const response = await fetch(`/api/blobs?prefix=${encodeKey(searchPrefix)}&limit=${limit}`);
240const data = await response.json();
241setBlobs(data);
242} catch (error) {
243console.error("Error fetching blobs:", error);
244} finally {
245setLoading(false);
248249useEffect(() => {
250fetchBlobs();
251}, [fetchBlobs]);
252253const handleSearch = (e) => {
264setBlobContentLoading(true);
265try {
266const response = await fetch(`/api/blob?key=${encodeKey(clickedBlob.key)}`);
267const content = await response.text();
268setSelectedBlob({ ...clickedBlob, key: decodeKey(clickedBlob.key) });
269setEditContent(content);
270} catch (error) {
271console.error("Error fetching blob content:", error);
272} finally {
273setBlobContentLoading(false);
278const handleSave = async () => {
279try {
280await fetch(`/api/blob?key=${encodeKey(selectedBlob.key)}`, {
281method: "PUT",
282body: editContent,
290const handleDelete = async (key) => {
291try {
292await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
293setBlobs(blobs.filter(b => b.key !== key));
294if (selectedBlob && selectedBlob.key === key) {
307const key = `${searchPrefix}${file.name}`;
308formData.append("key", encodeKey(key));
309await fetch("/api/blob", { method: "POST", body: formData });
310const newBlob = { key, size: file.size, lastModified: new Date().toISOString() };
311setBlobs([newBlob, ...blobs]);
315}
316}
317fetchBlobs();
318};
319329try {
330const fullKey = `${searchPrefix}${key}`;
331await fetch(`/api/blob?key=${encodeKey(fullKey)}`, {
332method: "PUT",
333body: "",
344const handleDownload = async (key) => {
345try {
346const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
347const blob = await response.blob();
348const url = window.URL.createObjectURL(blob);
363if (newKey && newKey !== oldKey) {
364try {
365const response = await fetch(`/api/blob?key=${encodeKey(oldKey)}`);
366const content = await response.blob();
367await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
368method: "PUT",
369body: content,
370});
371await fetch(`/api/blob?key=${encodeKey(oldKey)}`, { method: "DELETE" });
372setBlobs(blobs.map(b => b.key === oldKey ? { ...b, key: newKey } : b));
373if (selectedBlob && selectedBlob.key === oldKey) {
383const newKey = `__public/${key}`;
384try {
385const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
386const content = await response.blob();
387await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
388method: "PUT",
389body: content,
390});
391await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
392setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
393if (selectedBlob && selectedBlob.key === key) {
402const newKey = key.slice(9); // Remove "__public/" prefix
403try {
404const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
405const content = await response.blob();
406await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
407method: "PUT",
408body: content,
409});
410await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
411setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
412if (selectedBlob && selectedBlob.key === key) {
838});
839840export default lastlogin((request: Request) => app.fetch(request));
wikidataredirectormain.tsx5 matches
7* 3. Automatically redirect to the first website if only one exists
8*
9* Uses Wikidata's EntityData API to fetch website information
10*/
11import { Hono } from 'npm:hono';
8586try {
87const res = await fetch(`https://www.wikidata.org/wiki/Special:EntityData/${qid}.json?flavor=simple`);
88const data = await res.json();
89140141} catch (error) {
142console.error('Wikidata fetch error:', error);
143return c.text('Error fetching Wikidata information', 500);
144}
145});
146147export default app.fetch;
ValueAwardmain.tsx12 matches
7778useEffect(() => {
79fetchHighFives();
80if (isAdmin) {
81fetchAnalytics();
82}
83}, [isAdmin]);
91}, [employeeSearch]);
9293const fetchHighFives = async () => {
94const response = await fetch('/api/highfives');
95const data = await response.json();
96setHighFives(data);
97};
9899const fetchAnalytics = async () => {
100const response = await fetch('/api/analytics');
101const data = await response.json();
102setAnalytics(data);
117if (isAdminUser) {
118setIsAdmin(true);
119fetchAnalytics();
120} else {
121alert('Invalid admin credentials');
125data.awardDate = new Date().toISOString().split('T')[0];
126127const response = await fetch('/api/highfives', {
128method: 'POST',
129headers: {
136alert('High five submitted successfully!');
137event.target.reset();
138fetchHighFives();
139} else {
140alert('Error submitting high five. Please try again.');
144145const handleDownloadCSV = async () => {
146const response = await fetch('/api/download-csv');
147if (response.ok) {
148const blob = await response.blob();
162const handleDeleteAnalytics = async () => {
163if (window.confirm('Are you sure you want to delete all recorded data and start fresh? This action cannot be undone.')) {
164const response = await fetch('/api/delete-analytics', { method: 'POST' });
165if (response.ok) {
166alert('All recorded data has been deleted. Analytics will start fresh from now.');
167fetchAnalytics();
168} else {
169alert('Error deleting analytics data. Please try again.');