1import { fetch } from "https://esm.town/v/std/fetch";
2
3export default async function proxy(req: Request) {
4 const resp = await fetch(
5 "http://api.quotable.io/quotes/random?limit=1",
6 );
16async function POST(cmd: string, data: { [key: string]: string }) {
17 const url = BOT + "/" + cmd;
18 return await (await fetch(
19 url,
20 {
27
28async function GET(cmd: string) {
29 return await (await fetch(BOT + "/" + cmd)).json();
30}
31
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" },
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" },
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" },
67 }
68
69 console.log(`Fetching contributions for ${username}`);
70 try {
71 let vals;
81 }
82
83 console.log(`Fetched ${vals.length} contributions`);
84 const contributionData = processVals(vals, useVersions);
85 console.log(`Processed ${contributionData.length} contributions`);
282}
283
284export default (typeof Deno !== "undefined" && Deno.env.get("valtown")) ? app.fetch : app;
67 }
68
69 console.log(`Fetching contributions for ${username}`);
70 try {
71 let vals;
81 }
82
83 console.log(`Fetched ${vals.length} contributions`);
84 const contributionData = processVals(vals, useVersions);
85 console.log(`Processed ${contributionData.length} contributions`);
282}
283
284export default (typeof Deno !== "undefined" && Deno.env.get("valtown")) ? app.fetch : app;
20
21 useEffect(() => {
22 fetchTables();
23 }, []);
24
25 const fetchTables = async () => {
26 try {
27 const response = await fetch("/tables");
28 const data = await response.json();
29 setTables(data);
30 } catch (err) {
31 setError("Failed to fetch tables");
32 }
33 };
34
35 const fetchTableData = async (tableName) => {
36 try {
37 const dataResponse = await fetch(`/table/${tableName}`);
38 const data = await dataResponse.json();
39 setTableData(data);
40
41 const schemaResponse = await fetch(`/schema/${tableName}`);
42 const schema = await schemaResponse.json();
43 setTableSchema(schema);
51 setNewRow(emptyRow);
52 } catch (err) {
53 setError(`Failed to fetch data for table ${tableName}`);
54 }
55 };
61 const handleSave = async (index) => {
62 try {
63 const response = await fetch(`/update/${selectedTable}`, {
64 method: "POST",
65 headers: {
72 }
73 setEditingRow(null);
74 await fetchTableData(selectedTable);
75 } catch (err) {
76 setError(`Failed to update row: ${err.message}`);
90 const handleAddRow = async () => {
91 try {
92 const response = await fetch(`/insert/${selectedTable}`, {
93 method: "POST",
94 headers: {
100 throw new Error("Failed to add new row");
101 }
102 await fetchTableData(selectedTable);
103 // Reset newRow to empty values
104 const emptyRow = Object.keys(newRow).reduce((acc, key) => {
120 <li
121 key={table}
122 onClick={() => fetchTableData(table)}
123 className={selectedTable === table ? "active" : ""}
124 >
9
10 try {
11 const response = await fetch(url);
12 const html = await response.text();
13
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" },