Search

jsr
@vladimyr
Try on Val Town This service enables quick generation of new val with specified jsr package.
Package authors can provide custom examples by setting either: valtownExample property of jsr.json / deno.json to contain example js/ts code valtownExampleFilename property of jsr.json / deno.json to point to the file with example js/ts code If no example is found val will be created with the default snippet, using @luca/flag as an example : import * as flag from "jsr:@luca/flag"; Go ahead āļø try it (on Val Town) ! š Additionally, the service supports ?code=<base64code> query param that allows overriding extracted/generated example code.
For example one might want to override @luca/flag 's snippet with: import { printProgress } from "jsr:@luca/flag@1";
printProgress(); In order to do so first you need to convert it to base64: $ printf 'import { printProgress } from "jsr:@luca/flag@1";\n\nprintProgress();' | base64 -w0
# ==> aW1wb3J0IHsgcHJpbnRQcm9ncmVzcyB9IGZyb20gImpzcjpAbHVjYS9mbGFnQDEiOwoKcHJpbnRQcm9ncmVzcygpOw== Then you simply construct the URL by setting the returned value to code query param: āļø https://vladimyr-jsr.web.val.run?code=aW1wb3J0IHsgcH... Usage https://vladimyr-jsr.web.val.run/<scope>/<name>[@<version>] https://vladimyr-jsr.web.val.run?code=<base64code> Example https://vladimyr-jsr.web.val.run/@luca/flag https://vladimyr-jsr.web.val.run/@std/assert@0.220.1 https://vladimyr-jsr.web.val.run/@mark/html@latest
HTTP
# Try on Val Town
[](https://spdx.org/licenses/0BSD.html)
This service enables quick generation of new val with specified [jsr](https://jsr.io) package.
Package authors can provide custom examples by setting either:
- `valtownExample` property of [`jsr.json`](https://jsr.io/docs/package-configuration)/[`deno.json`](https://docs.deno.com/runtime/manual/getting_started/configuration_file) to contain example js/ts code
- `valtownExampleFilename` property of [`jsr.json`](https://jsr.io/docs/package-configuration)/[`deno.json`](https://docs.deno.com/runtime/manual/getting_started/configuration_file) to point to the file with example js/ts code
// SPDX-License-Identifier: 0BSD
export default async function(req: Request, options?: {
transformReadme: HtmlProcessor;
}): Promise<Response> {

easyAQIExample
@dharmatech
An interactive, runnable TypeScript val by dharmatech
Script
import { easyAQI } from "https://esm.town/v/stevekrouse/easyAQI?v=3";
export const easyAQIExample = easyAQI({
location: "brooklyn navy yard",

pipeSampleLLMBind
@webup
An interactive, runnable TypeScript val by webup
Script
export const pipeSampleLLMBind = (async () => {
const { PromptTemplate } = await import("npm:langchain/prompts");
const prompt = PromptTemplate.fromTemplate(`Tell me a joke about {subject}`);
const mb = await getModelBuilder({
type: "chat",
provider: "openai",
const model = await mb();
const tb = await getLangSmithBuilder();
const tracer = await tb();
const functionSchema = [
retroVisitCounter
@maxm
Retro Visit Counter You are visitor number: How special! Want a retro visitor counter for your myspace page or geocities website? Fork this val and add the image link to your website: <img src="https://maxm-retrovisitcounter.web.val.run/counter.png">
<!-- Make sure you swap this subdomain out with the subdomain of your forked val -->
<img src="https://[CHANGE ME!].web.val.run/counter.png">
HTTP
# Retro Visit Counter
You are visitor number: 
How special!
Want a retro visitor counter for your myspace page or geocities website? Fork this val and add the image link to your website:
<img src="https://maxm-retrovisitcounter.web.val.run/counter.png">
<!-- Make sure you swap this subdomain out with the subdomain of your forked val -->
await sqlite.execute(`create table if not exists counter(
name text,
counter integer
async function getCurrentCount(): Promise<number> {
whatDoYouThinkOfItSoFar
@edgeeffect
What Do You Think of it so far? Rubbish! Our bin men (garbage men to you) come round every Friday morning.
But alternate weeks, they take either rubbish or recycling. This val extracts from our local council website which collection they're doing this week
and E. mails me the details every Thursday afternoon. I've hidden the URL in an environment variable (sorry) but the URL has details of our address
and I'm not sure how happy our local council would be to start getting loads of hits from all round the world.
But it's here as a sample of how easy it is to scrape a website and E. mail the details to yourself. And, on that subject, can I just say "hats off to val.town", I've been looking for a little
cloud host that will let me E. mail myself from a cron for absolutely ages.
Cron
# What Do You Think of it so far?
Rubbish!
Our bin men (garbage men to you) come round every Friday morning.
But alternate weeks, they take either rubbish or recycling.
This val extracts from our local council website which collection they're doing this week
and E. mails me the details every Thursday afternoon.
const extracted = (html: string) => {
const document = new DOMParser().parseFromString(html, "text/html");
const newDoc = ["<div style=\"color: #000\">"];
document.querySelectorAll(".bin-collection-container").forEach(

ping2
@simonharrisco
An interactive, runnable TypeScript val by simonharrisco
Cron
import { fetchHTML } from "https://esm.town/v/stevekrouse/fetchHTML?v=9";
export function ping2() {
fetchHTML("https://simonharrisco-site.vercel.app/");
animateElement
@iamseeley
An interactive, runnable TypeScript val by iamseeley
Script
export function animateElement(element, delay) {
return new Promise(resolve => {
setTimeout(() => {
element.classList.add('in-view');
resolve();
}, delay);
export async function animateElementsSimultaneously(elements, initialDelay) {
const promises = elements.map(element => animateElement(element, initialDelay));
await Promise.all(promises);
similarSites
@qiangua
Find similar pages on HN and return a streaming markdown summary. Powered by Exa and Substrate . šŖ© To fork, sign up for Substrate to get your own API key and $50 free credits.
HTTP
Find similar pages on HN and return a streaming markdown summary.
Powered by [Exa](https://exa.ai/) and [Substrate](https://substrate.run).
šŖ© To fork, [sign up for Substrate](https://substrate.run/signin) to get your own API key and $50 free credits.
const exa = new Exa(Deno.env.get("EXA_API_KEY"));
const substrate = new Substrate({ apiKey: Deno.env.get("SUBSTRATE_API_KEY") });
export default async function handler(req: Request): Promise<Response> {
const url = new URL(req.url).searchParams.get("url") || "https://thesephist.com/posts/synth/";
const searchResults = await exa.findSimilarAndContents(url, {
text: { maxCharacters: 1000 },
category: "personal site",

runGET
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
export let runGET = fetchJSON(
`https://api.val.town/v1/run/stevekrouse.add?args=${JSON.stringify([1, 2])}`,
examplebotendpoint
@mattx
An interactive, runnable TypeScript val by mattx
Express (deprecated)
export let examplebotendpoint = async (req: Request) => {
const headers = { "Content-type": "application/json" };
const text = await req.text();
const body = JSON.parse(text);
if (
!req.headers.get("X-Signature-Timestamp") ||
!req.headers.get("X-Signature-Ed25519")
return Response.json({ error: "bad request" }, { status: 400 });
const verified = await verify_discord_signature(
process.env.discord_pubkey,

thisWebEndpoint
@neverstew
// Forked from @stevekrouse.thisEmail
Script
import { parentReference } from "https://esm.town/v/stevekrouse/parentReference?v=3";
export let thisWebEndpoint = () => {
let { userHandle, valName } = parentReference();
return `https://${userHandle}-${valName}.web.val.run`;
// Forked from @stevekrouse.thisEmail
endpointCalculator
@ejfox
* This program creates a basic calculator endpoint that accepts and returns data in the specified format.
* It uses a RESTful API approach where the operation is specified in the URL path.
* The numbers to operate on are passed as query parameters.
* The result is returned as JSON.
HTTP
* This program creates a basic calculator endpoint that accepts and returns data in the specified format.
* It uses a RESTful API approach where the operation is specified in the URL path.
* The numbers to operate on are passed as query parameters.
* The result is returned as JSON.
export default async function server(request: Request): Promise<Response> {
const url = new URL(request.url);
const operation = url.pathname.split('/').pop();
const numbers = url.searchParams.getAll('num').map(Number);
if (!operation || numbers.length === 0) {
return new Response(JSON.stringify({ error: "Invalid request" }), {
metaCall
@eric
An interactive, runnable TypeScript val by eric
Script
export let metaCall = function() {
return this
printHeaders
@andreterron
An interactive, runnable TypeScript val by andreterron
Script
export const printHeaders = async (req: express.Request, res) => {
console.log("HEADERS");
console.log(req.options.headers);
res.send(req.options.headers);

vtTokenSessionAuth
@stevekrouse
Val Town Token Session Auth Protect your vals behind your Val Town API Token. Use session cookies to persist authentication. Forked from @pomdtr/password_auth. Usage import { vtTokenSessionAuth } from "https://esm.town/v/stevekrouse/vtTokenSessionAuthSafe";
export default vtTokenSessionAuth(() => Response.json("Authenticated!")) To sign out, navigate to /signout .
Script
# Val Town Token Session Auth
Protect your vals behind your Val Town API Token. Use session cookies to persist authentication.
Forked from @pomdtr/password_auth.
## Usage
```ts
export default vtTokenSessionAuth(() => Response.json("Authenticated!"))
type Session = {
id: string;
expiresAt: number;
async function createSessionTable(tableName: string) {