86});
87
88export type WideApi = typeof routes;
89
90export default app.fetch.bind(app);
2
3import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
4import { api } from "https://esm.town/v/pomdtr/api";
5import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo";
6import { gfm } from "https://esm.town/v/pomdtr/gfm";
28export function mdx(author: string, name: string) {
29 return async (req: Request) => {
30 const { readme } = await api(`/v1/alias/${author}/${name}`);
31 const vfile = await compile(readme, {
32 jsxImportSource: "https://esm.sh/preact",
4
51. Sign up for [Cerebras](https://cloud.cerebras.ai/)
62. Get a Cerebras API Key
73. Save it in a [Val Town environment variable](https://www.val.town/settings/environment-variables) called `CEREBRAS_API_KEY`
8
9# Todos
9const STARTER_PROMPTS = [
10 "todo list app persisted in local storage",
11 "weather app using open-meteo API",
12 "interactive markdown editor with live preview",
13 "pomodoro timer with sound notifications",
5 try {
6 // Use a public screenshot service that doesn't require authentication
7 const screenshotResponse = await fetch(`https://api.urlbox.io/v1/render/screenshot?url=${encodeURIComponent(url)}&width=1280&height=720`);
8
9 if (!screenshotResponse.ok) {
10 throw new Error(`Screenshot API error: ${screenshotResponse.status}`);
11 }
12
4
51. Sign up for [Cerebras](https://cloud.cerebras.ai/)
62. Get a Cerebras API Key
73. Save it in a [Val Town environment variable](https://www.val.town/settings/environment-variables) called `CEREBRAS_API_KEY`
8
9# Todos
9const STARTER_PROMPTS = [
10 "todo list app persisted in local storage",
11 "weather app using open-meteo API",
12 "interactive markdown editor with live preview",
13 "pomodoro timer with sound notifications",
6
7export let currency = async (desired, base = "usd", amount = 1) => {
8 let { rates } = await fetchJSON(`https://open.er-api.com/v6/latest/${base}`);
9 if (false && rates && rates[desired.toUpperCase()]) return amount * (rates[desired.toUpperCase()]);
10 else {
11 let { rates } = await fetchJSON("https://api.coingecko.com/api/v3/exchange_rates");
12 return amount * rates[desired.toLowerCase()]?.value / rates[base.toLowerCase()]?.value;
13 }
4
51. Sign up for [Cerebras](https://cloud.cerebras.ai/)
62. Get a Cerebras API Key
73. Save it in a [Val Town environment variable](https://www.val.town/settings/environment-variables) called `CEREBRAS_API_KEY`
8
9# Todos
9const STARTER_PROMPTS = [
10 "todo list app persisted in local storage",
11 "weather app using open-meteo API",
12 "interactive markdown editor with live preview",
13 "pomodoro timer with sound notifications",