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/image-url.jpg?q=function&page=10&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 28575 results for "function"(1234ms)

MiniAppStarterExample.tsx1 match

@moeโ€ขUpdated 14 hours ago
5import { ShareButton } from "./ui.tsx";
6
7export function Example() {
8 const [context, setContext] = useState<any>();
9 useEffect(() => {

logMoodindex.html1 match

@Merisolaโ€ขUpdated 14 hours ago
96 });
97
98 async function loadLogs() {
99 logList.innerHTML = "Loading...";
100 const res = await fetch(getMoodLogUrl);

ChatMessage.tsx1 match

@c15rโ€ขUpdated 14 hours ago
49/* โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ */
50
51export default function MessageComponent({ message, onDelete, onRetry, canRetry }: MessageProps) {
52 const formatRegularContent = (content: string) => <div dangerouslySetInnerHTML={{ __html: marked(content) }}></div>;
53

thirdTimerindex.tsx1 match

@nbbaierโ€ขUpdated 14 hours ago
17import { HelpText } from "./components/HelpText.tsx";
18
19function ThirdTimeApp() {
20 const [state, setState] = useState<TimerState>({
21 mode: "idle",

thirdTimerutils.ts2 matches

@nbbaierโ€ขUpdated 14 hours ago
1export function formatTime(seconds: number): string {
2 const hours = Math.floor(seconds / 3600);
3 const minutes = Math.floor((seconds % 3600) / 60);
12}
13
14export function formatMinutes(minutes: number): string {
15 if (minutes < 1) return `${Math.round(minutes * 60)}s`;
16 if (minutes < 60) return `${Math.round(minutes)}m`;

thirdTimerval-town.mdc12 matches

@nbbaierโ€ขUpdated 14 hours 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

MiniAppStarterCustomHaptics.tsx4 matches

@moeโ€ขUpdated 14 hours ago
8import { Button, Input, Section, MonoButtonWithStatus } from '../components/ui.tsx'
9
10export function CustomHaptics() {
11 const [context, setContext] = useState<any>()
12
73}
74
75async function hapticsPattern(pattern: string) {
76 function delay(ms?: number) {
77 return new Promise((resolve) => setTimeout(resolve, ms || 150))
78 }
79 function hapticsChar(char: string) {
80 if (char === 's') return fcsdk.haptics?.notificationOccurred?.('success').then(() => delay())
81 if (char === '*') return fcsdk.haptics?.impactOccurred?.('heavy').then(() => delay())

ReactHonoStarterTestsApp.tsx1 match

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

Websocketstest2.tsx1 match

@wolfโ€ขUpdated 15 hours ago
1export default function handler(req: Request) {
2 if (req.headers.get("upgrade") != "websocket") {
3 return new Response(null, { status: 501 });

uppsalatech25data.ts6 matches

@ljusโ€ขUpdated 15 hours ago
8type Message = z.infer<typeof messageSchema>;
9type MessageWithSource = Message & { source: "email" | "sms" | "api" };
10export async function getMessages(): Promise<MessageWithSource[]> {
11 let messages = await blob.getJSON(key);
12 if (!messages) {
16}
17const maxMessages = 100;
18export async function addEmail(email: Email) {
19 return addMessage({ message: email.text, subject: email.subject }, "email");
20}
21export async function addApiMessage(apiMessage: unknown) {
22 return addMessage(apiMessage, "api");
23}
24export async function addSms(sms: unknown) {
25 return addMessage(sms, "sms");
26}
27async function addMessage(
28 message: unknown,
29 source: "sms" | "email" | "api",
40 return validMessage;
41}
42export async function clearMessages() {
43 await blob.setJSON(key, []);
44}

getFileEmail4 file matches

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

tuna8 file matches

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