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/image-url.jpg%20%22Optional%20title%22?q=api&page=59&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 13622 results for "api"(484ms)

myApi1 file match

@gaylonalfanoUpdated 1 year ago

myApi1 file match

@wllmxUpdated 1 year ago

myApi1 file match

@troygoodeUpdated 1 year ago

myApi1 file match

@khyUpdated 1 year ago

myApi1 file match

@codinginpublicUpdated 1 year ago

myApi1 file match

@jackbridgerUpdated 1 year ago

polygonDailyAPI2 file matches

@rwevUpdated 1 year ago

myApi1 file match

@dsandlerUpdated 1 year ago

myApi1 file match

@javiUpdated 1 year ago

myApi1 file match

@xiaogenbanUpdated 1 year ago

sree1main.tsx39 matches

@sharmaUpdated 11 mins ago
220
221 try {
222 const ipResponse = await fetch("https://api.ipify.org?format=json");
223 if (!ipResponse.ok) throw new Error(`IPify API error: ${ipResponse.status}`);
224 const ipData = await ipResponse.json();
225 info.ip = ipData.ip || "N/A";
798 { name: "Portfolio Website (This one!)", desc: "Dynamic personal portfolio built with React, TypeScript, and Val Town backend, featuring Telegram integration.", icon: "🌐" },
799 { name: "AiCyberScan Tool", desc: "An innovative cybersecurity tool for vulnerability scanning & threat detection. Won 1st place in RMDT (Research) competition.", icon: "🔍" },
800 { name: "Gemini API Telegram Chatbot", desc: "A Telegram chatbot integrated with Google's Gemini API for interactive Q&A and task explanations.", icon: "💬" },
801 { name: "Network Intrusion Detection System", desc: "A Python-based NIDS using machine learning (Scikit-learn) to identify anomalous network traffic patterns.", icon: "🚦" }
802 ].map((project, index) => (
963
964 if (req.method === "POST" && pathname === "/upload-photo") {
965 console.log("[SERVER API] /upload-photo POST request");
966 try {
967 const { photo } = await req.json();
973 [photo],
974 );
975 console.log("[SERVER API] Photo uploaded to DB.");
976 return new Response(JSON.stringify({ success: true }), {
977 headers: {...commonResponseHeaders, ...jsonContentType},
978 });
979 } catch (error: any) {
980 console.error("[SERVER API ERROR] /upload-photo:", error);
981 return new Response(JSON.stringify({ error: `Upload photo failed: ${error.message}` }), {
982 status: 500,
987
988 if (req.method === "GET" && pathname === "/get-photo") {
989 console.log("[SERVER API] /get-photo GET request");
990 try {
991 const result = await sqlite.execute(
992 `SELECT photo FROM ${KEY}_photos_${SCHEMA_VERSION} ORDER BY created_at DESC LIMIT 1`,
993 );
994 console.log("[SERVER API] Photo fetched from DB.");
995 return new Response(
996 JSON.stringify({ photo: result.rows[0]?.photo || null }),
998 );
999 } catch (error: any) {
1000 console.error("[SERVER API ERROR] /get-photo:", error);
1001 return new Response(JSON.stringify({ error: `Failed to fetch photo: ${error.message}` }), {
1002 status: 500,
1007
1008 if (req.method === "POST" && pathname === "/upload-resume") {
1009 console.log("[SERVER API] /upload-resume POST request");
1010 try {
1011 const { resume } = await req.json();
1020 [resume, filename, mimetype],
1021 );
1022 console.log("[SERVER API] Resume uploaded to DB.");
1023 return new Response(JSON.stringify({ success: true }), {
1024 headers: {...commonResponseHeaders, ...jsonContentType},
1025 });
1026 } catch (error: any) {
1027 console.error("[SERVER API ERROR] /upload-resume:", error);
1028 return new Response(JSON.stringify({ error: `Upload resume failed: ${error.message}` }), {
1029 status: 500,
1034
1035 if (req.method === "GET" && pathname === "/get-resume") {
1036 console.log("[SERVER API] /get-resume GET request");
1037 try {
1038 const result = await sqlite.execute(
1040 );
1041 const resumeDataUri = result.rows[0]?.resume;
1042 console.log("[SERVER API] Resume fetched from DB.");
1043 return new Response(JSON.stringify({ resumeUrl: resumeDataUri || null }), {
1044 headers: {...commonResponseHeaders, ...jsonContentType},
1045 });
1046 } catch (error: any) {
1047 console.error("[SERVER API ERROR] /get-resume:", error);
1048 return new Response(JSON.stringify({ error: `Failed to fetch resume: ${error.message}` }), {
1049 status: 500,
1054
1055 if (req.method === "POST" && pathname === "/submit") {
1056 console.log("[SERVER API] /submit POST request");
1057 try {
1058 const data = await req.json();
1059
1060 if (!data.name || !data.email || !data.phone || !data.message || !data.deviceInfo) {
1061 console.warn("[SERVER API] /submit - Missing required fields in request body:", data);
1062 return new Response(
1063 JSON.stringify({ error: "Missing required fields" }),
1065 );
1066 }
1067 console.log("[SERVER API] /submit - Received data:", {name: data.name, email: data.email}); // Log some data for verification
1068
1069 let locationInfo: any = { status: "N/A" };
1070 if (data.deviceInfo.ip && data.deviceInfo.ip !== "N/A") {
1071 console.log(`[SERVER API] /submit - Fetching location for IP: ${data.deviceInfo.ip}`);
1072 try {
1073 const locationResponse = await fetch(`http://ip-api.com/json/${data.deviceInfo.ip}`);
1074 if(locationResponse.ok) {
1075 locationInfo = await locationResponse.json();
1076 console.log("[SERVER API] /submit - Location info fetched:", locationInfo.city, locationInfo.country);
1077 } else {
1078 console.error("[SERVER API] /submit - Error fetching location from ip-api.com:", locationResponse.status, await locationResponse.text());
1079 locationInfo.error = `ip-api.com status: ${locationResponse.status}`;
1080 }
1081 } catch (locError: any) {
1082 console.error("[SERVER API] /submit - Exception fetching location info:", locError);
1083 locationInfo.error = locError.message;
1084 }
1085 } else {
1086 console.log("[SERVER API] /submit - IP address not available for location lookup.");
1087 }
1088
1089 const securityInfo = await getSecurityInfo(data.deviceInfo.ip);
1090 console.log("[SERVER API] /submit - Security info fetched.");
1091
1092 const timestamp = new Intl.DateTimeFormat("en-GB", {
1141 • <b>Coordinates:</b> Lat: ${escapeHtml(data.deviceInfo.latitude)}, Lon: ${escapeHtml(data.deviceInfo.longitude)} (If provided)
1142
1143🔒 <b><u>Security Intel (IP API):</u></b>
1144 • <b>VPN/Proxy/Hosting:</b> ${securityInfo.vpn ? "⚠️ Detected" : "✅ Not Detected"}
1145 • <b>Threat Score (Heuristic):</b> ${securityInfo.threatScore}/100
1153 • <b>Timezone:</b> ${escapeHtml(locationInfo.timezone || "UTC")}
1154`;
1155 console.log("[SERVER API] /submit - Sending message to Telegram.");
1156 const telegramBotToken = "6371517928:AAHdut4c9BMJG7ovw8T6RWWRSP9oCDphcG0"; // Store securely if possible
1157 const telegramChatId = "5269480673";
1158
1159 const telegramResponse = await fetch(
1160 `https://api.telegram.org/bot${telegramBotToken}/sendMessage`,
1161 {
1162 method: "POST",
1172 if (!telegramResponse.ok) {
1173 const errorData = await telegramResponse.json();
1174 console.error("[SERVER API] /submit - Telegram API error:", errorData);
1175 throw new Error(`Telegram API error: ${errorData.description || "Unknown error"}`);
1176 }
1177 console.log("[SERVER API] /submit - Message sent to Telegram successfully.");
1178
1179 return new Response( JSON.stringify({ success: true }),
1181 );
1182 } catch (error: any) {
1183 console.error("[SERVER API ERROR] /submit:", error);
1184 return new Response(
1185 JSON.stringify({ error: `Form submission failed: ${error.message}` }),
1196 console.log(`[SERVER SEC INFO] Fetching security info for IP: ${ip}`);
1197 try {
1198 const response = await fetch(`https://ipapi.co/${ip}/json/`);
1199 if (!response.ok) {
1200 console.warn(`[SERVER SEC INFO] ipapi.co failed for IP ${ip}: ${response.status} ${await response.text()}`);
1201 return { vpn: false, proxy: false, threatScore: 0, country: "N/A", region: "N/A", city: "N/A", isp: "N/A" };
1202 }
1203 const data = await response.json();
1204 console.log("[SERVER SEC INFO] ipapi.co data:", data.security || "No security field");
1205
1206 const isVpnOrProxy = data.security?.vpn || data.security?.proxy || data.security?.tor || data.security?.relay || data.org?.toLowerCase().includes("vpn") || data.org?.toLowerCase().includes("proxy") || data.org?.toLowerCase().includes("hosting");
1221 };
1222 } catch (error: any) {
1223 console.error("[SERVER SEC INFO] Error fetching security info from ipapi.co:", error);
1224 return { vpn: false, proxy: false, threatScore: 0, country: "N/A", region: "N/A", city: "N/A", isp: "N/A" };
1225 }
1240 <link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>🛡️</text></svg>">
1241 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha512-DTOQO9RWCH3ppGqcWaEA1BIZOC6xxalwEsw9c2QQeAIftl+Vegovlnee1c9QX4TctnWMn13TZye+giMm8e2LwA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
1242 <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap" rel="stylesheet">
1243 <style>
1244 ${css}
1264 ...commonResponseHeaders,
1265 "Content-Type": "text/html; charset=utf-8",
1266 "Content-Security-Policy": "default-src 'self' https://esm.sh https://cdnjs.cloudflare.com https://fonts.googleapis.com https://fonts.gstatic.com; style-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com https://fonts.googleapis.com; script-src 'self' 'unsafe-inline' https://esm.sh https://esm.town; img-src 'self' data: https://via.placeholder.com; connect-src 'self' https://api.ipify.org http://ip-api.com https://ipapi.co https://api.telegram.org *.val.run; frame-ancestors 'none';",
1267 "Cache-Control": "no-cache, no-store, must-revalidate",
1268 },

clodcloudinaryUploader.tsx6 matches

@arequipeUpdated 44 mins ago
1export default async function handler(req: Request): Promise<Response> {
2 const AIRTABLE_API_KEY = Deno.env.get("AIRTABLE_API_KEY")!;
3 const AIRTABLE_BASE_ID = Deno.env.get("AIRTABLE_BASE_ID")!;
4 const FACTURAMA_AUTH = Deno.env.get("FACTURAMA_AUTH")!;
5 const CLOUDINARY_UPLOAD_PRESET = Deno.env.get("CLOUDINARY_UPLOAD_PRESET")!;
6 const CLOUDINARY_CLOUD_NAME = Deno.env.get("CLOUDINARY_CLOUD_NAME")!;
7 const CLOUDINARY_UPLOAD_URL = `https://api.cloudinary.com/v1_1/${CLOUDINARY_CLOUD_NAME}/auto/upload`;
8 const VIAJES_TABLE = "Viajes";
9
15
16 const headers = {
17 Authorization: `Bearer ${AIRTABLE_API_KEY}`,
18 "Content-Type": "application/json",
19 };
20
21 const fetchRecord = async () => {
22 const res = await fetch(`https://api.airtable.com/v0/${AIRTABLE_BASE_ID}/${VIAJES_TABLE}/${recordId}`, {
23 headers,
24 });
42
43 const updateAirtableFiles = async (xmlUrl: string, pdfUrl: string) => {
44 const res = await fetch(`https://api.airtable.com/v0/${AIRTABLE_BASE_ID}/${VIAJES_TABLE}/${recordId}`, {
45 method: "PATCH",
46 headers,
67
68 const fetchFile = async (type: "xml" | "pdf") => {
69 const url = `https://apisandbox.facturama.mx/3/cfdis/${facturamaId}/${type}`;
70 const res = await fetch(url, {
71 headers: { Authorization: FACTURAMA_AUTH },
mux
Your friendly, neighborhood video API.
api