Readme

This val is supposed to be used with the val.town extension. See the extension readme for installation instructions.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { Base64 } from "npm:js-base64@3.7.5";
import { BrowserContext } from "https://esm.town/v/pomdtr/browser";
import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo";
export default async function(ctx: BrowserContext<{ author: string; name: string }>) {
const { author, name } = ctx.params;
const title = `@${author}/${name}`;
const resp = await fetch(`https://api.val.town/v1/alias/${author}/${name}`, {
headers: {
Authorization: `Bearer ${Deno.env.get("valtown")}`,
},
});
if (!resp.ok) {
throw new Error(await resp.text());
}
const { code } = await resp.json();
const hash = `#language=tsx&title=${title}&code=${Base64.encodeURI(code)}`;
return { type: "open", url: `https://ray.so${hash}` };
}
// #web
👆 This is a val. Vals are TypeScript snippets of code, written in the browser and run on our servers. Create scheduled functions, email yourself, and persist small pieces of data — all from the browser.