21});
22
23// HTTP vals expect an exported "fetch handler"
24// This is how you "run the server" in Val Town with Hono
25export default app.fetch;
8 }
9
10 const response = await fetch(`https://ntfy.sh/${ntfyChannel}`, {
11 method: "POST",
12 body: `How much do you weigh?`,
2 * Random Subcurrent RSS Aggregator Post Selector
3 *
4 * This Val fetches the RSS feed from Astoria Tech's Subcurrent RSS aggregator,
5 * selects a random post, and displays its metadata.
6 */
18export default async function (req: Request): Promise<Response> {
19 try {
20 // Fetch the RSS feed
21 const response = await fetch(
22 "https://astoria-tech.github.io/subcurrent-astro/rss.xml"
23 );
25 if (!response.ok) {
26 throw new Error(
27 `Failed to fetch RSS feed: ${response.status} ${response.statusText}`
28 );
29 }
172 <div class="max-w-2xl mx-auto bg-white p-6 rounded-lg shadow-md">
173 <h1 class="text-2xl font-bold text-red-700 mb-4">Error</h1>
174 <p class="mb-4">Sorry, something went wrong while fetching or processing the RSS feed:</p>
175 <div class="bg-red-50 border-l-4 border-red-500 p-4 mb-4">
176 <p class="text-red-700">${
43
44// This is the entry point for HTTP vals
45export default app.fetch;
18 // console.log(host);
19 const url = `https://${host}/cache`;
20 const response = await fetch(url, {
21 method: "GET",
22 headers: {},
41 const host = new URL(c.req.url).host; // see: https://github.com/orgs/honojs/discussions/3644
42 const url = `https://${host}/cache`;
43 const response = await fetch(url, {
44 method: "GET",
45 headers: {},
71 });
72
73 // fetch current status
74 const res = await sqlite.execute({
75 sql: `SELECT status, assistant_text, full_json
63
64 // 3. send to Anthropic
65 const batch = await fetch("https://api.anthropic.com/v1/messages/batches", {
66 method: "POST",
67 headers: {
21 let follows: any[] = [];
22 let cursor: string | undefined = undefined;
23 let pagesFetched = 0;
24
25 let seenDids = new Set();
54 // Take time between each page to avoid hammering bluesky too much
55 await new Promise(resolve => setTimeout(resolve, 100));
56 pagesFetched++;
57 console.log(`${pagesFetched} PAGES FETCHED`);
58 }
59
60 console.log(`${pagesFetched} PAGES FETCHED`);
61 console.log(`${follows.length} PROFILES FETCHED`);
62
63 type R = {
1// harvest_results.cron.ts โ now authenticates results_url fetch
2import { sqlite } from "https://esm.town/v/std/sqlite";
3const log = (...m: unknown[]) => console.log(new Date().toISOString(), "โ", ...m);
45// โโ batch handler โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
46async function handleBatch(id: string) {
47 const info = await fetch(`https://api.anthropic.com/v1/messages/batches/${id}`, {
48 headers: { "x-api-key": API_KEY!, "anthropic-version": VERSION_HEADER },
49 }).then(r => r.json());
53
54 // โ
authenticated download
55 const raw = await fetch(info.results_url, {
56 headers: { "x-api-key": API_KEY!, "anthropic-version": VERSION_HEADER },
57 }).then(r => r.text());
21 let follows: any[] = [];
22 let cursor: string | undefined = undefined;
23 let pagesFetched = 0;
24
25 let seenDids = new Set();
54 // Take time between each page to avoid hammering bluesky too much
55 await new Promise(resolve => setTimeout(resolve, 100));
56 pagesFetched++;
57 console.log(`${pagesFetched} PAGES FETCHED`);
58 }
59
60 console.log(`${pagesFetched} PAGES FETCHED`);
61 console.log(`${follows.length} PROFILES FETCHED`);
62
63 type R = {