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=24&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 33028 results for "function"(1988ms)

stevensDemo.cursorrules15 matches

@andreswebsβ€’Updated 1 day ago
8### 1. Script Vals
9
10- Basic JavaScript/TypeScript functions
11- Can be imported by other vals
12- Example structure:
13
14```typescript
15export function myFunction() {
16 // Your code here
17}
25
26```typescript
27export default async function (req: Request) {
28 return new Response("Hello World");
29}
37
38```typescript
39export default async function () {
40 // Scheduled task code
41}
49
50```typescript
51export default async function (email: Email) {
52 // Process email
53}
57
58- Ask clarifying questions when requirements are ambiguous
59- Provide complete, functional solutions rather than skeleton implementations
60- Test your logic against edge cases before presenting the final solution
61- Ensure all code follows Val Town's specific platform requirements
70- **Never bake in secrets into the code** - always use environment variables
71- Include comments explaining complex logic (avoid commenting obvious operations)
72- Follow modern ES6+ conventions and functional programming practices if possible
73
74## Val Town Standard Libraries
75
76Val Town provides several hosted services and utility functions.
77
78### Blob Storage
124```
125
126## Val Town Utility Functions
127
128Val Town provides several utility functions to help with common project tasks.
129
130### Importing Utilities
176 {
177 name: "should add numbers correctly",
178 function: () => {
179 expect(1 + 1).toBe(2);
180 },
210β”‚ β”œβ”€β”€ database/
211β”‚ β”‚ β”œβ”€β”€ migrations.ts # Schema definitions
212β”‚ β”‚ β”œβ”€β”€ queries.ts # DB query functions
213β”‚ β”‚ └── README.md
214β”‚ β”œβ”€β”€ index.ts # Main entry point
226└── shared/
227 β”œβ”€β”€ README.md
228 └── utils.ts # Shared types and functions
229```
230
232- Hono is the recommended API framework (similar to Express, Flask, or Sinatra)
233- Main entry point should be `backend/index.ts`
234- **Static asset serving:** Use the utility functions to read and serve project files:
235 ```ts
236 // Use the serveFile utility to handle content types automatically
273- Run migrations on startup or comment out for performance
274- Change table names when modifying schemas rather than altering
275- Export clear query functions with proper TypeScript typing
276- Follow the queries and migrations pattern from the example
277

stevensDemocronDailyBrief.ts1 match

@andreswebsβ€’Updated 1 day ago
1import { sendDailyBriefing } from "./sendDailyBrief.ts";
2
3export async function cronDailyBrief() {
4 try {
5 const chatId = Deno.env.get("TELEGRAM_CHAT_ID");

stevensDemoApp.tsx2 matches

@andreswebsβ€’Updated 1 day ago
62};
63
64export function App() {
65 const [memories, setMemories] = useState<Memory[]>([]);
66 const [loading, setLoading] = useState(true);
139 const data = await response.json();
140
141 // Change the sorting function to show memories in chronological order
142 const sortedMemories = [...data].sort((a, b) => {
143 const dateA = a.createdDate || 0;

untitled-1572main.tsx3 matches

@andreystarenkyβ€’Updated 1 day ago
1// src/pages/api/tool.tsx
2
3export default async function httpHandler(req: Request): Promise<Response> {
4 // 1️⃣ Only accept POST
5 if (req.method !== "POST") {
22 console.log(body.message.toolCalls);
23 console.log("arguments:");
24 let args: any = body.message.toolCalls[0]?.function.arguments;
25 console.log(args);
26
50 * Map your incoming args to Zendesk custom‐field IDs
51 */
52 function mapToZendeskFields(
53 args: Args,
54 sessionId: string, // hard-coded per your example

ChatStreamingChat.tsx1 match

@c15rβ€’Updated 1 day ago
47};
48
49export default function StreamingChat({
50 config,
51 messages,

ChatEnhancedCommandPalette.tsx2 matches

@c15rβ€’Updated 1 day ago
71}
72
73// Helper functions for JSON Schema handling
74const getDefaultValue = (schema: any): any => {
75 if (schema.default !== undefined) return schema.default;
151};
152
153export default function EnhancedCommandPalette({
154 servers,
155 query,

Change-Logs-Generatorgh-to-discord.tsx2 matches

@hussufoβ€’Updated 1 day ago
5
6/**
7 * Main cron function - always looks at the last 7 days
8 */
9export default async function githubChangelogNotifier(): Promise<void> {
10 const now = new Date();
11 const sevenDaysAgo = new Date(now.getTime() - SEVEN_DAYS_MS);

Change-Logs-Generatorprocess-commits.tsx11 matches

@hussufoβ€’Updated 1 day ago
1/**
2 * Helper functions for cron (gh-to-discord.tsx) and playground.tsx
3 */
4
50 * Check if a commit author should be skipped (bots, etc.)
51 */
52function shouldSkipAuthor(commit: any): boolean {
53 const authorUsername = commit.author?.login || commit.commit.author.name || "";
54 return SKIP_AUTHORS.some((skipAuthor) => authorUsername.toLowerCase().includes(skipAuthor.toLowerCase()));
58 * Generate a user-focused summary of a commit using GPT
59 */
60async function generateUserFocusedSummary(
61 fullCommitMessage: string,
62 commitType: string,
65
66 const prompt =
67 `You are documenting commit changes for Steel, a browser API for AI agents. Write a clear, descriptive one-line summary of what this commit actually changed. Be specific about components and functionality, but avoid unnecessary repetition.
68
69Commit message:
113 * Format a single commit into a clean message with category
114 */
115export async function formatCommit(commit: any) {
116 const fullMessage = commit.commit.message; // Get full message including description
117 const originalMessage = fullMessage.split("\n")[0];
146 * Categorize commits into organized groups
147 */
148export async function categorizeCommits(commits: any[]) {
149 const categorizedCommits: Record<string, { messages: string[] }> = {};
150
178 * Build the Discord message from categorized commits
179 */
180export function buildDiscordMessage(
181 categorizedCommits: Record<string, { messages: string[] }>,
182 repoName: string,
246 * Split a long Discord message into multiple messages respecting Discord's character limit
247 */
248function splitDiscordMessage(content: string): string[] {
249 if (content.length <= DISCORD_MESSAGE_LIMIT) {
250 return [content];
303 * Fetch commits from GitHub for the given date range
304 */
305export async function fetchCommits(
306 since: string,
307 until: string,
392 * Fetch commits and post to Discord
393 */
394export async function fetchAndPostCommits(
395 since: string,
396 until: string,
416 const discordMessageContent = buildDiscordMessage(
417 categorizedCommits,
418 "", // No longer needed since we build repo list inside the function
419 since,
420 until,
4// Handles the initial cancellation event and sends a Discord notification
5// with customer details, subscription info, and cancellation reason
6async function handleCancellation(subscription: any, stripeKey: string) {
7 const amount = subscription.items?.data?.[0]?.price?.unit_amount ||
8 subscription.plan?.amount || 0;

simple-imagespage.ts4 matches

@blazemcworldβ€’Updated 1 day ago
29</style>
30<script>
31 function edit(task, origin) {
32 return "https://image.pollinations.ai/prompt/" + encodeURIComponent(task) + "?model=" + document.getElementById("editModel").value + "&image=" + encodeURIComponent(origin) + "&referrer=tgpt&nofeed=true&nologo=true";
33 }
34
35 function create(task) {
36 return "https://image.pollinations.ai/prompt/" + encodeURIComponent(task) + "?model=" + document.getElementById("createModel").value + "&nofeed=true&nologo=true";
37 }
38
39 function newImage() {
40 addImage(create(prompt("Creation Prompt")))
41 }
42
43 function addImage(url) {
44 let img = new Image();
45 img.src = url;

discordWebhook2 file matches

@stevekrouseβ€’Updated 2 days ago
Helper function to send Discord messages
tuna

tuna9 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.