103 tests[testID].status = "running";
104 setTests({ ...tests });
105 const resp = await fetch("/api/run", {
106 method: "POST",
107 body: JSON.stringify({
17 const query = c.req.query();
18
19 const code = await fetchValCode(`${params.author}/${params.name}`);
20 const imageURL = await createScreenshot(code, query.theme);
21 return Response.redirect(imageURL);
22});
23
24export default router.fetch;
25
26export async function createScreenshot(code: string, theme: string = "dark-plus"): Promise<URL> {
35}
36
37async function fetchValCode(alias: string): Promise<string> {
38 const prefixUrl = "https://api.val.town/v1/alias";
39 const { code } = await ky.get(alias, { prefixUrl }).json();
23 return [scope, html`${value}`];
24 } catch (e) {
25 console.log("could not fetch scope", scope, e);
26 }
27 })).then(res => Object.fromEntries(res.filter(Boolean)));
3export { Test } from "https://esm.town/v/pomdtr/test";
4
5export default router.fetch;
12}
13
14export default app.fetch;
11 const name = getValNameFromUrl(url).slice(1);
12
13 const res = await fetch(`https://api.val.town/v1/alias/${name}`, {
14 headers: {
15 authorization: `Bearer ${Deno.env.get("valtown")}`,
39 }
40
41 return fetch(url).then((res) => res.text()).then(text => {
42 moduleSourceCache.set(url, text);
43 return text;
4export default async function(ctx: BrowserContext<{ user: string }>) {
5 const { user: userID } = ctx.params;
6 const resp = await fetch(`https://api.val.town/v1/me/likes?limit=100`, {
7 headers: {
8 Authorization: `Bearer ${Deno.env.get("valtown")}`,
2
3export async function randomLike() {
4 const { data } = await fetch("https://api.val.town/v1/me/likes", {
5 headers: {
6 Authorization: `Bearer ${Deno.env.get("valtown")}`,
29 };
30 }
31 const res = await fetch(url);
32 if (!res.ok)
33 throw Object.assign(new Error(res.statusText + " " + url), { res });
3import ky from "npm:ky";
4
5export async function fetchPost(url: string | URL) {
6 const postURL = new URL(url);
7 if (postURL.hostname !== "bsky.app") {