Search

Results include substring matches and semantically similar vals. Learn more
easrng avatar
vtTypes
@easrng
An interactive, runnable TypeScript val by easrng
HTTP
export default async function(req: Request): Promise<Response> {
const urls = [
"https://deno.land/x/deno@v1.40.2/cli/tsc/dts/lib.d.ts",
awhitter avatar
API_URL
@awhitter
Val Town API URL When Val Town code is run on Val Town servers we use a local URL so we can save time by skipping a roundtrip to the public internet. However, if you want to run your vals that use our API, ie std library vals, locally, you'll want to use our public API's URL, https://api.val.town . We recommend importing and using std/API_URL whenever you use our API so that you are always using the most efficient route. Example Usage import { API_URL } from "https://esm.town/v/std/API_URL"; const response = await fetch(`${API_URL}/v1/me`, { headers: { Authorization: `Bearer ${Deno.env.get("valtown")}`, Accept: "application/json", }, }); const data = await response.json(); console.log(data)
Script
import { val } from 'https://esm.town/v/std/val';
import { OpenAI } from 'https://esm.town/v/std/openai';
// Initialize OpenAI
const openai = new OpenAI();
// Type definitions for Airtable attachments
error?: string;
// Helper function to safely get attachment URL
function getAttachmentUrl(attachments: AirtableAttachment[] | undefined): string {
if (!attachments || !attachments[0]) return '';
// Val Town HTTP Endpoint for Airtable → Framer Fetch
export default async function (req: Request): Promise<Response> {
// Setup CORS Headers for Framer Fetch compatibility
} while (offset);
// Helper function to extract attachment URL
const getAttachmentUrl = (field: any): string => {
Content: ${content.fields["Intro Content"]} ${content.fields["Body Content 1"]} ${content.fields["Body Content 2"]}
const completion = await openai.chat.completions.create({
messages: [
return null;
// Helper functions for AI analysis parsing
const extractTags = (analysis: string): string[] => {
alejandro avatar
myApi
@alejandro
An interactive, runnable TypeScript val by alejandro
Script
export function myApi(name) {
return "hi " + name;
mrshorts avatar
grammarCheckApp
@mrshorts
@jsxImportSource https://esm.sh/react@18.2.0
HTTP
import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
function App() {
const [text, setText] = useState('');
textDecoration: 'none',
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
if (request.method === 'POST') {
const { OpenAI } = await import("https://esm.town/v/std/openai");
const openai = new OpenAI();
try {
const { text } = await request.json();
const completion = await openai.chat.completions.create({
messages: [
pomdtr avatar
extractArgs
@pomdtr
An interactive, runnable TypeScript val by pomdtr
Script
export async function extractArgs(code: string) {
// Traverse the abstract syntax tree (AST) to find the function declaration
function findFunctionDeclaration(
): ts.FunctionDeclaration | undefined {
if (ts.isFunctionDeclaration(node)) {
return node.forEachChild(findFunctionDeclaration);
// Find the function declaration
const functionDeclaration = findFunctionDeclaration(sourceFile);
if (!functionDeclaration) {
return functionDeclaration.parameters.map((param) => ({
icezee avatar
p5Aloha
@icezee
// Only call client function in browser environment
HTTP
import React from "https://esm.sh/react@18.2.0";
function Sketch() {
const [p5Loaded, setP5Loaded] = React.useState(false);
</div>
function client() {
// Dynamically import React DOM to ensure it's only loaded in the browser
createRoot(root).render(<Sketch />);
// Only call client function in browser environment
if (typeof window !== "undefined") { client(); }
export default async function server(request: Request) {
return new Response(
saolsen avatar
connect4_agent_rand
@saolsen
An interactive, runnable TypeScript val by saolsen
HTTP
} from "https://esm.town/v/saolsen/gameplay_connect4";
import { agentHandler } from "https://esm.town/v/saolsen/gameplay_agent";
function rand_action(
state: Connect4State,
agent_data?: { counter: number },
stevekrouse avatar
expressHTMLExample2
@stevekrouse
// View at https://stevekrouse-expressHTMLExample2.express.val.run?name=Steve
Express (deprecated)
// View at https://stevekrouse-expressHTMLExample2.express.val.run?name=Steve
export async function expressHTMLExample2(
req: express.Request,
res: express.Response,
dhvanil avatar
val_rf0NeaYrZY
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export default async function handler(req) {
try {
const result = await (async () => {
opeala avatar
LegoIWant
@opeala
@jsxImportSource https://esm.sh/react
HTTP
import { FontAwesomeIcon } from "npm:@fortawesome/react-fontawesome";
import { renderToString } from "npm:react-dom/server";
export default async function(req: Request) {
return new Response(
renderToString(
stevekrouse avatar
twitterAlert
@stevekrouse
Twitter/𝕏 keyword alerts Custom notifications for when you, your company, or anything you care about is mentioned on Twitter. If you believe in Twitter/𝕏-driven development, you want to get notified when anyone is talking about your tech, even if they're not tagging you. To get this Twitter Alert bot running for you, fork this val and modify the query and where the notification gets delivered. 1. Query Change the keywords for what you want to get notified for and the excludes for what you don't want to get notified for. You can use Twitter's search operators to customize your query, for some collection of keywords, filtering out others, and much more! 2. Notification Below I'm sending these mentions to a public channel in our company Discord, but you can customize that to whatever you want, @std/email, Slack, Telegram, whatever. Twitter Data & Limitations The Twitter API has become unusable. This val gets Twitter data via SocialData , an affordable Twitter scraping API. In order to make this val easy for you to fork & use without signing up for another API, I am proxying SocialData via @stevekrouse/socialDataProxy. Val Town Pro users can call this proxy 100 times per day, so be sure not to set this cron to run more than once every 15 min. If you want to run it more, get your own SocialData API token and pay for it directly.
Cron
.map((k) => "\"" + k + "\"")
.join(" OR ") + " " + excludes;
function relevant(t: Tweet) {
if (keywords.some(k => t.full_text?.includes(k))) return true;
return t.entities.urls?.some(u => keywords.some(k => u.expanded_url?.includes(k)));
// to run query for past 48 hours
const isProd = true;
export async function twitterAlert({ lastRunAt }: Interval) {
// search
const since = isProd
healeycodes avatar
isMyWebsiteDown
@healeycodes
Uptime Checker & Status Page Installation Fork this val Edit the list of URLs to what you want to check For the status page, fork this val: @stevekrouse/status
Script
await sqlite.execute(
"CREATE TABLE IF NOT EXISTS uptime (id INTEGER PRIMARY KEY AUTOINCREMENT, url TEXT, ok INTEGER, reason TEXT, status INTEGER
export async function uptimeCheck(url: string) {
let ok = true;
let reason: string;
janpaul123 avatar
valle_tmp_66885881021009121244024526935712
@janpaul123
// This val responds with "Hello world" on every HTTP request
HTTP
// This val responds with "Hello world" on every HTTP request
export default async function(req: Request): Promise<Response> {
return new Response("Hello world");
janpaul123 avatar
valle_tmp_5519595717424861508096128925398838
@janpaul123
// This val will respond with a fun HTML page with crazy fonts and gradients
HTTP
// This val will respond with a fun HTML page with crazy fonts and gradients
export default async function main(): Promise<Response> {
const htmlContent = `
<!DOCTYPE html>
smetzdev avatar
myApi
@smetzdev
An interactive, runnable TypeScript val by smetzdev
Script
export function myApi(name) {
return "hi " + name;