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";
15import { passwordAuth } from "https://esm.town/v/pomdtr/password_auth?v=70";
16import { ResultSet, sqlite } from "https://esm.town/v/std/sqlite";
17import { reloadOnSaveFetchMiddleware } from "https://esm.town/v/stevekrouse/reloadOnSave";
18import { Hono } from "npm:hono";
19import type { FC } from "npm:hono/jsx";
174});
175
176export const handler = app.fetch;
177export default iframeHandler(modifyFetchHandler(passwordAuth(handler)));
60}
61
62async function fetchUser(token: string): Promise<{ id: string }> {
63 const resp = await fetch("https://api.val.town/v1/me", {
64 headers: {
65 Authorization: `Bearer ${token}`,
68
69 if (resp.status !== 200) {
70 throw new Error("Could not fetch user");
71 }
72
76async function verifyApiToken(token: string) {
77 try {
78 const [currentUser, requestUser] = await Promise.all([fetchUser(Deno.env.get("valtown")), fetchUser(token)]);
79 return currentUser.id == requestUser.id;
80 } catch (_) {
86 const y = d3.select(this).attr("cy");
87
88 fetch(`/update?x=${x}&y=${y}&i=${d3.select(this).attr("idx")}`, { method: "post" });
89 d3.select(this).attr("stroke", null);
90 }
190 return new Response(body, { headers: { "Content-Type": "text/event-stream" } });
191});
192export default app.fetch;
2import { updateValByName } from "https://esm.town/v/nbbaier/updateValByName?v=14";
3import { basicAuth } from "https://esm.town/v/pomdtr/basicAuth?v=62";
4import { fetchText } from "https://esm.town/v/stevekrouse/fetchText";
5import { chat } from "https://esm.town/v/stevekrouse/openai";
6
100It stores each line of the poem in sqlite.
101It has a textbox that lets anyone input a new line to the poem.`,
102 content: await fetchText("https://esm.town/v/stevekrouse/poembuilder3?v=4"),
103 },
104 {
105 user: "an app that uses chatgpt to convert natural language to cron syntax",
106 content: await fetchText("https://esm.town/v/stevekrouse/cron2"),
107 },
108];
114 content: `Convert user requests to code. Write ONLY Deno TypeScript.
115
116 If you use Hono, use \`export default app.fetch;\` to start the server.
117
118 Only use web standard fetch.
119 // Our library for SQLite
120 import { sqlite } from "https://esm.town/v/std/sqlite";
1export default async function(req: Request) {
2 const body = (await fetch("https://live.staticflickr.com/65535/53782948438_9b85e57a6c_o_d.png")).body
3 return new Response(body, {headers: {"Content-Type": "image/png"}});
4}
14 start = performance.now();
15 try {
16 const res = await fetch(url);
17 end = performance.now();
18 status = res.status;
25 } catch (e) {
26 end = performance.now();
27 reason = `couldn't fetch: ${e}`;
28 ok = false;
29 console.log(`Website down (${url}): ${reason} (${end - start}ms)`);
33
34 // Post the message so we can deal with large text data.
35 await fetch(`/post-message?threadId=${input.getAttribute("data-thread-id")}`, {
36 method: "post",
37 body: msgDiv.textContent,
147 return new Response(body, { headers: { "Content-Type": "text/event-stream" } });
148});
149export default app.fetch;
1import { Hono } from 'npm:hono';
2import sheet from 'npm:@yawnxyz/sheetlog@0.0.15';
3import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
4import { Sema } from 'npm:async-sema';
5import { modelProvider } from 'https://esm.town/v/yawnxyz/ai';
98 // console.log('gql:', JSON.stringify(gql));
99
100 let results = await fetchJSON(`https://archive.sidebar.io/graphql`, {
101 method: 'POST',
102 headers: {
139 allLinks = allLinks.concat(links);
140 if (links.length < limit) {
141 break; // No more links to fetch
142 }
143 offset += limit;
165
166// Start server
167export default app.fetch;
168
169// let links = await getSidebar(500, 618); // Example usage: limit 10, start from 5
132 return new Response(body, { headers: { "Content-Type": "text/event-stream" } });
133});
134export default app.fetch;
5
6export const resumeConfig = {
7 // URL to fetch the resume JSON data. This should point to your raw resume JSON.
8 // If you want to host your resume JSON somewhere I recommend a setup like this on val town (https://www.val.town/v/iamseeley/resumeDetails) or a github gist.
9 // You can test out the resume view using my resume: https://iamseeley-resumedetails.web.val.run