36
37 useEffect(() => {
38 async function fetchStats() {
39 const response = await fetch("/dashboard-stats");
40 const data = await response.json();
41 setStats(data);
42 }
43 fetchStats();
44 }, []);
45
146
147 try {
148 const response = await fetch("/", {
149 method: "POST",
150 body: JSON.stringify({
20 for (const topic of KEYWORDS) {
21 const results = await Promise.allSettled([
22 fetchHackerNewsResults(topic),
23 fetchTwitterResults(topic),
24 fetchRedditResults(topic),
25 ]);
26
49}
50
51// Fetch Hacker news, Twitter, and Reddit results
52async function fetchHackerNewsResults(topic: string): Promise<Website[]> {
53 return hackerNewsSearch({
54 query: topic,
58}
59
60async function fetchTwitterResults(topic: string): Promise<Website[]> {
61 return twitterSearch({
62 query: topic,
67}
68
69async function fetchRedditResults(topic: string): Promise<Website[]> {
70 return redditSearch({ query: topic });
71}
84 }
85
86 const response = await fetch(slackWebhookUrl, {
87 method: "POST",
88 headers: { "Content-Type": "application/json" },
90
91 try {
92 const response = await fetch("/ask", {
93 method: "POST",
94 headers: {
87
88 try {
89 const response = await fetch("/summarize", {
90 method: "POST",
91 body: JSON.stringify({ url }),
224 const { url } = await request.json();
225
226 // Fetch webpage content
227 const webpageResponse = await fetch(url);
228 const webpageText = await webpageResponse.text();
229
145
146 try {
147 const response = await fetch("/ask", {
148 method: "POST",
149 headers: {
8 }
9
10 const response = await fetch(`https://ntfy.sh/${ntfyChannel}`, {
11 method: "POST",
12 body: `What did you throw out today?`,
35}, { concurrency: 3 })).filter(Boolean);
36
37// fetch text from endpoint
38const vals3 = await pMap(vals2, async (v) => {
39 if (!v.links.endpoint) return v;
40 const text = await (await fetch(v.links.endpoint)).text();
41 return { ...v, endpointText: text };
42}, { concurrency: 3 });
69}
70
71// fetch ai summary of val
72const vals4 = await pMap(vals3, async (v) => {
73 const descriptions = await getDescriptions(v);
76
77async function getScreenshot(url: string) {
78 const resp = await fetch(
79 "https://api.apiflash.com/v1/urltoimage?" + new URLSearchParams({
80 access_key: Deno.env.get("API_FLASH"),
88export type WideApi = typeof routes;
89
90export default app.fetch.bind(app);
1/** @jsxImportSource https://esm.sh/preact **/
2
3import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
4import { api } from "https://esm.town/v/pomdtr/api";
5import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo";
145
146 try {
147 const response = await fetch("/ask", {
148 method: "POST",
149 headers: {