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/$1?q=api&page=13&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 15626 results for "api"(3121ms)

Testindex.ts2 matches

@wolf•Updated 18 hours ago
12app.get("/frontend/**/*", c => serveFile(c.req.path, import.meta.url));
13
14// Add your API routes here
15// app.get("/api/data", c => c.json({ hello: "world" }));
16
17// Unwrap and rethrow Hono errors as the original error

todo-apptypes.ts1 match

@pals_with_Val•Updated 18 hours ago
36}
37
38export interface ApiResponse<T = any> {
39 success: boolean;
40 data?: T;

todo-appTodoList.tsx1 match

@pals_with_Val•Updated 18 hours ago
179 <span className="text-sm text-gray-500">{getCategoryLabel(todo.category)}</span>
180 <span className="text-sm">{getPriorityIcon(todo.priority)}</span>
181 <span className="text-xs text-gray-500 capitalize">{todo.priority === 'high' ? 'Alta' : todo.priority === 'medium' ? 'Média' : 'Baixa'} prioridade</span>
182 {isOverdue(todo.dueDate) && !todo.completed && (
183 <span className="text-xs bg-red-100 text-red-700 px-2 py-1 rounded-full">

todo-appREADME.md6 matches

@pals_with_Val•Updated 18 hours ago
19```
20├── backend/
21│ ├── index.ts # Servidor Hono com API REST
22│ └── README.md
23├── frontend/
36```
37
38## 🚀 API Endpoints
39
40- `GET /` - Página inicial (landing page ou app)
41- `GET /api/todos` - Buscar tarefas do usuário
42- `POST /api/todos` - Criar nova tarefa
43- `PUT /api/todos/:id` - Atualizar tarefa
44- `DELETE /api/todos/:id` - Excluir tarefa
45
46## 🔧 Tecnologias

todo-appindex.ts20 matches

@pals_with_Val•Updated 18 hours ago
3import { blob } from "https://esm.town/v/std/blob";
4import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
5import type { Todo, User, CreateTodoRequest, UpdateTodoRequest, ApiResponse } from "../shared/types.ts";
6
7const app = new Hono();
69});
70
71// API Routes
72
73// Get todos for authenticated user
74app.get("/api/todos", async (c) => {
75 const email = c.req.header("X-LastLogin-Email");
76
77 if (!email) {
78 return c.json<ApiResponse>({ success: false, error: "Not authenticated" }, 401);
79 }
80
81 try {
82 const userData = await getUserData(email);
83 return c.json<ApiResponse<Todo[]>>({ success: true, data: userData.todos });
84 } catch (error) {
85 return c.json<ApiResponse>({ success: false, error: "Failed to fetch todos" }, 500);
86 }
87});
88
89// Create new todo
90app.post("/api/todos", async (c) => {
91 const email = c.req.header("X-LastLogin-Email");
92
93 if (!email) {
94 return c.json<ApiResponse>({ success: false, error: "Not authenticated" }, 401);
95 }
96
114 await saveUserData(userData);
115
116 return c.json<ApiResponse<Todo>>({ success: true, data: newTodo });
117 } catch (error) {
118 return c.json<ApiResponse>({ success: false, error: "Failed to create todo" }, 500);
119 }
120});
121
122// Update todo
123app.put("/api/todos/:id", async (c) => {
124 const email = c.req.header("X-LastLogin-Email");
125 const todoId = c.req.param("id");
126
127 if (!email) {
128 return c.json<ApiResponse>({ success: false, error: "Not authenticated" }, 401);
129 }
130
135 const todoIndex = userData.todos.findIndex(todo => todo.id === todoId);
136 if (todoIndex === -1) {
137 return c.json<ApiResponse>({ success: false, error: "Todo not found" }, 404);
138 }
139
148 await saveUserData(userData);
149
150 return c.json<ApiResponse<Todo>>({ success: true, data: updatedTodo });
151 } catch (error) {
152 return c.json<ApiResponse>({ success: false, error: "Failed to update todo" }, 500);
153 }
154});
155
156// Delete todo
157app.delete("/api/todos/:id", async (c) => {
158 const email = c.req.header("X-LastLogin-Email");
159 const todoId = c.req.param("id");
160
161 if (!email) {
162 return c.json<ApiResponse>({ success: false, error: "Not authenticated" }, 401);
163 }
164
168 const todoIndex = userData.todos.findIndex(todo => todo.id === todoId);
169 if (todoIndex === -1) {
170 return c.json<ApiResponse>({ success: false, error: "Todo not found" }, 404);
171 }
172
174 await saveUserData(userData);
175
176 return c.json<ApiResponse>({ success: true });
177 } catch (error) {
178 return c.json<ApiResponse>({ success: false, error: "Failed to delete todo" }, 500);
179 }
180});

