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=180&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 14776 results for "api"(1740ms)

FloodAppindex.ts4 matches

@excel•Updated 1 week ago
29});
30
31// API routes
32app.route("/api/auth", auth);
33app.route("/api/locations", locations);
34
35// Check for floods for a specific user
36app.post("/api/check-floods", async (c) => {
37 try {
38 const { userId } = await c.req.json();

FloodAppfloodPredictor.ts4 matches

@excel•Updated 1 week ago
5const RAINFALL_THRESHOLD = 50; // Adjust based on local conditions
6
7// Open-Meteo API for weather forecasts
8const WEATHER_API_URL = "https://api.open-meteo.com/v1/forecast";
9
10interface WeatherForecast {
17// Get weather forecast for a location
18async function getWeatherForecast(latitude: number, longitude: number): Promise<WeatherForecast> {
19 const url = new URL(WEATHER_API_URL);
20 url.searchParams.append("latitude", latitude.toString());
21 url.searchParams.append("longitude", longitude.toString());
27
28 if (!response.ok) {
29 throw new Error(`Weather API error: ${response.statusText}`);
30 }
31

FloodAppREADME.md2 matches

@excel•Updated 1 week ago
12## Project Structure
13
14- `/backend` - Server-side code and API endpoints
15- `/frontend` - User interface and client-side code
16- `/shared` - Shared types and utilities
21- Database: SQLite
22- Frontend: HTML, JavaScript, Tailwind CSS
23- Weather Data: Open-Meteo API
24- Notifications: Email
25

JobAppindex.ts5 matches

@excel•Updated 1 week ago
56setupDatabase().catch(console.error);
57
58// API Routes
59
60// Get all job postings
61app.get("/api/jobs", async (c) => {
62 const jobs = await sqlite.execute(`SELECT * FROM ${JOBS_TABLE} ORDER BY created_at DESC`);
63 return c.json(jobs);
65
66// Create a new job posting
67app.post("/api/jobs", async (c) => {
68 const body = await c.req.json();
69 const { title, description, company, location, salary, contact } = body;
85
86// Get chat messages
87app.get("/api/chat", async (c) => {
88 const messages = await sqlite.execute(
89 `SELECT * FROM ${CHAT_TABLE} ORDER BY created_at DESC LIMIT 100`
93
94// Post a chat message
95app.post("/api/chat", async (c) => {
96 const body = await c.req.json();
97 const { username, message } = body;

GodinoMawabankAuthContext.tsx11 matches

@Godino•Updated 1 week ago
2import React, { createContext, useContext, useState, useEffect } from "https://esm.sh/react@18.2.0";
3import { useNavigate } from "https://esm.sh/react-router-dom@6.16.0?deps=react@18.2.0";
4import { User, AuthResponse, ApiResponse } from "../../../shared/types";
5
6interface AuthContextType {
8 isAuthenticated: boolean;
9 isLoading: boolean;
10 login: (email: string, password: string) => Promise<ApiResponse<AuthResponse>>;
11 register: (formData: any) => Promise<ApiResponse<AuthResponse>>;
12 logout: () => void;
13 checkAuth: () => Promise<boolean>;
42
43 try {
44 const response = await fetch("/api/auth/me", {
45 headers: {
46 Authorization: `Bearer ${token}`
52 }
53
54 const data: ApiResponse<User> = await response.json();
55
56 if (data.success && data.data) {
70 };
71
72 const login = async (email: string, password: string): Promise<ApiResponse<AuthResponse>> => {
73 try {
74 const response = await fetch("/api/auth/login", {
75 method: "POST",
76 headers: {
80 });
81
82 const data: ApiResponse<AuthResponse> = await response.json();
83
84 if (data.success && data.data) {
98 };
99
100 const register = async (formData: any): Promise<ApiResponse<AuthResponse>> => {
101 try {
102 const response = await fetch("/api/auth/register", {
103 method: "POST",
104 headers: {
108 });
109
110 const data: ApiResponse<AuthResponse> = await response.json();
111
112 if (data.success && data.data) {

GodinoMawabankindex.ts4 matches

@Godino•Updated 1 week ago
21app.use("*", cors());
22
23// Mount API routes
24app.route("/api/auth", authRoutes);
25app.route("/api/kyc", kycRoutes);
26app.route("/api/accounts", accountRoutes);
27
28// Mount static routes (should be last)

GodinoMawabankstatic.ts1 match

@Godino•Updated 1 week ago
37
38// Serve KYC document images
39staticRoutes.get("/api/images/:key", async (c) => {
40 try {
41 const key = c.req.param("key");

GodinoMawabankaccounts.ts13 matches

@Godino•Updated 1 week ago
7 getUserById
8} from "../database/queries";
9import { createApiResponse, generateAccountNumber } from "../../shared/utils";
10import {
11 Account,
34 const user = await getUserById(userId);
35 if (!user) {
36 return c.json(createApiResponse(false, undefined, "User not found"), 404);
37 }
38
39 if (user.kycStatus !== KYCStatus.APPROVED) {
40 return c.json(
41 createApiResponse(
42 false,
43 undefined,
52 if (existingAccounts.length > 0) {
53 return c.json(
54 createApiResponse<AccountGenerationResponse>(
55 true,
56 { accounts: existingAccounts },
114 // Return the generated accounts
115 return c.json(
116 createApiResponse<AccountGenerationResponse>(
117 true,
118 { accounts: generatedAccounts }
122 } catch (error) {
123 console.error("Account generation error:", error);
124 return c.json(createApiResponse(false, undefined, "Account generation failed"), 500);
125 }
126});
135 const accounts = await getAccountsByUserId(userId);
136
137 return c.json(createApiResponse(true, { accounts }));
138 } catch (error) {
139 console.error("Get accounts error:", error);
140 return c.json(createApiResponse(false, undefined, "Failed to get accounts"), 500);
141 }
142});
150
151 if (isNaN(accountId)) {
152 return c.json(createApiResponse(false, undefined, "Invalid account ID"), 400);
153 }
154
157
158 if (!account) {
159 return c.json(createApiResponse(false, undefined, "Account not found"), 404);
160 }
161
162 // Check if account belongs to user
163 if (account.userId !== userId) {
164 return c.json(createApiResponse(false, undefined, "Unauthorized"), 403);
165 }
166
167 return c.json(createApiResponse(true, { account }));
168 } catch (error) {
169 console.error("Get account error:", error);
170 return c.json(createApiResponse(false, undefined, "Failed to get account"), 500);
171 }
172});

GodinoMawabankkyc.ts15 matches

@Godino•Updated 1 week ago
3import { blob } from "https://esm.town/v/std/blob";
4import { createKYCData, getKYCDataByUserId, updateKYCStatus, updateUserKYCStatus } from "../database/queries";
5import { createApiResponse } from "../../shared/utils";
6import { DocumentType, KYCData, KYCStatus, KYCSubmissionResponse } from "../../shared/types";
7
27 !data.country || !data.postalCode || !data.documentType ||
28 !data.documentId || !data.documentImageUrl || !data.selfieImageUrl) {
29 return c.json(createApiResponse(false, undefined, "All fields are required"), 400);
30 }
31
34 if (existingKYC) {
35 return c.json(
36 createApiResponse(false, undefined, "KYC already submitted. Current status: " + existingKYC.status),
37 409
38 );
53 // Return success response
54 return c.json(
55 createApiResponse<KYCSubmissionResponse>(
56 true,
57 {
64 } catch (error) {
65 console.error("KYC submission error:", error);
66 return c.json(createApiResponse(false, undefined, "KYC submission failed"), 500);
67 }
68});
79
80 if (!file || !documentType) {
81 return c.json(createApiResponse(false, undefined, "Document file and type are required"), 400);
82 }
83
84 // Validate document type
85 if (!Object.values(DocumentType).includes(documentType as DocumentType)) {
86 return c.json(createApiResponse(false, undefined, "Invalid document type"), 400);
87 }
88
97 // Return the blob key as the URL
98 return c.json(
99 createApiResponse(true, { documentUrl: blobKey }),
100 200
101 );
102 } catch (error) {
103 console.error("Document upload error:", error);
104 return c.json(createApiResponse(false, undefined, "Document upload failed"), 500);
105 }
106});
116
117 if (!file) {
118 return c.json(createApiResponse(false, undefined, "Selfie file is required"), 400);
119 }
120
129 // Return the blob key as the URL
130 return c.json(
131 createApiResponse(true, { selfieUrl: blobKey }),
132 200
133 );
134 } catch (error) {
135 console.error("Selfie upload error:", error);
136 return c.json(createApiResponse(false, undefined, "Selfie upload failed"), 500);
137 }
138});
148 if (!kycData) {
149 return c.json(
150 createApiResponse(true, { status: KYCStatus.NOT_STARTED, message: "KYC not started" })
151 );
152 }
154 // Return KYC status
155 return c.json(
156 createApiResponse(true, {
157 status: kycData.status,
158 message: getKYCStatusMessage(kycData.status),
163 } catch (error) {
164 console.error("Get KYC status error:", error);
165 return c.json(createApiResponse(false, undefined, "Failed to get KYC status"), 500);
166 }
167});

GodinoMawabankauth.ts16 matches

@Godino•Updated 1 week ago
2import { jwt } from "https://esm.sh/hono@3.11.7/jwt";
3import { createUser, getUserByEmail, getUserPasswordHash } from "../database/queries";
4import { createApiResponse, isStrongPassword, isValidEmail } from "../../shared/utils";
5import { AuthResponse, User, UserCredentials, UserRegistration } from "../../shared/types";
6
25 // Validate input
26 if (!data.email || !data.password || !data.firstName || !data.lastName || !data.phone) {
27 return c.json(createApiResponse(false, undefined, "All fields are required"), 400);
28 }
29
30 if (!isValidEmail(data.email)) {
31 return c.json(createApiResponse(false, undefined, "Invalid email format"), 400);
32 }
33
34 if (!isStrongPassword(data.password)) {
35 return c.json(
36 createApiResponse(
37 false,
38 undefined,
46 const existingUser = await getUserByEmail(data.email);
47 if (existingUser) {
48 return c.json(createApiResponse(false, undefined, "Email already registered"), 409);
49 }
50
66
67 // Return user data and token
68 return c.json(createApiResponse<AuthResponse>(true, { user, token }), 201);
69 } catch (error) {
70 console.error("Registration error:", error);
71 return c.json(createApiResponse(false, undefined, "Registration failed"), 500);
72 }
73});
80 // Validate input
81 if (!email || !password) {
82 return c.json(createApiResponse(false, undefined, "Email and password are required"), 400);
83 }
84
86 const user = await getUserByEmail(email);
87 if (!user) {
88 return c.json(createApiResponse(false, undefined, "Invalid credentials"), 401);
89 }
90
92 const storedHash = await getUserPasswordHash(email);
93 if (!storedHash) {
94 return c.json(createApiResponse(false, undefined, "Invalid credentials"), 401);
95 }
96
104 // Compare hashes
105 if (passwordHash !== storedHash) {
106 return c.json(createApiResponse(false, undefined, "Invalid credentials"), 401);
107 }
108
111
112 // Return user data and token
113 return c.json(createApiResponse<AuthResponse>(true, { user, token }));
114 } catch (error) {
115 console.error("Login error:", error);
116 return c.json(createApiResponse(false, undefined, "Login failed"), 500);
117 }
118});
127 const user = await getUserByEmail(payload.email);
128 if (!user) {
129 return c.json(createApiResponse(false, undefined, "User not found"), 404);
130 }
131
132 return c.json(createApiResponse<User>(true, user));
133 } catch (error) {
134 console.error("Get user error:", error);
135 return c.json(createApiResponse(false, undefined, "Failed to get user data"), 500);
136 }
137});

book-lookup-notion6 file matches

@nucky•Updated 12 hours ago
use google book api to look up bibliographic metadata elements

openai_api_project_Pauline2 file matches

@Paulineseemann•Updated 12 hours ago
Kapil01
apiv1