Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/$%7BsvgDataUrl%7D?q=function&page=28&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=function

Returns an array of strings in format "username" or "username/projectName"

Found 30773 results for "function"(3549ms)

my-first-val04_email.tsx1 match

@ccaoUpdated 1 day ago
2// Click "Run", copy and paste the email address and send an email to it.
3// This example will log the email details received.
4export default async function emailHandler(email: Email){
5 console.log("Email received!", email.from, email.subject, email.text);
6 for (const file of email.attachments) {

my-first-val03_cron.tsx1 match

@ccaoUpdated 1 day ago
2// Configure the timer with the 🕒 icon in the top right.
3// This example just logs the current time.
4export function scheduledHandler() {
5 const timestamp = new Date().toISOString();
6 console.log(`Cron val executed at: ${timestamp}`);

my-first-val02_http.tsx1 match

@ccaoUpdated 1 day ago
2// Access it via its public URL (you can also pick a nicer subdomain).
3// Try adding ?name=YourName to the URL!
4export default function httpHandler(req: Request): Response {
5 const url = new URL(req.url);
6 const name = url.searchParams.get("name") || "Friend";

my-first-val01_script.tsx1 match

@ccaoUpdated 1 day ago
1// This script returns a random fun fact
2// You can run scripts manually in this view or call it from other vals.
3export default function getRandomFact() {
4 const funFacts = [
5 "Honey never spoils.",

rotationindex.ts3 matches

@panphoraUpdated 1 day ago
90};
91
92function getWeekAndDay(startDate: Date, currentDate: Date): { week: number, dayOfWeek: number } {
93 const diffTime = currentDate.getTime() - startDate.getTime();
94 const diffDays = Math.floor(diffTime / (1000 * 60 * 60 * 24));
99}
100
101function getEmailTemplate(week: number, dayOfWeek: number) {
102 // If we're past week 6, use maintenance template
103 if (week > 6) {
112}
113
114export default async function() {
115 const now = new Date();
116 const dayOfWeek = now.getDay();
2import { db } from "./db.ts";
3
4export async function createTables() {
5 // Uncomment to reset database
6 // await db.run(sql`DROP TABLE IF EXISTS messages`);

anchorPDSauth.ts1 match

@tijsUpdated 1 day ago
9const CACHE_TTL = 3600000; // 1 hour
10
11export async function validateToken(token: string): Promise<AuthContext | null> {
12 console.log(`🔐 Validating token: ${token.substring(0, 20)}... (length: ${token.length})`);
13

anchorPDSanchor.ts1 match

@tijsUpdated 1 day ago
8
9// Middleware for authentication
10async function authenticateRequest(c: any) {
11 const authHeader = c.req.header("Authorization");
12 if (!authHeader || !authHeader.startsWith("Bearer ")) {

puk-timermain.tsx1 match

@paranoidrayUpdated 1 day ago
9// if(request.query.code == process.env.SECRET) {
10
11export default async function(req: Request): Promise<Response> {
12 const url = new URL(req.url);
13 const query = url.searchParams;

puk-timerold.tsx1 match

@paranoidrayUpdated 1 day ago
6// import { serveFile } from "../index.ts";
7
8export function staticHTTPServer(importMetaURL: string) {
9 const app = new Hono();
10 app.get("/", () => serveFile("/index.html", importMetaURL));
tuna

tuna9 file matches

@jxnblkUpdated 1 week ago
Simple functional CSS library for Val Town

getFileEmail4 file matches

@shouserUpdated 1 month ago
A helper function to build a file's email
lost1991
import { OpenAI } from "https://esm.town/v/std/openai"; export default async function(req: Request): Promise<Response> { if (req.method === "OPTIONS") { return new Response(null, { headers: { "Access-Control-Allow-Origin": "*",
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.