todo-appindex.html1 match

@pals_with_Val•Updated 18 hours ago
7 <script src="https://cdn.twind.style" crossorigin></script>
8 <script src="https://esm.town/v/std/catch"></script>
9 <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
10 <style>
11 * {

todo-appApp.tsx10 matches

@pals_with_Val•Updated 18 hours ago
5import TodoForm from "./TodoForm.tsx";
6import LandingPage from "./LandingPage.tsx";
7import type { Todo, User, ApiResponse } from "../../shared/types.ts";
8
9interface AppProps {
27 }
28
29 // Fetch todos from API
30 const fetchTodos = async () => {
31 if (!isAuthenticated) return;
33 setLoading(true);
34 try {
35 const response = await fetch('/api/todos');
36 const result: ApiResponse<Todo[]> = await response.json();
37
38 if (result.success && result.data) {
58 setLoading(true);
59 try {
60 const response = await fetch('/api/todos', {
61 method: 'POST',
62 headers: { 'Content-Type': 'application/json' },
64 });
65
66 const result: ApiResponse<Todo> = await response.json();
67
68 if (result.success && result.data) {
82 setLoading(true);
83 try {
84 const response = await fetch(`/api/todos/${id}`, {
85 method: 'PUT',
86 headers: { 'Content-Type': 'application/json' },
88 });
89
90 const result: ApiResponse<Todo> = await response.json();
91
92 if (result.success && result.data) {
108 setLoading(true);
109 try {
110 const response = await fetch(`/api/todos/${id}`, {
111 method: 'DELETE'
112 });
113
114 const result: ApiResponse = await response.json();
115
116 if (result.success) {

dashboard-propsv1main.tsx1 match

@arthrod•Updated 19 hours ago
5 <meta name="viewport" content="width=device-width, initial-scale=1.0">
6 <title>CICERO Dashboard - Professional Landing Pages</title>
7 <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;500;900&display=swap" rel="stylesheet">
8 <style>
9 * {

fetch-socialsendpoint.tsx10 matches

@welson•Updated 19 hours ago
1// Val.town HTTP endpoint to serve archived posts with pagination and filtering
2// This will be accessible at: https://USERNAME-posts-api.web.val.run
3
4import { createClient } from "https://esm.sh/@supabase/supabase-js@2";
23}
24
25interface ApiResponse {
26 success: boolean;
27 data?: {
67 // Check authorization
68 const authHeader = req.headers.get("Authorization");
69 const apiKey = Deno.env.get("POSTS_API_KEY");
70
71 if (!apiKey || authHeader !== `Bearer ${apiKey}`) {
72 return new Response(
73 JSON.stringify({ success: false, error: "Unauthorized" }),
132
133 // Build response
134 const response: ApiResponse = {
135 success: true,
136 data: {
152 return new Response(JSON.stringify(response), { status: 200, headers });
153 } catch (error: any) {
154 console.error("API Error:", error);
155
156 const errorResponse: ApiResponse = {
157 success: false,
158 error: error.message || "Internal server error",
166}
167
168// API Documentation (for reference)
169/*
170# Posts API Documentation
171
172## Authentication
173All requests must include an Authorization header:
174Authorization: Bearer YOUR_API_KEY
175
176## Endpoints

cerebras_coderstarter-prompts.js1 match

@Rana882•Updated 19 hours ago
12 },
13 {
14 "prompt": "weather dashboard for nyc using open-meteo API for NYC with icons",
15 "title": "Weather App",
16 "code":

googleGeminiAPI2 file matches

@michaelwschultz•Updated 4 hours ago

HN-fetch-call2 file matches

@ImGqb•Updated 3 days ago
fetch HackerNews by API
Kapil01
apiv1