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//%22Wolf?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"(745ms)

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
tuna

tuna9 file matches

@jxnblkโ€ขUpdated 3 months ago
Simple functional CSS library for Val Town

getFileEmail4 file matches

@shouserโ€ขUpdated 4 months ago
A helper function to build a file's email

AutomationFunction1 file match

@saradpโ€ขUpdated 5 months ago

TwilioHelperFunctions

@vawogbemiโ€ขUpdated 7 months ago

trmnl_plugins2 file matches

@camflanโ€ขUpdated 7 months ago
Backend functions for TRMNL plugins

exampleTestFunctions1 file match

@willthereaderโ€ขUpdated 7 months ago

generateFunction1 file match

@wolfโ€ขUpdated 8 months ago

functionExercise2 file matches

@willthereaderโ€ขUpdated 9 months ago

vtEditorFilesAGENTS.md12 matches

@jrmann100โ€ขUpdated 1 hour 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
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({
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.