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/$%7BsvgDataUrl%7D?q=function&page=32&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 30865 results for "function"(2294ms)

11 * Enhanced client info extraction using Cloudflare headers when available
12 *
13 * This function prioritizes Cloudflare headers for accurate geographic and network data,
14 * falling back to standard headers when CF data is not available.
15 *
17 * @returns Enhanced client information object
18 */
19export function extractEnhancedClientInfo(c: Context<{ Variables: Variables }>): ClientInfo {
20 const cfData = c.get("cfData") as CloudflareHeaderData | undefined;
21 const headers = c.req.raw.headers;
76 * @returns Basic client information object
77 */
78export function extractBasicClientInfo(c: Context): {
79 ip: string;
80 userAgent?: string;
106 * @returns True if request has Cloudflare headers
107 */
108export function isCloudflareRequest(c: Context): boolean {
109 const headers = c.req.raw.headers;
110 return !!(headers.get("CF-Ray") || headers.get("CF-Connecting-IP"));
116 * @returns Object with Cloudflare header data
117 */
118export function extractCloudflareData(c: Context): CloudflareHeaderData | null {
119 const headers = c.req.raw.headers;
120
341
342/**
343 * Standalone function wrapper for adding internal tokens to headers
344 * Convenience function that uses the singleton service instance
345 */
346export async function addInternalTokenToHeaders(
347 c: Context<{ Variables: HonoVariables }>,
348 targetEndpoint: string,

api_ianmenethil_comcacheService.ts5 matches

@ianmenethil•Updated 1 day ago
464export const cacheService = new CacheService();
465
466// Utility functions for backward compatibility with old cache.ts
467export async function generateCacheKey(url: string, options: unknown): Promise<string> {
468 return await cacheService.generateCacheKey(`firecrawl:${url}`, options);
469}
470
471export async function getFirecrawlCacheEntry(cacheKey: string): Promise<unknown> {
472 const result = await cacheService.get(cacheKey, { storage: "blob" });
473 if (!result) return null;
482}
483
484export async function setFirecrawlCacheEntry(
485 cacheKey: string,
486 _url: string,
494}
495
496export function initializeFirecrawlCacheTable(): void {
497 // No-op for new architecture - initialization handled automatically
498 console.log("Cache service ready (using enhanced multi-storage backend)");

api_ianmenethil_comrouteLogger.ts2 matches

@ianmenethil•Updated 1 day ago
13import { convertOpenApiPathToHono } from "./pathUtils.ts";
14
15// Basic OpenAPI types for logging functionality
16interface OpenAPIOperation {
17 operationId?: string;
32 * @param middlewareGroups - Registry of middleware groups for each security type
33 */
34export function logAllRoutes(
35 spec: OpenAPISpec,
36 middlewareGroups: Record<string, Array<unknown>>,

api_ianmenethil_comrouteGenerator.ts8 matches

@ianmenethil•Updated 1 day ago
103 const handler = async (c: Context<{ Variables: Variables }>) => {
104 try {
105 let handlerFunction = null;
106
107 // Try controller registry first (new system)
108 if (route.controller && route.methodName) {
109 try {
110 handlerFunction = await HandlerResolver.resolveHandler(
111 route.controller,
112 route.methodName,
123
124 // Fallback to service router (legacy system)
125 if (!handlerFunction) {
126 const serviceHandler = getServiceHandler(route.operationId, this.serviceRouter);
127 if (serviceHandler) {
128 handlerFunction = serviceHandler;
129 }
130 }
131
132 if (!handlerFunction) {
133 console.error(`No handler found for operationId: ${route.operationId}`);
134 return c.json(
147 }
148
149 const result = await handlerFunction(c);
150 return result;
151 } catch (error) {
195 | "options"
196 | "head";
197 if (typeof (this.app as any)[honoMethod] === "function") {
198 if (middlewareChain.length > 0) {
199 (this.app as any)[honoMethod](route.path, ...middlewareChain, handler);
385}
386
387export async function generateRoutesFromOpenAPI(
388 app: Hono<{ Variables: Variables }>,
389 specPath: string,

api_ianmenethil_comloader.ts2 matches

@ianmenethil•Updated 1 day ago
107}
108
109// Export a function to load the OpenAPI spec
110export async function loadOpenAPISpec(rootPath: string): Promise<OpenAPIDocument> {
111 const loader = new OpenAPILoader(rootPath);
112 return await loader.loadSpec();

api_ianmenethil_compathUtils.ts3 matches

@ianmenethil•Updated 1 day ago
10 * {id} -> :id
11 */
12export function convertOpenApiPathToHono(openApiPath: string): string {
13 return openApiPath.replace(/\{([^}]+)\}/g, ":$1");
14}
18 * :id -> {id}
19 */
20export function convertHonoPathToOpenApi(honoPath: string): string {
21 return honoPath.replace(/:([^/]+)/g, "{$1}");
22}
25 * Extract parameters from OpenAPI path
26 */
27export function extractOpenApiParams(
28 pathTemplate: string,
29 actualPath: string,

api_ianmenethil_comzTracker.ts6 matches

@ianmenethil•Updated 1 day ago
11import { getCurrentDateInSydney, getSydneyTimestampMillis } from "@/utils/dateUtils.ts";
12
13function generateZID(): string {
14 // Generate two 4-character random parts from UUIDs
15 const randomPart1 = crypto.randomUUID().slice(0, 4);
32 * @returns Decoded ZID components or null if invalid
33 */
34export function decodeZID(encodedZid: string): {
35 originalString: string;
36 randomPart1: string;
72 *
73 * @param c - Hono context
74 * @param next - Next middleware function
75 */
76export const zidTrackingMiddleware = async (
152 * @returns Current ZID or null if not set
153 */
154export function getZID(c: Context<{ Variables: Variables }>): string | null {
155 return c.get("zid") || null;
156}
161 * @returns Request timing info or null if not available
162 */
163export function getRequestTiming(c: Context<{ Variables: Variables }>): {
164 startTime: number;
165 duration: number;
181 * @param data - Additional log data
182 */
183export function logWithZID(
184 { c, level, message, data }: {
185 c: Context<{ Variables: Variables }>;

api_ianmenethil_comsessionManager.ts3 matches

@ianmenethil•Updated 1 day ago
19 *
20 * @param c - Hono context with Variables type extension for session data
21 * @param next - Next middleware function in the chain
22 * @throws {Error} When session parsing fails or cookie operations encounter errors
23 */
148
149/**
150 * Configuration management functions for cookie session middleware
151 */
152
162 newConfig: Partial<CookieSessionConfig>,
163) => {
164 // updateConfig functionality has been removed
165 console.warn(
166 "updateSessionConfig is called, but runtime config updates are currently disabled.",

api_ianmenethil_comreqQuery.ts2 matches

@ianmenethil•Updated 1 day ago
116 *
117 * @param c - Hono context object containing request and response data
118 * @param next - Next middleware function in the Hono processing chain
119 * @returns Promise<void> - Completes after validation check and next() execution
120 */
140/**
141 * @param schemaName - Name of the validation schema to retrieve from available schemas
142 * @returns Corresponding validator function for the specified schema type
143 */
144export const getQueryValidator = (schemaName: keyof typeof queryValidationSchemas) => {
tuna

tuna9 file matches

@jxnblk•Updated 1 week ago
Simple functional CSS library for Val Town

getFileEmail4 file matches

@shouser•Updated 1 month ago
A helper function to build a file's email
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.