Search
aqi
@lavallee
An interactive, runnable TypeScript val by lavallee
Cron
export let aqi = async () => {
let pm25 = (
await fetchJSON(
"https://api.openaq.org/v2/latest?" +
new URLSearchParams({
limit: "10",
page: "1",
location: "Miami",
offset: "0",
sort: "desc",

shiningCyanMuskox
@steveruizok
tldraw computer custom endpoint example This val is an example custom endpoint for tldraw computer 's data component. Usage To use this val with tldraw.computer, follow these steps: Fork this Val. Click the Copy endpoint button on your new Val. Open a project on tldraw.computer Create a Data component in your tldraw computer project In the Source dropdown, select Custom and the POST method Paste the endpoint into Data component's the HTTP Endpoint input. Run the component. To see the output, connect the Data component to a Text component. How it works In tldraw computer, you can configure a Data component to use a custom HTTP endpoint as its data source. You can also configure the request method, either GET or POST. If a Data component's request method is POST, then when the component next updates, it will send a POST request to the endpoint. The request's body will contain an array of the Data objects that the component had received as inputs. If the request method if GET, then the component will only make the request—its body will be empty. In both cases, the component will expect back a response that includes an array of Data objects these objects will be passed along as the data component's outputs. The endpoint (your forked version of this Val) can do whatever it likes between the request and response, but the response must include data in the correct format. If the format is wrong, the computer app will create a text data object instead that includes the response as plain text. Support If you're running into any difficulties, check out the #tldraw-computer channel on the tldraw discord.
HTTP
# tldraw computer custom endpoint example
This val is an example custom endpoint for [tldraw computer](tldraw.computer)'s data component.
### Usage
To use this val with tldraw.computer, follow these steps:
1. Fork this Val.
2. Click the **Copy endpoint** button on your new Val.
// This endpoint accepts and returns data.
type BooleanData = {
type: "boolean";
text: "true" | "false" | "maybe";

consoleEmailEx
@adam12
An interactive, runnable TypeScript val by adam12
Script
export let consoleEmailEx = () => {
console.email(`message the current time is ${new Date()}`); // any JSON object can be the message
console.email({ html: "<h1>hello html emails!</h1>" }); // you can send HTML emails
console.email({ hi: "there" }, "Subject Line"); // optional second arg is the subject line
console.email({ html: "<b>hi!</b>", subject: "Subject accepted here too" });

signedFetch
@vladimyr
// SPDX-License-Identifier: 0BSD
Script
// SPDX-License-Identifier: 0BSD
export type SignatureOptions = {
pkcs8: string;
publicKeyId: string | URL;
algorithm?: "rsa-sha256";
signFn?: (message: string, pkcs8: string, algorithm: SignatureOptions["algorithm"]) => Promise<string>;
export function createSignedFetch(
options: SignatureOptions & {
fetch?: typeof fetch;
const fetch = options.fetch ?? globalThis.fetch;
activitypub
@tmcw
WebFinger This is a not-quite-complete ActivityPub implementation based on my blog post about building an AP implementation . It includes enough to look up bot@tmcw-activitypub.web.val.run on Mastodon and get some basic information.
HTTP
# WebFinger
This is a not-quite-complete ActivityPub implementation based on my [blog post about building an AP implementation](https://macwright.com/2022/12/09/activitypub). It includes enough to look up `bot@tmcw-activitypub.web.val.run` on Mastodon and get some basic information.
export const activitypub = async (req: Request) => {
const { Hono } = await import("npm:hono@3.4.3");
const app = new Hono();
const DOMAIN = "tmcw-activitypub.web.val.run";
const USERS = new Map([
`acct:bot@${DOMAIN}`,
subject: `acct:bot@${DOMAIN}`,
aliases: [],
northernChocolateFish
@seanyang0813
An interactive, runnable TypeScript val by seanyang0813
Cron
import { email } from "https://esm.town/v/std/email";
export default async function(interval: Interval) {
await email({
subject: "This is your daily ping!",
text: "Do your daily ping at https://benjaminaster.com/daily-ping/",
getValTownTest
@xiyouMc
An interactive, runnable TypeScript val by xiyouMc
Script
import { getValTown } from "https://esm.town/v/xiyouMc/getValTown";
export let getValTownTest = (async () => {
return await getValTown();

feps
@vladimyr
An interactive, runnable TypeScript val by vladimyr
HTTP
import { Hono } from "npm:hono@3.12.7";
const app = new Hono();
app.get("/:fepId{[A-za-z0-9]{4}}", (c) => {
const fepId = c.req.param("fepId").toLowerCase();
return c.redirect(`https://codeberg.org/fediverse/fep/src/branch/main/fep/${fepId}/fep-${fepId}.md`);
export default app.fetch;

greetWebhook
@tmalaher
An interactive, runnable TypeScript val by tmalaher
Script
export let greetWebhook = (req: express.Request, res: express.Response) => {
res.json({ data: `Hello, ${req.body.name}!` });
// res.status(500).send("Testing");

resumeWebsite
@ajax
An interactive, runnable TypeScript val by ajax
Script
import { resumeHtml } from "https://esm.town/v/ajax/resumeHtml";
export function resumeWebsite(req, res) {
res.set("Content-Type", "text/html");
res.send(resumeHtml);
turquoiseLlama
@rvorias
An interactive, runnable TypeScript val by rvorias
HTTP
const gist =
"https://gist.githubusercontent.com/rvorias/2af68a5974bdbebba5925bbdba52c07d/raw/4320ade50bcccd020127db24607ca4fac71ff0f6/data.json";
export const queryParams = async (req: Request) => {
const data = await fetch(gist);
const jsonData = await data.json();
const searchParams = new URL(req.url).searchParams;
const params = Object.fromEntries(searchParams.entries());
const id = parseInt(params["id"]) - 1;
const code = jsonData["data"][id];
let ans;
getPocket
@jessmartin
An interactive, runnable TypeScript val by jessmartin
Script
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
export function getPocket(params) {
return fetchJSON("https://getpocket.com/v3/get", {
method: "POST",
body: JSON.stringify(params),
proxyFetch1
@alp
An interactive, runnable TypeScript val by alp
Script
import { fetch } from "https://esm.town/v/std/fetch";
export const proxyFetch1 = async (req, res) => {
const { url, options } = req.body;
try {
const response = await fetch(url, options);
return res.status(response.status).send(await response.text());
} catch (e) {
const errorMessage = e instanceof Error ? e.message : "Unknown error";
console.error("Failed to initiate fetch", e);
return res.status(500).send(`Failed to initiate fetch: ${errorMessage}`);
simpsonifyMe
@jeffreyyoung
An interactive, runnable TypeScript val by jeffreyyoung
HTTP
const basePrompt =
`Generate an image generation model prompt (description) for the previous image, in the Simpsons cartoon style
Be extremely detailed in describing:
- Hair color
- Poses and expressions
- Gender
- Clothing details and materials
- Skin tone
- Race
- Exact color schemes

saveFormData
@vtdocs
An interactive, runnable TypeScript val by vtdocs
Script
let { submittedEmailAddresses } = await import("https://esm.town/v/vtdocs/submittedEmailAddresses");
export const saveFormData = async (req: express.Request, res: express.Response) => {
// Create somewhere to store data if it doesn't already exist
if (submittedEmailAddresses === undefined) {
submittedEmailAddresses = [];
// Pick out the form data
const emailAddress = req.body.email;
if (submittedEmailAddresses.includes(emailAddress)) {
return res.send("you're already signed up!");
await email({