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=2509&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 34996 results for "function"(8672ms)

SethGodinBlogEmailmain.tsx1 match

@danaly•Updated 4 months ago
1import { email } from "https://esm.town/v/std/email";
2
3export default async function (interval: Interval) {
4 try {
5 // Fetch RSS feed from Seth's blog

SSEDemomain.tsx1 match

@stevekrouse•Updated 4 months ago
1const msg = new TextEncoder().encode("data: hello\r\n\r\n");
2
3export default async function(req: Request): Promise<Response> {
4 let timerId: number | undefined;
5 try {

annual_feedbackmain.tsx1 match

@stevekrouse•Updated 4 months ago
17)`);
18
19async function addFeedback(req: Request) {
20 const formData = await req.formData();
21 let data = Object.fromEntries(formData.entries());

OpenTowniesoundEffects.ts3 matches

@stevekrouse•Updated 4 months ago
1/**
2 * Sound effects utility functions for the application
3 */
4
7 * @returns A Promise that resolves when the sound has started playing
8 */
9export function playBellSound(): Promise<void> {
10 return new Promise((resolve) => {
11 try {
69 * @returns A Promise that resolves when the sound has started playing
70 */
71export function playSimpleNotification(): Promise<void> {
72 return new Promise((resolve) => {
73 try {

instagramScrapingutils.ts4 matches

@wolf•Updated 4 months ago
1import * as cheerio from "npm:cheerio";
2
3function getIdFromInstagramLink(url: string): string {
4 const match = url.match(/\/p\/([^/]+)/);
5 return match ? match[1] : "";
6}
7
8function extractInstagramCaption(html: string): string | undefined {
9 const $ = cheerio.load(html);
10
17}
18
19function extractInstagramUsername(html: string): string | undefined {
20 const $ = cheerio.load(html);
21
36}
37
38export default async function instagramPostExtract(
39 url: string,
40): Promise<InstagramPostMeta> {

instagramScrapingApp.tsx1 match

@wolf•Updated 4 months ago
2import { useEffect, useRef, useState } from "https://esm.sh/react@18.2.0";
3
4export default function App() {
5 const [url, setUrl] = useState("");
6 const [resultCaption, setResultText] = useState("");

BingImageOfDayfetchBingImage.tsx2 matches

@wolf•Updated 4 months ago
1/**
2 * Helper function to fetch the Bing Image of the Day
3
4 * @returns Promise containing the image response
5 */
6export async function fetchBingImage(): Promise<Response> {
7 try {
8 // Fetch the HTML page

BingImageOfDaybackupImage.tsx1 match

@wolf•Updated 4 months ago
5 * Backup the current Bing Image of the Day to blob storage
6 */
7export async function backupBingImage(): Promise<void> {
8 try {
9 // Fetch the Bing image of the day using our helper

cloudflare_zonemain.tsx1 match

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

AlwaysHereBackendREADME.md2 matches

@ninadxc•Updated 4 months ago
16In a normal server environment, you would likely use a middleware [like this one](https://hono.dev/docs/getting-started/nodejs#serve-static-files) to serve static files. Some frameworks or deployment platforms automatically make any content inside a `public/` folder public.
17
18However in Val Town you need to handle this yourself, and it can be suprisingly difficult to read and serve files in a Val Town Project. This template uses helper functions from [stevekrouse/utils/serve-public](https://www.val.town/x/stevekrouse/utils/branch/main/code/serve-public/README.md), which handle reading project files in a way that will work across branches and forks, automatically transpiles typescript to javascript, and assigns content-types based on the file's extension.
19
20### `index.html`
26## CRUD API Routes
27
28This app has two CRUD API routes: for reading and inserting into the messages table. They both speak JSON, which is standard. They import their functions from `/backend/database/queries.ts`. These routes are called from the React app to refresh and update data.
29
30## Errors

discordWebhook2 file matches

@stevekrouse•Updated 2 weeks ago
Helper function to send Discord messages
tuna

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