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=210&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 18222 results for "api"(1134ms)

untitled-5321ImageGenerator.tsx1 match

@Lyte•Updated 5 days ago
29 };
30
31 const response = await fetch('/api/generate-image', {
32 method: 'POST',
33 headers: {

untitled-5321ChatInterface.tsx1 match

@Lyte•Updated 5 days ago
36 };
37
38 const response = await fetch('/api/chat', {
39 method: 'POST',
40 headers: {

jeffiutils.ts2 matches

@jeffy•Updated 5 days ago
123
124export function getAvatarUrl(name: string): string {
125 return `https://ui-avatars.com/api/?name=${encodeURIComponent(name)}&background=6366f1&color=fff&size=40`;
126}
127
131}
132
133export function capitalizeFirst(text: string): string {
134 return text.charAt(0).toUpperCase() + text.slice(1);
135}

jeffitypes.ts1 match

@jeffy•Updated 5 days ago
128}
129
130export interface ApiResponse<T = any> {
131 success: boolean;
132 data?: T;

jeffiREADME.md7 matches

@jeffy•Updated 5 days ago
53
54## Getting Started
551. The backend serves the frontend and API endpoints
562. SQLite database is automatically initialized
573. Sample data is seeded on first run
584. Access the site at the HTTP endpoint URL
59
60## API Endpoints
61- `GET /` - Homepage
62- `GET /api/products` - Product listing with filters
63- `GET /api/products/:id` - Product details
64- `POST /api/auth/login` - User authentication
65- `POST /api/cart` - Cart operations
66- `POST /api/orders` - Order placement
67- `GET /admin/*` - Admin dashboard (protected)

jeffiproducts.ts20 matches

@jeffy•Updated 5 days ago
9 getProductReviews
10} from "../database/queries.ts";
11import type { ProductFilters, ProductSort, PaginationParams, ApiResponse } from "../../shared/types.ts";
12
13const products = new Hono();
42 const result = await getProducts(filters, sort, pagination);
43
44 return c.json<ApiResponse>({
45 success: true,
46 data: result
48 } catch (error) {
49 console.error("Get products error:", error);
50 return c.json<ApiResponse>({
51 success: false,
52 error: "Failed to fetch products"
61 const featuredProducts = await getFeaturedProducts(limit);
62
63 return c.json<ApiResponse>({
64 success: true,
65 data: featuredProducts
67 } catch (error) {
68 console.error("Get featured products error:", error);
69 return c.json<ApiResponse>({
70 success: false,
71 error: "Failed to fetch featured products"
80
81 if (isNaN(id)) {
82 return c.json<ApiResponse>({
83 success: false,
84 error: "Invalid product ID"
89
90 if (!product) {
91 return c.json<ApiResponse>({
92 success: false,
93 error: "Product not found"
95 }
96
97 return c.json<ApiResponse>({
98 success: true,
99 data: product
101 } catch (error) {
102 console.error("Get product error:", error);
103 return c.json<ApiResponse>({
104 success: false,
105 error: "Failed to fetch product"
115
116 if (isNaN(id)) {
117 return c.json<ApiResponse>({
118 success: false,
119 error: "Invalid product ID"
123 const relatedProducts = await getRelatedProducts(id, limit);
124
125 return c.json<ApiResponse>({
126 success: true,
127 data: relatedProducts
129 } catch (error) {
130 console.error("Get related products error:", error);
131 return c.json<ApiResponse>({
132 success: false,
133 error: "Failed to fetch related products"
142
143 if (isNaN(id)) {
144 return c.json<ApiResponse>({
145 success: false,
146 error: "Invalid product ID"
150 const reviews = await getProductReviews(id);
151
152 return c.json<ApiResponse>({
153 success: true,
154 data: reviews
156 } catch (error) {
157 console.error("Get product reviews error:", error);
158 return c.json<ApiResponse>({
159 success: false,
160 error: "Failed to fetch product reviews"
168 const categories = await getCategories();
169
170 return c.json<ApiResponse>({
171 success: true,
172 data: categories
174 } catch (error) {
175 console.error("Get categories error:", error);
176 return c.json<ApiResponse>({
177 success: false,
178 error: "Failed to fetch categories"
188
189 if (!category) {
190 return c.json<ApiResponse>({
191 success: false,
192 error: "Category not found"
194 }
195
196 return c.json<ApiResponse>({
197 success: true,
198 data: category
200 } catch (error) {
201 console.error("Get category error:", error);
202 return c.json<ApiResponse>({
203 success: false,
204 error: "Failed to fetch category"

jeffiProductCard.tsx2 matches

@jeffy•Updated 5 days ago
34
35 try {
36 const response = await fetch('/api/cart/add', {
37 method: 'POST',
38 headers: {
56
57 // Refresh cart
58 const cartResponse = await fetch('/api/cart', {
59 credentials: 'include'
60 });

jeffiorders.ts12 matches

@jeffy•Updated 5 days ago
8} from "../database/queries.ts";
9import { authMiddleware } from "./auth.ts";
10import type { CheckoutRequest, ApiResponse } from "../../shared/types.ts";
11
12const orders = new Hono();
24 // Validate required fields
25 if (!shippingAddress || !billingAddress || !paymentMethod) {
26 return c.json<ApiResponse>({
27 success: false,
28 error: "Missing required checkout information"
34
35 if (cartItems.length === 0) {
36 return c.json<ApiResponse>({
37 success: false,
38 error: "Cart is empty"
69 await clearCart(user.userId);
70
71 return c.json<ApiResponse>({
72 success: true,
73 data: order,
76 } catch (error) {
77 console.error("Create order error:", error);
78 return c.json<ApiResponse>({
79 success: false,
80 error: "Failed to create order"
89 const userOrders = await getUserOrders(user.userId);
90
91 return c.json<ApiResponse>({
92 success: true,
93 data: userOrders
95 } catch (error) {
96 console.error("Get user orders error:", error);
97 return c.json<ApiResponse>({
98 success: false,
99 error: "Failed to fetch orders"
109
110 if (isNaN(orderId)) {
111 return c.json<ApiResponse>({
112 success: false,
113 error: "Invalid order ID"
119 // Check if user owns this order (or is admin)
120 if (order.userId !== user.userId && !user.isAdmin) {
121 return c.json<ApiResponse>({
122 success: false,
123 error: "Access denied"
125 }
126
127 return c.json<ApiResponse>({
128 success: true,
129 data: order
133
134 if (error.message === "Order not found") {
135 return c.json<ApiResponse>({
136 success: false,
137 error: "Order not found"
139 }
140
141 return c.json<ApiResponse>({
142 success: false,
143 error: "Failed to fetch order"

jeffiindex.ts5 matches

@jeffy•Updated 5 days ago
29}
30
31// API Routes
32app.route("/api/auth", auth);
33app.route("/api/products", products);
34app.route("/api/cart", cart);
35app.route("/api/orders", orders);
36
37// Serve static files

jeffiHeader.tsx2 matches

@jeffy•Updated 5 days ago
39 const handleLogout = async () => {
40 try {
41 await fetch('/api/auth/logout', {
42 method: 'POST',
43 credentials: 'include'
174 >
175 <img
176 src={`https://ui-avatars.com/api/?name=${encodeURIComponent(user.firstName + ' ' + user.lastName)}&background=6366f1&color=fff&size=32`}
177 alt={user.firstName}
178 className="h-8 w-8 rounded-full"

github-api1 file match

@cricks_unmixed4u•Updated 3 hours ago

beeminder-api4 file matches

@cricks_unmixed4u•Updated 3 hours ago
Kapil01
apiv1