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//%22https:/cdn.jsdelivr.net/npm/@mediapipe/drawing_utils/drawing_utils.js/%22?q=function&page=1&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 40467 results for "function"(767ms)

vtEditorFilesAGENTS.md12 matches

@jrmann100โ€ขUpdated 34 mins ago
4
5- Ask clarifying questions when requirements are ambiguous
6- Provide complete, functional solutions rather than skeleton implementations
7- Test your logic against edge cases before presenting the final solution
8- Ensure all code follows Val Town's specific platform requirements
17- **Never bake in secrets into the code** - always use environment variables
18- Include comments explaining complex logic (avoid commenting obvious operations)
19- Follow modern ES6+ conventions and functional programming practices if possible
20
21## Types of triggers
28
29```ts
30export default async function (req: Request) {
31 return new Response("Hello World");
32}
42
43```ts
44export default async function () {
45 // Scheduled task code
46}
56
57```ts
58export default async function (email: Email) {
59 // Process email
60}
66## Val Town Standard Libraries
67
68Val Town provides several hosted services and utility functions.
69
70### Blob Storage
120```
121
122## Val Town Utility Functions
123
124Val Town provides several utility functions to help with common project tasks.
125
126### Importing Utilities
200โ”‚ โ”œโ”€โ”€ database/
201โ”‚ โ”‚ โ”œโ”€โ”€ migrations.ts # Schema definitions
202โ”‚ โ”‚ โ”œโ”€โ”€ queries.ts # DB query functions
203โ”‚ โ”‚ โ””โ”€โ”€ README.md
204โ”‚ โ””โ”€โ”€ routes/ # Route modules
219โ””โ”€โ”€ shared/
220 โ”œโ”€โ”€ README.md
221 โ””โ”€โ”€ utils.ts # Shared types and functions
222```
223
226- Hono is the recommended API framework
227- Main entry point should be `backend/index.ts`
228- **Static asset serving:** Use the utility functions to read and serve project files:
229 ```ts
230 import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
260- Run migrations on startup or comment out for performance
261- Change table names when modifying schemas rather than altering
262- Export clear query functions with proper TypeScript typing
263
264## Common Gotchas and Solutions

TopTenVideosfree-beautiful-pages-iframe.html5 matches

@pmapowerโ€ขUpdated 49 mins ago
362
363 // Handle main niche selection
364 nicheSelect.addEventListener('change', function() {
365 const selectedValue = this.value;
366
387 });
388
389 // Banner preview functionality
390 function updateBannerPreview(bannerNumber) {
391 const imageUrl = document.getElementById(`banner${bannerNumber}_image`).value;
392 const clickUrl = document.getElementById(`banner${bannerNumber}_url`).value;
422
423 // Handle form submission
424 form.addEventListener('submit', function(e) {
425 e.preventDefault();
426
486
487 // Auto-resize iframe
488 function resizeIframe() {
489 const height = document.body.scrollHeight;
490 parent.postMessage({

untitled-2952main.ts1 match

@xxxjjjโ€ขUpdated 2 hours ago
1// Learn more: https://docs.val.town/vals/http/
2export default async function (req: Request): Promise<Response> {
3 const searchParams = new URL(req.url).searchParams;
4
11- **Schedule**: Every minute
12- **Threshold**: Sessions older than 60 seconds without heartbeat updates
13- **Function**: Marks stale sessions as not viewing and syncs to Notion
14
15**How Viewing Sessions Work**:
39- **Purpose**: Cleans up orphaned agent blobs
40- **Schedule**: Every minute
41- **Function**: Deletes agent blobs where the agent ID doesn't match the demo's
42 "Glimpse agents" relation in Notion
43- **Read-Only Notion**: Only reads Notion data, never modifies it
9 * Hook for tracking user viewing status with automatic updates
10 */
11export function useViewingTracking(
12 glimpseId: string,
13 isAuthorized: boolean
63
64
65 // Cleanup function
66 return () => {
67 if (intervalRef.current) {

spotymain.ts1 match

@skirtownerโ€ขUpdated 2 hours ago
4};
5
6export default async function handler(req: Request) {
7 if (req.method !== "GET") {
8 return new Response("Method Not Allowed", { status: 405 });

untitled-7644new-file-7315.ts1 match

@coolmovesโ€ขUpdated 2 hours ago
1export default async function (interval: Interval) {
2 const f = await fetch("https://sih-2025-demo.onrender.com/");
3 const s = await f.text();
255```typescript
256// In route handler
257const result = await controllerFunction(params);
258
259if (!result.success) {
10**Returns:** `UseAuthReturn`
11- `userEmail` - Current user's email from window data
12- `isAuthorized(pageProperties)` - Function to check if user can access a page
13
14**Usage:**
29- `loading` - Loading state
30- `error` - Error state
31- `refetch` - Function to manually refetch data
32
33**Usage:**

eventsCalendartmp.ts1 match

@roopโ€ขUpdated 4 hours ago
3import { marked } from "npm:marked";
4
5export default async function (req: Request) {
6 const vt = new ValTown();
7 const val_id = "4cbcd1ae-8b94-11f0-b01a-0224a6c84d84";

ratelimit4 file matches

@unkeyโ€ขUpdated 1 month ago
Rate limit your serverless functions

discordWebhook2 file matches

@stevekrouseโ€ขUpdated 2 months ago
Helper function to send Discord messages
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.