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%20%22Optional%20title%22?q=function&page=103&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 21024 results for "function"(1752ms)

vectorsroutes.tsx5 matches

@jxnblk•Updated 3 days ago
6const API_URL = "https://react-router-hono.val.run/api";
7
8function HTML ({ children }: {
9 children: React.ReactNode;
10}) {
21}
22
23function Layout () {
24 return (
25 <HTML>
47}
48
49function Home () {
50 const [count, setCount] = React.useState(0);
51 return (
58}
59
60function About () {
61 const data = useLoaderData();
62
69}
70
71async function catsLoader () {
72 const data = await fetch(API_URL)
73 .then(res => res.json());

Jobchatappqueries.ts4 matches

@bwalya15•Updated 3 days ago
20
21// Job posting queries
22export async function getAllJobs(): Promise<JobPosting[]> {
23 const result = await sqlite.execute(
24 `SELECT * FROM ${JOB_POSTINGS_TABLE} ORDER BY created_at DESC`
27}
28
29export async function createJob(job: JobPosting): Promise<JobPosting> {
30 const now = new Date().toISOString();
31 const result = await sqlite.execute(
39
40// Chat message queries
41export async function getChatMessages(limit = 50): Promise<ChatMessage[]> {
42 const result = await sqlite.execute(
43 `SELECT * FROM ${CHAT_MESSAGES_TABLE}
49}
50
51export async function createChatMessage(message: ChatMessage): Promise<ChatMessage> {
52 const now = new Date().toISOString();
53 const result = await sqlite.execute(

Jobchatappmigrations.ts1 match

@bwalya15•Updated 3 days ago
8 * Initialize database tables
9 */
10export async function initDatabase() {
11 // Create job postings table
12 await sqlite.execute(`

FullstackStarterNumber.loader.ts1 match

@wolf•Updated 3 days ago
1import { client } from "../hono.ts";
2
3export async function loader() {
4 try {
5 console.log("Number loader running");
21
22/* ── helper: pull one page synchronously ── */
23async function fetchPage(offset: number) {
24 const query = `
25 SELECT
59
60/* ── main: iterate pages & upsert ── */
61export default async function refreshUsage() {
62 let total = 0;
63

untitled-3473todo-list.ts6 matches

@dwen•Updated 3 days ago
5
6// Initialize with empty todo list if none exists
7async function initializeTodoList() {
8 try {
9 const existingList = await blob.get(TODO_LIST_KEY);
19
20// Get the current todo list
21async function getTodoList(): Promise<string> {
22 await initializeTodoList();
23 const result = await blob.get(TODO_LIST_KEY);
26
27// Add a new task to the todo list
28async function addTask(task: string): Promise<void> {
29 if (!task.trim()) return;
30
35
36// Toggle a task's completion status
37async function toggleTask(lineIndex: number): Promise<void> {
38 const currentList = await getTodoList();
39 const lines = currentList.split('\n');
57
58// Generate HTML for the todo list
59function generateHtml(todoListMarkdown: string) {
60 const lines = todoListMarkdown.split('\n');
61 const taskLines = lines.map((line, index) => {
180}
181
182export default async function(req: Request): Promise<Response> {
183 const url = new URL(req.url);
184 const action = url.searchParams.get('action');

untitled-3473README.md1 match

@dwen•Updated 3 days ago
32
33- Uses Val Town's blob storage to persist the todo list
34- Single HTTP Val handles all functionality
35- No external dependencies beyond Val Town's standard libraries
36- Responsive design with Twind (Tailwind CSS)

my-first-valqueries.ts14 matches

@dieberuo•Updated 3 days ago
4
5// User queries
6export async function createUser(user: Omit<User, 'id' | 'createdAt'>): Promise<User> {
7 const createdAt = new Date().toISOString();
8 const result = await sqlite.execute(
23}
24
25export async function getUserById(id: number): Promise<User | null> {
26 const result = await sqlite.execute(
27 `SELECT * FROM ${TABLES.USERS} WHERE id = ?`,
46}
47
48export async function getUserByUsername(username: string): Promise<User | null> {
49 const result = await sqlite.execute(
50 `SELECT * FROM ${TABLES.USERS} WHERE username = ?`,
70
71// Glucose reading queries
72export async function createGlucoseReading(reading: Omit<GlucoseReading, 'id'>): Promise<GlucoseReading> {
73 const result = await sqlite.execute(
74 `INSERT INTO ${TABLES.GLUCOSE_READINGS} (
87}
88
89export async function getGlucoseReadingsByUserId(userId: number): Promise<GlucoseReading[]> {
90 const result = await sqlite.execute(
91 `SELECT * FROM ${TABLES.GLUCOSE_READINGS} WHERE user_id = ? ORDER BY timestamp DESC`,
103}
104
105export async function getGlucoseReadingsByDateRange(
106 userId: number,
107 startDate: string,
126
127// Meal queries
128export async function createMeal(meal: Omit<Meal, 'id' | 'foods'>, foodItems: Omit<FoodItem, 'id' | 'mealId'>[]): Promise<Meal> {
129 // Start a transaction
130 await sqlite.execute('BEGIN TRANSACTION');
179}
180
181export async function getMealsByUserId(userId: number): Promise<Meal[]> {
182 // Get meals
183 const mealsResult = await sqlite.execute(
226}
227
228export async function getMealsByDateRange(
229 userId: number,
230 startDate: string,
280
281// Recipe queries
282export async function getAllRecipes(): Promise<Recipe[]> {
283 const recipesResult = await sqlite.execute(`SELECT * FROM ${TABLES.RECIPES}`);
284 const recipes: Recipe[] = [];
325}
326
327export async function getRecipeById(id: number): Promise<Recipe | null> {
328 const recipeResult = await sqlite.execute(
329 `SELECT * FROM ${TABLES.RECIPES} WHERE id = ?`,
374}
375
376export async function searchRecipes(query: string): Promise<Recipe[]> {
377 const recipesResult = await sqlite.execute(
378 `SELECT * FROM ${TABLES.RECIPES}
425
426// Herb and spice queries
427export async function getAllHerbsAndSpices(): Promise<HerbSpice[]> {
428 const result = await sqlite.execute(`SELECT * FROM ${TABLES.HERBS_SPICES}`);
429
438}
439
440export async function getHerbById(id: number): Promise<HerbSpice | null> {
441 const result = await sqlite.execute(
442 `SELECT * FROM ${TABLES.HERBS_SPICES} WHERE id = ?`,

litindex.ts1 match

@probablycorey•Updated 3 days ago
1import { readFile } from "https://esm.town/v/std/utils@85-main/index.ts";
2
3export default async function(req: Request): Promise<Response> {
4 // Serve the HTML file
5 const html = await readFile("/index.html", import.meta.url);

my-first-valschema.ts2 matches

@dieberuo•Updated 3 days ago
13
14// Initialize database schema
15export async function initializeDatabase() {
16 // Users table
17 await sqlite.execute(`
124
125// Seed initial data for recipes and herbs/spices
126async function seedInitialData() {
127 // Check if we already have herbs and spices data
128 const herbsCount = await sqlite.execute(`SELECT COUNT(*) as count FROM ${TABLES.HERBS_SPICES}`);

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 4 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.