1/** @jsxImportSource https://esm.sh/hono@4.0.8/jsx **/
2
3import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
4import view_route from "https://esm.town/v/pomdtr/blob_admin_blob";
5import create_route from "https://esm.town/v/pomdtr/blob_admin_create";
137});
138
139export default modifyFetchHandler(passwordAuth(app.fetch));
1Migrated from folder: tools/cfetch
95 const getVQD = async () => {
96 try {
97 const response = await fetch(STATUS_URL, {
98 headers: {
99 "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.3",
102 });
103
104 console.log('VQD Fetch Headers:', Object.fromEntries(response.headers.entries()));
105 const newVQD = response.headers.get('x-vqd-4') || '';
106 console.log('Fetched VQD:', newVQD);
107 setVqd(newVQD);
108 return newVQD;
109 } catch (error) {
110 console.error('VQD Fetch Error:', error);
111 return '';
112 }
125 let currentVQD = vqd || await getVQD();
126
127 const response = await fetch(CHAT_URL, {
128 method: 'POST',
129 headers: {
381 if (request.url.includes('/api/status')) {
382 try {
383 const statusResponse = await fetch('https://duckduckgo.com/duckchat/v1/status', {
384 headers: {
385 "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.3",
400 } catch (error) {
401 console.error('Status Proxy Error:', error);
402 return new Response(JSON.stringify({ error: 'Failed to fetch VQD' }), {
403 status: 500,
404 headers: {
413 try {
414 const requestBody = await request.json();
415 const chatResponse = await fetch('https://duckduckgo.com/duckchat/v1/chat', {
416 method: 'POST',
417 headers: {
35}
36
37// ----- fetch or read from file
38
39async function fetchOutages() {
40 const res = await fetch(OUTAGES_URL);
41 const json = await res.json();
42 return json as OutagesJson;
101export async function getOutages() {
102 // const outagesJson = await readOutages();
103 const outagesJson = await fetchOutages();
104
105 // Create check
10app.get("/", async (c) => c.html(await sqlite_admin_tables()));
11app.get("/:table", async (c) => c.html(await sqlite_admin_table(c.req.param("table"))));
12export default basicAuth(app.fetch, { verifyUser: (_, password) => verifyToken(password) });
1import { email } from "https://esm.town/v/std/email?v=9";
2
3// Fetches a random joke.
4function fetchRandomJoke() {
5 const response = fetch(
6 "https://official-joke-api.appspot.com/random_joke",
7 );
9}
10
11const randomJoke = fetchRandomJoke();
12const setup = randomJoke.setup;
13const punchline = randomJoke.punchline;
14 start = performance.now();
15 try {
16 const res = await fetch(url);
17 end = performance.now();
18 status = res.status;
25 } catch (e) {
26 end = performance.now();
27 reason = `couldn't fetch: ${e}`;
28 ok = false;
29 console.log(`Website down (${url}): ${reason} (${end - start}ms)`);
1// ... imports ...
2
3// Fetches a random joke.
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",
7 );
9}
10
11const randomJoke = await fetchRandomJoke();
12const setup = randomJoke.setup;
13const punchline = randomJoke.punchline;
16// --------------------------
17
18async function fetchNews(queries: any, hours: number, lang: string, region: string) {
19 let news;
20 let results = [];
103export default async function(interval: Interval) {
104 try {
105 const results = await fetchNews(queries, hours, lang, region);
106 console.log(`${
107 results.map(q => {
41 { query, hours, lang, region }: { query: string; hours: number; lang: string; region: string },
42) {
43 const response = await fetch(
44 getFeedUrl(query, hours, lang, region),
45 );