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=api&page=29&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=api

Returns an array of strings in format "username" or "username/projectName"

Found 19287 results for "api"(2939ms)

api_ianmenethil_comrouter.ts18 matches

@ianmenethil•Updated 1 day ago
1/**
2 * request-gateway.ts — Hono-based request gateway for the v2 API server.
3 * Now properly integrated with middleware chains for consistent request processing.
4 */
49
50/**
51 * OpenAPI Operation interface
52 */
53interface OpenAPIOperation {
54 operationId?: string;
55 summary?: string;
174
175 /**
176 * Register a handler for an OpenAPI operation ID
177 */
178 registerHandler(operationId: string, handler: RouteHandler): this {
217 case GatewayRouteType.BROWSER:
218 default:
219 return "/api/v1";
220 }
221 }
222
223 /**
224 * Register OpenAPI routes from specification
225 */
226 registerOpenApiRoutes(spec: any): this {
227 if (!spec.paths) return this;
228
233 }
234
235 const operation = operationData as OpenAPIOperation;
236 const operationId = operation.operationId;
237 if (!operationId) continue;
243 }
244
245 // Determine route type from OpenAPI extensions or path
246 const routeType = this.determineRouteType(path, operation);
247
248 // Convert OpenAPI path to Hono path format
249 const honoPath = path.replace(/\{([^}]+)\}/g, ":$1");
250
272 * Determine route type from path and operation
273 */
274 private determineRouteType(path: string, operation: OpenAPIOperation): GatewayRouteType {
275 // Check OpenAPI extensions first
276 if (operation["x-route-type"]) {
277 return operation["x-route-type"] as GatewayRouteType;
294
295 /**
296 * Extract authentication requirement from OpenAPI operation
297 */
298 private extractAuthRequirement(operation: OpenAPIOperation): AuthMethod {
299 if (!operation.security || operation.security.length === 0) {
300 return "none";
306
307 if (securitySchemes.includes("bearerAuth")) return "jwt";
308 if (securitySchemes.includes("apiKey")) return "apiKey";
309 if (securitySchemes.includes("oauth2")) return "oauth";
310 if (securitySchemes.includes("basicAuth")) return "basic";
370 */
371 serve(port = 8000): void {
372 console.log(`🚀 API Gateway starting on port ${port}`);
373 console.log(`📚 API Documentation: ${APP_CONFIG.server.BASE_URL}/docs`);
374 console.log(`🔗 API Base URL: ${APP_CONFIG.server.BASE_URL}/api/v1`);
375 console.log("");
376 console.log("Middleware chains configured:");

api_ianmenethil_comtavilyClient.ts42 matches

@ianmenethil•Updated 1 day ago
1/**
2 * tavily-client.ts - Tavily API integration client for v2
3 */
4
5import { z } from "z";
6
7// --- Tavily Search Schema (based on actual API documentation) ---
8export const TavilySearchSchema = z.object({
9 query: z.string().min(1, "Search query cannot be empty"),
31export type TavilySearchInput = z.infer<typeof TavilySearchSchema>;
32
33// --- Tavily Extract Schema (based on actual API documentation) ---
34export const TavilyExtractSchema = z.object({
35 urls: z.union([
45export type TavilyExtractInput = z.infer<typeof TavilyExtractSchema>;
46
47// --- Tavily Crawl Schema (based on actual API documentation) ---
48export const TavilyCrawlInputSchema = z.object({
49 url: z.string().url("Root URL to begin crawling is required"),
76export type TavilyCrawlInput = z.infer<typeof TavilyCrawlInputSchema>;
77
78// --- Tavily Map Schema (based on actual API documentation) ---
79export const TavilyMapInputSchema = z.object({
80 url: z.string().url("Root URL to begin mapping is required"),
81 max_depth: z.number().int().min(1).optional().default(1),
101});
102
103export type TavilyMapInput = z.infer<typeof TavilyMapInputSchema>;
104
105// API configuration
106function getTavilyApiKey(): string {
107 const key = Deno.env.get("TAVILY_API_KEY") || "";
108 if (!key) {
109 throw new Error("Configuration error: invalid or missing TAVILY_API_KEY");
110 }
111 return key;
112}
113
114const TAVILY_API_BASE_URL = "https://api.tavily.com";
115
116/**
117 * Perform a search using the Tavily API.
118 */
119export async function performTavilySearch(input: TavilySearchInput): Promise<unknown> {
120 const apiKey = getTavilyApiKey();
121 const options = {
122 method: "POST",
123 headers: {
124 "Authorization": `Bearer ${apiKey}`,
125 "Content-Type": "application/json",
126 },
128 };
129
130 const response = await fetch(`${TAVILY_API_BASE_URL}/search`, options);
131
132 if (!response.ok) {
136 } catch {
137 console.error(
138 `Failed to parse error response from Tavily API for search: ${response.status} - ${response.statusText}`,
139 );
140 }
146
147/**
148 * Perform an extract using the Tavily API.
149 */
150export async function performTavilyExtract(input: TavilyExtractInput): Promise<unknown> {
151 const apiKey = getTavilyApiKey();
152
153 // Ensure urls is always an array for the API
154 const apiInput = {
155 ...input,
156 urls: Array.isArray(input.urls) ? input.urls : [input.urls],
160 method: "POST",
161 headers: {
162 "Authorization": `Bearer ${apiKey}`,
163 "Content-Type": "application/json",
164 },
165 body: JSON.stringify(apiInput),
166 };
167
168 const response = await fetch(`${TAVILY_API_BASE_URL}/extract`, options);
169
170 if (!response.ok) {
174 } catch {
175 console.error(
176 `Failed to parse error response from Tavily API for extract: ${response.status} - ${response.statusText}`,
177 );
178 }
184
185/**
186 * Perform a crawl using the Tavily API (BETA).
187 */
188export async function performTavilyCrawl(input: TavilyCrawlInput): Promise<unknown> {
189 const apiKey = getTavilyApiKey();
190
191 // Convert empty arrays to null as per API documentation
192 const apiInput = {
193 ...input,
194 select_paths: input.select_paths?.length ? input.select_paths : null,
202 method: "POST",
203 headers: {
204 "Authorization": `Bearer ${apiKey}`,
205 "Content-Type": "application/json",
206 },
207 body: JSON.stringify(apiInput),
208 };
209
210 const response = await fetch(`${TAVILY_API_BASE_URL}/crawl`, options);
211
212 if (!response.ok) {
216 } catch {
217 console.error(
218 `Failed to parse error response from Tavily API for crawl: ${response.status} - ${response.statusText}`,
219 );
220 }
226
227/**
228 * Perform a site map using the Tavily API (BETA).
229 */
230export async function performTavilyMap(input: TavilyMapInput): Promise<unknown> {
231 const apiKey = getTavilyApiKey();
232
233 // Convert empty arrays to null as per API documentation
234 const apiInput = {
235 ...input,
236 select_paths: input.select_paths?.length ? input.select_paths : null,
244 method: "POST",
245 headers: {
246 "Authorization": `Bearer ${apiKey}`,
247 "Content-Type": "application/json",
248 },
249 body: JSON.stringify(apiInput),
250 };
251
252 const response = await fetch(`${TAVILY_API_BASE_URL}/map`, options);
253
254 if (!response.ok) {
258 } catch {
259 console.error(
260 `Failed to parse error response from Tavily API for map: ${response.status} - ${response.statusText}`,
261 );
262 }

api_ianmenethil_comopenaiClient.ts2 matches

@ianmenethil•Updated 1 day ago
1// Future implementation of OpenAI client for API calls
2import { OpenAI } from "openai";
3
4const openai = new OpenAI({
5 apiKey: Deno.env.get("OPENAI_API_KEY"),
6});
7

api_ianmenethil_comfirecrawlClient.ts20 matches

@ianmenethil•Updated 1 day ago
1// F:\zApps\valtown.servers\APIServer\src\external-apis\firecrawl-client.ts
2
3import FirecrawlApp from "firecrawl";
94export type ScraperInput = z.infer<typeof ScraperSchema>;
95
96// Map schema - Based on actual Firecrawl API documentation
97export const FirecrawlMapInputSchema = z.object({
98 url: z.string().url("Invalid URL format"),
99 search: z.string().optional(),
105});
106
107export type FirecrawlMapInput = z.infer<typeof FirecrawlMapInputSchema>;
108
109function getApiKey(): string {
110 const key = Deno.env.get("FIRECRAWL_API_KEY") || "";
111 if (!key) {
112 throw new Error("Configuration error: invalid or missing FIRECRAWL_API_KEY");
113 }
114 return key;
116
117function getFirecrawlClient(): FirecrawlApp {
118 const apiKey = getApiKey();
119 return new FirecrawlApp({ apiKey });
120}
121
122/**
123 * Fetch content via the Firecrawl API scrape endpoint.
124 * Handles single page scraping with all supported options.
125 */
126export async function fetchFromFirecrawlAPI(
127 input: ScraperInput,
128): Promise<unknown> {
170
171/**
172 * Perform a map operation using the Firecrawl API.
173 * Maps all URLs from a website using Firecrawl's dedicated map endpoint.
174 */
175export async function performFirecrawlMap(
176 input: FirecrawlMapInput,
177): Promise<unknown> {
178 const firecrawl = getFirecrawlClient();
181 // Use the dedicated map method from FirecrawlApp
182 // Note: The FirecrawlApp SDK might need to be updated to support the map endpoint
183 // If the SDK doesn't have a map method, we'll need to make a direct API call
184
185 // Check if FirecrawlApp has a map method
195 });
196 } else {
197 // Fallback to direct API call if SDK doesn't support map
198 const apiKey = getApiKey();
199 const response = await fetch("https://api.firecrawl.dev/v1/map", {
200 method: "POST",
201 headers: {
202 "Authorization": `Bearer ${apiKey}`,
203 "Content-Type": "application/json",
204 },
212 } catch {
213 console.error(
214 `Failed to parse error response from Firecrawl API for map: ${response.status} - ${response.statusText}`,
215 );
216 }

api_ianmenethil_comserviceRegistry.ts13 matches

@ianmenethil•Updated 1 day ago
13
14// Documentation services - Updated to use handler functions
15import { getOpenAPIJSON, getOpenAPIYAML } from "../handlers/openapiService.ts";
16import { getSwaggerUI } from "../handlers/swaggerService.ts";
17import { getRedoc } from "../handlers/redoclyService.ts";
21import { proxyGetHandler, proxyPostHandler } from "../handlers/proxyService.ts";
22
23// External API services
24import {
25 tavilyCrawlHandler,
27 tavilyMapHandler,
28 tavilySearchHandler,
29} from "../handlers/tavilyApiService.ts";
30import { firecrawlMapHandler, firecrawlScrapeHandler } from "../handlers/firecrawlApiService.ts";
31import { getApiInfo, getVersion } from "../handlers/infoService.ts";
32import { getHash } from "../handlers/hashService.ts";
33
84
85 // === Documentation Handlers - Now using imported functions ===
86 getOpenAPIJSON,
87 getOpenAPIYAML,
88 getSwaggerUI,
89 getRedoc,
95 proxyPost: proxyPostHandler,
96
97 // === External API Handlers ===
98 tavilySearch: tavilySearchHandler,
99 tavilyExtract: tavilyExtractHandler,
104
105 // Info and Version Handlers (Implemented)
106 getApiInfo,
107 getVersion,
108
191 "handleSpotifyCallback",
192 ],
193 "Documentation": ["getOpenAPIJSON", "getOpenAPIYAML", "getSwaggerUI", "getRedoc"],
194 "Utility (Echo)": ["echoGet", "echoPost"],
195 "Utility (Proxy)": ["proxyGet", "proxyPost"],
196 "External API (Tavily)": ["tavilySearch", "tavilyExtract", "tavilyCrawl", "tavilyMap"],
197 "External API (Firecrawl)": ["firecrawlScrape", "firecrawlMap"],
198 "Info": ["getApiInfo", "getVersion"],
199 };
200

api_ianmenethil_comservicesConfig.ts13 matches

@ianmenethil•Updated 1 day ago
1// F:\zApps\valtown.servers\APIServer\src\config\services.config.ts
2export const EXTERNAL_SERVICES_CONFIG = {
3 TAVILY: {
4 API_KEY: Deno.env.get("TAVILY_API_KEY"),
5 BASE_URL: "https://api.tavily.com",
6 TIMEOUT: 30000,
7 ENABLED: !!Deno.env.get("TAVILY_API_KEY"),
8 },
9 FIRECRAWL: {
10 API_KEY: Deno.env.get("FIRECRAWL_API_KEY"),
11 BASE_URL: "https://api.firecrawl.dev",
12 TIMEOUT: 60000,
13 ENABLED: !!Deno.env.get("FIRECRAWL_API_KEY"),
14 },
15 OPENAI: {
16 API_KEY: Deno.env.get("OPENAI_API_KEY"),
17 BASE_URL: "https://api.openai.com/v1",
18 TIMEOUT: 30000,
19 ENABLED: !!Deno.env.get("OPENAI_API_KEY"),
20 },
21 RESEND: {
22 API_KEY: Deno.env.get("RESEND_API_KEY"),
23 BASE_URL: "https://api.resend.com",
24 TIMEOUT: 30000,
25 ENABLED: !!Deno.env.get("RESEND_API_KEY"),
26 },
27};

api_ianmenethil_comsecurityConfig.ts2 matches

@ianmenethil•Updated 1 day ago
111 } as Record<string, { windowMs: number; maxRequests: number }>,
112
113 /* OAuth & internal API limits */
114 oauth: { windowMs: 900_000, maxAttempts: 5 },
115 internal: { windowMs: 60_000, maxRequests: 1_000, burstLimit: 50 },
116
117 /* Response shaping */
118 standardHeaders: true,
119 legacyHeaders: false,

api_ianmenethil_comsecurityTypes.ts2 matches

@ianmenethil•Updated 1 day ago
1// F:\zApps\valtown.servers\APIServer\src\core\security.types.ts
2/**
3 * Unified Security Types
241
242/**
243 * Internal API rate limit configuration
244 */
245export interface InternalRateLimit {

api_ianmenethil_comrequestTypes.ts5 matches

@ianmenethil•Updated 1 day ago
1// F:\zApps\valtown.servers\APIServer\src\core\request.types.ts
2
3import type {
70 userAgent?: string;
71 plugin?: string;
72 openApiPath?: string;
73 openApiOperation?: unknown;
74 metadata?: Record<string, unknown>;
75}
80}
81
82export interface OpenAPIOperationExtension {
83 "x-rate-limit"?: RouteRateLimitConfig;
84 "x-auth-required"?: boolean;
100 handler: RouteHandler;
101 middleware: MiddlewareHandler[];
102 auth: AuthMethod | "none" | "jwt" | "apiKey" | "oauth";
103 plugin?: string;
104 rateLimit?: RouteRateLimitConfig;

api_ianmenethil_comheaderTypes.ts1 match

@ianmenethil•Updated 1 day ago
1// F:\zApps\valtown.servers\APIServer\src\config\header.types.ts
2/**
3 * CORS configuration types
Plantfo

Plantfo8 file matches

@Llad•Updated 11 hours ago
API for AI plant info

api_ianmenethil_com133 file matches

@ianmenethil•Updated 20 hours ago
vapicxy
apiry