Search

Results include substring matches and semantically similar vals. Learn more
jxnblk avatar
tunaTestSuite
@jxnblk
Example of using jxnblk/test to test jxnblk/tuna
HTTP (deprecated)
Example of using [jxnblk/test][] to test [jxnblk/tuna][]
[![][badge]][url]
[badge]: https://jxnblk-test.web.val.run?url=https://jxnblk-tunatestsuite.web.val.run
[url]: https://www.val.town/v/jxnblk/tunaTestSuite
[jxnblk/test]: https://val.town/v/jxnblk/test
[jxnblk/tuna]: https://val.town/v/jxnblk/tuna
const matches = (a, b) => assertMatch(a, new RegExp(b));
export default describe("tuna tests", () => {
const bodyStyles = css({
body: {
nimalu avatar
chat
@nimalu
// https://api.val.town/express/@nimalu.chat
Script
// https://api.val.town/express/@nimalu.chat
export const chat = (req, res) => {
const messages = chatMessages
.map(
({ message, sender }) =>
`<li><span class="font-semibold text-gray-900">${sender}: </span>${message}</li>`
.reverse()
.join("");
res.set("Content-Type", "text/html");
res.send(`
maxm avatar
fetsServerExample
@maxm
An interactive, runnable TypeScript val by maxm
HTTP (deprecated)
export const router = createRouter().route({
method: "GET",
path: "/",
schemas: {
responses: {
200: {
type: "object",
properties: {
message: {
type: "string",
liamdanielduffy avatar
reactTodoListWebsite
@liamdanielduffy
// https://api.val.town/v1/express/liamdanielduffy.reactTodoListWebsite
Script
import { buildHtml } from "https://esm.town/v/liamdanielduffy/buildHtml";
// https://api.val.town/v1/express/liamdanielduffy.reactTodoListWebsite
export function reactTodoListWebsite(req, res) {
res.set("Content-Type", "text/html");
res.send(buildHtml({
scripts: [addReactFromValCDN()],
styles: REACT_TODO_LIST_CONTENTS.styles,
body: REACT_TODO_LIST_CONTENTS.body,
fab1an avatar
browserlessScrapeExample
@fab1an
An interactive, runnable TypeScript val by fab1an
Script
export const browserlessScrapeExample = (async () => {
const res = await fetchJSON(
`https://chrome.browserless.io/scrape?token=${process.env.browserlessKey}`,
method: "POST",
body: JSON.stringify({
"url": "https://en.wikipedia.org/wiki/OpenAI",
"elements": [{
// The second <p> element on the page
"selector": "p:nth-of-type(2)",
// For this request, Browserless returns one data item
janpaul123 avatar
valle_tmp_50449610377968496666839612547843
@janpaul123
// This val serves an HTML page emulating a Hacker News clone.
HTTP (deprecated)
// This val serves an HTML page emulating a Hacker News clone.
// Titles are clickable and lead to a page with fake story content.
export default async function(req: Request): Promise<Response> {
const url = new URL(req.url);
const pathname = url.pathname;
if (pathname === "/story1") {
return Response.json({
title: "First Fake Story",
content: `
<h2>First Fake Story</h2>
maxm avatar
greenBat
@maxm
An interactive, runnable TypeScript val by maxm
Script
import build from "https://esm.sh/build";
const ret = await build({
dependencies: {
"@aws-sdk/client-dynamodb": "^3.587.0",
source: `
/* @jsx h */
export * as ddb from "@aws-sdk/client-dynamodb";
// for types checking and LSP completion
const ddb = await import(ret.url);
nifei avatar
myApi
@nifei
An interactive, runnable TypeScript val by nifei
Script
export function myApi(name) {
return "hi " + name;
janpaul123 avatar
valle_tmp_09983323334565619759844043742776
@janpaul123
// Initialize sample stories and store them in blob storage
HTTP (deprecated)
// Initialize sample stories and store them in blob storage
const SAMPLE_STORIES_KEY = "hn_sample_stories";
async function initializeSampleStories() {
const existingStories = await blob.getJSON(SAMPLE_STORIES_KEY);
if (!existingStories) {
const sampleStories = [
{ id: 1, title: "Show HN: This website recreates the feeling of playing a roguelike in a terminal", url: "https://examp
{ id: 2, title: "Ask HN: How do I learn Deno?", url: "https://example.com/story2", votes: 150 },
{ id: 3, title: "Tell HN: I built a new static site generator", url: "https://example.com/story3", votes: 200 },
{ id: 4, title: "Launch HN: We're Kicking off our New AI Service for Developers", url: "https://example.com/story4", vo
iamseeley avatar
helloResume
@iamseeley
šŸŽØ styles for the hello, resume landing page
Script
## šŸŽØ styles for the [hello, resume](https://iamseeley-resumehandler.web.val.run/) landing page
export const helloResume = `
body {
padding: 5px;
margin-top: 32px;
background-color: #2c3e50;
font-family: 'Arial', sans-serif;
color: #ecf0f1;
@media (min-width: 640px) {
body {
benigeri avatar
githubGists
@benigeri
An interactive, runnable TypeScript val by benigeri
Script
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
// GitHub gists
export let githubGists = fetchJSON(
"https://api.github.com/users/stevekrouse/gists"
janpaul123 avatar
valle_tmp_3607258085523705726507190480068266
@janpaul123
// Initialize sample stories and store them in blob storage
HTTP (deprecated)
// Initialize sample stories and store them in blob storage
const SAMPLE_STORIES_KEY = "hn_sample_stories";
async function initializeSampleStories() {
const existingStories = await blob.getJSON(SAMPLE_STORIES_KEY);
if (!existingStories) {
const sampleStories = Array.from({ length: 30 }).map((_, idx) => ({
id: idx + 1,
title: `Sample Story ${idx + 1}`,
url: `https://example.com/story${idx + 1}`,
votes: Math.floor(Math.random() * 100),
stevekrouse avatar
nicoFunctionScript
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
import { fetchJSON } from "https://val.town/v/stevekrouse/fetchJSON";
await fetchJSON("/1");
const a = (x) => x + 1;
const b = (y) => a(y);
export const nicoFunctionScript = [a(5), b(5)];
janpaul123 avatar
valle_tmp_071643302414527117543908170364975
@janpaul123
// This val will respond to any request with an HTML "Hello, world!" message with some fun CSS styles
HTTP (deprecated)
// This val will respond to any request with an HTML "Hello, world!" message with some fun CSS styles
export default async function(req: Request): Promise<Response> {
const html = `
<html>
<head>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
cole avatar
fetchCat
@cole
An interactive, runnable TypeScript val by cole
Script
import { fetch } from "https://esm.town/v/std/fetch";
export let fetchCat = async () => {
const result = await fetch("https://aws.random.cat/meow");
const json = await result.json();
return json.file;