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/?q=api&page=235&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 18960 results for "api"(4117ms)

To-Do-ListREADME.md6 matches

@Moeakaeโ€ขUpdated 1 week ago
19โ”‚ โ”‚ โ””โ”€โ”€ queries.ts # Database operations
20โ”‚ โ”œโ”€โ”€ routes/
21โ”‚ โ”‚ โ””โ”€โ”€ todos.ts # Todo API routes
22โ”‚ โ””โ”€โ”€ index.ts # Main server entry point
23โ”œโ”€โ”€ frontend/
34```
35
36## API Endpoints
37
38- `GET /api/todos` - Get all todos
39- `POST /api/todos` - Create a new todo
40- `PUT /api/todos/:id` - Update a todo
41- `DELETE /api/todos/:id` - Delete a todo
42
43## Usage

untitled-5312README.md7 matches

@ideckโ€ขUpdated 1 week ago
17โ”‚ โ”‚ โ””โ”€โ”€ queries.ts # Database query functions
18โ”‚ โ”œโ”€โ”€ routes/
19โ”‚ โ”‚ โ”œโ”€โ”€ jobs.ts # Job posting API routes
20โ”‚ โ”‚ โ””โ”€โ”€ chat.ts # Chat API routes
21โ”‚ โ””โ”€โ”€ index.ts # Main Hono server
22โ”œโ”€โ”€ frontend/
32```
33
34## API Endpoints
35
36### Jobs
37- `GET /api/jobs` - Get all job postings
38- `POST /api/jobs` - Create a new job posting
39
40### Chat
41- `GET /api/chat/messages` - Get chat messages
42- `POST /api/chat/messages` - Send a chat message
43
44## Getting Started

Emmtettindex.ts3 matches

@Emmtettโ€ขUpdated 1 week ago
16await runMigrations();
17
18// API routes
19app.route("/api/jobs", jobsRouter);
20app.route("/api/chat", chatRouter);
21
22// Serve static files

EmmtettChatRoom.tsx5 matches

