Search

Results include substring matches and semantically similar vals. Learn more
paul_lecam avatar
EnkakuStatelessHTTPExample
@paul_lecam
An interactive, runnable TypeScript val by paul_lecam
HTTP
const transport = new ServerTransport();
serve({
public: true,
transport,
handlers: {
"example:event": (ctx) => {
console.log("received event:", ctx.data);
"example:request": () => {
console.log("received request");
return { test: true };
janpaul123 avatar
valle_tmp_0114941516041842115534002538246594
@janpaul123
// This val responds with "Hello, world!"
HTTP
// This val responds with "Hello, world!"
export default async function(req: Request): Promise<Response> {
return new Response("Hello, world!");
mttlws avatar
TodayForAnnalisa
@mttlws
An interactive, runnable TypeScript val by mttlws
Express (deprecated)
export async function TodayForAnnalisa(req: express.Request, res: express.Response) {
const { activity } = await fetchJSON(
"https://www.boredapi.com/api/activity",
return res.send(`
<html>
<head>
<title>Today for Annalisa 🥹</title>
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.
<meta name="description" content="Today for Annalisa 🥹" />
<meta name="description" content="Today for Annalisa 🥹" />
sethdijkstra avatar
myTestForm
@sethdijkstra
// set by sethdijkstra.handleFormExample2 at 2023-04-25T08:38:19.257Z
Script
// set by sethdijkstra.handleFormExample2 at 2023-04-25T08:38:19.257Z
export let myTestForm = [{
"name": "Howdy",
"email": "Yoooo@icloud.com",
"message": "asdfassdafas"
"name": "Seth",
"email": "seth@dijkjdfs.com",
"message": "Thankyou"
"name": "set",
"email": "seth@dijkjdfs.com",
siygle avatar
resumeHandler
@siygle
📄 hello, resume Creating, customizing, and hosting resumes can get complicated and time-consuming. This project aims to simplify that process and maybe make it a little more enjoyable. Follow the steps in your resumeConfig to get started . Happy job hunting! 💼✨ Thanks to @nbbaier for the great feedback and resumeValidator ! Also, big thanks to Thomas Davis for JSON Resume Standard!
HTTP
## 📄 hello, resume
Creating, customizing, and hosting resumes can get complicated and time-consuming. This project aims to simplify that process
*Follow the steps in your **resumeConfig** to get started*.
Happy job hunting! 💼✨
Thanks to [@nbbaier](https://www.val.town/u/nbbaier) for the great feedback and [resumeValidator](https://www.val.town/v/nbba
Also, big thanks to [Thomas Davis](https://github.com/thomasdavis) for JSON Resume Standard!
export default async function resumeHandler(req: Request): Promise<Response> {
if (req.method === "GET") {
try {
const config = await resumeSetup(resumeConfig);
vladimyr avatar
pipeResponse
@vladimyr
// SPDX-License-Identifier: 0BSD
Script
// SPDX-License-Identifier: 0BSD
export type RequestHandler = (req?: Request) => Response | Promise<Response>;
export function createWrappedHandler(
handler: RequestHandler,
...transforms: ReadableWritablePair[]
): RequestHandler {
return async (req?: Request) => {
const res = await handler(req);
return pipeResponse(res, ...transforms);
export function pipeResponse(
stevekrouse avatar
FetchBasic
@stevekrouse
Framer Fetch: Basic A basic example of an API endpoint to use with Framer Fetch. CORS headers are permissive by default on Val Town, so no need to set them.
HTTP
# Framer Fetch: Basic
A basic example of an API endpoint to use with Framer Fetch. CORS headers are permissive by default on Val Town, so no need t
export default async function(req: Request): Promise<Response> {
// Pick a random greeting
const greetings = ["Hello!", "Welcome!", "Hi!", "Heya!", "Hoi!"];
const index = Math.floor(Math.random() * greetings.length);
return Response.json({ data: greetings[index] });
mharris717 avatar
createVal
@mharris717
An interactive, runnable TypeScript val by mharris717
Script
export interface ValResponse {
id: string;
author: {
id: string;
username: string;
name: string;
code: string;
public: boolean;
privacy: "public" | "unlisted" | "private"; // Added privacy type
version: number;
whatrocks avatar
hnTopStory
@whatrocks
An interactive, runnable TypeScript val by whatrocks
Cron
export async function hnTopStory() {
const topStories: Number[] = await fetch(
"https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty"
).then((res) => res.json());
const id = topStories[0];
const story: {
title: string;
url: string;
time: number;
type: string;
easrng avatar
generateKeys
@easrng
An interactive, runnable TypeScript val by easrng
Script
import { Buffer } from "node:buffer";
export async function generateKeys() {
const { default: nacl } = await import("npm:tweetnacl@1.0.3");
const keyPair = nacl.sign.keyPair();
return {
publicKey: Buffer.from(keyPair.publicKey).toString("base64"),
secretKey: Buffer.from(keyPair.secretKey).toString("base64"),
jshawl avatar
csp
@jshawl
An interactive, runnable TypeScript val by jshawl
Script
export async function csp(url) {
const response = await fetch(url);
const policies = response.headers.get("Content-Security-Policy").split(";")
.map((p) => p.trim()).filter(String);
return policies.reduce((acc, el) => {
const spaceIndex = el.indexOf(" ");
const directive = el.slice(0, spaceIndex);
const values = el.slice(spaceIndex + 1, el.length);
acc[directive] = values.split(" ");
return acc;
stevekrouse avatar
politelyinvinciblepointerHandleFormEx
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
import { fetch } from "https://esm.town/v/std/fetch";
export const politelyinvinciblepointerHandleFormEx = (async () => {
let body = { args: [{ email: "example@example.com" }] };
const response =
(await fetch(
"https://api.val.town/v1/run/politelyinvinciblepointer.handleForm",
method: "POST",
body: JSON.stringify(body),
)).json();
console.log(response);
stevekrouse avatar
hello_world
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
HTTP
export default async function(req: Request): Promise<Response> {
return Response.json("hello world!");
stevekrouse avatar
frequencyDotPlot
@stevekrouse
https://observablehq.com/plot/marks/dot
HTTP
https://observablehq.com/plot/marks/dot
/** @jsxImportSource npm:hono/jsx **/
const app = new Hono();
const title = "Frequency Dot Plot";
const View = () => {
return (
<html>
<body>
<h1>{title}</h1>
<div id="myplot"></div>
jeffreyyoung avatar
poisedOrangeJellyfish
@jeffreyyoung
An interactive, runnable TypeScript val by jeffreyyoung
HTTP
const html = `<html>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/series-label.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>
<figure class="highcharts-figure">
<div id="container"></div>
</figure>
<style>