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=30&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 30800 results for "function"(2209ms)

api_ianmenethil_comappConfig.ts1 match

@ianmenethil•Updated 1 day ago
171export const SERVER = APP_CONFIG.server;
172
173export function getConfig<T = unknown>(path: string): T {
174 const keys = path.split(".");
175 let current: any = APP_CONFIG;

Studybeaststudybeast.tsx6 matches

@Nothingboy•Updated 1 day ago
136];
137
138function LoginTimer({ loginTime, onExpire }: { loginTime: number; onExpire: () => void }) {
139 const [timeLeft, setTimeLeft] = useState(0);
140 const [progressPercent, setProgressPercent] = useState(100);
187}
188
189function LoginPage({ onLogin }: { onLogin: (username: string) => void }) {
190 const [username, setUsername] = useState("");
191 const [password, setPassword] = useState("");
277}
278
279function CourseCard({ course }: { course: Course }) {
280 return (
281 <div className="bg-white rounded-lg shadow-md overflow-hidden hover:shadow-lg transition-shadow">
319}
320
321function App() {
322 const [searchTerm, setSearchTerm] = useState("");
323 const [isLoggedIn, setIsLoggedIn] = useState(false);
478}
479
480function client() {
481 createRoot(document.getElementById("root")).render(<App />);
482}
483if (typeof document !== "undefined") { client(); }
484
485export default async function server(request: Request): Promise<Response> {
486 return new Response(
487 `

hm-invoicesv1val-town.mdc17 matches

@arfan•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}
43## Val Town Standard Libraries
44
45Val Town provides several hosted services and utility functions.
46
47### Blob Storage
85```
86
87## Val Town Utility Functions
88
89Val Town provides several utility functions to help with common project tasks.
90
91### Importing Utilities
168├── backend/
169│ ├── database/
170│ │ ├── queries.ts # DB query functions (CRUD operations)
171│ │ └── README.md
172│ └── routes/ # Route modules
188 ├── README.md
189 ├── config.ts # Database table names and shared config
190 └── utils.ts # Shared types and functions
191```
192
267
268 <script>
269 function showResult(data, isError = false) {
270 const resultDiv = document.getElementById('result');
271 resultDiv.className = \`mt-6 p-4 rounded-lg \${isError ? 'bg-red-100 border border-red-300 text-red-800' : 'bg-green-100 border border-green-300 text-green-800'}\`;
274 }
275
276 async function makeRequest(action) {
277 try {
278 const response = await fetch(\`?action=\${action}\`, { method: 'POST' });
284 }
285
286 function getStatus() {
287 makeRequest('status');
288 }
289
290 function seedDatabase() {
291 makeRequest('seed');
292 }
293
294 function forceSeed() {
295 makeRequest('force-seed');
296 }
297
298 function clearDatabase() {
299 if (confirm('Are you sure you want to clear all data from the database?')) {
300 makeRequest('clear');
379- Main entry point should be `main.tsx`
380- **Database Setup:** Use the admin utilities to handle table creation and seeding. Backend should focus on CRUD operations only
381- **Database Queries:** Keep all query functions in `backend/database/queries.ts` with proper TypeScript typing
382- **Static asset serving:** Use the utility functions to read and serve project files:
383 ```ts
384 import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
417- **Backend Focus:** Backend database queries should only handle CRUD operations, not table creation
418- Change table names when modifying schemas rather than altering (update in `shared/config.ts`)
419- Export clear query functions with proper TypeScript typing
420
421## Common Gotchas and Solutions
583. **Backend Database Layer**
59 - Create `backend/database/queries.ts` with CRUD operations
60 - Implement vendor management functions
61 - Implement invoice management functions
62
63### Deliverables:
135 - Quick status updates (click to advance status)
136 - Bulk operations (select multiple invoices)
137 - Search functionality
138 - Sort by different columns
139
164 - Export invoices to CSV
165 - Import invoices from CSV
166 - Backup/restore functionality
167 - Data validation and error messages
168
199
200## Deployment Strategy
201Each phase will be deployable and functional, allowing for iterative development and testing. The admin tools will be available throughout for database management and debugging.
202```
203
227- Admin utilities for easy database management and seeding
228
229Each phase is designed to be deployable and functional on its own, so you can test and use the system as we build it incrementally. The admin tools will be available from Phase 1, making it easy to manage your data throughout development.
230
231Would you like me to start implementing Phase 1, or would you like to review/modify any part of the plan first?

api_ianmenethil_commain.tsx3 matches

@ianmenethil•Updated 1 day ago
9let initializationPromise: Promise<boolean> | null = null;
10
11async function initializeRoutes(): Promise<boolean> {
12 if (routesInitialized) {
13 return true;
48
49/**
50 * Main server function for Val.town
51 * @param request - Incoming HTTP request
52 * @returns Response object
53 */
54async function server(request: Request): Promise<Response> {
55 try {
56 if (!routesInitialized) {

Studypoor5paid.tsx4 matches

@Aditya0010•Updated 1 day ago
31];
32
33function LoginPage() {
34 const [userId, setUserId] = useState("");
35 const [password, setPassword] = useState("");
176}
177
178function DashboardApp() {
179 const [activeSubject, setActiveSubject] = useState(null);
180
232}
233
234function client() {
235 const path = window.location.pathname;
236 if (path === "/dashboard") {
242if (typeof document !== "undefined") { client(); }
243
244export default async function server(request: Request): Promise<Response> {
245 // Comprehensive user credentials
246 const validCredentials = {

invest-trackermacro_news_daily.tsx1 match

@samxii777•Updated 1 day ago
3const KEY = Deno.env.get("NEWSAPI");
4
5export default async function run() {
6 const q = encodeURIComponent(`Fed OR CPI OR inflation OR ECB OR RBA`);
7 const url = `https://newsapi.org/v2/everything?` +

honeydewmain.tsx25 matches

@legal•Updated 1 day ago
88 `;
89
90function generateHtmlShell(sourceUrl: string): string {
91 return ` 
92 <!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Honeydew</title>
473 <template id="review-task-template"><div class="review-task-item"><input type="text" class="review-task-content" placeholder="Task description" required><input type="date" class="review-task-due-date" title="Due Date"><select class="review-task-load" title="Cognitive Load"><option value="Low">Low</option><option value="Medium" selected>Medium</option><option value="High">High</option></select><button type="button" class="review-task-delete-btn" title="Remove Task">&times;</button></div></template> 
474 <script> 
475 (function() {
476  const API_URL = '${sourceUrl}'; 
477  const STORE_KEYS = { projects: 'honeydew_projects_v1', tasks: 'honeydew_tasks_v1', theme: 'honeydew_theme_v1' }; 
483  const genId = () => Date.now().toString(36) + Math.random().toString(36).substr(2, 9); 
484  
485  function loadState() { 
486    projects = getStore(STORE_KEYS.projects); 
487    tasks = getStore(STORE_KEYS.tasks); 
492  } 
493
494  function render() { 
495    renderSidebar(); 
496    renderTaskList(); 
498  } 
499
500  function toggleLoading(btn, show) { 
501    if (!btn) return; 
502    btn.disabled = show; 
504  } 
505  
506  function updateUIElements() { 
507    const todayStr = new Date().toISOString().split("T")[0]; 
508    const todayTasks = tasks.filter(t => !t.isCompleted && t.dueDate === todayStr); 
522  } 
523
524  function renderSidebar() { 
525    const mainViews = [ 
526      {id:'today',name:'Today',icon:'M6 2a1 1 0 00-1 1v1H4a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-1V3a1 1 0 10-2 0v1H7V3a1 1 0 00-1-1z'}, 
531  } 
532
533  function renderTaskList() { 
534    const container = $("#task-list"); 
535    let filteredTasks = [], title = 'Tasks'; 
561  } 
562
563  function renderChatLog() { 
564    const log = $("#chat-log"); 
565    log.innerHTML = conversationHistory.map(msg => { 
632  }; 
633
634 function executeSingleCommand(command) {
635 if (!command || !command.tool_name) return;
636 if (command.tool_name === 'ask_for_confirmation') {
657 }
658
659 function executeManualCommand(command) {
660 if (Array.isArray(command)) {
661 command.forEach(c => executeSingleCommand(c));
665 }
666
667  async function handleChatSubmit(e) { 
668    e.preventDefault(); 
669    const input = $("#chat-input"), userMessage = input.value.trim(); 
713  } 
714  
715  function handleAddTask(e) { 
716    e.preventDefault(); 
717    const input = $("#new-task-input"), content = input.value.trim(); 
738  } 
739
740  function handleTaskClick(e) { 
741    const target = e.target, taskItem = target.closest(".task-item"); 
742    if (!taskItem) return; 
756  } 
757
758  function openEditModal(task) { 
759    $("#edit-task-id").value = task.id; 
760    $("#edit-task-content").value = task.content; 
765  } 
766
767  function handleUpdateTask(e) { 
768    e.preventDefault(); 
769    const taskId = $("#edit-task-id").value, task = tasks.find(t => t.id === taskId); 
777  } 
778  
779  async function triggerProjectSynthesisFromButton() { 
780    const goal = prompt("Describe your new project or goal:", "Plan a launch party for a new product"); 
781    if (!goal) return; 
794  } 
795  
796  async function triggerDailyRebalance() { 
797    const todayStr = new Date().toISOString().split("T")[0]; 
798    const todayTasks = tasks.filter(t => !t.isCompleted && t.dueDate === todayStr); 
820  } 
821
822  function handleOpenChat() { 
823    const mainInput = $('#new-task-input'); 
824    const text = mainInput.value.trim(); 
833  } 
834  
835  function addReviewTaskRow(taskData = {}) { 
836    const template = $('#review-task-template'); 
837    const clone = template.content.cloneNode(true); 
844  } 
845
846  function openProjectReviewModal(data) { 
847    const { projectName, tasks: aiTasks } = data; 
848    $('#review-project-name').value = projectName; 
855  } 
856
857  function handleProjectReviewSubmit(e) { 
858    e.preventDefault(); 
859    const projectName = $('#review-project-name').value.trim(); 
877  } 
878
879 function initTheme() {
880 const themeToggle = $('#theme-toggle');
881 const storedTheme = localStorage.getItem(STORE_KEYS.theme);
897 }
898
899  function bindEventListeners() { 
900    document.body.addEventListener('click', e => { 
901      if (e.target.closest('[data-view]')) { 
953}
954
955export default async function(req: Request): Promise<Response> {
956 const openai = new OpenAI();
957 const url = new URL(req.url);

ChatEnhancedCommandPalette.tsx2 matches

@c15r•Updated 1 day ago
58}
59
60// Helper functions for JSON Schema handling
61const getDefaultValue = (schema: any): any => {
62 if (schema.default !== undefined) return schema.default;
138};
139
140export default function EnhancedCommandPalette({
141 servers,
142 query,

fart-with-aiindex.html2 matches

@sirmews•Updated 1 day ago
261 const soundWaves = document.getElementById('soundWaves');
262
263 function createSoundWave() {
264 const wave = document.createElement('div');
265 wave.className = 'wave';
271 }
272
273 function createStinkCloud() {
274 const cloud = document.createElement('div');
275 cloud.className = 'cloud';
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.