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=25&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 30766 results for "function"(2601ms)

api_ianmenethil_comfirecrawlClient.ts5 matches

@ianmenethilโ€ขUpdated 23 hours 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 23 hours 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 23 hours 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 23 hours 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 (

api_ianmenethil_comcontrollerRegistry.ts11 matches

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

api_ianmenethil_comappConfig.ts1 match

@ianmenethilโ€ขUpdated 23 hours ago
171export const SERVER = APP_CONFIG.server;
172
173export function getConfig<T = unknown>(path: string): T {
174 const keys = path.split(".");
175 let current: any = APP_CONFIG;

Studybeaststudybeast.tsx6 matches

@Nothingboyโ€ขUpdated 23 hours ago
136];
137
138function LoginTimer({ loginTime, onExpire }: { loginTime: number; onExpire: () => void }) {
139 const [timeLeft, setTimeLeft] = useState(0);
140 const [progressPercent, setProgressPercent] = useState(100);
187}
188
189function LoginPage({ onLogin }: { onLogin: (username: string) => void }) {
190 const [username, setUsername] = useState("");
191 const [password, setPassword] = useState("");
277}
278
279function CourseCard({ course }: { course: Course }) {
280 return (
281 <div className="bg-white rounded-lg shadow-md overflow-hidden hover:shadow-lg transition-shadow">
319}
320
321function App() {
322 const [searchTerm, setSearchTerm] = useState("");
323 const [isLoggedIn, setIsLoggedIn] = useState(false);
478}
479
480function client() {
481 createRoot(document.getElementById("root")).render(<App />);
482}
483if (typeof document !== "undefined") { client(); }
484
485export default async function server(request: Request): Promise<Response> {
486 return new Response(
487 `

hm-invoicesv1val-town.mdc17 matches

@arfanโ€ขUpdated 23 hours ago
9
10- Ask clarifying questions when requirements are ambiguous
11- Provide complete, functional solutions rather than skeleton implementations
12- Test your logic against edge cases before presenting the final solution
13- Ensure all code follows Val Town's specific platform requirements
22- **Never bake in secrets into the code** - always use environment variables
23- Include comments explaining complex logic (avoid commenting obvious operations)
24- Follow modern ES6+ conventions and functional programming practices if possible
25
26## Types of triggers
33
34```ts
35export default async function (req: Request) {
36 return new Response("Hello World");
37}
43## Val Town Standard Libraries
44
45Val Town provides several hosted services and utility functions.
46
47### Blob Storage
85```
86
87## Val Town Utility Functions
88
89Val Town provides several utility functions to help with common project tasks.
90
91### Importing Utilities
168โ”œโ”€โ”€ backend/
169โ”‚ โ”œโ”€โ”€ database/
170โ”‚ โ”‚ โ”œโ”€โ”€ queries.ts # DB query functions (CRUD operations)
171โ”‚ โ”‚ โ””โ”€โ”€ README.md
172โ”‚ โ””โ”€โ”€ routes/ # Route modules
188 โ”œโ”€โ”€ README.md
189 โ”œโ”€โ”€ config.ts # Database table names and shared config
190 โ””โ”€โ”€ utils.ts # Shared types and functions
191```
192
267
268 <script>
269 function showResult(data, isError = false) {
270 const resultDiv = document.getElementById('result');
271 resultDiv.className = \`mt-6 p-4 rounded-lg \${isError ? 'bg-red-100 border border-red-300 text-red-800' : 'bg-green-100 border border-green-300 text-green-800'}\`;
274 }
275
276 async function makeRequest(action) {
277 try {
278 const response = await fetch(\`?action=\${action}\`, { method: 'POST' });
284 }
285
286 function getStatus() {
287 makeRequest('status');
288 }
289
290 function seedDatabase() {
291 makeRequest('seed');
292 }
293
294 function forceSeed() {
295 makeRequest('force-seed');
296 }
297
298 function clearDatabase() {
299 if (confirm('Are you sure you want to clear all data from the database?')) {
300 makeRequest('clear');
379- Main entry point should be `main.tsx`
380- **Database Setup:** Use the admin utilities to handle table creation and seeding. Backend should focus on CRUD operations only
381- **Database Queries:** Keep all query functions in `backend/database/queries.ts` with proper TypeScript typing
382- **Static asset serving:** Use the utility functions to read and serve project files:
383 ```ts
384 import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
417- **Backend Focus:** Backend database queries should only handle CRUD operations, not table creation
418- Change table names when modifying schemas rather than altering (update in `shared/config.ts`)
419- Export clear query functions with proper TypeScript typing
420
421## Common Gotchas and Solutions
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.