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=212&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 18269 results for "api"(1306ms)

untitled-3191api.ts40 matches

@Lyte•Updated 5 days ago
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import type { ApiResponse } from "../../shared/types.ts";
3import {
4 getSettings,
12} from "../database/queries.ts";
13
14const api = new Hono();
15
16// Get current settings
17api.get("/settings", async (c) => {
18 try {
19 const settings = await getSettings();
20 const response: ApiResponse = {
21 success: true,
22 data: settings
25 } catch (error) {
26 console.error("Error getting settings:", error);
27 const response: ApiResponse = {
28 success: false,
29 error: "Failed to get settings"
34
35// Update settings
36api.post("/settings", async (c) => {
37 try {
38 const body = await c.req.json();
39 await updateSettings(body);
40
41 const response: ApiResponse = {
42 success: true,
43 data: { message: "Settings updated successfully" }
46 } catch (error) {
47 console.error("Error updating settings:", error);
48 const response: ApiResponse = {
49 success: false,
50 error: "Failed to update settings"
55
56// Get keyword responses
57api.get("/keywords", async (c) => {
58 try {
59 const keywords = await getKeywordResponses();
60 const response: ApiResponse = {
61 success: true,
62 data: keywords
65 } catch (error) {
66 console.error("Error getting keywords:", error);
67 const response: ApiResponse = {
68 success: false,
69 error: "Failed to get keywords"
74
75// Add keyword response
76api.post("/keywords", async (c) => {
77 try {
78 const { keyword, response, exact_match } = await c.req.json();
79
80 if (!keyword || !response) {
81 const apiResponse: ApiResponse = {
82 success: false,
83 error: "Keyword and response are required"
84 };
85 return c.json(apiResponse, 400);
86 }
87
88 await addKeywordResponse(keyword, response, exact_match || false);
89
90 const apiResponse: ApiResponse = {
91 success: true,
92 data: { message: "Keyword response added successfully" }
93 };
94 return c.json(apiResponse);
95 } catch (error) {
96 console.error("Error adding keyword:", error);
97 const response: ApiResponse = {
98 success: false,
99 error: "Failed to add keyword response"
104
105// Update keyword response
106api.put("/keywords/:id", async (c) => {
107 try {
108 const id = parseInt(c.req.param("id"));
110
111 if (!keyword || !response) {
112 const apiResponse: ApiResponse = {
113 success: false,
114 error: "Keyword and response are required"
115 };
116 return c.json(apiResponse, 400);
117 }
118
119 await updateKeywordResponse(id, keyword, response, exact_match || false);
120
121 const apiResponse: ApiResponse = {
122 success: true,
123 data: { message: "Keyword response updated successfully" }
124 };
125 return c.json(apiResponse);
126 } catch (error) {
127 console.error("Error updating keyword:", error);
128 const response: ApiResponse = {
129 success: false,
130 error: "Failed to update keyword response"
135
136// Delete keyword response
137api.delete("/keywords/:id", async (c) => {
138 try {
139 const id = parseInt(c.req.param("id"));
140 await deleteKeywordResponse(id);
141
142 const response: ApiResponse = {
143 success: true,
144 data: { message: "Keyword response deleted successfully" }
147 } catch (error) {
148 console.error("Error deleting keyword:", error);
149 const response: ApiResponse = {
150 success: false,
151 error: "Failed to delete keyword response"
156
157// Get message history
158api.get("/messages", async (c) => {
159 try {
160 const limit = parseInt(c.req.query("limit") || "50");
162
163 const messages = await getMessageHistory(limit, offset);
164 const response: ApiResponse = {
165 success: true,
166 data: messages
169 } catch (error) {
170 console.error("Error getting messages:", error);
171 const response: ApiResponse = {
172 success: false,
173 error: "Failed to get message history"
178
179// Get dashboard statistics
180api.get("/stats", async (c) => {
181 try {
182 const stats = await getDashboardStats();
183 const response: ApiResponse = {
184 success: true,
185 data: stats
188 } catch (error) {
189 console.error("Error getting stats:", error);
190 const response: ApiResponse = {
191 success: false,
192 error: "Failed to get dashboard statistics"
197
198// Test endpoint to send a test message
199api.post("/test-message", async (c) => {
200 try {
201 const { to, message } = await c.req.json();
202
203 if (!to || !message) {
204 const response: ApiResponse = {
205 success: false,
206 error: "Phone number and message are required"
213
214 if (!accessToken || !phoneNumberId) {
215 const response: ApiResponse = {
216 success: false,
217 error: "WhatsApp API credentials not configured"
218 };
219 return c.json(response, 500);
241 if (whatsappResponse.ok) {
242 const result = await whatsappResponse.json();
243 const response: ApiResponse = {
244 success: true,
245 data: { message: "Test message sent successfully", result }
248 } else {
249 const error = await whatsappResponse.text();
250 const response: ApiResponse = {
251 success: false,
252 error: `Failed to send test message: ${error}`
256 } catch (error) {
257 console.error("Error sending test message:", error);
258 const response: ApiResponse = {
259 success: false,
260 error: "Failed to send test message"
264});
265
266export default api;

untitled-5183JobBoard.tsx1 match

@nobody•Updated 5 days ago
16 try {
17 setLoading(true);
18 const response = await fetch('/api/jobs');
19 if (!response.ok) throw new Error('Failed to fetch jobs');
20 const jobsData = await response.json();

untitled-3191webhook.ts1 match

@Lyte•Updated 5 days ago
135
136 if (!accessToken || !phoneNumberId) {
137 console.error("Missing WhatsApp API credentials");
138 return false;
139 }

Freelancingindex.ts5 matches

@Sandra_Ozumba•Updated 5 days ago
21}
22
23// API routes
24app.route("/api/auth", authRoutes);
25app.route("/api/users", userRoutes);
26app.route("/api/jobs", jobRoutes);
27app.route("/api/chat", chatRoutes);
28
29// Static file serving and main app
23 const fetchProperties = async () => {
24 try {
25 const response = await fetch('/api/properties');
26 if (response.ok) {
27 const data = await response.json();

FreelancingFreelancerDirectory.tsx3 matches

@Sandra_Ozumba•Updated 5 days ago
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import React, { useState, useEffect } from "https://esm.sh/react@18.2.0";
3import type { User, ApiResponse } from "../../shared/types.ts";
4
5export default function FreelancerDirectory() {
16 const fetchFreelancers = async () => {
17 try {
18 const response = await fetch('/api/users?limit=50');
19 const data: ApiResponse<User[]> = await response.json();
20
21 if (data.success && data.data) {

FreelancingUserProfile.tsx3 matches

@Sandra_Ozumba•Updated 5 days ago
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import React, { useState, useEffect } from "https://esm.sh/react@18.2.0";
3import type { User, ApiResponse } from "../../shared/types.ts";
4
5interface UserProfileProps {
45 const skills = formData.skills.split(',').map(s => s.trim()).filter(s => s);
46
47 const response = await fetch(`/api/users/${user.id}`, {
48 method: 'PUT',
49 headers: {
58 });
59
60 const data: ApiResponse<User> = await response.json();
61
62 if (data.success && data.data) {
19 const fetchProperties = async () => {
20 try {
21 const response = await fetch(`/api/gardens/${garden.id}/properties`);
22 if (response.ok) {
23 const data = await response.json();
297 <div className="space-y-4 text-gray-600">
298 <p>
299 {garden.location} is one of the most prestigious and rapidly developing areas in Enugu State.
300 Known for its peaceful environment and excellent infrastructure, it offers residents easy
301 access to major amenities and transportation networks.

Jotterindex.ts2 matches

@zoebee•Updated 5 days ago
15await createNotesTable();
16
17// API routes
18app.route("/api/notes", notesRoutes);
19
20// Serve static files

untitled-3191types.ts1 match

@Lyte•Updated 5 days ago
67}
68
69export interface ApiResponse<T = any> {
70 success: boolean;
71 data?: T;

github-api1 file match

@cricks_unmixed4u•Updated 6 hours ago

beeminder-api4 file matches

@cricks_unmixed4u•Updated 7 hours ago
Kapil01
apiv1