26 visited.add(url);
27
28 const response = await fetch(url);
29 const html = await response.text();
30 const $ = cheerio.load(html);
1/** @jsxImportSource npm:hono@3/jsx */
2import { modifyFetchHandler as codeOnValTownBanner } from "https://esm.town/v/andreterron/codeOnValTown";
3import { passwordAuth } from "https://esm.town/v/pomdtr/password_auth";
4import { Hono } from "npm:hono@3";
122
123export default codeOnValTownBanner(
124 passwordAuth(app.fetch, { verifyPassword: verifyToken }),
125);
128 }
129
130 // Fetch recent requests
131 const requests = await sqlite.execute(`
132 SELECT id, method, url, timestamp
1/**
2 * This val creates a Postman-like interface for testing HTTP requests directly in the browser.
3 * It uses React for the UI and the Fetch API to make requests.
4 * The server function serves the HTML and handles the API requests.
5 */
24 body: method !== 'GET' && body ? body : undefined
25 };
26 const res = await fetch('/proxy', {
27 method: 'POST',
28 headers: { 'Content-Type': 'application/json' },
108 const { url: targetUrl, options } = await request.json();
109 try {
110 const response = await fetch(targetUrl, options);
111 const data = await response.json();
112 return new Response(JSON.stringify({
43 }
44
45 // Fetch todos from the database
46 const todos = await sqlite.execute(`SELECT * FROM ${KEY}_todos_${SCHEMA_VERSION} ORDER BY id DESC`);
47
76 if (valURL) {
77 try {
78 await fetch(valURL)
79 .then(res => res.json())
80 .then(res => {
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,
68 headers?: Record<string, string>;
69}) => {
70 let result = await fetch(
71 `${API_URL}/v1/email`,
72 {
35
36async function execute(statement: InStatement): Promise<ResultSet> {
37 const res = await fetch(`${API_URL}/v1/sqlite/execute`, {
38 method: "POST",
39 headers: {
49
50async function batch(statements: InStatement[], mode?: TransactionMode): Promise<ResultSet[]> {
51 const res = await fetch(`${API_URL}/v1/sqlite/batch`, {
52 method: "POST",
53 headers: {
83 const form = event.target;
84 const formData = new FormData(form);
85 const response = await fetch('/api', {
86 method: 'POST',
87 headers: {