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=2492&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 28692 results for "function"(4128ms)

allvalsmain.tsx1 match

@ejfox•Updated 9 months ago
1import ValTown from "https://esm.sh/@valtown/sdk";
2
3async function server(request: Request): Promise<Response> {
4 const debugMessages: string[] = [];
5

btcPriceAlertmain.tsx1 match

@endzel•Updated 9 months ago
4import { currency } from "https://esm.town/v/stevekrouse/currency";
5
6export async function btcPriceAlert() {
7 const lastBtcPrice: number = await blob.getJSON("lastBtcPrice");
8 let btcPrice = await currency("usd", "btc");

uptimemain.tsx1 match

@endzel•Updated 9 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

@endzel•Updated 9 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",

dailyDadJokemain.tsx1 match

@frobyte•Updated 9 months ago
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3
4export async function dailyDadJoke() {
5 let { setup, punchline } = await fetchJSON("https://official-joke-api.appspot.com/random_joke");
6 return email({

dailyDadJokemain.tsx1 match

@njuribarri•Updated 9 months ago
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3
4export async function dailyDadJoke() {
5 let { setup, punchline } = await fetchJSON("https://official-joke-api.appspot.com/random_joke");
6 return email({

dailyDadJokemain.tsx1 match

@megafredrik•Updated 9 months ago
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3
4export async function dailyDadJoke() {
5 let { setup, punchline } = await fetchJSON("https://official-joke-api.appspot.com/random_joke");
6 return email({

shySapphireLeopardmain.tsx3 matches

@stevekrouse•Updated 9 months ago
5import { createRoot } from "https://esm.sh/react-dom/client";
6
7function App() {
8 const links = [
9 { name: "Portfolio", url: "https://owais-warsi.vercel.app" },
31}
32
33function client() {
34 createRoot(document.getElementById("root")).render(<App />);
35}
37if (typeof document !== "undefined") { client(); }
38
39async function server(request: Request): Promise<Response> {
40 return new Response(
41 `

claudeForwardermain.tsx3 matches

@prabhanshu•Updated 9 months ago
1// This val implements a function to call the Claude API using fetch.
2// It handles the API request and response processing.
3// The Claude API key is expected to be provided in the request headers.
4// CORS is enabled for all origins.
5
6export default async function server(req: Request): Promise<Response> {
7 // Handle preflight requests
8 if (req.method === "OPTIONS") {
48}
49
50async function callClaudeApi(systemPrompt: string, userPrompt: string, apiKey: string): Promise<string> {
51 const url = "https://api.anthropic.com/v1/messages";
52 const headers = {

btcPriceAlertmain.tsx1 match

@jasondeepny•Updated 9 months ago
4import { currency } from "https://esm.town/v/stevekrouse/currency";
5
6export async function btcPriceAlert() {
7 const lastBtcPrice: number = await blob.getJSON("lastBtcPrice");
8 let btcPrice = await currency("usd", "btc");

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.