135
136 // Proceed with the proxy request
137 let resp = await fetch("https://news.ycombinator.com" + url.pathname + url.search, {
138 headers: req.headers,
139 method: req.method,
1/** @jsxImportSource https://esm.sh/hono@latest/jsx **/
2
3import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
4import { iframeHandler } from "https://esm.town/v/nbbaier/iframeHandler";
5import { resetStyle } from "https://esm.town/v/nbbaier/resetStyle";
16import { verifyToken } from "https://esm.town/v/pomdtr/verifyToken";
17import { ResultSet, sqlite } from "https://esm.town/v/std/sqlite";
18import { reloadOnSaveFetchMiddleware } from "https://esm.town/v/stevekrouse/reloadOnSave";
19import { Hono } from "npm:hono";
20import type { FC } from "npm:hono/jsx";
175});
176
177export const handler = app.fetch;
178export default iframeHandler(modifyFetchHandler(passwordAuth(handler, { verifyPassword: verifyToken })));
68 headers?: Record<string, string>;
69}) => {
70 let result = await fetch(
71 `${API_URL}/v1/email`,
72 {
44
45 useEffect(() => {
46 fetchAnswersAndRankings();
47 }, [user]);
48
49 const fetchAnswersAndRankings = async () => {
50 if (user) {
51 const response = await fetch("/api/answers");
52 const data = await response.json();
53 setAnswers(data.answers);
59 const saveAnswer = useCallback(async (newAnswer: Answer, losingAnswer: string) => {
60 if (user) {
61 await fetch("/api/answer", {
62 method: "POST",
63 headers: { "Content-Type": "application/json" },
64 body: JSON.stringify({ ...newAnswer, losingAnswer }),
65 });
66 fetchAnswersAndRankings();
67 }
68 }, [user]);
70 const clearAnswers = useCallback(async () => {
71 if (user) {
72 await fetch("/api/clear-answers", { method: "POST" });
73 setAnswers([]);
74 setRankings([]);
242 const handleLogin = useCallback(async (e: React.FormEvent) => {
243 e.preventDefault();
244 const response = await fetch("/api/login", {
245 method: "POST",
246 headers: { "Content-Type": "application/json" },
1/**
2 * This val creates an elegant and professional web app for managing panel members for the State Street discussion.
3 * It uses React for the UI, SQLite for storing panel member information, and the Fetch API to communicate with the server.
4 * The design is clean and sophisticated, with a muted color palette and subtle animations.
5 */
16
17 useEffect(() => {
18 fetchPanelMembers();
19 }, []);
20
21 const fetchPanelMembers = async () => {
22 setIsLoading(true);
23 try {
24 const response = await fetch("/panel-members");
25 if (!response.ok) {
26 throw new Error("Failed to fetch panel members");
27 }
28 const data = await response.json();
39 setIsLoading(true);
40 try {
41 const response = await fetch("/add-member", {
42 method: "POST",
43 headers: { "Content-Type": "application/json" },
48 }
49 setNewMember({ name: "", expertise: "" });
50 fetchPanelMembers();
51 } catch (err) {
52 setError("Failed to add panel member. Please try again.");
1// This val fetches movie showings hourly, compares with previous data,
2// and sends an email for new movies. It uses the Val Town Blob storage
3// for persistence and the std/email module for sending notifications.
9const STORAGE_KEY = "alamo_showings";
10
11async function fetchShowings() {
12 const response = await fetch(THEATER_API);
13 return await response.json();
14}
37
38export default async function main() {
39 const showings = await fetchShowings();
40 await compareAndNotify(showings);
41 return new Response("Movie showings checked and notifications sent if needed.");
673
674 try {
675 const response = await fetch(url, {
676 method: "POST",
677 headers: headers,
83
84 console.log("Sending request to /analyze");
85 const response = await fetch('/analyze', {
86 method: 'POST',
87 body: formData
1import { fetch } from "https://esm.town/v/std/fetch";
2import { email, IAddress } from "https://esm.town/v/std/email";
3import { DOMParser, Element } from "jsr:@b-fuze/deno-dom";
38async function checkHN(matchedStories) {
39 // Get the title of the top story on Hacker News
40 const res = await fetch("https://hacker-news.firebaseio.com/v0/topstories.json")
41 const topStories = await res.json()
42 const frontPage = topStories.slice(0, 50)
43
44 const promises = frontPage.map(async storyId => {
45 const res = await fetch(`https://hacker-news.firebaseio.com/v0/item/${storyId}.json`)
46 const story = await res.json()
47 try {
57
58async function checkLobsters(matchedStories) {
59 const res = await fetch(`https://lobste.rs`)
60 const text = await res.text()
61
1import { fetch } from "https://esm.town/v/std/fetch";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3
4// Get the title of the top story on Hacker News
5export async function hnTopStory() {
6 const topStories: Number[] = await fetch(
7 "https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty",
8 ).then((res) => res.json());
15 score: number;
16 by: string;
17 } = await fetchJSON(
18 `https://hacker-news.firebaseio.com/v0/item/${id}.json`,
19 );