Search
harryPotterData
@byzantine_emperor
// when a request comes in fetch hpotter data
Script
import { fetch } from "https://esm.town/v/std/fetch";
// when a request comes in fetch hpotter data
export async function harryPotterData(req: express.Request, res) {
try {
const responseData = await fetch(
"https://hp-api.onrender.com/api/characters",
const data = await responseData.json();
res.json(data);
catch (e) {
res.status(500).send("Internal Server Error");
handleDiscordInteraction
@camajudson
Bot for Cama discord server. To initialize new slash commands, you have to run a separate bit of code. This is for modifying their functionality
HTTP
Bot for Cama discord server. To initialize new slash commands, you have to run a separate bit of code. This is for modifying their functionality
export const handleDiscordInteraction = async (req: Request) => {
// Bump version
let bank = await blob.getJSON("bank");
let bets = await blob.getJSON("bets");
const starting_amount = 5;
if (!bank) {
bank = {};
await blob.setJSON("bank", bank);
if (!bets) {
helloval
@yusukebe
An interactive, runnable TypeScript val by yusukebe
HTTP
import { Hono } from "npm:hono@4";
const app = new Hono();
app.get("/", (c) => c.text("Hello Val!!!!!!"));
export default app.fetch;
exceptionalBlushCarp
@toowired
An interactive, runnable TypeScript val by toowired
Script
export async function windsurfIDE(args) {
const { type, ...params } = args;
try {
switch(type) {
case 'start-goal':
return await handleStartGoal(params.goal);
case 'complete-task':
return await handleCompleteTask(params.taskId);
case 'auto-next':
return await handleAutoNext();

gistFetcher
@tgrecojs
An interactive, runnable TypeScript val by tgrecojs
Script
const getFileData = (fileName = "fileName.json") => ({ files }) => files[fileName];
const getContent = ({ content }) => content;
const getData = ({ data }) => data;
const mapper = fn => array => array.map(fn);
const getPubkeyAndAddresses = ({ pubkey = { key: "" }, address = "" }) => ({
address,
pubkey: {
key: pubkey.key,
const compose = (...fns) => (initialValue) => fns.reduceRight((acc, val) => val(acc), initialValue);
const getFileContents = (fileName = "") =>
tinygoHttp
@maxm
Class representing a BufferResult.
Script
/** Class representing a BufferResult. */
class BufferResult {
* @member {Uint8Array}
buffer: Uint8Array;
* @member {boolean}
isError = false;
* Create a Buffer Result.
* @param {Uint8Array} buffer - the payload.
* @param {boolean} isError - is the result an error
constructor(buffer: Uint8Array, isError: boolean) {
valle_tmp_7814561962855233872642258373586
@janpaul123
// This val will respond with "Hello world" to all incoming HTTP requests.
HTTP
// This val will respond with "Hello world" to all incoming HTTP requests.
export default async function main(req: Request): Promise<Response> {
return new Response("Hello world");
valle_tmp_115772121902645334646172151872623
@janpaul123
* This val creates a simple hacker news clone with 30 fake sample stories.
* It uses blob storage to store story data, including the ability to submit
* new stories and upvote existing stories.
HTTP
* This val creates a simple hacker news clone with 30 fake sample stories.
* It uses blob storage to store story data, including the ability to submit
* new stories and upvote existing stories.
interface Story {
id: number;
title: string;
url: string;
points: number;
createdAt: string;
const DEFAULT_STORIES: Story[] = Array.from({ length: 30 }).map((_, idx) => ({
valle_tmp_66391058371017956900111721083726
@janpaul123
// This val responds with "Hello, world!"
HTTP
// This val responds with "Hello, world!"
export default async function main(req: Request): Promise<Response> {
return new Response("Hello, world!");
valTownBadgeMiddleware
@jxnblk
An interactive, runnable TypeScript val by jxnblk
Script
export default function badgeMiddleware(handler, url: string) {
return async function(req: Request): Promise<Response> {
if (req.method !== "GET") return await handler(req);
let res = await handler(req);
if (res.headers.get("Content-Type")?.includes("text/html")) {
let body = await res.text();
const badge = valTownBadge(url);
body += `<div style="position:fixed;right:0;bottom:0;margin:8px">${badge}</div>`;
res = new Response(body, res);
return res;
t
@tmcw
An interactive, runnable TypeScript val by tmcw
Script
export function t(tag: string, args: any = {}, children: any[] = []) {
const func = (...argsOrChildren: any) => {
if (Array.isArray(argsOrChildren[0]))
return func(...argsOrChildren[0], ...argsOrChildren.slice(1));
const args2 = { ...args },
ch2 = [...children];
for (const c of argsOrChildren) {
if (typeof c === "string") ch2.push(c);
else if (typeof c.html === "string") ch2.push(c.html);
else for (const k in c) args2[k] = c[k];
agenta_webhook_eval
@mmabrouk
Example webhook evaluator (see docs in http://docs.agenta.ai/evaluation/evaluators/webhook-evaluator)
HTTP
Example webhook evaluator (see docs in http://docs.agenta.ai/evaluation/evaluators/webhook-evaluator)
export default async function server(request: Request): Promise<Response> {
// Parse the request body
let body: { inputs: Record<string, string>, output: string, correct_answer: string };
body = await request.json();
const score = body.output.toLowerCase() === body.correct_answer.toLowerCase() ? 1.0 : 0.0;
const responseBody = { score };
return new Response(JSON.stringify(responseBody), {
status: 200,
headers: { 'Content-Type': 'application/json' }

bandcampWrappedScript
@donmccurdy
An interactive, runnable TypeScript val by donmccurdy
Script
const replacements = [
[/\*/g, "\\*"],
[/#/g, "\\#"],
[/\//g, "\\/"],
[/\(/g, "\\("],
[/\)/g, "\\)"],
[/\[/g, "\\["],
[/\]/g, "\\]"],
[/</g, "<"],
[/>/g, ">"],

password_auth
@stevekrouse
Password Auth Middleware Protect your vals behind a password. Use session cookies to persist authentication. Demo See @pomdtr/password_auth_test Usage If you want to use an api token to authenticate: import { passwordAuth } from "https://esm.town/v/pomdtr/password_auth";
export default passwordAuth(() => {
return new Response("OK");
}); Or if you prefer to use a string: import { passwordAuth } from "https://esm.town/v/pomdtr/password_auth";
export default passwordAuth(() => {
return new Response("OK");
}, { password: Deno.env.get("MY_PASSWORD") }); Or if you want to share your val with someone without sharing your main password, you can set multiple ones import { passwordAuth } from "https://esm.town/v/pomdtr/password_auth";
export default passwordAuth(() => {
return new Response("OK");
}, { password: [Deno.env.get("MY_PASSWORD"), Deno.env.get("STEVE_PASSWORD")] }); Note that authenticating using your api token is always an option. TODO [x] allow to authenticate using a val town token [ ] add a way to send an email to ask a password from the val owner [ ] automatically extend the session [ ] automatically remove expired sessions FAQ How to sign out ? Navigate to <your-site>/signout .
Script
# Password Auth Middleware
Protect your vals behind a password. Use session cookies to persist authentication.

## Demo
See @pomdtr/password_auth_test
## Usage
type Session = {
id: string;
expiresAt: number;
async function createSessionTable(tableName: string) {
antonia_tim_burton
@jeffreyyoung
An interactive, runnable TypeScript val by jeffreyyoung
HTTP
const basePrompt = [
`Generate an image generation model prompt (description) for the previous image, in nightmare before christmas chibi 3D anime style.`,
`The objective is to try to replicate the image as closely as possible,`,
`but in the new style. To do that, you should be very detailed in including`,
`relevant information necessary to reproduce the image, e.g. colors, poses,`,
`facial expressions, background objects, etc. Ensure that the entire description `,
`is consistent with the nightmare before christmas chibi 3D anime style, especially`,
`the 'nightmare before christmas 3D' part. Output only the prompt and nothing else.`,
].join(" ");
const settings = {