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=23&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 30765 results for "function"(2607ms)

api_ianmenethil_comemailService.ts11 matches

@ianmenethil•Updated 21 hours ago
191
192// ============================================================================
193// UTILITY FUNCTIONS
194// ============================================================================
195
198 * @returns ISO date string in Sydney timezone
199 */
200function getCurrentDateInSydney(): string {
201 return new Date().toLocaleString("en-AU", {
202 timeZone: "Australia/Sydney",
214 * @returns Basic configuration object
215 */
216function getConfig<T>(): T {
217 return {} as T;
218} // ============================================================================
219// HTTP UTILITY FUNCTIONS
220// ============================================================================
221
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 "";
242 * @returns Complete URL string
243 */
244function buildUrl(endpoint: string, baseUrl?: string): string {
245 const base = baseUrl || DEFAULT_EMAIL_CONFIG.baseUrl;
246 const cleanEndpoint = endpoint.startsWith("/") ? endpoint : `/${endpoint}`;
254 * @returns Promise resolving to Response
255 */
256async function makeRequest(url: string, options: RequestInit): Promise<Response> {
257 const controller = new AbortController();
258 const timeoutId = setTimeout(() => controller.abort(), DEFAULT_EMAIL_CONFIG.timeout);
274 }
275} // ============================================================================
276// CORE EMAIL FUNCTIONS
277// ============================================================================
278
294 * ```
295 */
296export async function sendEmail(
297 options: EmailOptions,
298): Promise<EmailOperationResult<{ message: string }>> {
366 */
367
368export function sendSimpleEmail(
369 to: string[],
370 subject: string,
1051// ============================================================================
1052
1053// Export all types and functions
1054export type {
1055 EmailAttachment,

api_ianmenethil_comblobService.ts19 matches

@ianmenethil•Updated 21 hours ago
141 * ```
142 */
143function validateBlobKey(key: string): void {
144 if (typeof key !== "string") {
145 throw new BlobServiceError("Blob key must be a string", STATUS_CODES.BAD_REQUEST);
172 */
173
174function validateBearerToken(token: string): void {
175 if (typeof token !== "string" || token.trim().length === 0) {
176 throw new BlobServiceError(
197 * ```
198 */
199function createHeaders(bearerToken?: string, contentType?: string): Record<string, string> {
200 const headers: Record<string, string> = {};
201
225 * ```
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}`;
264 */
265
266async function makeRequest(url: string, options: RequestInit): Promise<Response> {
267 let lastError: Error | null = null;
268
299
300// ============================================================================
301// CORE BLOB SERVICE FUNCTIONS
302// ============================================================================
303
318 * ```
319 */
320export async function listBlobs(
321 options: ListBlobsOptions = {},
322): Promise<BlobOperationResult<BlobListingItem[]>> {
371 */
372
373export async function downloadBlob(key: string): Promise<BlobOperationResult<ArrayBuffer>> {
374 try {
375 validateBlobKey(key);
422 * ```
423 */
424export async function downloadBlobAsText(
425 key: string,
426 encoding: string = "utf-8",
475 */
476
477export async function storeBlob(
478 key: string,
479 data: ArrayBuffer | Uint8Array | string,
543 * ```
544 */
545export async function storeBlobAsJson(
546 key: string,
547 data: unknown,
582 */
583
584export async function deleteBlob(
585 key: string,
586 options: AuthenticatedBlobOptions,
622
623// ============================================================================
624// UTILITY FUNCTIONS
625// ============================================================================
626
639 * ```
640 */
641export async function blobExists(key: string): Promise<boolean> {
642 try {
643 validateBlobKey(key);
668 */
669
670export async function getBlobMetadata(key: string): Promise<BlobListingItem | null> {
671 try {
672 const result = await listBlobs();
695 * ```
696 */
697export async function downloadBlobAsJson<T = unknown>(
698 key: string,
699): Promise<BlobOperationResult<T>> {
740 * ```
741 */
742export async function copyBlob(
743 sourceKey: string,
744 destinationKey: string,
788 */
789
790export async function bulkDeleteBlobsByPrefix(
791 prefix: string,
792 options: AuthenticatedBlobOptions,
1188}
1189
1190// Export all types and functions
1191export type {
1192 AuthenticatedBlobOptions,

api_ianmenethil_comwebhookService.ts7 matches

@ianmenethil•Updated 21 hours 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 webhook creation result
72 */
73export async function createWebhook(c: Context<{ Variables: Variables }>): Promise<Response> {
74 const requestId = crypto.randomUUID();
75
159 * @returns Response with webhook records list
160 */
161export async function listWebhooks(c: Context<{ Variables: Variables }>): Promise<Response> {
162 const requestId = crypto.randomUUID();
163
249 * @returns Response with webhook record details
250 */
251export async function getWebhook(c: Context<{ Variables: Variables }>): Promise<Response> {
252 const requestId = crypto.randomUUID();
253
316 * @returns Response with deletion confirmation
317 */
318export async function deleteWebhook(c: Context<{ Variables: Variables }>): Promise<Response> {
319 const requestId = crypto.randomUUID();
320

api_ianmenethil_comtavilyApiService.ts5 matches

@ianmenethil•Updated 21 hours ago
16} from "@/external-apis/tavilyClient.ts";
17
18function getLocalErrorMessage(error: unknown): string {
19 if (error instanceof Error) return error.message;
20 if (typeof error === "string") return error;
30 * Handles requests to the Tavily search API.
31 */
32export async function tavilySearchHandler(c: Context<{ Variables: Variables }>): Promise<Response> {
33 try {
34 const requestBody = await c.req.json();
95 * Handles requests to the Tavily extract API.
96 */
97export async function tavilyExtractHandler(
98 c: Context<{ Variables: Variables }>,
99): Promise<Response> {
162 * Handles requests to the Tavily crawl API.
163 */
164export async function tavilyCrawlHandler(c: Context<{ Variables: Variables }>): Promise<Response> {
165 try {
166 const requestBody = await c.req.json();
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();

api_ianmenethil_comswaggerService.ts2 matches

@ianmenethil•Updated 21 hours ago
98
99/**
100 * Swagger UI handler function for use in service router
101 * @param c - Hono context with Variables
102 * @returns Response with Swagger UI HTML
103 */
104export function getSwaggerUI(c: Context<{ Variables: Variables }>): Response {
105 try {
106 const html = swaggerUIService.generateSwaggerHTML("/v1/openapi.json");

api_ianmenethil_comredoclyService.ts2 matches

@ianmenethil•Updated 21 hours ago
71
72/**
73 * Redoc handler function for use in service router
74 * @param c - Hono context with Variables
75 * @returns Response with Redoc HTML
76 */
77export function getRedoc(c: Context<{ Variables: Variables }>): Response {
78 try {
79 const html = redoclyService.generateRedocHTML("/v1/openapi.json");

api_ianmenethil_comproxyService.ts4 matches

@ianmenethil•Updated 21 hours ago
58
59// Shared error message helper (ideally from a utils file)
60function getLocalErrorMessage(error: unknown): string {
61 if (error instanceof Error) return error.message;
62 if (typeof error === "string") return error;
222export const proxyService = new ProxyService();
223
224// --- Add Hono Handler Functions directly in this file ---
225
226export async function proxyGetHandler(c: Context<{ Variables: Variables }>): Promise<Response> {
227 try {
228 const targetUrl = c.req.query("url");
259}
260
261export async function proxyPostHandler(c: Context<{ Variables: Variables }>): Promise<Response> {
262 try {
263 const targetUrl = c.req.query("url");

api_ianmenethil_comopenapiService.ts5 matches

@ianmenethil•Updated 21 hours ago
15 * @returns A string representation of the error message
16 */
17function getErrorMessage(error: unknown): string {
18 if (error instanceof Error) {
19 return error.message;
115
116/**
117 * OpenAPI JSON handler function for use in service router
118 * @param c - Hono context with Variables
119 * @returns Response with OpenAPI JSON specification
120 */
121export async function getOpenAPIJSON(c: Context<{ Variables: Variables }>): Promise<Response> {
122 try {
123 const spec = await openapiSpecService.getOpenAPIJSONObject();
131
132/**
133 * OpenAPI YAML handler function for use in service router
134 * @param c - Hono context with Variables
135 * @returns Response with OpenAPI YAML specification
136 */
137export async function getOpenAPIYAML(c: Context<{ Variables: Variables }>): Promise<Response> {
138 try {
139 const yamlString = await openapiSpecService.getOpenAPIYAMLString();

api_ianmenethil_comspotifyAuthService.ts5 matches

@ianmenethil•Updated 21 hours ago
18 * Get Spotify OAuth URL - implements getSpotifyOAuthURL operation
19 */
20export function getSpotifyOAuthURL(c: Context<{ Variables: Variables }>): Promise<Response> {
21 try {
22 // Generate CSRF state token
32 });
33
34 // Generate OAuth URL using existing function
35 const authUrl = generateOAuthUrl("spotify", state);
36
75 * Handle Spotify OAuth callback - implements handleSpotifyCallback operation
76 */
77export async function handleSpotifyCallback(
78 c: Context<{ Variables: Variables }>,
79): Promise<Response> {
230 * Exchange authorization code for access tokens
231 */
232async function exchangeCodeForTokens(code: string) {
233 try {
234 const spotifyConfig = AUTH_CONFIG.oauth.providers.SPOTIFY;
290 * Fetch user information from Spotify
291 */
292async function fetchSpotifyUserInfo(accessToken: string) {
293 try {
294 const userRequest = await fetch("https://api.spotify.com/v1/me", {

api_ianmenethil_comgoogleAuthService.ts5 matches

@ianmenethil•Updated 21 hours ago
21 * Get Google OAuth URL - implements getGoogleOAuthURL operation
22 */
23export function getGoogleOAuthURL(c: Context<{ Variables: Variables }>): Promise<Response> {
24 try {
25 // Generate CSRF state token
35 });
36
37 // Generate OAuth URL using existing function
38 const authUrl = generateOAuthUrl("google", state);
39
78 * Handle Google OAuth callback - implements handleGoogleCallback operation
79 */
80export async function handleGoogleCallback(
81 c: Context<{ Variables: Variables }>,
82): Promise<Response> {
231 * Exchange authorization code for access tokens
232 */
233async function exchangeCodeForTokens(code: string) {
234 try {
235 const googleConfig = AUTH_CONFIG.oauth.providers.GOOGLE;
279 * Fetch user information from Google
280 */
281async function fetchGoogleUserInfo(accessToken: string) {
282 try {
283 const googleConfig = AUTH_CONFIG.oauth.providers.GOOGLE;
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.