Search
testWebpage
@joemccourt
An interactive, runnable TypeScript val by joemccourt
Script
export const testWebpage = async () => {
// const games = await @jdan.lichessTVGames();
// const validGameTypes = [
// "Bot",
// "UltraBullet",
// "Bullet",
// "Computer",
// "Rapid",
// "Top Rated",
// "Blitz",
cliOld
@pomdtr
Cli Vals Cli vals are a new type of val (same as http, email, cron and script vals). A cli val must use a function without args as it's default export. The function body will run on the user device using deno . An error message will be shown if deno is not installed. export default function() {
if (Deno.args.length == 0) {
console.error("<name> arg is required!");
Deno.exit(1);
}
console.log(`Hey ${Deno.args[0]}!`);
} Fork @pomdtr/example_cli to get started. Of course, you can use a cli framework to parse arguments (ex: cliffy ). Running a cli val Go to https://pomdtr-cli.web.val.run/v/<author>/<name>[?v=<version>] to get a runnable script for your val. You can pipe the script to a shell to test it curl 'https://pomdtr-cli.web.val.run/v/pomdtr/cli_example' | sh -s Steve
Hello Steve! Or save it to your $PATH . # save the script to the ~/.local/bin folder
curl 'https://pomdtr-cli.web.val.run/v/pomdtr/cli_example' > ~/.local/bin/cli_example
# make the script executable
chmod +x ~/.local/bin/cli_example
# run the installed val
cli_example Steve Allowing cli vals to access private resources Cli vals run on your device, so by default they can only access public/unlisted vals. You can set the DENO_AUTH_TOKENS env var in your shell config to allow deno to import private vals. export DENO_AUTH_TOKENS=<your-token>@esm.town Cli vals don't have access to val town tokens. Instead of trying to replicate your valtown secrets locally, you can configure your cli vals to call your http endpoints using fetch .
HTTP
# Cli Vals
Cli vals are a new type of val (same as http, email, cron and script vals). A cli val must use a function without args as it's default export.
The function body will run on the user device using [deno](https://deno.com). An error message will be shown if deno is not installed.
```typescript
export default function() {
if (Deno.args.length == 0) {
const script = (esmUrl) =>
`#!/bin/sh
# check if deno is installed
if ! command -v deno >/dev/null; then
sampleFirehose
@lukas
An interactive, runnable TypeScript val by lukas
Script
export async function sampleFirehose() {
const cborx = await import("https://deno.land/x/cbor@v1.5.2/index.js");
const multiformats = await import("npm:multiformats");
const uint8arrays = await import("npm:uint8arrays");
const { z } = await import("https://deno.land/x/zod@v3.21.4/mod.ts");
const xrpc = await import("npm:@atproto/xrpc");
const cborCodec = await import(
"https://cdn.jsdelivr.net/npm/@ipld/dag-cbor/+esm"
const cborEncode = cborCodec.encode;
enum FrameType {
calorieapp
@stevekrouse
@jsxImportSource npm:hono/jsx
HTTP
/** @jsxImportSource npm:hono/jsx */
await sqlite.execute(`
CREATE TABLE IF NOT EXISTS food_entries2 (
id INTEGER PRIMARY KEY AUTOINCREMENT,
food TEXT,
calories INTEGER,
date TEXT
const app = new Hono();
app.get("/", async (c) => {
const today = new Date().toISOString().slice(0, 10);
blocks
@vlad
// Forked from @tmcw.blocks_inner
HTTP
export let blocks_inner = async (request: Request) => {
const [_, user, id, ...file] = new URL(request.url).pathname.split("/");
const gist = await fetch(`https://api.github.com/gists/${id}`).then((r) => r.json());
// res.set("Cache-Control", "public,max-age=64800");
// if (file.filter(Boolean).length) {
// if (gist.files[file.filter(Boolean).join("/")].raw_url.endsWith(".js")) {
// res.set("Content-Type", "application/javascript");
// return res.send(
// await fetch(gist.files[file.filter(Boolean).join("/")].raw_url).then((
// r,
invoice_deta
@pomdtr
@jsxImportSource npm:hono/jsx
HTTP
/** @jsxImportSource npm:hono/jsx **/
const router = new Hono();
router.get("/", (c) => {
return c.html(
<html>
<body>
<ul>
{Object.keys(invoices).map((key) => (
<li key={key}>
<a href={`/${key}`}>{key}</a>
jadeCod
@u
An interactive, runnable TypeScript val by u
HTTP
export async function handlePlexWebhook(req: Request) {
console.log(await req.text());
renderHTMLWithHono
@daisuke
An interactive, runnable TypeScript val by daisuke
HTTP
const app = new Hono();
app.get("/", (c) => {
return c.html(html`
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Honoを使ったHTMLレンダリング サンプル</title>
<style>
bskyEmptyMessagesBug
@healeycodes
An interactive, runnable TypeScript val by healeycodes
Script
export let bskyEmptyMessagesBug = (async () => {
const ws = new WebSocketStream(
"wss://bsky.social/xrpc/com.atproto.sync.subscribeRepos",
const { readable } = await ws.connection;
const reader = readable.getReader();
for (let i = 0; i < 200; i++) {
console.log(i);
const { value, done } = await reader.read();
console.log({ value, done });
drivingTealKite
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
HTTP
export default async function (req: Request): Promise<Response> {
return Response.json({ ok: true })
lavenderPinniped
@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 their functionality
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);
create_val
@nbbaier
An interactive, runnable TypeScript val by nbbaier
Script
export default async function(ctx: BrowserContext) {
const val = await fetchJSON("https://api.val.town/v1/vals", {
headers: {
Authorization: `Bearer ${Deno.env.get("valtown")}`,
method: "POST",
body: JSON.stringify({
code: "console.log('a')",
return {
type: "open",
url: `https://val.town/v/${val.author.username}/${val.name}`,
slackReplyToMessage
@naquiroz
An interactive, runnable TypeScript val by naquiroz
Script
export const slackReplyToMessage = async (
req: express.Request,
res: express.Response,
// Verify the request is genuine
if (req.body.token !== process.env.slackVerificationToken) {
return res.status(401);
// Respond to the initial challenge (when events are enabled)
if (req.body.challenge) {
return res.send({ challenge: req.body.challenge });
// Reply to app_mention events
dateme_layout
@vawogbemi
@jsxImportSource npm:hono@3/jsx
Script
/** @jsxImportSource npm:hono@3/jsx */
const tabs = { "/": "Home", "/browse": "Browse", "/faq": "FAQ" };
export default function({ activeTab, children }: PropsWithChildren<{ activeTab: string }>) {
return (
<html>
<head>
<title>I'm Looking for a Man In Finance</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script src="https://cdn.tailwindcss.com" />
</head>