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=31&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 30731 results for "function"(1726ms)

cardamonval-town.mdc12 matches

@connnollyโ€ขUpdated 1 day ago
9
10- Ask clarifying questions when requirements are ambiguous
11- Provide complete, functional solutions rather than skeleton implementations
12- Test your logic against edge cases before presenting the final solution
13- Ensure all code follows Val Town's specific platform requirements
22- **Never bake in secrets into the code** - always use environment variables
23- Include comments explaining complex logic (avoid commenting obvious operations)
24- Follow modern ES6+ conventions and functional programming practices if possible
25
26## Types of triggers
33
34```ts
35export default async function (req: Request) {
36 return new Response("Hello World");
37}
45
46```ts
47export default async function () {
48 // Scheduled task code
49}
57
58```ts
59export default async function (email: Email) {
60 // Process email
61}
65## Val Town Standard Libraries
66
67Val Town provides several hosted services and utility functions.
68
69### Blob Storage
119```
120
121## Val Town Utility Functions
122
123Val Town provides several utility functions to help with common project tasks.
124
125### Importing Utilities
181โ”‚ โ”œโ”€โ”€ database/
182โ”‚ โ”‚ โ”œโ”€โ”€ migrations.ts # Schema definitions
183โ”‚ โ”‚ โ”œโ”€โ”€ queries.ts # DB query functions
184โ”‚ โ”‚ โ””โ”€โ”€ README.md
185โ”‚ โ””โ”€โ”€ routes/ # Route modules
200โ””โ”€โ”€ shared/
201 โ”œโ”€โ”€ README.md
202 โ””โ”€โ”€ utils.ts # Shared types and functions
203```
204
208- Main entry point should be `backend/index.ts`
209- Do NOT use Hono serveStatic middleware
210- **Static asset serving:** Use the utility functions to read and serve project files:
211 ```ts
212 import { readFile, serveFile } from "https://esm.town/v/std/utils/index.ts";
242- Run migrations on startup or comment out for performance
243- Change table names when modifying schemas rather than altering
244- Export clear query functions with proper TypeScript typing
245
246## Common Gotchas and Solutions

emailtesttrigger3 matches

