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/$%7Burl%7D?q=function&page=72&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 22745 results for "function"(1772ms)

useraccessmanagementauth.middleware.ts3 matches

@shivaam2804โ€ขUpdated 2 days ago
1import { Request, Response, NextFunction } from "express";
2import jwt from "jsonwebtoken";
3import { UserRole } from "../entities";
16}
17
18export const authenticate = (req: Request, res: Response, next: NextFunction) => {
19 try {
20 const authHeader = req.headers.authorization;
44
45export const authorize = (roles: UserRole[]) => {
46 return (req: Request, res: Response, next: NextFunction) => {
47 if (!req.user) {
48 return res.status(401).json({ message: "Authentication required" });

useraccessmanagementREADME.md3 matches

@shivaam2804โ€ขUpdated 2 days ago
30โ”‚ โ”‚ โ”œโ”€โ”€ routes/ # API routes
31โ”‚ โ”‚ โ”œโ”€โ”€ services/ # Business logic
32โ”‚ โ”‚ โ”œโ”€โ”€ utils/ # Helper functions
33โ”‚ โ”‚ โ”œโ”€โ”€ app.ts # Express app setup
34โ”‚ โ”‚ โ””โ”€โ”€ index.ts # Entry point
42โ”‚ โ”‚ โ”œโ”€โ”€ contexts/ # React contexts (Auth)
43โ”‚ โ”‚ โ”œโ”€โ”€ pages/ # Page components
44โ”‚ โ”‚ โ”œโ”€โ”€ services/ # API service functions
45โ”‚ โ”‚ โ”œโ”€โ”€ types/ # TypeScript interfaces
46โ”‚ โ”‚ โ”œโ”€โ”€ utils/ # Helper functions
47โ”‚ โ”‚ โ”œโ”€โ”€ App.tsx # Main app component
48โ”‚ โ”‚ โ””โ”€โ”€ index.tsx # Entry point

rcptblob.tsx1 match

@temptempโ€ขUpdated 2 days ago
1import { blob } from "https://esm.town/v/std/blob";
2export default async function(req: Request): Promise<Response> {
3 if (req.method.toUpperCase() === "POST") {
4 await blob.setJSON("DBX", await req.json());

globeindex.html9 matches

@samjb123โ€ขUpdated 3 days ago
113
114 <script>
115 // Status update function
116 function updateStatus(message) {
117 document.getElementById('status').textContent = message;
118 console.log(message);
120
121 // Wait for DOM to be fully loaded
122 document.addEventListener('DOMContentLoaded', function() {
123 updateStatus('DOM loaded, initializing globe...');
124
184 ];
185
186 // Function to convert lat/lng to 3D position
187 function latLngToVector3(lat, lng, radius) {
188 const phi = (90 - lat) * (Math.PI / 180);
189 const theta = (lng + 180) * (Math.PI / 180);
251
252 // Mouse move event for raycasting
253 container.addEventListener('mousemove', function(event) {
254 const rect = container.getBoundingClientRect();
255 mouse.x = ((event.clientX - rect.left) / container.clientWidth) * 2 - 1;
258
259 // Click event for selecting regions
260 container.addEventListener('click', function() {
261 raycaster.setFromCamera(mouse, camera);
262 const intersects = raycaster.intersectObjects(markers);
289
290 // Window resize event
291 window.addEventListener('resize', function() {
292 camera.aspect = container.clientWidth / container.clientHeight;
293 camera.updateProjectionMatrix();
296
297 // Animation loop
298 function animate() {
299 requestAnimationFrame(animate);
300

globeglobe.js2 matches

@samjb123โ€ขUpdated 3 days ago
3import { OrbitControls } from 'https://cdn.jsdelivr.net/npm/three@0.160.0/examples/jsm/controls/OrbitControls.js';
4
5// Debug function
6function debug(message) {
7 const debugElement = document.getElementById('debug');
8 if (debugElement) {

MiniAppStarterui.tsx8 matches

@null360upโ€ขUpdated 3 days ago
3import { useEffect, useState } from "https://esm.sh/react@19";
4
5export function Section({ children, ...props }: any) {
6 const sectionClass = `p-5 rounded-3xl bg-neutral-400/15 ${props.className || ""}`;
7 return <div class={sectionClass}>{children}</div>;
93};
94
95// export function Input(props: any) {
96// const inputClass = "dark:bg-white dark:text-black bg-black text-white rounded-md px-3 py-1 ";
97// return <input class={inputClass} {...props} />;
98// }
99
100// export function Button(props: any) {
101// const buttonClass = "dark:bg-white dark:text-black bg-black text-white rounded-md px-3 py-1 ";
102// return <button class={buttonClass} {...props} />;
103// }
104
105export function MonoButton(props: any) {
106 return (
107 <Button {...props}>
111}
112
113export function MonoButtonWithStatus(props: any) {
114 const [status, setStatus] = useState<any>();
115 const handleClick = async () => {
132}
133
134export function formatJSON(json: any) {
135 return JSON.stringify(json, null, 2);
136}
146};
147
148export function BackButton({}) {
149 return <ArrowLeft className="w-5 h-5 m-2 cursor-pointer opacity-50" onClick={() => window.location.href = "/"} />;
150}
151
152export function ShareButton({ onClick }) {
153 return <Share className="w-5 h-5 m-2 cursor-pointer opacity-50" onClick={onClick} />;
154}

MiniAppStarterneynar.ts7 matches

@null360upโ€ขUpdated 3 days ago
1const baseUrl = "https://api.neynar.com/v2/farcaster/";
2
3export async function fetchNeynarGet(path: string) {
4 const res = await fetch(baseUrl + path, {
5 method: "GET",
14}
15
16export function fetchUser(username: string) {
17 return fetchNeynarGet(`user/by_username?username=${username}`).then(r => r.user);
18}
19export function fetchUsersById(fids: string) {
20 return fetchNeynarGet(`user/bulk?fids=${fids}`).then(r => r.users);
21}
22
23export function fetchUserFeed(fid: number) {
24 return fetchNeynarGet(
25 `feed?feed_type=filter&filter_type=fids&fids=${fid}&with_recasts=false&with_replies=false&limit=100&cursor=`,
27}
28
29export function fetchChannel(channelId: string) {
30 return fetchNeynarGet(`channel?id=${channelId}`).then(r => r.channel);
31}
32
33export function fetchChannelFeed(channelId: string) {
34 return fetchNeynarGet(
35 `feed/channels?channel_ids=${channelId}&with_recasts=false&limit=100`,
37}
38
39export function fetchChannelsFeed(channelIds: array) {
40 return fetchNeynarGet(
41 `feed/channels?channel_ids=${channelIds.join(",")}&with_recasts=false&limit=100`,

MiniAppStarterindex.tsx1 match

@null360upโ€ขUpdated 3 days ago
35});
36
37function generateHtml(baseUrl: string, path: string = "/"): any {
38 return (
39 <html>

MiniAppStarterimage.tsx4 matches

@null360upโ€ขUpdated 3 days 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 <div tw="w-full h-full flex justify-start items-end text-[100px] bg-black text-white p-[50px]">
31}
32
33export async function iconImage() {
34 return await ogImage(
35 <div tw="w-full h-full flex justify-center items-center text-[100px] bg-black text-white p-[50px]">
45//////////
46
47export async function ogImage(body, options = {}) {
48 const svg = await satori(
49 body,

MiniAppStarterHome.tsx1 match

@null360upโ€ขUpdated 3 days ago
9import { fetchUsersById } from "../util/neynar.ts";
10
11export function Home() {
12 return (
13 <div class="p-5 mb-8">

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.