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/?q=function&page=970&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 14904 results for "function"(1496ms)

OpenRouterChatCompletionLeadmain.tsx1 match

@rozek•Updated 3 months ago
4/**** how long until "OpenAIChatCompletion" becomes available again? ****/
5
6 export default async function (Request:Request):Promise<Response> {
7 if (Request.method === 'OPTIONS') {
8 return new Response(null, {

lastloginmain.tsx4 matches

@AIWB•Updated 3 months ago
1/** @jsxImportSource npm:hono/jsx */
2async function createSession(email: string, hostname: string) {
3 const { zip } = await import("https://esm.town/v/pomdtr/sql");
4 const { sqlite } = await import("https://esm.town/v/std/sqlite");
23}
24
25async function getSession(sessionID: string, hostname: string) {
26 const { zip } = await import("https://esm.town/v/pomdtr/sql");
27 const { sqlite } = await import("https://esm.town/v/std/sqlite");
52}
53
54async function deleteSession(sessionID: string) {
55 const { sqlite } = await import("https://esm.town/v/std/sqlite");
56
64const OAUTH_COOKIE = "oauth_store";
65
66export function lastlogin(
67 handler: (req: Request) => Response | Promise<Response>,
68) {

translatormain.tsx2 matches

@AIWB•Updated 3 months ago
346
347
348 // Helper function to get the supported MIME type
349 function getSupportedMimeType() {
350 const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
351 const mimeTypes = [

getLemmyJwtmain.tsx2 matches

@AIWB•Updated 3 months ago
1export async function getLemmyJwt({ instance, username, password }: {
2 instance: string;
3 username: string;
7 const { LemmyHttp } = await import("npm:lemmy-js-client@0.18.1");
8 let client = new LemmyHttp(`https://${instance}`, {
9 fetchFunction: fetch,
10 });
11 try {

webhookHandlermain.tsx1 match

@AIWB•Updated 3 months ago
8});
9
10export default async function(req: Request): Promise<Response> {
11 if (req.method === "GET") {
12 return Response.json({ ignored: true });

URLReceivermainFunctionURLReciver21 match

@willthereader•Updated 3 months ago
3import { URLCrawler } from "./urlCrawlerComponent";
4
5export async function checkWebsite(inputURL: string) {
6 const urlReceiver = new URLReceiver();
7 const urlCrawler = new URLCrawler(3);

API_URLmain.tsx5 matches

@awhitter•Updated 3 months ago
96}
97
98// Helper function to safely get attachment URL
99function getAttachmentUrl(attachments: AirtableAttachment[] | undefined): string {
100 if (!attachments || !attachments[0]) return '';
101 return attachments[0].url;
103
104// Val Town HTTP Endpoint for Airtable → Framer Fetch
105export default async function (req: Request): Promise<Response> {
106 // Setup CORS Headers for Framer Fetch compatibility
107 const headers = new Headers({
149 } while (offset);
150
151 // Helper function to extract attachment URL
152 const getAttachmentUrl = (field: any): string => {
153 if (Array.isArray(field) && field[0]?.url) {
195 };
196
197 // Helper functions for AI analysis parsing
198 const extractTags = (analysis: string): string[] => {
199 const tagMatch = analysis.match(/Tags:([^\n]*)/);

Globemain.tsx3 matches

@johndevor•Updated 3 months ago
4import * as THREE from 'https://esm.sh/three@0.132.2';
5
6function HelloWorld() {
7 React.useEffect(() => {
8 const scene = new THREE.Scene();
119}
120
121function client() {
122 createRoot(document.getElementById("root")).render(<HelloWorld />);
123}
125if (typeof document !== "undefined") { client(); }
126
127export default async function server(request: Request) {
128 return new Response(`
129 <html>

codeOnValTownmain.tsx2 matches

@AIWB•Updated 3 months ago
9 * @param val Define which val should open. Defaults to the root reference
10 */
11export function modifyHtmlString(
12 bodyText: string,
13 { val, style }: { val?: ValRef; style?: string } = {},
40 * @param val Define which val should open
41 */
42export function modifyFetchHandler(
43 handler: (req: Request) => Response | Promise<Response>,
44 { val, style }: { val?: ValRef; style?: string } = {},

codeOnValTownREADME.md1 match

@AIWB•Updated 3 months ago
49### Linking to the val
50
51These functions infer the val using the call stack or the request URL. If the inference isn't working, or if you want to ensure it links to a specific val, pass the `val` argument:
52
53- `modifyFetchHandler(handler, {val: { handle: "andre", name: "foo" }})`

getFileEmail4 file matches

@shouser•Updated 1 week ago
A helper function to build a file's email
tuna

tuna8 file matches

@jxnblk•Updated 1 week ago
Simple functional CSS library for Val Town
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": "*",