130 return c.json(await getRows());
131 } catch (error) {
132 console.error("Error fetching data:", error);
133 return c.text("Error fetching data", 500);
134 }
135});
170 `);
171
172 return app.fetch(req);
173}
93});
94
95export default app.fetch;
21 const url = new URL(`${this.baseURL}/twitter/search`);
22 url.searchParams.set("query", query);
23 const resp = await fetch(url, {
24 headers: {
25 Authorization: `Bearer ${this.bearerToken}`,
5async function servePublicFile(path: string): Promise<Response> {
6 const url = new URL("./public/" + path, import.meta.url);
7 const text = await (await fetch(url, {
8 headers: {
9 "User-Agent": "", // to transpile TS to JS
181
182 try {
183 const response = await fetch("/", {
184 method: "POST",
185 body: JSON.stringify({
1import { fetch } from "https://esm.town/v/std/fetch";
2import { parseXML } from "https://esm.town/v/stevekrouse/parseXML";
3let { parse } = await import("npm:node-html-parser");
11 oldItems ??= {};
12
13 // Fetch each source, filter unseen news items
14 for (const source of sources) {
15 const sourceItems = await fetchSource(source, oldItems, descMaxLength);
16 newItems = { ...newItems, ...sourceItems };
17 }
26}
27
28async function fetchSource(url: string, oldItems: any, descMaxLength: number) {
29 // Fetch a source, filter unseen news items
30 console.log(`fetch: ${url}`);
31
32 function parseDescription(description: string, maxlength: number) {
52 try {
53 const oldLinks = new Set(Object.keys(oldItems));
54 const response = await fetch(url, { signal: AbortSignal.timeout(5000) });
55 const responseJSON = await parseXML(await response.text());
56 const items = responseJSON.rss.channel.item.filter(
21 const url = new URL(`${this.baseURL}/twitter/search`);
22 url.searchParams.set("query", query);
23 const resp = await fetch(url, {
24 headers: {
25 Authorization: `Bearer ${this.bearerToken}`,
101});
102
103export default app.fetch;
21 const url = new URL(`${this.baseURL}/twitter/search`);
22 url.searchParams.set("query", query);
23 const resp = await fetch(url, {
24 headers: {
25 Authorization: `Bearer ${this.bearerToken}`,
5async function servePublicFile(path: string): Promise<Response> {
6 const url = new URL("./public/" + path, import.meta.url);
7 const text = await (await fetch(url, {
8 headers: {
9 "User-Agent": "", // to transpile TS to JS