1// SPDX-License-Identifier: 0BSD
2import { fetchVal } from "https://esm.town/v/vladimyr/fetchVal";
3import { serveReadme } from "https://esm.town/v/vladimyr/serveReadme";
4import { toHonoHandler } from "https://esm.town/v/vladimyr/toHonoHandler";
11 // const { author, name } = c.req.param();
12 const query = c.req.query();
13 const res = await fetch(
14 "https://raw.githubusercontent.com/burningion/dab-and-tpose-controlled-lights/master/src/dab-tpose-controller.py",
15 );
19});
20
21export default router.fetch;
22
23export async function createScreenshot(code: string, theme: string = "dark-plus"): Promise<URL> {
24In any other platform, I would have just given up and moved on. But Val Town is different. I was confident that I could address this issue in userspace, without having to wait for the platform to implement it.
25
26Val Town allows you to run a val on a cron schedule, so I wrote a val that would fetch all the vals from the API, and store them as a sqlite table (did I mention that every user get it's own sqlite database ?).
27
28```ts
38 let url = "https://api.val.town/v1/search/vals?query=%20&limit=100";
39
40 // fetch all vals, and store them in the sqlite table
41 while (true) {
42 const resp = await fetch(url);
43 if (!resp.ok) {
44 throw new Error(await resp.text());
1import { fetch } from "https://esm.town/v/std/fetch";
2
3// Send a pushover message.
16 url: string;
17}) {
18 return await fetch("https://api.pushover.net/1/messages.json", {
19 method: "POST",
20 headers: {
9}
10
11async function fetchText(url: string, options?: any) {
12 const response = await fetch(normalizeURL(url), {
13 redirect: "follow",
14 ...(options || {}),
19
20export const webScrapeBytesNewsletter = async () => {
21 const html = await fetchText(NEWSLETTER_URL);
22 const $ = cheerio.load(html);
23 const latestIssueSection = $("main > :nth-child(2)");
1import { email } from "https://esm.town/v/std/email?v=9";
2
3// Fetches a random joke.
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",
7 );
9}
10
11const randomJoke = await fetchRandomJoke();
12const setup = randomJoke.setup;
13const punchline = randomJoke.punchline;
24 let example;
25 try {
26 example = await fetchValtownExample(scope, name, version);
27 } catch {}
28 if (example) {
39}
40
41async function fetchValtownExample(scope: string, name: string, version: string) {
42 const pkgConfig = await getConfig(scope, name, version);
43 version = pkgConfig.version;
3import { gfm } from "https://esm.town/v/pomdtr/gfm?v=24";
4import { appendFragment } from "https://esm.town/v/vladimyr/appendFragment";
5import { fetchVal } from "https://esm.town/v/vladimyr/fetchVal";
6import { linkifyReadme } from "https://esm.town/v/vladimyr/linkifyReadme";
7
14 return async (): Promise<Response> => {
15 const { author, name } = extractValInfo(valUrl);
16 const { readme } = await fetchVal(author, name);
17 if (!readme) {
18 return new Response(null, { status: 404 });
66 "embed",
67 "document",
68 ].includes(req.headers.get("sec-fetch-dest"))
69 )
70 return new Response(
2 const before = Date.now();
3 const serverTs = new Date(
4 (await fetch(
5 "https://www.dumbingofage.com/wp-content/uploads/css/custom_style.css?v=" +
6 Date.now()
1Migrated from folder: a2_shared/fetch_example2