Search

Results include substring matches and semantically similar vals. Learn more
Llad avatar
aquaCoyote
@Llad
An interactive, runnable TypeScript val by Llad
HTTP (deprecated)
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!"));
export default app.fetch;
stevekrouse avatar
tealBadger
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
HTTP (deprecated)
export default async function(req: Request): Promise<Response> {
const openai = new OpenAI();
const stream = await openai.chat.completions.create({
stream: true,
messages: [{ role: "user", content: "Write a poem in the style of beowulf about the DMV" }],
model: "gpt-3.5-turbo",
max_tokens: 2048,
return new Response(
new ReadableStream({
async start(controller) {
browserbase avatar
TopHackerNewsDailyEmail
@browserbase
Browserbase Browserbase offers a reliable, high performance serverless developer platform to run, manage, and monitor headless browsers at scale. Leverage our infrastructure to power your web automation and AI agents. Get started with Browserbase for free here . If you have any questions, reach out to developer@browserbase.com.
Cron
### Browserbase
Browserbase offers a reliable, high performance serverless developer platform to run, manage, and monitor headless browsers a
Get started with Browserbase for free [here](browserbase.com).
If you have any questions, reach out to developer@browserbase.com.
let html = await loadPageContent("https://news.ycombinator.com/", { textContent: false });
html = html.replace(/<style[^>]*>[\s\S]*?<\/style>/gi, ""); // remove useless context
// Then, we define the shape of the data to extract
// with a `zod` schema
const schema = z.object({
top: z
pomdtr avatar
coffeeFowl
@pomdtr
An interactive, runnable TypeScript val by pomdtr
Script
// Import Astral
const command = new Command().arguments("<app>").action(async (_, app) => {
// Launch the browser
const browser = await launch();
// Open a new page
const page = await browser.newPage(`https://${app}.localhost`);
// Take a screenshot of the page and save that to disk
const screenshot = await page.screenshot();
Deno.stdout.write(screenshot);
browser.close();
dnishiyama avatar
dailySlackStandup
@dnishiyama
An interactive, runnable TypeScript val by dnishiyama
Cron
import process from "node:process";
export const slackWebHookMessageExample = (async () => {
const webhookUrl = process.env.slackTeamWebhookURL;
const text = `Time for standup!`;
const res = await fetch(
webhookUrl,
method: "POST",
body: JSON.stringify({
"text": text,
return res.statusText;
cathy avatar
testcron
@cathy
An interactive, runnable TypeScript val by cathy
Script
import { mathFact } from "https://esm.town/v/cathy/mathFact";
let { hello } = await import("https://esm.town/v/cathy/hello");
export let testcron = () => {
hello += `${mathFact}\n`;
return hello;
omgwtfbrblolttyl avatar
writeFileEndpoint
@omgwtfbrblolttyl
TODO: [ ] get token from header [ ] decode using secret from env [ ] look up globs for user with id from token [ ] get path from req.body [ ] test path against all globs for user [ ] if none pass, 403 with message [ ] if any pass, write val to db with path as key (overwrite if exists) [ ] return new value
Express
# TODO:
- [ ] get token from header
- [ ] decode using secret from env
- [ ] look up globs for user with id from token
- [ ] get path from req.body
- [ ] test path against all globs for user
export const writeFileEndpoint = async (
req: express.Request,
res: express.Response,
if (req.method !== "POST") {
ae_play avatar
counterTest
@ae_play
An interactive, runnable TypeScript val by ae_play
Script
import { setCounter } from "https://esm.town/v/ae_play/setCounter";
export function counterTest() {
setCounter(c => c + 1);
console.log(counter);
rcurtiss avatar
untitled_moccasinWildebeest
@rcurtiss
@jsxImportSource https://esm.sh/preact
HTTP (deprecated)
/** @jsxImportSource https://esm.sh/preact */
import { render } from "npm:preact-render-to-string";
export default async function(req: Request) {
return new Response(
yuiseki avatar
untitled_beigeLemur
@yuiseki
@jsxImportSource https://esm.sh/react
HTTP (deprecated)
/** @jsxImportSource https://esm.sh/react */
import * as React from "npm:react";
/** @jsxImportSource https://esm.sh/react */
import { renderToString } from "npm:react-dom/server";
import { Map } from "https://esm.sh/react-map-gl@7.1.7/maplibre";
const MyMap: React.FC = () => {
return (
neverstew avatar
untitled_674cf68f
@neverstew
@jsxImportSource https://esm.sh/preact
HTTP (deprecated)
/** @jsxImportSource https://esm.sh/preact */
import { htmlResponse } from "https://esm.town/v/neverstew/htmlResponse";
export async function untitled_674cf68f(request: Request): Promise<Response> {
tr3ntg avatar
untitled_silverGoose
@tr3ntg
An interactive, runnable TypeScript val by tr3ntg
Script
export const untitled_silverGoose = (async () => {
async function saveTickerToSupabase(request) {
const { createClient } = await import(
"https://esm.sh/@supabase/supabase-js@2"
const supabase = createClient(
process.env.marketMemoSupabaseApiUrl,
process.env.marketMemoSupabaseServiceRoleKey,
boucher avatar
untitled_blackBee
@boucher
Deprecated in favor of std/sqlite (also powered by Turso) std/turso was the initial version of our integration with Turso. It was so popular, we rebuilt it to be faster and easier to use: std/sqlite . Turso is a serverless SQLite platform designed for the edge. It runs libSQL , their open contribution fork of SQLite. Every Val Town user automatically gets their own Turso SQLite database! It's great for >100kb data (ie bigger than a val) or when you need SQL: relations, ACID transactions, etc. Storage used in Turso will count against your Val Town total storage (10mb for free users; 1gb for Pro users). Contact us if you'd need more – it should be no problem! Getting started This val uses our public key auth scheme . Generate your keypair On your publicKey click the lock icon🔒 to change the permissions to Unlisted . Fork this helper function replacing stevekrouse with your own username Try out some queries! Usage This val returns a Turso SDK's Client , which supports execute , batch , and transaction . await @me.turso().execute(`create table blobs( key text unique, value text )`) More example usage Architecture This @std.turso function is the client or SDK to @std.tursoAPI, which acts as a "proxy" to Turso. It handles authentication, creates databases, and forwards on your SQL queries. You can get lower latency (~200ms vs ~800ms), more storage, databases, CLI & API access by having your own Turso account.
Script
## Usage
This val returns a [Turso SDK's Client](https://docs.turso.tech/reference/client-access/javascript-typescript-sdk), which sup
```js
## Architecture
This @std.turso function is the client or SDK to @std.tursoAPI, which acts as a "proxy" to Turso. It handles authentication,
import { runValAPIAuth } from "https://esm.town/v/stevekrouse/runValAPIAuth";
// grab the types off turso's client without importing it
let tursoImport = () => import("https://esm.sh/@libsql/client/web");
type createClient = Awaited<ReturnType<typeof tursoImport>>["createClient"];
export function turso(keys, handle?) {
return {
execute: f("execute") as ReturnType<createClient>["execute"],
batch: f("batch") as ReturnType<createClient>["batch"],
transaction: f("transaction") as ReturnType<createClient>["transaction"],
export const endpoint = function(req, res) {
liflovs avatar
untitled_aquaQuail
@liflovs
Val Town SQLite Docs: https://docs.val.town/std/sqlite/
Script
import { API_URL } from "https://esm.town/v/std/API_URL";
import { LibsqlError, type ResultSet, type TransactionMode } from "npm:@libsql/client";
import { z } from "npm:zod";
export const sqlite = {
neoneffect avatar
untitled_pinkSkunk
@neoneffect
An interactive, runnable TypeScript val by neoneffect
Script
"https://www.itraveljerusalem.com/tour/a-private-tour-of-jerusalem-bethlehem-guide-now",
"https://www.itraveljerusalem.com/tour/private-tour-masada-and-dead-sea-yaron-hovav",
"https://www.itraveljerusalem.com/tour/change-your-perspective-with-encounters-outside-the-box-private-tour",
"https://www.itraveljerusalem.com/tour/jerusalem-temple-mount-and-dome-of-the-rock-bhm",
"https://www.itraveljerusalem.com/tour/virtual-guided-tours-via-zoom-itamar-ben-david",
"https://www.itraveljerusalem.com/accommodation/prima-royale",
"https://www.itraveljerusalem.com/accommodation/ramat-rachel",
"https://www.itraveljerusalem.com/accommodation/refael-residence",
"https://www.itraveljerusalem.com/accommodation/rimonim-jerusalem",
"https://www.itraveljerusalem.com/accommodation/ritz-hotel",