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=1432&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 18633 results for "function"(4889ms)

getJsonAndRenderAsImageREADME.md2 matches

@ashryanio•Updated 7 months ago
23
24 - The client-side React component makes a fetch request to "/image".
25 - This request is handled by our server function.
26
27
282. Server-side handling:
29
30 - The server function calls `blob.getJSON("image-test")`.
31 - This `blob.getJSON()` method makes an HTTP request to the Val Town API.
32 - The API returns a Response object containing the JSON data.

hackerNewsDigestmain.tsx4 matches

@workingpleasewait•Updated 7 months ago
3import { email } from "https://esm.town/v/std/email";
4
5async function fetchStories(type: string, count: number) {
6 const response = await fetch(`https://hacker-news.firebaseio.com/v0/${type}stories.json`);
7 const storyIds = await response.json();
15}
16
17function createStoryHTML(story: any) {
18 return `
19 <li>
28}
29
30function createEmailContent(
31 topStories: any[],
32 newStories: any[],
118}
119
120export default async function server(req: Request) {
121 try {
122 const topStories = await fetchStories("top", 10);

testCachemain.tsx1 match

@pomdtr•Updated 7 months ago
1const cache = await caches.open("valtown")
2
3export default async function(req: Request) {
4 const cached = await cache.match(req)
5 if (cached) {

OpenAImain.tsx1 match

@It_FITS_Marketing•Updated 7 months ago
12 * @param {number} [opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
13 * @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
14 * @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
15 * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
16 * @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.

stockAPImain.tsx3 matches

@pete•Updated 7 months ago
3const ALPHA_VANTAGE_API_KEY = "your_api_key_here"; // Replace with your actual API key
4
5async function fetchStockData(symbol: string) {
6 const apiUrl =
7 `https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol=${symbol}&apikey=${ALPHA_VANTAGE_API_KEY}`;
8 const response = await fetch(apiUrl);
9 const data = await response.json();
27
28// This is the default export for Val Town
29export default async function(req: Request): Promise<Response> {
30 const url = new URL(req.url);
31 const symbol = url.searchParams.get("symbol");

uptimemain.tsx1 match

@cjpais•Updated 7 months ago
6);
7
8export async function uptimeCheck(url: string) {
9 let reason: string, status: number, end: number;
10 let ok = true;

statusmain.tsx3 matches

@cjpais•Updated 7 months ago
5import { renderToString } from "npm:react-dom/server";
6
7function StatusRow({ rows }) {
8 return (
9 <div className="w-full flex flex-col space-y-2">
28}
29
30function StatusSection({ url, rows }) {
31 const sectionRows = rows.filter(row => row[0] === url);
32 const percentUp = Math.round((sectionRows.filter(row => row[1]).length / sectionRows.length) * 100);
44}
45
46export default async function(req: Request): Promise<Response> {
47 const { rows } = await sqlite.execute(
48 "select url, ok, duration, timestamp from uptime order by timestamp desc limit 200",

fantasticPurplePossummain.tsx1 match

@maxm•Updated 7 months ago
1export default async function(req: Request): Promise<Response> {
2 return Response.json({ ok: false });
3}

csvToSqliteUploadermain.tsx4 matches

@vawogbemi•Updated 7 months ago
4import { createRoot } from "https://esm.sh/react-dom/client";
5
6function App() {
7 const [file, setFile] = useState(null);
8 const [tableName, setTableName] = useState("");
66}
67
68function client() {
69 createRoot(document.getElementById("root")).render(<App />);
70}
72if (typeof document !== "undefined") { client(); }
73
74export default async function server(request: Request): Promise<Response> {
75 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
76 const { parse } = await import("https://esm.sh/csv-parse/sync");
79 const KEY = "csvToSqliteUploader";
80
81 function sanitizeColumnName(name: string): string {
82 return name.replace(/[^a-zA-Z0-9_]/g, "_").replace(/^(\d)/, "_$1");
83 }

intenseLimeBuzzardmain.tsx1 match

@maxm•Updated 7 months ago
42);
43
44export default async function(req: Request): Promise<Response> {
45 return Response.json(
46 await db.query(`

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 2 weeks ago
Simple functional CSS library for Val Town
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.
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": "*",