Search

Results include substring matches and semantically similar vals. Learn more
jeffreyyoung avatar
smilingLimeCardinal
@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 ani
`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 = {
jdan avatar
myspaceCSS
@jdan
An interactive, runnable TypeScript val by jdan
Script
export function myspaceCSS() {
return `
.verdana12 {
font-family: verdana;
font-size: 12px;
font-weight: normal;
color: #000000;
.button {
padding-left: .6em;
padding-right: .6em;
dhvanil avatar
val_6ob0t5Fmjm
@dhvanil
An interactive, runnable TypeScript val by dhvanil
Script
export default async function handler(req) {
try {
const result = await (async () => {
function isPrime(num) {
if (num <= 1) return false;
for (let i = 2; i <= Math.sqrt(num); i++) {
if (num % i === 0) return false;
return true;
function findLowestThreeDigitPrime() {
for (let num = 100; num < 1000; num++) {
stevekrouse avatar
badArgs1
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
export let badArgs1 = (async () => {
// this should error helpfully
console.log(
await fetchText(
"https://api.val.town/v1/run/stevekrouse.id",
method: "POST",
body: JSON.stringify("hi"),
// this should error helpfully
console.log(
await fetchText(
rayyan avatar
syllabus
@rayyan
@jsxImportSource npm:hono@3/jsx
HTTP
/** @jsxImportSource npm:hono@3/jsx */
function omit<T>(key: keyof T, obj: T) {
const { [key]: omitted, ...rest } = obj;
return rest;
function omitKeys<T>(keys: Array<keyof T>, obj: T) {
const newObj: Record<keyof T, T[keyof T]> = {};
for (const key in obj) {
if (!keys.includes(key)) {
newObj[key] = obj[key];
return newObj;
yawnxyz avatar
magentaCanidae
@yawnxyz
An interactive, runnable TypeScript val by yawnxyz
HTTP
export default async function (req: Request): Promise<Response> {
return new Response('HELLO HELLO', { status: 200 });
ir1d avatar
tldraw_computer_example
@ir1d
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";
freecrayon avatar
zodStringToJSON_example
@freecrayon
// usually this will be passed to you by your Server (i.e. SvelteKit, Remix)
Script
import { zfd } from "npm:zod-form-data";
const $CommentFormData = zfd.formData({
commentId: zfd.text(),
content: zfd.text(zodStringToJSON()),
// usually this will be passed to you by your Server (i.e. SvelteKit, Remix)
const formData = new FormData();
formData.set("commentId", "abc123");
formData.set("content", `{"hello":"world","value":12}`);
const { commentId, content } = $CommentFormData.parse(formData);
console.log({ commentId, content });
dhvanil avatar
val_Ox1arYWfoX
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export const jsonOkExample = () => Response.json({ ok: true });
stevekrouse avatar
myExpressApi
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Express (deprecated)
import { set } from "https://esm.town/v/std/set?v=11";
export async function myExpressApi(req: express.Request, res: express.Response) {
res.json({
count: await set(
"myState",
myState + 1,
dhvanil avatar
val_0rFpB1L3Tu
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export const jsonOkExample = () => Response.json({ ok: true });
aeaton avatar
peelSessionArtists
@aeaton
An interactive, runnable TypeScript val by aeaton
Script
import { fetchHtmlDom } from "https://esm.town/v/aeaton/fetchHtmlDom";
export async function peelSessionArtists(url) {
const dom = await fetchHtmlDom(url);
const items = dom.querySelectorAll(".link-list > li > a");
return [...items].map((link) =>
new URL(link.getAttribute("href"), url).toString()
justbe avatar
highlightExample
@justbe
Highlight Example This is an example of my highlight val.
HTTP
# Highlight Example
This is an example of my [highlight](https://www.val.town/v/just_be/highlight) val.
export default async function(req: Request): Promise<Response> {
const { searchParams } = new URL(req.url);
const code = await searchParams.get("code") ?? "let builder = WebViewBuilder::new(&window);";
const lang = searchParams.get("lang") ?? "rust";
const theme = searchParams.get("theme") ?? "nord";
return fetch(`https://just_be-highlight.web.val.run?lang=${lang}&theme=${theme}`, {
method: "POST",
body: code,
runningj avatar
foo
@runningj
An interactive, runnable TypeScript val by runningj
Script
import { fetch } from "https://esm.town/v/std/fetch";
export const foo = () => {
fetch("ipinfo.io")
.then((res) => {
console.log("ok");
console.log(res);
console.email("runningj@duck.com");
.catch((e) => {
console.log("error");
console.error(e);
qqyule avatar
honoExample
@qqyule
An interactive, runnable TypeScript val by qqyule
HTTP
import { Hono } from "npm:hono@3";
const app = new Hono();
app.get("/", (c) => c.text("Hello from Hono!"));
app.get("/yeah", (c) => c.text("Routing!"));
app.post("/json", async (c) => {
const body = await c.req.json();
return c.json(body);
export default app.fetch;