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/$1?q=function&page=6&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 23725 results for "function"(905ms)

discordmain.tsx1 match

@valdottown•Updated 6 hours ago
1export default async function(req: Request): Promise<Response> {
2 return new Response(null, {
3 status: 301,

untitled-341index.ts1 match

@alexmcroberts•Updated 7 hours ago
1export default async function(req: Request) {
2 const html = `<!DOCTYPE html>
3<html lang="en">
15
16// Initialize Slack client
17function getSlackClient(): WebClient | null {
18 const slackToken = Deno.env.get("SLACK_BOT_TOKEN");
19 if (!slackToken) {
25
26// Main handler for HTTP requests
27export default async function(req: Request): Promise<Response> {
28 try {
29 // Handle Slack URL verification challenge
82 * Process a message from Slack and check if it's a bug report
83 */
84async function processSlackMessage(event: any): Promise<void> {
85 // Skip messages in threads (we only want to process new messages)
86 if (event.thread_ts && event.thread_ts !== event.ts) {
127 * Use LLM to detect if a message is a bug report
128 */
129async function isBugReportLLM(text: string): Promise<boolean> {
130 try {
131 // Check if OpenAI API key is available
144Analyze the following message and determine if it's reporting a bug, technical issue, or problem. Consider:
145- Technical problems (crashes, errors, performance issues)
146- User experience issues (confusing UI, broken functionality)
147- Data problems (incorrect results, missing information)
148- Regression issues (something that used to work)
149- User complaints about functionality not working as expected
150
151DO NOT classify as bug reports:
179 * Detect if a message is a bug report using LLM
180 */
181async function isBugReport(text: string | undefined): Promise<boolean> {
182 if (!text) {
183 return false;
190 * Fetch all open issues from GitHub repository using Octokit
191 */
192async function fetchOpenIssues(): Promise<any[]> {
193 const githubToken = Deno.env.get("GITHUB_TOKEN");
194 const githubRepo = Deno.env.get("GITHUB_REPO");
247 * Use LLM to find semantically related issues
248 */
249async function findRelatedIssues(slackMessage: string, issues: any[]): Promise<any[]> {
250 try {
251 // Check if OpenAI API key is available
357 * Format the related issues into final Slack message
358 */
359function formatRelatedIssues(issueMatches: any[]): string {
360 if (issueMatches.length === 0) {
361 return "No related open issues found. This might be a new issue that hasn't been reported yet.";
378 * Post a message to a Slack thread
379 */
380async function postToSlackThread(channel: string, thread_ts: string, text: string): Promise<void> {
381 const webClient = getSlackClient();
382 if (!webClient) {

reactHonoStarterApp.tsx1 match

@lightweight•Updated 7 hours ago
12};
13
14export function App() {
15 const [clicked, setClicked] = useState(0);
16 return (

Smart_Expense_TrackerTravelPlanner.tsx1 match

@gunjana_04•Updated 8 hours ago
9}
10
11export default function TravelPlanner({ onNotification, refreshTrigger, onRefresh }: TravelPlannerProps) {
12 const [destinations, setDestinations] = useState([]);
13 const [loading, setLoading] = useState(true);

Smart_Expense_TrackerGoalTracker.tsx1 match

@gunjana_04•Updated 8 hours ago
9}
10
11export default function GoalTracker({ onNotification, refreshTrigger, onRefresh }: GoalTrackerProps) {
12 const [goals, setGoals] = useState([]);
13 const [showForm, setShowForm] = useState(false);

Smart_Expense_TrackerExpenseForm.tsx1 match

@gunjana_04•Updated 8 hours ago
9}
10
11export default function ExpenseForm({ onNotification, refreshTrigger, onRefresh }: ExpenseFormProps) {
12 const [formData, setFormData] = useState({
13 amount: '',

Smart_Expense_TrackerDashboard.tsx1 match

@gunjana_04•Updated 8 hours ago
9}
10
11export default function Dashboard({ onNotification, refreshTrigger, onRefresh }: DashboardProps) {
12 const [loading, setLoading] = useState(true);
13 const [data, setData] = useState<any>({

Smart_Expense_TrackerApp.tsx3 matches

@gunjana_04•Updated 8 hours ago
17}
18
19export default function App() {
20 const [activeTab, setActiveTab] = useState<Tab>('dashboard');
21 const [notifications, setNotifications] = useState<Notification[]>([]);
22 const [refreshTrigger, setRefreshTrigger] = useState(0);
23
24 // Function to trigger data refresh across components
25 const triggerRefresh = () => {
26 setRefreshTrigger(prev => prev + 1);
27 };
28
29 // Function to show notifications
30 const showNotification = (notification: Omit<Notification, 'id'>) => {
31 const id = Date.now().toString();

Smart_Expense_Trackerqueries.ts15 matches

@gunjana_04•Updated 8 hours ago
4
5// User queries
6export async function getUser(userId: number = 1): Promise<User | null> {
7 const result = await sqlite.execute("SELECT * FROM users_v1 WHERE id = ?", [userId]);
8 if (result.length === 0) return null;
18}
19
20export async function updateUser(userId: number, updates: Partial<User>): Promise<void> {
21 const fields = [];
22 const values = [];
45
46// Expense queries
47export async function addExpense(expense: Omit<Expense, 'id' | 'createdAt'>): Promise<number> {
48 const result = await sqlite.execute(`
49 INSERT INTO expenses_v1 (user_id, amount, category, description, date)
54}
55
56export async function getExpenses(userId: number = 1, limit: number = 50): Promise<Expense[]> {
57 const result = await sqlite.execute(`
58 SELECT * FROM expenses_v1
73}
74
75export async function getExpensesByMonth(userId: number = 1, month: string = getMonthYear()): Promise<Expense[]> {
76 const result = await sqlite.execute(`
77 SELECT * FROM expenses_v1
91}
92
93export async function deleteExpense(expenseId: number, userId: number = 1): Promise<void> {
94 await sqlite.execute("DELETE FROM expenses_v1 WHERE id = ? AND user_id = ?", [expenseId, userId]);
95}
96
97// Goal queries
98export async function addGoal(goal: Omit<Goal, 'id' | 'createdAt' | 'isCompleted'>): Promise<number> {
99 const result = await sqlite.execute(`
100 INSERT INTO goals_v1 (user_id, title, description, target_amount, current_amount, target_date, category, image_url)
105}
106
107export async function getGoals(userId: number = 1): Promise<Goal[]> {
108 const result = await sqlite.execute(`
109 SELECT * FROM goals_v1
127}
128
129export async function updateGoalProgress(goalId: number, amount: number, userId: number = 1): Promise<void> {
130 await sqlite.execute(`
131 UPDATE goals_v1
136}
137
138export async function deleteGoal(goalId: number, userId: number = 1): Promise<void> {
139 await sqlite.execute("DELETE FROM goals_v1 WHERE id = ? AND user_id = ?", [goalId, userId]);
140}
141
142// Budget queries
143export async function setBudget(userId: number, category: string, monthlyLimit: number, month: string = getMonthYear()): Promise<void> {
144 await sqlite.execute(`
145 INSERT OR REPLACE INTO budgets_v1 (user_id, category, monthly_limit, month)
148}
149
150export async function getBudgets(userId: number = 1, month: string = getMonthYear()): Promise<Budget[]> {
151 const result = await sqlite.execute(`
152 SELECT b.*, COALESCE(SUM(e.amount), 0) as current_spent
170
171// Travel destinations
172export async function getTravelDestinations(): Promise<TravelDestination[]> {
173 const result = await sqlite.execute("SELECT * FROM travel_destinations_v1 ORDER BY name");
174
189
190// Analytics queries
191export async function getMonthlyReport(userId: number = 1, month: string = getMonthYear()): Promise<MonthlyReport> {
192 const user = await getUser(userId);
193 const expenses = await getExpensesByMonth(userId, month);
222}
223
224export async function getCategorySpending(userId: number = 1, months: number = 6): Promise<Record<string, number[]>> {
225 const result = await sqlite.execute(`
226 SELECT

getFileEmail4 file matches

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

tuna8 file matches

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