Search

Results include substring matches and semantically similar vals. Learn more
dhvanil avatar
val_ab1cAriYki
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_ab1cAriYki(req) {
try {
// Execute the code directly and capture its result
maxm avatar
evalUI
@maxm
An interactive, runnable TypeScript val by maxm
HTTP
import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo?v=29";
import safeJsonValue from "npm:safe-json-value";
export default async function(req: Request): Promise<Response> {
if (req.method === "GET") {
return new Response(indexHTML, {
iansavchenko avatar
myApi
@iansavchenko
An interactive, runnable TypeScript val by iansavchenko
Script
export function myApi(name) {
return "hi " + name;
janpaul123 avatar
valle_tmp_60836902668989675457109372512279
@janpaul123
@jsxImportSource https://esm.sh/react
HTTP
import OpenAI from "npm:openai";
unless strictly necessary, for example use APIs that don't require a key, prefer internal function
functions where possible. Unless specified, don't add error handling,
The val should create a "export default async function main" which is the main function that gets
function write(text) {
function updateValName(valName) {
function saveVal() {
function openTab(tab) {
function toggleTab() {
const callback = function (mutationsList, observer) {
yawnxyz avatar
htmxGenFormsExample
@yawnxyz
An interactive, runnable TypeScript val by yawnxyz
HTTP
return c.text(showClicked());
export default app.fetch;
export function showClicked() {
return "Button Clicked!";
farahani avatar
mightyGraySkink
@farahani
// Initialize the bot
HTTP
last_name?: string;
async function createOrUpdateUser(telegramUser: TelegramUser, referredBy?: number): Promise<void> {
try {
throw error;
async function getUserReferrals(userId: string): Promise<User[]> {
try {
throw error;
async function processDeposit(userId: string, amount: number, txId: string): Promise<void> {
try {
throw error;
// ... (keep the existing code for other functions)
bot.command("start", async (ctx) => {
await ctx.reply(message);
// ... (keep the existing code for other command handlers and main function)
export default async function(req: Request): Promise<Response> {
// ... (keep the existing code for the main function)
// ... (keep the existing code for setup and other functions)
dhvanil avatar
val_l8coqheYHp
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_l8coqheYHp(req) {
try {
// Execute the code directly and capture its result
cyrilos avatar
tonpick
@cyrilos
// handle incoming requests
Script
const VAL_URL = "https://cyrilos-tonpick.web.val.run";
// handle incoming requests
export default async function(req) {
const PLATFORM = "tonpick.game";
// const cookies = await blob.getJSON("platforms");
dhvanil avatar
val_tlcH2AKDA2
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_tlcH2AKDA2(req) {
try {
// Execute the code directly and capture its result
woop avatar
myApi
@woop
An interactive, runnable TypeScript val by woop
Script
export function myApi(name) {
return "hi " + name;
adagradschool avatar
claude_new
@adagradschool
An interactive, runnable TypeScript val by adagradschool
HTTP
export default function handler(req) {
return new Response(`"\n <!DOCTYPE html>\n <html>\n <head>\n <title>Claude Chat Conversation</title
headers: {
gugge avatar
myApi
@gugge
An interactive, runnable TypeScript val by gugge
Script
export function myApi(name) {
return "Hello " + name;
adagradschool avatar
openPurpleHippopotamus
@adagradschool
An interactive, runnable TypeScript val by adagradschool
HTTP
export default function handler(req) {
return new Response(`"\n <!DOCTYPE html>\n <html>\n <head>\n <title>Claude Chat Conversation</title
headers: {
yawnxyz avatar
createGeneratedVal
@yawnxyz
Use GPT to generate vals on your account! Describe the val that you need, call this function, and you'll get a new val on your workspace generated by OpenAI's API! First, ensure you have a Val Town API Token , then call @andreterron.createGeneratedVal({...}) like this example : @andreterron.createGeneratedVal({ valTownKey: @me.secrets.vt_token, description: "A val that given a text file position in `{line, col}` and the text contents, returns the index position", }); This will create a val in your workspace, and here's the one created by the example above: https://www.val.town/v/andreterron.getFileIndexPosition
Script
# Use GPT to generate vals on your account!
Describe the val that you need, call this function, and you'll get a new val on your workspace generated by OpenAI's API!
First, ensure you have a [Val Town API Token](https://www.val.town/settings/api), then call `@andreterron.createGeneratedVal(
import { runVal } from "https://esm.town/v/std/runVal";
import { OpenAI } from "https://esm.town/v/std/openai";
const openai = new OpenAI();
export const generateValCode = async (
const lodash = await import('npm:lodash');
const response = await openai.chat.completions.create({
model: "gpt-4o",
role: "user",
content: `Here's the description of the function I want to write:
${description}
Please start writing the function now, and just write the function, no console.log required:
const message: string = response.choices[0].message.content;
return code;
export async function createVal({ description, valTownKey, code, name, type }) {
// give it code or generate code
pomdtr avatar
basicAuth
@pomdtr
Val Town Basic Auth Add basic auth on top of any http val Usage Wrap your HTTP handler in the basicAuth middleware. import { basicAuth } from "https://esm.town/v/pomdtr/basicAuth"; function handler(req: Request) { return new Response("You are authenticated!"); } export default basicAuth(handler, { verifyUser: (username, password) => username == "user" && password == "password" }); If you want to use an apiToken as a password: import { basicAuth } from "https://esm.town/v/pomdtr/basicAuth"; import { verifyToken } from "https://www.val.town/v/pomdtr/verifyToken" function handler(req: Request) { return new Response("You are authenticated!"); } export default basicAuth(handler, { verifyUser: (_, password) => verifyToken(password) });
Script
import { basicAuth } from "https://esm.town/v/pomdtr/basicAuth";
function handler(req: Request) {
return new Response("You are authenticated!");
import { verifyToken } from "https://www.val.town/v/pomdtr/verifyToken"
function handler(req: Request) {
return new Response("You are authenticated!");
function extractCredentials(authorization) {
const parts = authorization.split(" ");
export type ServeHandler = (req: Request) => Response | Promise<Response>
export function basicAuth(next: ServeHandler, params: {
verifyUser: (username: string, password: string) => boolean | Promise<boolean>;