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=39&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 30885 results for "function"(3426ms)

api_ianmenethil_comcallbackService.ts7 matches

@ianmenethil•Updated 1 day ago
23 * @returns Sanitized string
24 */
25function sanitizeInput(input: string): string {
26 return input.replace(/[<>\"'&]/g, "").trim();
27}
33 * @returns Parsed timestamp filter object
34 */
35function parseTimestampFilters(from?: string, to?: string): { from?: Date; to?: Date } {
36 const result: { from?: Date; to?: Date } = {};
37
58 * @returns Headers as key-value object
59 */
60function extractHeaders(request: Request): Record<string, string> {
61 const headers: Record<string, string> = {};
62 request.headers.forEach((value, key) => {
71 * @returns Response with callback creation result
72 */
73export async function createCallback(c: Context<{ Variables: Variables }>): Promise<Response> {
74 const requestId = crypto.randomUUID();
75
159 * @returns Response with callback records list
160 */
161export async function listCallbacks(c: Context<{ Variables: Variables }>): Promise<Response> {
162 const requestId = crypto.randomUUID();
163
249 * @returns Response with callback record details
250 */
251export async function getCallback(c: Context<{ Variables: Variables }>): Promise<Response> {
252 const requestId = crypto.randomUUID();
253
316 * @returns Response with deletion confirmation
317 */
318export async function deleteCallback(c: Context<{ Variables: Variables }>): Promise<Response> {
319 const requestId = crypto.randomUUID();
320

api_ianmenethil_comauthService.ts4 matches

@ianmenethil•Updated 1 day ago
18 * Generates and returns a new CSRF token for form protection
19 */
20export function getCsrfToken(c: Context<{ Variables: Variables }>): Response {
21 try {
22 // Generate a secure CSRF token
73 * Returns the current authenticated user from the OAuth session
74 */
75export function getCurrentUser(c: Context<{ Variables: Variables }>): Response {
76 try {
77 // Get session data from cookie
197 * Clears OAuth session cookies and ends the user session
198 */
199export function logout(c: Context<{ Variables: Variables }>): Response {
200 try {
201 // Get current session for logging
265 * Converts API keys to JWT tokens for secure service access
266 */
267export async function exchangeToken(c: Context<{ Variables: Variables }>): Promise<Response> {
268 try {
269 // Extract token key from header or query parameter

api_ianmenethil_comtavilyClient.ts5 matches

@ianmenethil•Updated 1 day ago
104
105// API configuration
106function getTavilyApiKey(): string {
107 const key = Deno.env.get("TAVILY_API_KEY") || "";
108 if (!key) {
117 * Perform a search using the Tavily API.
118 */
119export async function performTavilySearch(input: TavilySearchInput): Promise<unknown> {
120 const apiKey = getTavilyApiKey();
121 const options = {
148 * Perform an extract using the Tavily API.
149 */
150export async function performTavilyExtract(input: TavilyExtractInput): Promise<unknown> {
151 const apiKey = getTavilyApiKey();
152
186 * Perform a crawl using the Tavily API (BETA).
187 */
188export async function performTavilyCrawl(input: TavilyCrawlInput): Promise<unknown> {
189 const apiKey = getTavilyApiKey();
190
228 * Perform a site map using the Tavily API (BETA).
229 */
230export async function performTavilyMap(input: TavilyMapInput): Promise<unknown> {
231 const apiKey = getTavilyApiKey();
232

api_ianmenethil_comfirecrawlClient.ts5 matches

@ianmenethil•Updated 1 day ago
107export type FirecrawlMapInput = z.infer<typeof FirecrawlMapInputSchema>;
108
109function getApiKey(): string {
110 const key = Deno.env.get("FIRECRAWL_API_KEY") || "";
111 if (!key) {
115}
116
117function getFirecrawlClient(): FirecrawlApp {
118 const apiKey = getApiKey();
119 return new FirecrawlApp({ apiKey });
124 * Handles single page scraping with all supported options.
125 */
126export async function fetchFromFirecrawlAPI(
127 input: ScraperInput,
128): Promise<unknown> {
173 * Maps all URLs from a website using Firecrawl's dedicated map endpoint.
174 */
175export async function performFirecrawlMap(
176 input: FirecrawlMapInput,
177): Promise<unknown> {
184
185 // Check if FirecrawlApp has a map method
186 if ("mapUrl" in firecrawl && typeof firecrawl.mapUrl === "function") {
187 // Use the SDK's map method if available
188 return await firecrawl.mapUrl(input.url, {

api_ianmenethil_comserviceRegistry.ts8 matches

@ianmenethil•Updated 1 day ago
12import { exchangeToken, getCsrfToken, getCurrentUser, logout } from "../handlers/authService.ts";
13
14// Documentation services - Updated to use handler functions
15import { getOpenAPIJSON, getOpenAPIYAML } from "../handlers/openapiService.ts";
16import { getSwaggerUI } from "../handlers/swaggerService.ts";
49// import { hashData } from '@/handlers/hash.service.ts';
50
51// // --- Helper function to get error messages ---
52// function getErrorMessage(error: unknown): string {
53// if (error instanceof Error) return error.message;
54// if (typeof error === 'string') return error;
67
68// --- Service Router Creation ---
69export function createServiceRouter(): ServiceRouter {
70 const router: ServiceRouter = {
71 // === Core Auth Handlers ===
83 handleSpotifyCallback,
84
85 // === Documentation Handlers - Now using imported functions ===
86 getOpenAPIJSON,
87 getOpenAPIYAML,
226}
227
228// --- Utility functions for the router ---
229export function getServiceHandler(
230 operationId: string,
231 router: ServiceRouter,
234}
235
236export function listOperations(router: ServiceRouter): string[] {
237 return Object.keys(router);
238}

api_ianmenethil_comsecurityConfig.ts5 matches

@ianmenethil•Updated 1 day ago
175
176// ============================================================================
177// HELPER FUNCTIONS
178// ============================================================================
179
181 * Check if IP is whitelisted
182 */
183export function isIpWhitelisted(ip: string): boolean {
184 return IP_WHITELIST.includes(ip);
185}
188 * Get rate limit for specific endpoint
189 */
190export function getEndpointRateLimit(path: string) {
191 const endpoints = RATE_LIMIT_CONFIG.endpoints as Record<
192 string,
202 * Check if country is allowed
203 */
204export function isCountryAllowed(country: string): boolean {
205 if (!GEOFENCING_CONFIG.enabled) return true;
206
219 * Check if scheme is blocked
220 */
221export function isSchemeBlocked(url: string): boolean {
222 return PATH_SECURITY_CONFIG.blockedSchemes.some((scheme) => url.toLowerCase().startsWith(scheme));
223}

api_ianmenethil_comheaderConfig.ts6 matches

@ianmenethil•Updated 1 day ago
93
94// ============================================================================
95// HELPER FUNCTIONS
96// ============================================================================
97
99 * Build CSP header string from config
100 */
101export function buildCSPHeader(config: CSPConfig = CSP_CONFIG): string {
102 if (!config.enabled) return "";
103
130 * Get CSP header value for current environment
131 */
132export function getCSPHeaderValue(): string {
133 return buildCSPHeader(CSP_CONFIG);
134}
214
215// ============================================================================
216// ADDITIONAL HELPER FUNCTIONS
217// ============================================================================
218
220 * Get all security headers
221 */
222export function getSecurityHeaders(): Record<string, string> {
223 return { ...SECURITY_HEADERS_CONFIG };
224}
227 * Update security header dynamically
228 */
229export function updateSecurityHeader(header: string, value: string): void {
230 SECURITY_HEADERS_CONFIG[header] = value;
231 if (
7
8/**
9 * Handler function signature for all API endpoints
10 */
11export type HandlerFunction = (c: Context) => Promise<Response> | Response;
12
13/**
89/**
90 * Dynamic handler resolver
91 * Resolves x-controller and x-method to actual handler functions
92 */
93export class HandlerResolver {
94 private static handlerCache = new Map<string, HandlerFunction>();
95
96 /**
101 method: string,
102 operationId: string,
103 ): Promise<HandlerFunction> {
104 const cacheKey = `${controller}.${method}`;
105
129 const module = await import(controllerConfig.module);
130
131 // Get the handler function
132 const handlerFunction = module[handlerName];
133 if (!handlerFunction || typeof handlerFunction !== "function") {
134 throw new Error(
135 `Handler function '${handlerName}' not found or not a function in module '${controllerConfig.module}'`,
136 );
137 }
138
139 // Cache the resolved handler
140 this.handlerCache.set(cacheKey, handlerFunction);
141
142 return handlerFunction;
143 } catch (error) {
144 throw new Error(

api_ianmenethil_comauthConfig.ts5 matches

@ianmenethil•Updated 1 day ago
259
260// ============================================================================
261// HELPER FUNCTIONS
262// ============================================================================
263
265 * Check if a specific auth method is enabled
266 */
267export function isAuthMethodEnabled(method: keyof typeof AUTH_METHODS_CONFIG): boolean {
268 return AUTH_METHODS_CONFIG[method]?.enabled ?? false;
269}
272 * Get OAuth provider configuration
273 */
274export function getOAuthProvider(provider: keyof typeof OAUTH_PROVIDERS_CONFIG.providers) {
275 const config = OAUTH_PROVIDERS_CONFIG.providers[provider];
276 if (!config?.ENABLED) {
283 * Check if user has required permission
284 */
285export function userHasPermission(userPermissions: string[], requiredPermission: string): boolean {
286 return userPermissions.includes(requiredPermission) ||
287 userPermissions.includes(AUTHORIZATION_CONFIG.adminPermission);
291 * Get CSRF exempt paths
292 */
293export function isCsrfExempt(path: string): boolean {
294 return CSRF_CONFIG.exempt.some((exempt) => {
295 if (exempt.endsWith("*")) {

api_ianmenethil_comauth.types.ts1 match

@ianmenethil•Updated 1 day ago
18export type Permission = BasePermission | string;
19
20export function isBasePermission(permission: string): permission is BasePermission {
21 return ["read", "write", "delete", "admin"].includes(permission);
22}
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.