Search

myApi
@SlugeR
An interactive, runnable TypeScript val by SlugeR
Script
export function myApi(count) {
return count + " dragons!";
valle_tmp_272229477861650756686636317711954
@janpaul123
// Initialize sample stories and store them in blob storage
HTTP
const SAMPLE_STORIES_KEY = "hn_realistic_sample_stories";
// Initialize sample stories and store them in blob storage
async function initializeSampleStories() {
const existingStories = await blob.getJSON(SAMPLE_STORIES_KEY);
if (!existingStories) {
honoFiberplaneStarter
@fiberplane
Example Hono app that integrates a Hono api with a Fiberplane API explorer. createOpenAPISpec utility creates a lightweight OpenAPI spec that lists all routes in the application createFiberplane mounts a UI at the root route ( / ), which can be used to explore the api's routes Coming Soon Traces! Traces! Traces! Host and connect to an OpenTelemetry trace exporter on ValTown. Wrapping your app with export default instrument(app).fetch can enable tracing for all API routes The tracing library will rely on the environment variable FIBERPLANE_OTEL_ENDPOINT
to be set to an OpenTelemetry trace collector.
(See: https://www.val.town/v/fiberplane/OpenTelemetryCollector)
HTTP
openapi: { url: "/openapi.json" },
otelEndpoint: Deno.env.get("FIBERPLANE_OTEL_ENDPOINT"),
// export default async function(req: Request): Promise<Response> {
// // HACK - Manually add the env vars to the request env, otherwise the client library can't seem to pick up on them
// return instrument(app, { libraryDebugMode: true }).fetch(req, Deno.env.toObject());
aquaAnt
@tempguy
// Import Cheerio and CryptoJS from npm
Script
console.log(this.results);
// Extract function to process encrypted data
async function extract(url) {
try {
const _0x3cbaf6 = "episode";
function key() {
return $("body[class^='container-']").attr("class").split("-").pop();
function iv() {
return $("div[class*='container-']").attr("class").split("-").pop();
function key2() {
return $("div[class*='videocontent-']").attr("class").split("-").pop();
} catch (error) {
console.error("Error in extract function:", error);
// Usage

FaucetShardeum
@newbee
An interactive, runnable TypeScript val by newbee
Cron
import { fetch } from "https://esm.town/v/std/fetch";
export async function FaucetShardeum() {
const data = await fetch("https://discord.com/api/v9/interactions", {
method: "POST",
randomMovieQuiz
@movienerd
@jsxImportSource https://esm.sh/react
HTTP
"Avatar",
function App() {
const [description, setDescription] = useState("");
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
client();
async function server(request: Request): Promise<Response> {
if (request.url.endsWith("/new-game")) {
const { OpenAI } = await import("https://esm.town/v/std/openai");
const openai = new OpenAI();
const correctMovie = movies[Math.floor(Math.random() * movies.length)];
`Give a rhyming vague description of the movie "${correctMovie}" without mentioning any character names, actor names, or the movie title. The description should be 4 to 8 lines long.`;
const completion = await openai.chat.completions.create({
messages: [{ role: "user", content: prompt }],

visitMetabase
@jlast
An interactive, runnable TypeScript val by jlast
Cron
import { fetch } from "https://esm.town/v/std/fetch";
export function visitMetabase() {
const url = "https://metabase.jlast.repl.co/";
return fetch(url).then((res) => {

myApi
@willosbourne
An interactive, runnable TypeScript val by willosbourne
Script
export function myApi(name) {
return "hi " + name;

telegramBotHandler
@stevekrouse
Telegram to DallE Bot Set up First you'll need to set yourself up to send and receive messages on Telegram. Follow all 5 steps here: https://www.val.town/v/stevekrouse.telegram Fork this @telegramBotHandler val below. Make sure you click Run to save it to your account. On your forked val, click the ⋮ menu > Endpoints > Copy express endpoint Message @ValTownBot /webhook Message @ValTownBot the express endpoint you copied You'll also need an openai key in your secrets for this particular DallE bot to work
HTTP
5. Message @ValTownBot the express endpoint you copied
6. You'll also need an `openai` key in [your secrets](/settings/secrets) for this particular DallE bot to work
import process from "node:process";
export default async function server(req: Request): Promise<Response> {
let responseBody = "{}";
let resp = await textToImageDalle(
process.env.openai,
text.replace("/dalle", ""),
bebopBotWebhook
@z233
An interactive, runnable TypeScript val by z233
Script
import { createFeishuCardBuilder } from "https://esm.town/v/z233/createFeishuCardBuilder";
import { bebopBotSecretToken } from "https://esm.town/v/z233/bebopBotSecretToken";
export async function bebopBotWebhook(
req: express.Request,
res: express.Response
await feishuGetInteractiveMessage({ card })
res.send("ok");
function getMarkdownLink(text, url) {
return `[${text}](${url})`;
parallaxWordsVal
@ashryanio
@jsxImportSource https://esm.sh/react
HTTP
import { createRoot } from "https://esm.sh/react-dom/client";
function ParallaxWords() {
const [words] = useState([
</div>
function client() {
createRoot(document.getElementById("root")).render(<ParallaxWords />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
return new Response(`
doesAdamSux
@ooo_ooo_oooooh
An interactive, runnable TypeScript val by ooo_ooo_oooooh
Script
export function doesAdamSux() {
return "Yes stupid.";
val_4VZJ1Gz7nR
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export default async function handler(req) {
try {
const result = await (async () => {

savvyPurpleSpoonbill
@stevekrouse
@jsxImportSource https://esm.sh/react
HTTP
import { tomorrow } from "https://esm.sh/react-syntax-highlighter/dist/esm/styles/prism";
function App() {
const [prompt, setPrompt] = useState("hello llamapalooza");
>(null);
async function handleSubmit(e: React.FormEvent) {
e.preventDefault();
setLoading(false);
function handleBack() {
if (currentIndex > 0) {
setCode(history[currentIndex - 1]);
function handleForward() {
if (currentIndex < history.length - 1) {
</div>
function client() {
createRoot(document.getElementById("root")!).render(<App />);
client();
function extractCodeFromFence(text: string): string {
const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
return htmlMatch ? htmlMatch[1].trim() : text;
export default async function server(req: Request): Promise<Response> {
if (req.method === "POST") {
multiplayerCircles
@maxm
Multiplayer Circles Move circles around. State is synced with the server. Open a window in another tab and watch the circles update as you move them .
HTTP
// await sqlite.execute({ sql: `INSERT INTO draggable_circles VALUES (?, ?, ?)`, args: [c.index, c.x, c.y] });
function parseResultSet<T>(row: ResultSet): T[] {
return row.rows.map((r) => Object.fromEntries(r.map((c, i) => [row.columns[i], c]))) as T[];
return parseResultSet<Circle>(await sqlite.execute("select * from draggable_circles"));
function diffCircles(array1: Circle[], array2: Circle[]): Circle[] {
const changes: Circle[] = [];
const drag = (() => {
function dragstarted() {
d3.select(this).attr("stroke", "black");
function dragged(event, d) {
d3.select(this).raise().attr("cx", d.x = event.x).attr("cy", d.y = event.y);
function dragended() {
const x = d3.select(this).attr("cx");
.on("click", clicked);
function clicked(event, d) {
if (event.defaultPrevented) return; // dragged