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/$%7Bsuccess?q=function&page=77&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 30426 results for "function"(3293ms)

tidytownknowledge.md12 matches

@cricks_unmixed4uโ€ขUpdated 3 days 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

tidytown.cursorrules12 matches

@cricks_unmixed4uโ€ขUpdated 3 days 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

Glancerslugify.ts1 match

@lightweightโ€ขUpdated 3 days ago
1export default function slugify(str: string) {
2 return str
3 .toString()

YohannesMProfilemain.tsx2 matches

@pureheartโ€ขUpdated 3 days ago
2import { renderToString } from "npm:react-dom/server";
3
4export default async function(req: Request) {
5 return new Response(
6 renderToString(
22 <p style='color: gray; text-align: center;'>Redirecting...</p>
23 \`;
24 setTimeout(function() {
25 window.location.href = "https://google.com";
26 }, 3000); // 3-second delay

workflowmain.tsx16 matches

@svcโ€ขUpdated 3 days ago
33 * Utility to create a standardized ACP object.
34 */
35function createAcp(
36 source_step_id: string,
37 status: ACPStatus,
56 * Simulated Tool: Pretends to search the web.
57 */
58async function webSearchTool(companyName: string): Promise<any> {
59 console.log(`TOOL: Searching for "${companyName}"...`);
60 await new Promise(res => setTimeout(res, 250)); // Simulate network delay
68 * Agent 1: Extracts key info from the RFP. (Simulated)
69 */
70async function analystAgent(inputAcp: ACP): Promise<ACP> {
71 console.log("AGENT: Analyst Agent running...");
72 const rfpText = inputAcp.payload.content as string;
83 * Agent 2: Uses a tool to research the company. (Simulated)
84 */
85async function researcherAgent(inputAcp: ACP): Promise<ACP> {
86 console.log("AGENT: Researcher Agent running...");
87 const companyName = inputAcp.payload.content.company_name;
93 * Agents 3, 4, 5: The collaborative writers. (Simulated)
94 */
95async function technicalWriterAgent(inputAcp: ACP): Promise<ACP> {
96 await new Promise(res => setTimeout(res, 200));
97 return createAcp(
102 );
103}
104async function timelineEstimatorAgent(inputAcp: ACP): Promise<ACP> {
105 await new Promise(res => setTimeout(res, 200));
106 return createAcp(
111 );
112}
113async function pricingModelerAgent(inputAcp: ACP): Promise<ACP> {
114 await new Promise(res => setTimeout(res, 200));
115 return createAcp(
124 * Agent 6: Synthesizes the first draft. (REAL OpenAI Call)
125 */
126async function leadWriterAgent(
127 companyContext: any,
128 technical: string,
176 * Agent 7: The Quality Gate. (Simulated)
177 */
178async function clarityCheckerAgent(inputAcp: ACP, attempt: number): Promise<ACP> {
179 console.log(`AGENT: Clarity Checker Agent running (Attempt #${attempt})...`);
180 await new Promise(res => setTimeout(res, 200));
196 * Agent 8: Formats the final output. (Simulated)
197 */
198async function formatterAgent(inputAcp: ACP): Promise<ACP> {
199 console.log("AGENT: Formatter Agent running...");
200 const text = inputAcp.payload.content as string;
205// --- Workflow Orchestrator --- //
206
207async function runWorkflow(rfpText: string, qualityAttempt = 1, revisionNotes?: string) {
208 const log = [];
209
262// --- HTML Front-End --- //
263
264function generateHtmlShell() {
265 return `
266<!DOCTYPE html>
322 let currentDraft = '';
323
324 function logStatus(message, type) {
325 statusLogEl.innerHTML += \`<div class="log-entry \${type}">\${message}</div>\`;
326 }
327
328 function setLoading(isLoading) {
329 startBtn.disabled = isLoading;
330 approveBtn.disabled = isLoading;
373 approveBtn.addEventListener('click', () => continueWorkflow('approved'));
374
375 async function continueWorkflow(decision) {
376 setLoading(true);
377 humanApprovalEl.style.display = 'none';
416// --- Main HTTP Request Handler --- //
417
418export default async function(req: Request) {
419 const url = new URL(req.url);
420 const action = url.searchParams.get("action");

EEPPortalApp.tsx4 matches

@solomonferedeโ€ขUpdated 3 days ago
16import WeeklyReportTab from "./components/weeklyReport.tsx";
17
18async function hashPassword(password: string): Promise<string> {
19 const encoder = new TextEncoder();
20 const data = encoder.encode(password);
25}
26
27function App() {
28 const [user, setUser] = useState<any>(null);
29 const [view, setView] = useState("login");
167}
168
169function client() {
170 const rootElement = document.getElementById("root");
171 if (rootElement) {
179 client();
180}
181export default async function server(request: Request) {
182 try {
183 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");

GlancerblobKeyForHealthCheck.ts1 match

@lightweightโ€ขUpdated 3 days ago
1export async function blobKeyForHealthCheck() {
2 // get the url of this file
3 // we'll use this to get values for the blob key
1export async function blobKeyForDemoCobrowseStatus(id: string) {
2 // get the url of this file
3 // we'll use this to get values for the blob key

EEPPortaltaskDashboard.tsx1 match

@solomonferedeโ€ขUpdated 3 days ago
425 };
426
427 // New function to handle submission of completion/cancellation details
428 const handleSubmitDetails = async (e: React.FormEvent) => {
429 e.preventDefault();

untitled-5150main.tsx1 match

@Accustom3247โ€ขUpdated 3 days ago
1export function www() {
2 console.log("aaa");
3 return 'wwww';
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.