Search

Results include substring matches and semantically similar vals. Learn more
axelav avatar
hnTopStories
@axelav
// https://api3.val.town/express/async%20(req,%20res)%20=%3Eres.send(@healeycodes.hnTopStories)
Script
export let // View this in a web browser!
// https://api3.val.town/express/async%20(req,%20res)%20=%3Eres.send(@healeycodes.hnTopStories)
const hnTopStories = (async () => {
let valTownFetchLimit = 100;
const topStories: Number[] = await fetch(
"https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty"
).then((res) => res.json());
valTownFetchLimit--;
const topStoriesData: Promise<{
title: string;
tmcw avatar
expressExampleNew
@tmcw
An interactive, runnable TypeScript val by tmcw
Express (deprecated)
import { Buffer } from "node:buffer";
export const expressExampleNew = (req, res) => res.json({ ok: true });
janpaul123 avatar
valle_tmp_76415677644054926617324615358083
@janpaul123
// This val responds with "Hello World" to all incoming HTTP requests
HTTP
// This val responds with "Hello World" to all incoming HTTP requests
export default async function main(req: Request): Promise<Response> {
return new Response("Hello World", { headers: { "Content-Type": "text/plain" } });
dhvanil avatar
val_n8RHhxGCyM
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_n8RHhxGCyM(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
const isValidBalancedParentheses = (str) => {
const stack = [];
for (const char of str) {
if (char === '(') {
stack.push(char);
} else if (char === ')') {
jamisonl avatar
stuckIvoryParakeet
@jamisonl
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
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) {
bets = [];
await blob.setJSON("bets", bets);
pomdtr avatar
hono_island
@pomdtr
Hono Island See it in action at @pomdtr/hono_island_demo
Script
# Hono Island
See it in action at @pomdtr/hono_island_demo
/** @jsxImportSource https://esm.sh/hono/jsx */
export function Island({
src,
name,
children,
src: string;
name: string;
children: any;
maxm avatar
discordSignatureVerifyExample
@maxm
// Your public key can be found on your application in the Developer Portal
HTTP
// Your public key can be found on your application in the Developer Portal
const PUBLIC_KEY = "APPLICATION_PUBLIC_KEY";
export default async (req: Request): Promise<Response> => {
const signature = req.headers.get("X-Signature-Ed25519");
const timestamp = req.headers.get("X-Signature-Timestamp");
if (!signature || !timestamp) {
return new Response("X-Signature-Ed25519 and X-Signature-Timestamp headers are required", { status: 400 });
const body = await req.text(); // rawBody is expected to be a string, not raw bytes
const isVerified = nacl.sign.detached.verify(
Buffer.from(timestamp + body),
stevekrouse avatar
robPikeIO
@stevekrouse
robpike.io A re-implementation of https://robpike.io/
HTTP
# robpike.io
A re-implementation of https://robpike.io/
export default async function(req: Request): Promise<Response> {
return new Response(
new ReadableStream({
async start(controller) {
for (let i = 0; i < 100; i++) {
controller.enqueue(new TextEncoder().encode("👋"));
await new Promise(r => setTimeout(r, 200));
controller.close();
taoji avatar
live
@taoji
An interactive, runnable TypeScript val by taoji
HTTP
export default async function server(request: Request): Promise<Response> {
try {
const cacheUrl = `https://tv.taoji.rr.nu/zb.txt`;
const cache = await caches.open('zb-txt-cache');
const cachedResponse = await cache.match(cacheUrl);
if (cachedResponse) {
return cachedResponse;
const response = await fetch(cacheUrl, {
// Add timeout and other performance optimizations
signal: AbortSignal.timeout(5000),
iamseeley avatar
pyodideDataVis
@iamseeley
An interactive, runnable TypeScript val by iamseeley
HTTP
export const pyodideExample = () => {
const html = `
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Data Vis with Pyodide</title>
<script type="text/javascript" src="https://cdn.jsdelivr.net/pyodide/v0.25.1/full/pyodide.js"></script>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</head>
stevekrouse avatar
serverlessMatrixEchoBot
@stevekrouse
// https://stevekrouse-serverlessMatrixEchoBot.express.val.run/_matrix/push/v1/notify
Express (deprecated)
// https://stevekrouse-serverlessMatrixEchoBot.express.val.run/_matrix/push/v1/notify
export async function serverlessMatrixEchoBot(req, res) {
res.send(req.path);
wilhelm avatar
bsky
@wilhelm
Showing my BlueSky posts using their public API
HTTP
Showing my BlueSky posts using their public API
/** @jsxImportSource npm:hono/jsx */
type Feed = {
feed: { post: { uri: string; author: { displayName: string; avatar: string }; record: { text: string } } }[];
export default async function(req: Request): Promise<Response> {
const url = "https://public.api.bsky.app/xrpc/app.bsky.feed.getAuthorFeed?actor=wilb.me&filter=posts_no_replies";
const data: Feed = await fetch(url).then((r) => r.json());
return new Response(
(<html>
<head>
pomdtr avatar
hackernews
@pomdtr
An interactive, runnable TypeScript val by pomdtr
Script
#!/usr/bin/env -S deno run -A
const manifest = {
title: "Hacker News",
description: "Browse Hacker News",
commands: [
name: "browse",
title: "Show a feed",
mode: "filter",
params: [{ name: "topic", label: "Topic", type: "text" }],
} as const satisfies sunbeam.Manifest;
yawnxyz avatar
valWall
@yawnxyz
Inspired by https://www.val.town/v/ejfox/valcontributionchart
HTTP
Inspired by https://www.val.town/v/ejfox/valcontributionchart
appendTrailingSlash,
} from 'npm:hono/trailing-slash'
// import { getVals, getValsWithVersions } from "./api.js";
const app = new Hono();
app.use(appendTrailingSlash())
app.get("/graph/:username?", async (c) => {
console.log("graph:", c.req.param("username") || c.req.query("username"));
const username = c.req.param("username") || c.req.query("username");
if (!username) {
git avatar
wormhole
@git
An interactive, runnable TypeScript val by git
HTTP
export default async (request: Request): Promise<Response> => {
return new Response(
/* html */ `<html>
<head>
<script
defer
type="module"
src="https://www.unpkg.com/@wormhole-foundation/wormhole-connect/dist/main.js">
</script>
<link rel="https://www.unpkg.com/@wormhole-foundation/wormhole-connect/dist/main.css" />