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`.
6import {
7 init,
8 traced_fetch,
9 traced_handler,
10} from "https://esm.town/v/saolsen/tracing";
39 val_req_url = `${val_req_url}?v=${version}`;
40 }
41 const val_resp: Response = await traced_fetch(val_req_url);
42 const val_version = Number(val_resp.url.split("?v=")[1]);
43 const val_body: string = await val_resp.text();
166async function handler(req: Request): Promise<Response> {
167 await track("saolsen.changes", req);
168 return await app.fetch(req);
169}
170
1import { email } from "https://esm.town/v/std/email?v=11";
2import { fetchRSS } from "https://esm.town/v/stevekrouse/fetchRSS";
3import { newRSSItems } from "https://esm.town/v/stevekrouse/newRSSItems?v=6";
4import { parseXML } from "https://esm.town/v/stevekrouse/parseXML";
8 const lastRunAt = interval.lastRunAt;
9
10 const response = await fetch("https://sive.rs/en.atom");
11 const xml = await response.text();
12 const data = await parseXML(xml);
2import { email } from "https://esm.town/v/std/email?v=9";
3import { set } from "https://esm.town/v/std/set?v=11";
4import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
5
6export const runner = async () => {
14 ];
15 const promises = ALERT_STRINGS.map(async function(keyword) {
16 let posts = await fetchJSON(
17 `https://search.bsky.social/search/posts?q=${keyword}`,
18 );