@Emmtettโ€ขUpdated 1 week ago
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import React, { useState, useEffect, useRef } from "https://esm.sh/react@18.2.0";
3import type { ChatMessage, CreateMessageRequest, ApiResponse } from "../../shared/types.ts";
4
5interface ChatRoomProps {
41 intervalRef.current = window.setInterval(async () => {
42 try {
43 const response = await fetch('/api/chat/messages');
44 const result: ApiResponse<ChatMessage[]> = await response.json();
45 if (result.success && result.data) {
46 setMessages(result.data);
71 setLoading(true);
72 try {
73 const response = await fetch('/api/chat/messages', {
74 method: 'POST',
75 headers: {
79 });
80
81 const result: ApiResponse<ChatMessage> = await response.json();
82
83 if (result.success && result.data) {

EmmtettJobForm.tsx3 matches

@Emmtettโ€ขUpdated 1 week ago
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import React, { useState } from "https://esm.sh/react@18.2.0";
3import type { Job, CreateJobRequest, ApiResponse } from "../../shared/types.ts";
4
5interface JobFormProps {
54 setLoading(true);
55 try {
56 const response = await fetch('/api/jobs', {
57 method: 'POST',
58 headers: {
62 });
63
64 const result: ApiResponse<Job> = await response.json();
65
66 if (result.success && result.data) {

EmmtettJobBoard.tsx3 matches

@Emmtettโ€ขUpdated 1 week ago
2import React, { useState } from "https://esm.sh/react@18.2.0";
3import JobForm from "./JobForm.tsx";
4import type { Job, ApiResponse } from "../../shared/types.ts";
5
6interface JobBoardProps {
25 setLoading(true);
26 try {
27 const response = await fetch(`/api/jobs/${jobId}`, {
28 method: 'DELETE',
29 });
30
31 const result: ApiResponse<{ deleted: boolean }> = await response.json();
32
33 if (result.success) {

untitled-5977index.ts2 matches

@Reneeโ€ขUpdated 1 week ago
14await runMigrations();
15
16// API routes
17app.route("/api/artists", artistsRoutes);
18
19// Static file serving and main page

Emmtettchat.ts9 matches

@Emmtettโ€ขUpdated 1 week ago
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { getRecentMessages, createMessage } from "../database/queries.ts";
3import type { CreateMessageRequest, ApiResponse } from "../../shared/types.ts";
4
5const chat = new Hono();
9 try {
10 const messages = await getRecentMessages(50);
11 const response: ApiResponse<typeof messages> = {
12 success: true,
13 data: messages
15 return c.json(response);
16 } catch (error) {
17 const response: ApiResponse<never> = {
18 success: false,
19 error: "Failed to fetch messages"
30 // Basic validation
31 if (!messageData.username || !messageData.message) {
32 const response: ApiResponse<never> = {
33 success: false,
34 error: "Username and message are required"
42
43 if (messageData.username.length > 50) {
44 const response: ApiResponse<never> = {
45 success: false,
46 error: "Username must be 50 characters or less"
50
51 if (messageData.message.length > 500) {
52 const response: ApiResponse<never> = {
53 success: false,
54 error: "Message must be 500 characters or less"
58
59 if (messageData.message.length === 0) {
60 const response: ApiResponse<never> = {
61 success: false,
62 error: "Message cannot be empty"
66
67 const newMessage = await createMessage(messageData);
68 const response: ApiResponse<typeof newMessage> = {
69 success: true,
70 data: newMessage
72 return c.json(response, 201);
73 } catch (error) {
74 const response: ApiResponse<never> = {
75 success: false,
76 error: "Failed to send message"

untitled-5977index.tsx2 matches

@Reneeโ€ขUpdated 1 week ago
126 try {
127 const url = state.editingArtist
128 ? `/api/artists/${state.editingArtist.id}`
129 : '/api/artists';
130
131 const method = state.editingArtist ? 'PUT' : 'POST';

Emmtettjobs.ts10 matches

@Emmtettโ€ขUpdated 1 week ago
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { getAllJobs, createJob, deleteJob } from "../database/queries.ts";
3import type { CreateJobRequest, ApiResponse } from "../../shared/types.ts";
4
5const jobs = new Hono();
9 try {
10 const jobList = await getAllJobs();
11 const response: ApiResponse<typeof jobList> = {
12 success: true,
13 data: jobList
15 return c.json(response);
16 } catch (error) {
17 const response: ApiResponse<never> = {
18 success: false,
19 error: "Failed to fetch jobs"
31 if (!jobData.title || !jobData.company || !jobData.description ||
32 !jobData.location || !jobData.salary || !jobData.contact_email) {
33 const response: ApiResponse<never> = {
34 success: false,
35 error: "All fields are required"
39
40 const newJob = await createJob(jobData);
41 const response: ApiResponse<typeof newJob> = {
42 success: true,
43 data: newJob
45 return c.json(response, 201);
46 } catch (error) {
47 const response: ApiResponse<never> = {
48 success: false,
49 error: "Failed to create job"
58 const id = parseInt(c.req.param("id"));
59 if (isNaN(id)) {
60 const response: ApiResponse<never> = {
61 success: false,
62 error: "Invalid job ID"
67 const deleted = await deleteJob(id);
68 if (!deleted) {
69 const response: ApiResponse<never> = {
70 success: false,
71 error: "Job not found"
74 }
75
76 const response: ApiResponse<{ deleted: boolean }> = {
77 success: true,
78 data: { deleted: true }
80 return c.json(response);
81 } catch (error) {
82 const response: ApiResponse<never> = {
83 success: false,
84 error: "Failed to delete job"

beeminder-api4 file matches

@cricks_unmixed4uโ€ขUpdated 18 hours ago

shippingAPI1 file match

@dynamic_silverโ€ขUpdated 1 day ago
apiry
snartapi