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/$%7BsvgDataUrl%7D?q=function&page=72&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 31560 results for "function"(4488ms)

val-to-textvaltown.mdc12 matches

@tkneislyโ€ขUpdated 4 days 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

val-to-textValOutput.tsx1 match

@tkneislyโ€ขUpdated 4 days ago
3import type { ValOutputProps } from "../types.ts";
4
5export function ValOutput({
6 text,
7 files,

val-to-textValForm.tsx1 match

@tkneislyโ€ขUpdated 4 days ago
3import type { ValFormProps } from "../types.ts";
4
5export function ValForm({
6 username,
7 valName,

val-to-textutils.ts3 matches

@tkneislyโ€ขUpdated 4 days ago
10type File = ValTown.Vals.Files.FileRetrieveResponse;
11
12export function formatOutput({
13 username,
14 valname,
42}
43
44export async function getTreeAndContent(id: string): Promise<{
45 filesWithContent: { name: string; content: string }[];
46 tree: FileTree;
71}
72
73export async function getFilesWithContent(
74 files: File[],
75 valId: string,

val-to-textuseValExport.ts1 match

@tkneislyโ€ขUpdated 4 days ago
1import { useState } from "https://esm.sh/react@18.2.0";
2
3export function useValExport() {
4 const [text, setText] = useState<undefined | string>();
5 const [files, setFiles] = useState<number>(0);

val-to-textApp.tsx1 match

@tkneislyโ€ขUpdated 4 days ago
5import { useValExport } from "../hooks/useValExport.ts";
6
7export function App() {
8 const [name, setName] = React.useState("val-to-text");
9 const [username, setUsername] = React.useState("nbbaier");

autonomous-valdemo.tsx7 matches

@tkneislyโ€ขUpdated 4 days ago
1import agent from "./agent.tsx";
2
3export default async function(req: Request) {
4 // Default objective as fallback
5 let objective = `Buy 100 shares of MSFT and 100 shares of NVDA.`;
89}
90
91// Function to generate HTML for tool calls
92function generateToolCallsHtml(results: any): string {
93 if (!results || !results.steps) {
94 return "";
146}
147
148// Function to generate the HTML page with the form and optional results
149function generateHtmlPage(objective?: string, results?: any, errorMessage?: string): string {
150 const defaultObjective = objective || `What is the current temperature in Tokyo?`;
151
233 </style>
234 <script>
235 // Function to populate the textarea with the selected prompt
236 function setPrompt(value) {
237 if (value) {
238 document.getElementById('objective').value = value;

autonomous-valagent.tsx1 match

@tkneislyโ€ขUpdated 4 days ago
16import { formatResult, parseStatusToolResult } from "./utils.tsx";
17
18export default async function POST(req: Request) {
19 if (req.headers.get("Authorization") !== `Bearer ${Deno.env.get("AGENT_API_KEY")}`) {
20 return new Response("Unauthorized", { status: 401 });

RequirementsWriterApp.tsx1 match

@tkneislyโ€ขUpdated 4 days ago
2import { useState } from "https://esm.sh/react@18.2.0";
3
4export function App() {
5 const [clicked, setClicked] = useState(0);
6 return (

untitled-6069main.tsx19 matches

@masterpieceโ€ขUpdated 4 days ago
296
297 <script>
298 // Data loading functions
299 async function fetchData(endpoint) {
300 try {
301 const response = await fetch(`/Repository/docrepo/backend/api/${endpoint}.php`);
371
372 // Toggle loading spinner
373 function toggleLoading(elementId, show) {
374 const element = document.getElementById(elementId);
375 if (element) {
378 }
379
380 // Render functions for each section
381 function renderWebinars(webinars) {
382 const container = document.getElementById('webinarsContainer');
383 if (!container) return;
399 }
400
401 function renderResearch(featured, recent) {
402 const featuredContainer = document.getElementById('featuredResearch');
403 const recentContainer = document.getElementById('recentResearch');
431 }
432
433 // Additional render functions would follow the same pattern...
434 // (renderInnovations, renderConferences, renderDepartments, etc.)
435
436 // Helper function to display time since
437 function timeSince(date) {
438 const seconds = Math.floor((new Date() - date) / 1000);
439 let interval = Math.floor(seconds / 31536000);
451 }
452
453 // Authentication functions
454 function checkAuthStatus() {
455 fetch('/Repository/docrepo/backend/api/auth/session.php')
456 .then(res => res.json())
463 }
464
465 function updateUIForLoggedInUser(user) {
466 const loginBtn = document.getElementById('loginToggle');
467 const registerBtn = document.getElementById('registerToggle');
478 }
479
480 async function handleLogout() {
481 try {
482 const response = await fetch('/Repository/docrepo/backend/api/auth/logout.php', {
498 const registerModal = document.getElementById('registerModal');
499
500 function toggleModal(show, hide) {
501 show.classList.remove('hidden');
502 hide.classList.add('hidden');
504 }
505
506 function clearMessages() {
507 document.getElementById('loginError').textContent = '';
508 document.getElementById('loginError').classList.add('hidden');
542 // Smooth scrolling for navigation links
543 document.querySelectorAll('a[href^="#"]').forEach(anchor => {
544 anchor.addEventListener('click', function (e) {
545 e.preventDefault();
546 const target = document.querySelector(this.getAttribute('href'));
614 });
615
616 function renderDepartments(departments) {
617 const container = document.getElementById('departmentsContainer');
618 if (!container || !departments) return;
639
640
641function renderDepartmentsDropdown(departments) {
642 const dropdown = document.getElementById('departmentsDropdown');
643 if (!dropdown || !departments) return;
650}
651
652async function fetchData(endpoint) {
653 const loadingElement = document.getElementById(`${endpoint}Loading`);
654 if (loadingElement) loadingElement.style.display = 'block';
tuna

tuna9 file matches

@jxnblkโ€ขUpdated 2 weeks ago
Simple functional CSS library for Val Town

getFileEmail4 file matches

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