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//%22https:/f2.phage.directory/capsid/kMu-biwJ/Kurt%20Profile%20Pic%20-%20Transparent%20Background_large.png/%22?q=function&page=1&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 40465 results for "function"(1328ms)

untitled-2952main.ts1 match

@xxxjjjUpdated 1 hour ago
1// Learn more: https://docs.val.town/vals/http/
2export default async function (req: Request): Promise<Response> {
3 const searchParams = new URL(req.url).searchParams;
4
11- **Schedule**: Every minute
12- **Threshold**: Sessions older than 60 seconds without heartbeat updates
13- **Function**: Marks stale sessions as not viewing and syncs to Notion
14
15**How Viewing Sessions Work**:
39- **Purpose**: Cleans up orphaned agent blobs
40- **Schedule**: Every minute
41- **Function**: Deletes agent blobs where the agent ID doesn't match the demo's
42 "Glimpse agents" relation in Notion
43- **Read-Only Notion**: Only reads Notion data, never modifies it
9 * Hook for tracking user viewing status with automatic updates
10 */
11export function useViewingTracking(
12 glimpseId: string,
13 isAuthorized: boolean
63
64
65 // Cleanup function
66 return () => {
67 if (intervalRef.current) {

spotymain.ts1 match

@skirtownerUpdated 1 hour ago
4};
5
6export default async function handler(req: Request) {
7 if (req.method !== "GET") {
8 return new Response("Method Not Allowed", { status: 405 });

untitled-7644new-file-7315.ts1 match

@coolmovesUpdated 1 hour ago
1export default async function (interval: Interval) {
2 const f = await fetch("https://sih-2025-demo.onrender.com/");
3 const s = await f.text();
255```typescript
256// In route handler
257const result = await controllerFunction(params);
258
259if (!result.success) {
10**Returns:** `UseAuthReturn`
11- `userEmail` - Current user's email from window data
12- `isAuthorized(pageProperties)` - Function to check if user can access a page
13
14**Usage:**
29- `loading` - Loading state
30- `error` - Error state
31- `refetch` - Function to manually refetch data
32
33**Usage:**

eventsCalendartmp.ts1 match

@roopUpdated 3 hours ago
3import { marked } from "npm:marked";
4
5export default async function (req: Request) {
6 const vt = new ValTown();
7 const val_id = "4cbcd1ae-8b94-11f0-b01a-0224a6c84d84";

eventsCalendarserver.ts4 matches

@roopUpdated 3 hours ago
2Use with bookmarklet:
3
4javascript: (function () {
5 var HOST = "https://extract-event-data.val.run";
6 var TOKEN = "<REPLACE>";
209});
210
211function update(stream: SSEStreamingApi, payload: any) {
212 return stream.writeSSE({
213 event: "update",
219}
220
221function complete(
222 stream: SSEStreamingApi,
223 state: "success" | "error",
232}
233
234function fail(
235 stream: SSEStreamingApi,
236 message?: string,
130
131 // Load free version
132 document.getElementById('loadFreeVersion').addEventListener('click', function() {
133 nicheIframe.src = 'free-input-iframe.html';
134 toolContainer.classList.remove('hidden');
138
139 // Load premium version
140 document.getElementById('loadPremiumVersion').addEventListener('click', function() {
141 nicheIframe.src = 'premium-input-iframe.html';
142 toolContainer.classList.remove('hidden');
146
147 // Clear tool
148 document.getElementById('clearTool').addEventListener('click', function() {
149 toolContainer.classList.add('hidden');
150 outputContainer.classList.add('hidden');
156
157 // Listen for messages from iframe
158 window.addEventListener('message', function(event) {
159 // Security check - in production, verify event.origin
160
175
176 // Generate output page
177 function generateOutputPage(data) {
178 try {
179 currentOutputData = data;
200
201 // Download HTML file
202 document.getElementById('downloadPage').addEventListener('click', function() {
203 if (!currentOutputHTML) {
204 alert('No page generated yet!');
225
226 // Preview page
227 document.getElementById('previewPage').addEventListener('click', function() {
228 if (!currentOutputHTML) {
229 alert('No page generated yet!');
242
243 // Copy HTML code
244 document.getElementById('copyCode').addEventListener('click', function() {
245 if (!currentOutputHTML) {
246 alert('No page generated yet!');
248 }
249
250 navigator.clipboard.writeText(currentOutputHTML).then(function() {
251 updateStatus('📋 HTML code copied to clipboard!');
252
263 btn.classList.add('bg-purple-600');
264 }, 2000);
265 }).catch(function(err) {
266 console.error('Failed to copy: ', err);
267 updateStatus('❌ Failed to copy to clipboard');
270
271 // Close preview modal
272 document.getElementById('closePreview').addEventListener('click', function() {
273 previewModal.classList.add('hidden');
274 previewFrame.src = '';
276
277 // Close modal on background click
278 previewModal.addEventListener('click', function(e) {
279 if (e.target === previewModal) {
280 previewModal.classList.add('hidden');
284
285 // Update status message
286 function updateStatus(message) {
287 document.getElementById('outputStatus').textContent = message;
288 console.log('Status:', message);

ratelimit4 file matches

@unkeyUpdated 1 month ago
Rate limit your serverless functions

discordWebhook2 file matches

@stevekrouseUpdated 2 months ago
Helper function to send Discord messages
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.