1/** @jsxImportSource https://esm.sh/preact */
2import { fetch } from "https://esm.town/v/std/fetch";
3import { render } from "npm:preact-render-to-string";
4
24 );
25 }
26 return fetch(feedUrl);
27}
35
36 // we check that we are not exposing private vals
37 const resp = await fetch(`https://api.val.town/v1/alias/${author}/${name}`, {
38 headers: {
39 authorization: `Bearer ${Deno.env.get("valtown")}`,
60});
61
62export default app.fetch;
35});
36
37export default app.fetch;
38
39// #cli
1export async function track(domain: string, req: Request) {
2 await fetch("https://plausible.io/api/event", {
3 method: "POST",
4 headers: {
2import { blob } from "https://esm.town/v/std/blob?v=11";
3import { email } from "https://esm.town/v/std/email?v=11";
4import { fetch } from "https://esm.town/v/std/fetch";
5
6export async function watchWebsite(url: string) {
7 const newHtml = await fetch(url).then(r => r.text());
8
9 const key = "watch:" + url;
13```
14
15You can then fetch the exported string from outside val.town using:
16
17```sh
2
3export const handler = async () => {
4 const hashrateResp = await fetch("https://mempool.space/api/v1/mining/hashrate/3y");
5 const { difficulty } = await hashrateResp.json();
6
2
3export default async function(req: Request): Promise<Response> {
4 const blockFeesResp = await fetch("https://mempool.space/api/v1/mining/blocks/fees/3y");
5 const blockFees = await blockFeesResp.json();
6
2
3export const handler = async () => {
4 const resp = await fetch("https://mempool.space/api/v1/mining/hashrate/3y");
5 const { difficulty, hashrates } = await resp.json();
6
52```
53
54Cli vals don't have access to val town tokens. Instead of trying to replicate your valtown secrets locally, you can configure your cli vals to call your http endpoints using `fetch`.