@universeโ€ขUpdated 1 day ago
4import { OpenAI } from "npm:openai";
5
6function pm(...lines: string[]): string {
7 return lines.join("\n");
8}
9
10export async function emailValHandler(inboundEmail: Email) {
11 const userPrompt = pm(
12 `From: ${inboundEmail.from}`,
23}
24
25export default async function(interval: Interval) {
26 const today = new Intl.DateTimeFormat("en-US", {
27 month: "short",

strategoindex.ts2 matches

@gueejlaโ€ขUpdated 1 day ago
20const wss = new WebSocketServer({ noServer: true });
21
22// Helper function to broadcast messages to all connected clients
23function broadcastToAll(data: any, excludeClient?: WebSocket) {
24 const message = JSON.stringify(data);
25 clients.forEach((client) => {

GlancerdemoCache.ts1 match

@lightweightโ€ขUpdated 1 day ago
9});
10
11export default async function (interval: Interval) {
12 // this cron runs every minute
13 // it saves a blob for every page in the "Glancer demos" database

GlancerrelatedPages.controller.ts1 match

@lightweightโ€ขUpdated 1 day ago
7});
8
9export async function getRelatedPagesFromDatabase(pageId: string) {
10 try {
11 const response = await notion.databases.query({

demoSDKmain.tsx1 match

@chadparkerโ€ขUpdated 1 day ago
1import ValTown from "npm:@valtown/sdk";
2
3export default async function(req: Request) {
4 try {
5 const vt = new ValTown();

val-town-http-mcp-servervtCli.ts9 matches

@nbbaierโ€ขUpdated 1 day ago
8 * @returns Promise resolving to boolean indicating CLI availability
9 */
10export async function isVtCliAvailable(): Promise<boolean> {
11 try {
12 const command = new Deno.Command("which", {
30 * @returns Promise resolving to boolean indicating CLI availability
31 */
32export async function getCliAvailability(): Promise<boolean> {
33 if (_isCliAvailable === null) {
34 _isCliAvailable = await isVtCliAvailable();
42 * @returns Promise resolving to an object containing command execution result
43 */
44export async function runVtCommand(args: string[]): Promise<{
45 success: boolean;
46 output: string;
71
72/**
73 * Parse CLI JSON output (placeholder for missing function)
74 * @param output CLI output string to parse
75 * @returns Parsed JSON object or error
76 */
77export function parseCliJsonOutput(output: string): any {
78 try {
79 return JSON.parse(output);
84
85/**
86 * Prepare Val workspace (placeholder for missing function)
87 * @param valId Val ID to prepare workspace for
88 * @returns Workspace preparation result
89 */
90export async function prepareValWorkspace(valId: string): Promise<{
91 success: boolean;
92 workspacePath?: string;
102
103/**
104 * Cleanup temporary directory (placeholder for missing function)
105 * @param dirPath Directory path to cleanup
106 * @returns Cleanup result
107 */
108export async function cleanupTempDirectory(dirPath: string): Promise<{
109 success: boolean;
110 error?: string;

val-town-http-mcp-servervalsTools.ts1 match

@nbbaierโ€ขUpdated 1 day ago
6import {z} from "npm:zod"
7
8export function registerValTools(server: McpServer, config: Config) {
9 // Get val by username and val name
10 server.tool(

val-town-http-mcp-servervalley.txt11 matches

@nbbaierโ€ขUpdated 1 day ago
10- **Never bake in secrets into the code** - always use environment variables
11- Include comments explaining complex logic (avoid commenting obvious operations)
12- Follow modern ES6+ conventions and functional programming practices if possible
13
14## Types of triggers
21
22```ts
23export default async function (req: Request) {
24 return new Response("Hello World");
25}
35
36```ts
37export default async function () {
38 // Scheduled task code
39}
49
50```ts
51export default async function (email: Email) {
52 // Process email
53}
58## Val Town Standard Libraries
59
60Val Town provides several hosted services and utility functions.
61
62### Blob Storage
112```
113
114## Val Town Utility Functions
115
116Val Town provides several utility functions to help with common project tasks.
117
118### Importing Utilities
191โ”‚ โ”œโ”€โ”€ database/
192โ”‚ โ”‚ โ”œโ”€โ”€ migrations.ts # Schema definitions
193โ”‚ โ”‚ โ”œโ”€โ”€ queries.ts # DB query functions
194โ”‚ โ”‚ โ””โ”€โ”€ README.md
195โ”‚ โ””โ”€โ”€ routes/ # Route modules
210โ””โ”€โ”€ shared/
211 โ”œโ”€โ”€ README.md
212 โ””โ”€โ”€ utils.ts # Shared types and functions
213```
214
217- Hono is the recommended API framework
218- Main entry point should be `backend/index.ts`
219- **Static asset serving:** Use the utility functions to read and serve project files:
220 ```ts
221 import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
251- Run migrations on startup or comment out for performance
252- Change table names when modifying schemas rather than altering
253- Export clear query functions with proper TypeScript typing
254
255## Common Gotchas and Solutions

val-town-http-mcp-servervalley_local.txt3 matches

@nbbaierโ€ขUpdated 1 day ago
6## Understanding Val Town
7
8Val Town is a platform for writing, running, and deploying JavaScript/TypeScript code in the cloud. It functions as a social coding environment where users can create and share code that runs on Val Town's serverless infrastructure.
9
10### Val Town Projects
21## Core Guidelines
22
23- Provide complete, functional solutions
24- Test logic against edge cases
25- Follow Val Town's platform requirements
26- Write clean, maintainable TypeScript/TSX code
27- Add appropriate TypeScript types for all data structures
28- Prefer functional programming practices where appropriate
29
30## Coding Requirements
tuna

tuna9 file matches

@jxnblkโ€ขUpdated 1 week ago
Simple functional CSS library for Val Town

getFileEmail4 file matches

@shouserโ€ขUpdated 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.