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=25&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 19269 results for "api"(1923ms)

api_ianmenethil_comauth.jwt.ts17 matches

@ianmenethilโ€ขUpdated 23 hours ago
1/**
2 * JWT authentication middleware for Hono-based API server.
3 * Provides JWT token creation, verification, and middleware functions.
4 */
31}
32
33const jwtApiConfig = AUTH_CONFIG.jwt.API;
34
35/**
45 return await signJwt(
46 restPayload as Record<string, unknown>,
47 jwtApiConfig.secretKey,
48 jwtApiConfig.algorithm,
49 {
50 issuer: jwtApiConfig.issuer,
51 audience: jwtApiConfig.audience,
52 expiresIn: jwtApiConfig.expiresIn,
53 subject: payload.sub || payload.id,
54 issuedAt: true,
74 const payload = await verifyJwt<AppJwtPayload>(
75 token,
76 customSecret || jwtApiConfig.secretKey,
77 {
78 issuer: jwtApiConfig.issuer,
79 audience: jwtApiConfig.audience,
80 algorithms: [jwtApiConfig.algorithm],
81 },
82 );
110 customSecret?: string,
111): Promise<AuthResult> {
112 if (!jwtApiConfig.enabled) {
113 return {
114 success: false,
270 return await signJwt(
271 refreshPayload as Record<string, unknown>,
272 jwtApiConfig.secretKey,
273 jwtApiConfig.algorithm,
274 {
275 issuer: jwtApiConfig.issuer,
276 audience: jwtApiConfig.audience,
277 expiresIn: jwtApiConfig.refreshExpiresIn,
278 subject: payload.sub || payload.id,
279 issuedAt: true,

api_ianmenethil_comsqlService.ts15 matches

@ianmenethilโ€ขUpdated 23 hours ago
12interface SqlServiceConfig {
13 readonly baseUrl: string;
14 readonly apiVersion: string;
15 readonly timeout: number;
16 readonly retryAttempts: number;
23 */
24const DEFAULT_SQL_CONFIG: SqlServiceConfig = {
25 baseUrl: "https://api.val.town",
26 apiVersion: "v1",
27 timeout: 30000,
28 retryAttempts: 3,
63
64/**
65 * SQLite value types supported by the API.
66 */
67type TursoValue = string | number | boolean | null | Uint8Array;
341
342/**
343 * Creates HTTP headers for SQL API requests.
344 *
345 * @param bearerToken - Bearer token for authentication
359
360/**
361 * Builds URL for SQL API endpoints.
362 *
363 * @param endpoint - The API endpoint path
364 * @returns Complete URL for the API request
365 *
366 * @example
370 */
371function buildSqlUrl(endpoint: string): string {
372 return `${DEFAULT_SQL_CONFIG.baseUrl}/${DEFAULT_SQL_CONFIG.apiVersion}${endpoint}`;
373}
374
383 * @example
384 * ```typescript
385 * const response = await makeSqlRequest('https://api.val.town/v1/sqlite/execute', {
386 * method: 'POST',
387 * headers: createSqlHeaders('token'),
432 * @param options - Authentication options
433 * @returns Promise resolving to query result
434 * @throws {SqlServiceError} On validation or API error
435 *
436 * @example
494 * @param options - Authentication and batch options
495 * @returns Promise resolving to array of query results
496 * @throws {SqlServiceError} On validation or API error
497 *
498 * @example
1725 // Auto-detect token from environment if not provided
1726 const token = config.token || Deno.env.get("VALTOWN_TOKEN") ||
1727 Deno.env.get("VALTOWN_API_KEY") || "";
1728
1729 if (!token) {
1730 throw new SqlServiceError(
1731 "Bearer token is required. Set VALTOWN_TOKEN, VALTOWN_API_KEY environment variable or pass token in config.",
1732 SQL_STATUS_CODES.UNAUTHORIZED,
1733 );
1764
1765 /**
1766 * Execute SQL statement with the exact old API signature for backward compatibility.
1767 *
1768 * @param statement - SQL statement as string or object

api_ianmenethil_comoauthDBService.ts5 matches

@ianmenethilโ€ขUpdated 23 hours ago
640 console.log(`[OAuthDbService] Processing OAuth user: ${provider}:${profile.id}`);
641
642 // Check if Val.town API key is available
643 const apiKey = Deno.env.get("VALTOWN_API_KEY") || Deno.env.get("VALTOWN_TOKEN");
644 if (!apiKey) {
645 console.error("๐Ÿšจ [OAuthDbService] VALTOWN_API_KEY not set - cannot process OAuth user");
646 console.error(`๐Ÿšจ [OAuthDbService] Provider: ${provider}, Profile ID: ${profile.id}`);
647 throw new Error("Database access unavailable - OAuth requires valid API key");
648 }
649

api_ianmenethil_comemailService.ts24 matches

@ianmenethilโ€ขUpdated 23 hours ago
14interface EmailServiceConfig {
15 readonly baseUrl: string;
16 readonly apiVersion: string;
17 readonly timeout: number;
18 readonly retryAttempts: number;
24 */
25const DEFAULT_EMAIL_CONFIG: EmailServiceConfig = {
26 baseUrl: "https://api.val.town",
27 apiVersion: "v1",
28 timeout: 30000,
29 retryAttempts: 3,
221
222/**
223 * Create headers for Val Town API requests.
224 * @param bearerToken Optional bearer token (uses env if not provided)
225 * @returns Headers object
226 */
227function createHeaders(bearerToken?: string): Record<string, string> {
228 const token = bearerToken || Deno.env.get("VALTOWN_TOKEN") || Deno.env.get("VALTOWN_API_KEY") ||
229 "";
230
237
238/**
239 * Build URL for Val Town API endpoints.
240 * @param endpoint API endpoint path
241 * @param baseUrl Optional base URL override
242 * @returns Complete URL string
249
250/**
251 * Make HTTP request to Val Town API.
252 * @param url Request URL
253 * @param options Request options
278
279/**
280 * Send email using Val Town API.
281 *
282 * @param options Email options including recipients, content, and authentication
300 const url = buildUrl("/email");
301
302 // Prepare request body according to Val.town API spec
303 const requestBody: Record<string, unknown> = {
304 subject: options.subject,
428 return {
429 bearerToken: this.config.token || Deno.env.get("VALTOWN_TOKEN") ||
430 Deno.env.get("VALTOWN_API_KEY") || "",
431 };
432 } /**
571 }
572
573 const subject = "๐Ÿ”„ API Changes Detected";
574 const htmlContent = this.generateChangeDetectionEmailHtml(data);
575 const textContent = this.generateChangeDetectionEmailText(data);
716 analysis
717 ? `
718 <h3>๐Ÿ” API Analysis</h3>
719 <table>
720 <tr><th>API Title</th><td>${analysis.title}</td></tr>
721 <tr><th>Version</th><td>${analysis.version}</td></tr>
722 <tr><th>Total Paths</th><td>${analysis.pathCount}</td></tr>
735 <li><a href="${
736 data.swaggerData?.spec?.servers?.[0]?.url || "#"
737 }">API Documentation</a></li>
738 </ul>
739 </div>
811 <h3>๐Ÿ”ง Recommended Actions</h3>
812 <ul>
813 <li>Check the Swagger API endpoint availability</li>
814 <li>Verify Postman API credentials</li>
815 <li>Review network connectivity</li>
816 <li>Check system logs for detailed error information</li>
851RECOMMENDED ACTIONS
852-------------------
853- Check the Swagger API endpoint availability
854- Verify Postman API credentials
855- Review network connectivity
856- Check system logs for detailed error information
875<head>
876 <meta charset="utf-8">
877 <title>API Changes Detected</title>
878 <style>
879 body { font-family: Arial, sans-serif; line-height: 1.6; color: #333; }
891 <div class="container">
892 <div class="header">
893 <h1>๐Ÿ”„ API Changes Detected</h1>
894 <p>Swagger-Postman Integration</p>
895 </div>
974
975 let content = `
976API CHANGES DETECTED
977====================
978
1040
1041 return {
1042 title: info.title || "Unknown API",
1043 version: info.version || "unknown",
1044 pathCount: Object.keys(paths).length,
1082 * await vtEmailService.sendWorkflowSuccessNotification({
1083 * changesDetected: true,
1084 * swaggerData: { spec: openApiSpec },
1085 * updateResult: { itemsUpdated: 5, collectionId: 'abc123' },
1086 * recipients: ['admin@example.com']

api_ianmenethil_comblobService.ts26 matches

@ianmenethilโ€ขUpdated 23 hours ago
1/**
2 * vt.blob.service.ts โ€” Val Town blob storage service with complete API integration.
3 */
4
12interface BlobServiceConfig {
13 readonly baseUrl: string;
14 readonly apiVersion: string;
15 readonly maxKeyLength: number;
16 readonly minKeyLength: number;
24 */
25const DEFAULT_BLOB_CONFIG: BlobServiceConfig = {
26 baseUrl: "https://api.val.town",
27 apiVersion: "v1",
28 maxKeyLength: 512,
29 minKeyLength: 1,
58
59/**
60 * Blob listing item returned from the API.
61 */
62interface BlobListingItem {
102
103/**
104 * Backward compatibility type aliases for the old BlobService API.
105 */
106type BlobConfig = BlobServiceConfig;
130
131/**
132 * Validates a blob key according to Val Town API constraints.
133 *
134 * @param key - The blob key to validate
186
187/**
188 * Creates HTTP headers for blob API requests.
189 *
190 * @param bearerToken - Optional bearer token for authentication
212
213/**
214 * Builds URL for blob API endpoints.
215 *
216 * @param endpoint - The API endpoint path
217 * @param key - Optional blob key for specific operations
218 * @param queryParams - Optional query parameters
219 * @returns Complete URL for the API request
220 *
221 * @example
226 */
227function buildUrl(endpoint: string, key?: string, queryParams?: Record<string, string>): string {
228 const baseUrl = `${DEFAULT_BLOB_CONFIG.baseUrl}/${DEFAULT_BLOB_CONFIG.apiVersion}`;
229 let url = `${baseUrl}${endpoint}`;
230
257 * @example
258 * ```typescript
259 * const response = await makeRequest('https://api.val.town/v1/blob', {
260 * method: 'GET',
261 * headers: createHeaders()
307 * @param options - Optional filtering options
308 * @returns Promise resolving to array of blob listing items
309 * @throws {BlobServiceError} On API error
310 *
311 * @example
362 * @param key - The unique blob key
363 * @returns Promise resolving to blob binary data as ArrayBuffer
364 * @throws {BlobServiceError} On validation or API error
365 *
366 * @example
414 * @param encoding - Text encoding (default: 'utf-8')
415 * @returns Promise resolving to blob content as string
416 * @throws {BlobServiceError} On validation or API error
417 *
418 * @example
460 * @param options - Authentication and storage options
461 * @returns Promise resolving to operation result
462 * @throws {BlobServiceError} On validation or API error
463 *
464 * @example
465 * ```typescript
466 * const result = await storeBlob('files/document.pdf', pdfBuffer, {
467 * bearerToken: 'your-api-token'
468 * });
469 *
470 * const textResult = await storeBlob('notes/memo.txt', 'Hello World', {
471 * bearerToken: 'your-api-token',
472 * contentType: 'text/plain'
473 * });
533 * @param options - Authentication options
534 * @returns Promise resolving to operation result
535 * @throws {BlobServiceError} On validation or API error
536 *
537 * @example
539 * const userData = { name: 'John', age: 30 };
540 * const result = await storeBlobAsJson('users/john.json', userData, {
541 * bearerToken: 'your-api-token'
542 * });
543 * ```
568 * @param options - Authentication options
569 * @returns Promise resolving to operation result
570 * @throws {BlobServiceError} On validation or API error
571 *
572 * @example
573 * ```typescript
574 * const result = await deleteBlob('temp/old-file.txt', {
575 * bearerToken: 'your-api-token'
576 * });
577 *
687 * @param key - The unique blob key
688 * @returns Promise resolving to parsed JSON data
689 * @throws {BlobServiceError} On validation, API, or JSON parsing error
690 *
691 * @example
736 * ```typescript
737 * const result = await copyBlob('temp/draft.txt', 'documents/final.txt', {
738 * bearerToken: 'your-api-token'
739 * });
740 * ```
777 * // Delete all temporary files
778 * const results = await bulkDeleteBlobsByPrefix('temp/', {
779 * bearerToken: 'your-api-token'
780 * });
781 *

api_ianmenethil_comwebhookService.ts1 match

@ianmenethilโ€ขUpdated 23 hours ago
1/**
2 * webhookService.ts โ€” Webhook endpoint handlers for managing webhook records with CRUD operations.
3 * Provides RESTful API for creating, listing, viewing, and deleting webhook entries.
4 */
5

api_ianmenethil_comtavilyApiService.ts26 matches

@ianmenethilโ€ขUpdated 23 hours ago
10 TavilyExtractInput,
11 TavilyExtractSchema,
12 TavilyMapInput,
13 TavilyMapInputSchema,
14 TavilySearchInput,
15 TavilySearchSchema,
16} from "@/external-apis/tavilyClient.ts";
17
18function getLocalErrorMessage(error: unknown): string {
28 * tavilySearch operation handler
29 * POST /v1/tavily/search
30 * Handles requests to the Tavily search API.
31 */
32export async function tavilySearchHandler(c: Context<{ Variables: Variables }>): Promise<Response> {
54 console.error("[tavilySearchHandler] Error during Tavily search:", error);
55
56 if (message.includes("Configuration error: invalid or missing TAVILY_API_KEY")) {
57 return c.json({
58 success: false,
59 error: "Tavily API configuration error. Please contact support.",
60 }, 503);
61 }
70 return c.json({
71 success: false,
72 error: "Tavily API returned an error during search.",
73 details: errorDetail,
74 }, 502);
76 return c.json({
77 success: false,
78 error: `Tavily API error during search. Parse Error: ${
79 parseError instanceof Error ? parseError.message : "Unknown error"
80 }`,
93 * tavilyExtract operation handler
94 * POST /v1/tavily/extract
95 * Handles requests to the Tavily extract API.
96 */
97export async function tavilyExtractHandler(
121 console.error("[tavilyExtractHandler] Error during Tavily extract:", error);
122
123 if (message.includes("Configuration error: invalid or missing TAVILY_API_KEY")) {
124 return c.json({
125 success: false,
126 error: "Tavily API configuration error. Please contact support.",
127 }, 503);
128 }
137 return c.json({
138 success: false,
139 error: "Tavily API returned an error during extract.",
140 details: errorDetail,
141 }, 502);
143 return c.json({
144 success: false,
145 error: `Tavily API error during extract. Parse Error: ${
146 parseError instanceof Error ? parseError.message : "Unknown error"
147 }`,
160 * tavilyCrawl operation handler (BETA)
161 * POST /v1/tavily/crawl
162 * Handles requests to the Tavily crawl API.
163 */
164export async function tavilyCrawlHandler(c: Context<{ Variables: Variables }>): Promise<Response> {
186 console.error("[tavilyCrawlHandler] Error during Tavily crawl:", error);
187
188 if (message.includes("Configuration error: invalid or missing TAVILY_API_KEY")) {
189 return c.json({
190 success: false,
191 error: "Tavily API configuration error. Please contact support.",
192 }, 503);
193 }
204 return c.json({
205 success: false,
206 error: "Tavily API returned an error during crawl.",
207 details: errorDetail,
208 }, 502);
210 return c.json({
211 success: false,
212 error: `Tavily API error during crawl. Parse Error: ${
213 parseError instanceof Error ? parseError.message : "Unknown error"
214 }`,
227 * tavilyMap operation handler (BETA)
228 * POST /v1/tavily/map
229 * Handles requests to the Tavily map API.
230 */
231export async function tavilyMapHandler(c: Context<{ Variables: Variables }>): Promise<Response> {
232 try {
233 const requestBody = await c.req.json();
234 const validationResult = TavilyMapInputSchema.safeParse(requestBody);
235
236 if (!validationResult.success) {
244
245 // Use the validated data with explicit type
246 const mapInput: TavilyMapInput = validationResult.data;
247 const tavilyResponse = await performTavilyMap(mapInput);
248
249 // Type assertion to ensure it's a valid JSON value
253 console.error("[tavilyMapHandler] Error during Tavily map:", error);
254
255 if (message.includes("Configuration error: invalid or missing TAVILY_API_KEY")) {
256 return c.json({
257 success: false,
258 error: "Tavily API configuration error. Please contact support.",
259 }, 503);
260 }
269 return c.json({
270 success: false,
271 error: "Tavily API returned an error during map.",
272 details: errorDetail,
273 }, 502);
275 return c.json({
276 success: false,
277 error: `Tavily API error during map. Parse Error: ${
278 parseError instanceof Error ? parseError.message : "Unknown error"
279 }`,

api_ianmenethil_comswaggerService.ts9 matches

@ianmenethilโ€ขUpdated 23 hours ago
5/**
6 * Service for generating Swagger UI HTML documentation
7 * Handles the generation of interactive Swagger UI that consumes OpenAPI specifications
8 */
9export class SwaggerUIService {
10 /**
11 * Generate Swagger UI HTML page
12 * Creates a complete HTML page with Swagger UI embedded that fetches the OpenAPI spec
13 *
14 * @param specUrl - URL to the OpenAPI JSON specification
15 * @returns HTML string for Swagger UI documentation page
16 */
17 generateSwaggerHTML(specUrl: string = "/v1/openapi.json"): string {
18 return `<!DOCTYPE html>
19<html>
20<head>
21 <title>API Documentation</title>
22 <link rel="stylesheet" type="text/css" href="https://unpkg.com/swagger-ui-dist@5.11.0/swagger-ui.css" />
23</head>
29 url: '${specUrl}',
30 dom_id: '#swagger-ui',
31 presets: [SwaggerUIBundle.presets.apis, SwaggerUIBundle.presets.standalone]
32 });
33 </script>
53 /**
54 * Validate that the spec URL is accessible
55 * Basic validation to ensure the OpenAPI spec URL is valid
56 *
57 * @param specUrl - URL to validate
65 return {
66 valid: false,
67 error: "Invalid OpenAPI specification URL",
68 };
69 }
104export function getSwaggerUI(c: Context<{ Variables: Variables }>): Response {
105 try {
106 const html = swaggerUIService.generateSwaggerHTML("/v1/openapi.json");
107 return c.html(html);
108 } catch (error) {

api_ianmenethil_comredoclyService.ts9 matches

@ianmenethilโ€ขUpdated 23 hours ago
5/**
6 * Service for generating Redoc HTML documentation
7 * Handles the generation of Redoc interface that consumes OpenAPI specifications
8 */
9export class RedoclyService {
10 /**
11 * Generate Redoc HTML page
12 * Creates a complete HTML page with Redoc embedded that fetches the OpenAPI spec
13 *
14 * @param specUrl - URL to the OpenAPI JSON specification
15 * @returns HTML string for Redoc documentation page
16 */
17 generateRedocHTML(specUrl: string = "/v1/openapi.json"): string {
18 return `<!DOCTYPE html>
19<html>
20<head>
21 <title>API Documentation - Redoc</title>
22 <meta charset="utf-8"/>
23 <meta name="viewport" content="width=device-width, initial-scale=1">
24 <link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">
25 <style>body{margin:0;padding:0;}</style>
26</head>
49 /**
50 * Validate that the spec URL is accessible
51 * Basic validation to ensure the OpenAPI spec URL is valid
52 *
53 * @param specUrl - URL to validate
61 return {
62 valid: false,
63 error: "Invalid OpenAPI specification URL",
64 };
65 }
77export function getRedoc(c: Context<{ Variables: Variables }>): Response {
78 try {
79 const html = redoclyService.generateRedocHTML("/v1/openapi.json");
80 return c.html(html);
81 } catch (error) {

api_ianmenethil_comproxyService.ts1 match

@ianmenethilโ€ขUpdated 23 hours ago
1// F:\zApps\valtown.servers\APIServer\src\handlers\proxy.service.ts
2import { getCurrentDateInSydney } from "@/utils/dateUtils.ts";
3import { Context } from "hono";
Plantfo

Plantfo8 file matches

@Lladโ€ขUpdated 6 hours ago
API for AI plant info

api_ianmenethil_com133 file matches

@ianmenethilโ€ขUpdated 15 hours ago
apiry
snartapi