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=55&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 31520 results for "function"(4193ms)

Glancer_Testform.tsx2 matches

@charmaineโ€ขUpdated 3 days ago
2import { useState } from "https://esm.sh/react@18.2.0";
3
4export function FormContent({ data, content }) {
5 // const { content, contentURL, docsURL } = config;
6 // console.log("content: ", content);
29 <h2>Cobrowse & mask fields on forms</h2>
30 <p>
31 Glance cobrowse provides a โ€œhookโ€ function to allow customers to
32 customize page and element masking during a cobrowse session.
33 </p>

Glancer_TestenrichAgent.ts1 match

@charmaineโ€ขUpdated 3 days ago
6});
7
8export async function enrichAgent(id: string, data: any) {
9 // console.log(data);
10 const properties = (data.length === 0)

Glancer_TestdemoCache.ts1 match

@charmaineโ€ขUpdated 3 days ago
11// this cron updates a blob that the ../../shared/utils/pollEnabledStatus.ts hits during demos
12// that blob determines whether or not the cobrowsing button is ON or OFF
13export default async function (interval: Interval) {
14 // every page in the "Glancer demo" database should have it's own blob, so we have a cache for each demo
15 // this cron saves a blob for every page in the Demos DB

Glancer_Test.cursorrules12 matches

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

Glancer_Testchess.tsx1 match

@charmaineโ€ขUpdated 3 days ago
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2
3export function ChessEmbedIframe({ config }) {
4 const { content, contentURL, docsURL } = config;
5 return (

Glancer_Testcheckout.tsx1 match

@charmaineโ€ขUpdated 3 days ago
2import { useState } from "https://esm.sh/react@18.2.0";
3
4export function CheckoutContent({ data, content }) {
5 // const { content, contentURL, docsURL } = config;
6 // console.log("content: ", content);

Glancer_TestblobKeyForDemoCache.ts1 match

@charmaineโ€ขUpdated 3 days ago
1export async function blobKeyForDemoCache(url: string, id: string) {
2 // convert url param to a URL object so we can get the path
3 const newURL = new URL(url);

Glancer_TestApp.tsx3 matches

@charmaineโ€ขUpdated 3 days ago
18}
19// Simple hook for mobile menu toggle
20function useMobileMenu() {
21 const [isOpen, setIsOpen] = useState(false);
22 const toggleMenu = () => setIsOpen(!isOpen);
26
27// Simple hook for tracking current hash for active nav styling
28function useCurrentHash() {
29 const [currentHash, setCurrentHash] = useState(() =>
30 window.location.hash.slice(1)
43}
44
45export function App({ initialData }: AppProps) {
46 // initialData
47 const { demoData, loading, error } = initialData;

GlancerstartSession.ts3 matches

@charmaineโ€ขUpdated 3 days ago
1export async function startSession() {
2 GLANCE.Cobrowse.Visitor.startSession("GLANCE_KEYTYPE_RANDOM");
3}
4// If you forget to add functions called by events
5// to the global scope (e.g., `onclick="startSession();"`),
6// then those functions won't be in the global scope,
7// and the onclick will fail with Uncaught ReferenceError.
8window.startSession = startSession;

Glancerslugify.ts1 match

@charmaineโ€ขUpdated 3 days ago
1export default function slugify(str: string) {
2 return str
3 .toString()
tuna

tuna9 file matches

@jxnblkโ€ขUpdated 2 weeks 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.