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/$1?q=function&page=48&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 29309 results for "function"(4653ms)

thirdTimer.cursorrules12 matches

@nbbaierโ€ขUpdated 1 day 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

voicemessagesVoiceRecorder.tsx1 match

@michaelwschultzโ€ขUpdated 1 day ago
16}
17
18export default function VoiceRecorder({ onVoiceNoteCreated }: VoiceRecorderProps) {
19 const [recordingState, setRecordingState] = useState<RecordingState>({
20 isRecording: false,

voicemessagesVoicePlayer.tsx1 match

@michaelwschultzโ€ขUpdated 1 day ago
7}
8
9export default function VoicePlayer({ voiceNoteId }: VoicePlayerProps) {
10 const [voiceNote, setVoiceNote] = useState<VoiceNote | null>(null);
11 const [loading, setLoading] = useState(true);

voicemessagesvoicenotes.ts2 matches

@michaelwschultzโ€ขUpdated 1 day ago
150 apiKey: Deno.env.get("GROQ_API_KEY") || "",
151});
152// Background transcription function
153async function transcribeAudio(voiceNoteId: string, audioBuffer: ArrayBuffer) {
154 try {
155 // Convert ArrayBuffer to File for OpenAI

voicemessagesShareModal.tsx1 match

@michaelwschultzโ€ขUpdated 1 day ago
9}
10
11export default function ShareModal({ onSave, onCancel, isUploading }: ShareModalProps) {
12 const [expirationType, setExpirationType] = useState<'none' | 'date' | 'listens'>('none');
13 const [expirationDate, setExpirationDate] = useState('');

voicemessagesqueries.ts6 matches

@michaelwschultzโ€ขUpdated 1 day ago
3import type { VoiceNote } from "../../shared/types.ts";
4
5export async function createVoiceNote(voiceNote: Omit<VoiceNote, 'isExpired'>): Promise<void> {
6 try {
7 await sqlite.execute(
29}
30
31export async function getVoiceNote(id: string): Promise<VoiceNote | null> {
32 try {
33 const result = await sqlite.execute(
68}
69
70export async function incrementListenCount(id: string): Promise<void> {
71 await sqlite.execute(
72 `UPDATE ${TABLE_NAME} SET current_listens = current_listens + 1 WHERE id = ?`,
75}
76
77export async function updateTranscription(id: string, transcription: string): Promise<void> {
78 await sqlite.execute(
79 `UPDATE ${TABLE_NAME} SET transcription = ? WHERE id = ?`,
82}
83
84export async function deleteVoiceNote(id: string): Promise<void> {
85 await sqlite.execute(
86 `DELETE FROM ${TABLE_NAME} WHERE id = ?`,
89}
90
91export async function getAllVoiceNotes(): Promise<VoiceNote[]> {
92 try {
93 const result = await sqlite.execute(`SELECT * FROM ${TABLE_NAME} ORDER BY created_at DESC`);

voicemessagesmigrations.ts1 match

@michaelwschultzโ€ขUpdated 1 day ago
3const TABLE_NAME = 'voice_notes_v1';
4
5export async function runMigrations() {
6 try {
7 // Create voice notes table

voicemessagesDashboard.tsx1 match

@michaelwschultzโ€ขUpdated 1 day ago
3import type { VoiceNote } from "../../shared/types.ts";
4
5export default function Dashboard() {
6 const [voiceNotes, setVoiceNotes] = useState<VoiceNote[]>([]);
7 const [loading, setLoading] = useState(true);

voicemessagesApp.tsx1 match

@michaelwschultzโ€ขUpdated 1 day ago
11}
12
13export default function App() {
14 const [currentView, setCurrentView] = useState<"recorder" | "player" | "dashboard">("recorder");
15 const voiceNoteId = window.__VOICE_NOTE_ID__;

wakatime-readme-chartmain.tsx7 matches

@loadingโ€ขUpdated 1 day ago
40}
41
42function App() {
43 const [chartUrl, setChartUrl] = useState<string | null>(null);
44
57}
58
59function client() {
60 createRoot(document.getElementById("root")!).render(<App />);
61}
65}
66
67async function fetchWakaTimeData(): Promise<DataPoint[]> {
68 const response = await fetch("https://wakatime.com/share/@load1n9/899abefd-d814-4e99-b603-e94af0305d4a.json");
69 const data = await response.json();
82};
83
84async function generateChart(data: DataPoint[]): Promise<string> {
85 const width = 1000;
86 const height = 600;
164}
165
166function roundRect(
167 ctx: CanvasRenderingContext2D,
168 x: number,
190}
191
192function roundRectTop(
193 ctx: CanvasRenderingContext2D,
194 x: number,
219}
220
221export default async function server(request: Request): Promise<Response> {
222 const url = new URL(request.url);
223
tuna

tuna9 file matches

@jxnblkโ€ขUpdated 1 day 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.