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/?q=function&page=518&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 20480 results for "function"(1849ms)

stevensDemogetWeather.ts5 matches

@turtlemonโ€ขUpdated 3 weeks ago
8const TABLE_NAME = `memories`;
9
10function summarizeWeather(weather: WeatherResponse) {
11 const summarizeDay = (day: WeatherResponse["weather"][number]) => ({
12 date: day.date,
25}
26
27async function generateConciseWeatherSummary(weatherDay) {
28 try {
29 // Get API key from environment
83}
84
85async function deleteExistingForecast(date: string) {
86 await sqlite.execute(
87 `
93}
94
95async function insertForecast(date: string, forecast: string) {
96 const { nanoid } = await import("https://esm.sh/nanoid@5.0.5");
97
112}
113
114export default async function getWeatherForecast(interval: number) {
115 const weather = await getWeather("Washington, DC");
116 console.log({ weather });

stevensDemo.cursorrules15 matches

@turtlemonโ€ขUpdated 3 weeks 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

@turtlemonโ€ขUpdated 3 weeks 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

@turtlemonโ€ขUpdated 3 weeks 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;

FileDumpThingREADME.md1 match

@wolfโ€ขUpdated 3 weeks ago
55
56- **Shared**: Code shared between frontend and backend
57 - `utils.ts`: Shared types and utility functions
58 - `mimetype.ts`: MIME type detection for various file formats
59

FileDumpThingFileDumper.tsx1 match

@wolfโ€ขUpdated 3 weeks ago
5import { ContentState } from "../../shared/utils.ts";
6
7export function FileDumper() {
8 const [content, setContent] = useState<ContentState>({ type: "text", value: "" });
9 const [uploadedUrl, setUploadedUrl] = useState("");

FileDumpThingupload.ts3 matches

@wolfโ€ขUpdated 3 weeks ago
18 * Copy text to clipboard based on the operating system
19 */
20async function copyToClipboard(text: string): Promise<boolean> {
21 const os = Deno.build.os;
22
95}
96
97async function main() {
98 try {
99 // Check for --no-copy flag
223}
224
225// Run the main function only once
226if (import.meta.main) {
227 main();

Dialoguemain.tsx3 matches

@koos68โ€ขUpdated 3 weeks ago
1export default async function server(request: Request): Promise<Response> {
2 const App = `
3 function App() {
4 const [step, setStep] = React.useState("start");
5 const [senderMessage, setSenderMessage] = React.useState("");
140 ${App}
141
142 function client() {
143 createRoot(document.getElementById("root")).render(React.createElement(App));
144 }

FileDumpThingupload.ts5 matches

@wolfโ€ขUpdated 3 weeks ago
8 */
9
10async function main() {
11 try {
12 // Get filename from args or use timestamp
78}
79
80// Run the main function
81if (import.meta.main) {
82 main();
83}
84
85// Run the main function
86if (import.meta.main) {
87 main();
88}
89
90// Run the main function
91if (import.meta.main) {
92 main();
93}
94
95// Run the main function
96if (import.meta.main) {
97 main();

tuckerStevenshandleTelegramMessage.ts5 matches

@tuckerwildeโ€ขUpdated 3 weeks ago
36 * Store a chat message in the database
37 */
38export async function storeChatMessage(
39 chatId,
40 senderId,
69 * Retrieve chat history for a specific chat
70 */
71export async function getChatHistory(chatId, limit = 50) {
72 try {
73 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
94 * Format chat history for Anthropic API
95 */
96function formatChatHistoryForAI(history) {
97 const messages = [];
98
118 * Analyze a Telegram message and extract memories from it
119 */
120async function analyzeMessageContent(
121 anthropic,
122 username,
499
500// Handle webhook requests
501export default async function (req: Request): Promise<Response> {
502 // Set webhook if it is not set yet
503 if (!isEndpointSet) {

getFileEmail4 file matches

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

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