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=2&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 7144 results for "function"(544ms)

my-first-valtest3 matches

@bugraipek•Updated 4 hours ago
16];
17
18function App() {
19 return (
20 <div
45}
46
47function client() {
48 createRoot(document.getElementById("root")).render(<App />);
49}
50if (typeof document !== "undefined") { client(); }
51
52export default async function server(request: Request): Promise<Response> {
53 // If it's a GET request to the base path, serve the HTML
54 if (request.method === "GET" && new URL(request.url).pathname === "/") {

CTGBreakerimage.tsx4 matches

@horsefacts•Updated 4 hours ago
5import satori from "npm:satori";
6
7export function handleImageEndpoints(app: Hono) {
8 const headers = {
9 "Content-Type": "image/png",
18}
19
20export async function homeImage() {
21 return await ogImage(
22 <img src="https://imagedelivery.net/BXluQx4ige9GuW0Ia56BHw/7502b893-e726-408e-d7d0-9d9974517500/original" />,
24}
25
26export async function iconImage() {
27 return await ogImage(
28 <img src="https://imagedelivery.net/BXluQx4ige9GuW0Ia56BHw/18baad43-5663-44ee-d9fc-c6d842d9cc00/original" />,
36//////////
37
38export async function ogImage(body, options = {}) {
39 const svg = await satori(
40 body,

JimeluStevensgetWeather.ts5 matches

@luke_f•Updated 5 hours ago
5const TABLE_NAME = `memories`;
6
7function summarizeWeather(weather: WeatherResponse) {
8 const summarizeDay = (day: WeatherResponse["weather"][number]) => ({
9 date: day.date,
21}
22
23async function generateConciseWeatherSummary(weatherDay) {
24 try {
25 // Get API key from environment
79}
80
81async function deleteExistingForecast(date: string) {
82 await sqlite.execute(
83 `
89}
90
91async function insertForecast(date: string, forecast: string) {
92 const { nanoid } = await import("https://esm.sh/nanoid@5.0.5");
93
108}
109
110export default async function getWeatherForecast(interval: number) {
111 const weather = await getWeather("Sydney, Australia");
112 console.log({ weather });

JimeluStevensgetCalendarEvents.ts6 matches

@luke_f•Updated 5 hours ago
6const LOCAL_TIMEZONE = "Australia/Sydney";
7
8async function deleteExistingCalendarEvents() {
9 await sqlite.execute(
10 `
15}
16
17// Helper function to extract time from ISO string without timezone conversion
18function extractTimeFromISO(isoString) {
19 // Match the time portion of the ISO string
20 const timeMatch = isoString.match(/T(\d{2}):(\d{2}):/);
31}
32
33function formatEventToNaturalLanguage(event) {
34 const summary = event.summary || "Untitled event";
35
78}
79
80async function insertCalendarEvent(date, eventText) {
81 const { nanoid } = await import("https://esm.sh/nanoid@5.0.5");
82
92}
93
94export default async function getCalendarEvents() {
95 try {
96 const events = await getEvents(

JimeluStevensgenerateFunFacts.ts8 matches

@luke_f•Updated 5 hours ago
11 * @returns Array of previous fun facts
12 */
13async function getPreviousFunFacts() {
14 try {
15 const result = await sqlite.execute(
32 * @param dates Array of date strings in ISO format
33 */
34async function deleteExistingFunFacts(dates) {
35 try {
36 for (const date of dates) {
51 * @param factText The fun fact text
52 */
53async function insertFunFact(date, factText) {
54 try {
55 await sqlite.execute(
75 * @returns Array of generated fun facts
76 */
77async function generateFunFacts(previousFacts) {
78 try {
79 // Get API key from environment
193 * @returns Array of parsed facts
194 */
195function parseFallbackFacts(responseText, expectedDates) {
196 // Try to extract facts using regex
197 const factPattern = /(\d{4}-\d{2}-\d{2})["']?[,:]?\s*["']?(.*?)["']?[,}]/gs;
256
257/**
258 * Main function to generate and store fun facts for the next 7 days
259 */
260export async function generateAndStoreFunFacts() {
261 try {
262 // Get previous fun facts
297 * Intended to be used as a Val Town cron job
298 */
299export default async function() {
300 console.log("Running fun facts generation cron job...");
301 return await generateAndStoreFunFacts();

gotonightapi1 match

@rosald•Updated 5 hours ago
1export default async function (req: Request): Promise<Response> {
2 return Response.json({ ok: true })
3}

lidingliding1 match

@rosald•Updated 5 hours ago
1export default async function (req: Request): Promise<Response> {
2 return Response.json({ ok: true })
3}

my-first-val04_email.tsx1 match

@bugraipek•Updated 5 hours ago
2// Click "Run", copy and paste the email address and send an email to it.
3// This example will log the email details received.
4export default async function emailHandler(email: Email){
5 console.log("Email received!", email.from, email.subject, email.text);
6 for (const file of email.attachments) {

my-first-val03_cron.tsx1 match

@bugraipek•Updated 5 hours ago
2// Configure the timer with the 🕒 icon in the top right.
3// This example just logs the current time.
4export function scheduledHandler() {
5 const timestamp = new Date().toISOString();
6 console.log(`Cron val executed at: ${timestamp}`);

my-first-val02_http.tsx1 match

@bugraipek•Updated 5 hours ago
2// Access it via its public URL (you can also pick a nicer subdomain).
3// Try adding ?name=YourName to the URL!
4export default function httpHandler(req: Request): Response {
5 const url = new URL(req.url);
6 const name = url.searchParams.get("name") || "Friend";

getFileEmail4 file matches

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

TwilioHelperFunctions

@vawogbemi•Updated 2 months ago