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=1391&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 18515 results for "function"(1928ms)

capturePostHogEventmain.tsx1 match

@comercium•Updated 6 months ago
1export async function capturePostHogEvent(
2 key: string,
3 distinct_id: string,

DailyMotivationmain.tsx1 match

@mahendradani•Updated 6 months ago
1import { email } from "https://esm.town/v/std/email";
2export default async function(interval: Interval) {
3 await email({ subject: "Daily Motivation", text: "You can do it!" });
4}

falDemoAppmain.tsx3 matches

@stevekrouse•Updated 6 months ago
5import { falProxyRequest } from "https://esm.town/v/stevekrouse/falProxyRequest";
6
7function App() {
8 const [prompt, setPrompt] = useState("");
9 const [imageUrl, setImageUrl] = useState("");
103}
104
105function client() {
106 createRoot(document.getElementById("root")).render(<App />);
107}
108if (typeof document !== "undefined") { client(); }
109
110export default async function server(req: Request): Promise<Response> {
111 const url = new URL(req.url);
112 if (url.pathname === "/") {

falDemoAppmain.tsx3 matches

@stevekrouse•Updated 6 months ago
5import { falProxyRequest } from "https://esm.town/v/stevekrouse/falProxyRequest";
6
7function App() {
8 const [prompt, setPrompt] = useState("");
9 const [imageUrl, setImageUrl] = useState("");
103}
104
105function client() {
106 createRoot(document.getElementById("root")).render(<App />);
107}
108if (typeof document !== "undefined") { client(); }
109
110export default async function server(req: Request): Promise<Response> {
111 const url = new URL(req.url);
112 if (url.pathname === "/") {

readmeValsmain.tsx1 match

@janpaul123•Updated 6 months ago
2const data = await blob.getJSON("readme-vals.json");
3
4export default async function(req: Request): Promise<Response> {
5 return Response.json(data, {
6 headers: { "Content-Type": "application/json" },

prodigiousTanTurtlemain.tsx21 matches

@ocholap9•Updated 6 months ago
36
37// Main App component
38function App() {
39 const [user, setUser] = useState(null);
40
86
87// Home component
88function Home({ user }) {
89 if (!user) {
90 return <h2>Welcome! Please login or register to use the system.</h2>;
104
105// Login component
106function Login({ setUser }) {
107 const [email, setEmail] = useState('');
108 const [password, setPassword] = useState('');
138
139// Register component
140function Register() {
141 const [email, setEmail] = useState('');
142 const [password, setPassword] = useState('');
175
176// Profile component
177function Profile({ user }) {
178 const [name, setName] = useState(user.name || '');
179 const [phone, setPhone] = useState(user.phone || '');
207
208// Logout component
209function Logout({ setUser }) {
210 const navigate = useNavigate();
211
220
221// Driver Dashboard component
222function DriverDashboard({ user }) {
223 const [vehicles, setVehicles] = useState([]);
224 const [transactions, setTransactions] = useState([]);
271
272// Operator Dashboard component
273function OperatorDashboard({ user }) {
274 const [tollBooths, setTollBooths] = useState([]);
275
307
308// Admin Dashboard component
309function AdminDashboard({ user }) {
310 const [revenueReport, setRevenueReport] = useState(null);
311 const [trafficAnalytics, setTrafficAnalytics] = useState(null);
355
356// Client-side rendering
357function client() {
358 createRoot(document.getElementById("root")).render(<App />);
359}
361
362// Server-side code
363export default async function server(request: Request): Promise<Response> {
364 const { pathname } = new URL(request.url);
365
391}
392
393async function handleApiRequest(request: Request): Promise<Response> {
394 const { pathname } = new URL(request.url);
395 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
467}
468
469async function handleRegister(request: Request, sqlite, KEY, SCHEMA_VERSION) {
470 if (request.method !== 'POST') {
471 return new Response('Method Not Allowed', { status: 405 });
492}
493
494async function handleLogin(request: Request, sqlite, KEY, SCHEMA_VERSION) {
495 if (request.method !== 'POST') {
496 return new Response('Method Not Allowed', { status: 405 });
520}
521
522function generateJWT(user) {
523 // This is a simplified JWT generation.
524 // In a real application, use a proper JWT library and keep the secret secure.
529}
530
531async function handleProfile(request: Request, sqlite, KEY, SCHEMA_VERSION, jwtDecode) {
532 if (request.method !== 'PUT') {
533 return new Response('Method Not Allowed', { status: 405 });
564}
565
566async function handleVehicles(request: Request, sqlite, KEY, SCHEMA_VERSION, jwtDecode) {
567 const token = request.headers.get('Authorization')?.split(' ')[1];
568 if (!token) {
586}
587
588async function handleTransactions(request: Request, sqlite, KEY, SCHEMA_VERSION, jwtDecode) {
589 const token = request.headers.get('Authorization')?.split(' ')[1];
590 if (!token) {
610}
611
612async function handleTollBooths(request: Request, sqlite, KEY, SCHEMA_VERSION, jwtDecode) {
613 const token = request.headers.get('Authorization')?.split(' ')[1];
614 if (!token) {
637}
638
639async function handleRevenueReport(request: Request, sqlite, KEY, SCHEMA_VERSION, jwtDecode) {
640 const token = request.headers.get('Authorization')?.split(' ')[1];
641 if (!token) {
666}
667
668async function handleTrafficAnalytics(request: Request, sqlite, KEY, SCHEMA_VERSION, jwtDecode) {
669 const token = request.headers.get('Authorization')?.split(' ')[1];
670 if (!token) {

usageAlertmain.tsx1 match

@stevekrouse•Updated 6 months ago
2import { email } from "https://esm.town/v/std/email?v=13";
3
4export function usageAlert(handler: (req: Request) => Promise<Response>) {
5 const requestCounts: number[] = [];
6 const LIMIT = 1000;

usageAlertREADME.md1 match

@stevekrouse•Updated 6 months ago
9import { usageAlert } from "https://esm.town/v/stevekrouse/usageAlert"
10
11async function sampleHandler(req: Request): Promise<Response> {
12 return new Response("Hello, World!");
13}

fastCoffeeLizardmain.tsx2 matches

@mvmattgray•Updated 6 months ago
4 const secret = "cfbd87a697526bf25127f998fe6388684b80524be46062a1a79d6dd26b5a6b90";
5
6 async function verifySignature(bodyText, receivedSignature) {
7 const encoder = new TextEncoder();
8 const keyData = encoder.encode(secret);
126
127 <script>
128 async function fetchData() {
129 try {
130 const response = await fetch(window.location.href, { headers: { 'accept': 'application/json' } });

sqliteExplorerAppREADME.md1 match

@robaggio•Updated 6 months ago
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable
35- [x] add export to CSV, and JSON (CSV and JSON helper functions written in [this val](https://www.val.town/v/nbbaier/sqliteExportHelpers). Thanks to @pomdtr for merging the initial version!)
36- [x] add listener for cmd+enter to submit query
37

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