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=104&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 20538 results for "function"(2379ms)

Townie-05dashboard.ts1 match

@jxnblkโ€ขUpdated 3 days ago
15}
16
17export function renderDashboard(data: UserSummaryRow[]): string {
18 // Calculate totals
19 const totalUsers = data.length;

Townie-05.cursorrules12 matches

@jxnblkโ€ข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

Townie-05calculateCost.tsx1 match

@jxnblkโ€ขUpdated 3 days ago
5const CACHE_WRITE_RATE = 3.75; // $3.75 per M cache-write tokens
6
7export function calculateCost({
8 input_tokens,
9 output_tokens,

Townie-05auth.ts1 match

@jxnblkโ€ขUpdated 3 days ago
5 * Returns null if authentication is successful, or a Response if it fails
6 */
7export async function basicAuthMiddleware(req: Request): Promise<Response | null> {
8 const realm = "Usage Dashboard";
9 const unauthorizedResponse = new Response("Unauthorized", {

MUSALLREADME.md1 match

@otega07โ€ขUpdated 3 days ago
3## FootballBeats - Music & Football Training MVP
4
5An AI-powered application that seamlessly integrates music and football functionalities to enhance workout and training experiences for football enthusiasts.
6
7## Features

Test1index.ts1 match

@Lellaโ€ขUpdated 3 days ago
1import { serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
2
3export default async function(req: Request) {
4 // Serve the main HTML file
5 return serveFile("/frontend/index.html", import.meta.url);

MUSALLdatabase.ts2 matches

@otega07โ€ขUpdated 3 days ago
11 * Initialize database tables
12 */
13export async function initDatabase() {
14 // Create users table
15 await sqlite.execute(`
489
490// Initialize some sample drills
491export async function initSampleDrills() {
492 const sampleDrills = [
493 {

MUSALLapp.js12 matches

@otega07โ€ขUpdated 3 days ago
41};
42
43// API Functions
44const api = {
45 // User-related API calls
184};
185
186// UI Functions
187const ui = {
188 // Show/hide loading overlay
381 `).join('');
382
383 // Add close functionality
384 const closeButtons = modalClone.querySelectorAll('.close-modal');
385 closeButtons.forEach(btn => {
408 modalClone.querySelector('.drill-instructions').textContent = drill.instructions;
409
410 // Add close functionality
411 const closeButtons = modalClone.querySelectorAll('.close-modal');
412 closeButtons.forEach(btn => {
436 modalClone.querySelector('.session-playlist-description').textContent = session.playlist.description;
437
438 // Add view playlist button functionality
439 const viewPlaylistBtn = modalClone.querySelector('.view-playlist');
440 viewPlaylistBtn.addEventListener('click', () => {
479 });
480
481 // Add close functionality
482 const closeButtons = modalClone.querySelectorAll('.close-modal');
483 closeButtons.forEach(btn => {
536 });
537
538 // Add close functionality
539 const closeButtons = modalClone.querySelectorAll('.close-modal');
540 closeButtons.forEach(btn => {
596 });
597
598 // Add close functionality
599 const closeButtons = modalClone.querySelectorAll('.close-modal');
600 closeButtons.forEach(btn => {
654 });
655
656 // Add close functionality
657 const closeButtons = modalClone.querySelectorAll('.close-modal');
658 closeButtons.forEach(btn => {
670
671// Event Handlers
672function setupEventListeners() {
673 // Profile form submission
674 elements.profileForm.addEventListener('submit', async (e) => {
776
777// Load user data
778async function loadUserData() {
779 try {
780 ui.showLoading('Loading your data...');
802
803// Initialize the app
804async function initApp() {
805 // Setup event listeners
806 setupEventListeners();

gordwameutils.ts1 match

@alexweinโ€ขUpdated 3 days ago
5export const MESSAGE_LIMIT = 5;
6
7export function stringToBoard(str: string) {
8 // check if even length
9 if (str.length % 2 !== 0) {

gordwameApp.tsx3 matches

@alexweinโ€ขUpdated 3 days ago
23}
24
25export function App({ board: initialBoard, solutions: initialSolutions, totalSolutions: initialTotalSolutions }: AppProps) {
26 const defaultBoard = [
27 { position: 0, inner: "", outer: "", flipped: false },
49 // Only fetch a new board if we don't have an initial board
50 if (!initialBoard) {
51 async function initializeBoard() {
52 setIsLoading(true);
53 try {
99
100 useEffect(() => {
101 function handleResize() {
102 const width = window.innerWidth;
103 const height = Math.min(window.innerHeight, width);

getFileEmail4 file matches

@shouserโ€ขUpdated 3 weeks ago
A helper function to build a file's email
tuna

tuna8 file matches

@jxnblkโ€ขUpdated 3 weeks ago
Simple functional CSS library for Val Town
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.