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=fetch&page=55&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=fetch

Returns an array of strings in format "username" or "username/projectName"

Found 15672 results for "fetch"(2880ms)

icalEventsshortener.ts2 matches

@conrad•Updated 1 week ago
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { createShortlink, getShortlink, incrementAccessCount, updateIcalContent } from "../services/shortener-simple.ts";
3import { fetchAndExtractEvents, generateIcal } from "../services/ical.ts";
4
5const app = new Hono();
65 // Generate new iCal content
66 console.log("Generating iCal for URL:", shortlink.original_url);
67 const events = await fetchAndExtractEvents(shortlink.original_url);
68 const title = shortlink.title || 'Events';
69 const icalContent = generateIcal(events, title);

icalEventsindex.ts2 matches

@conrad•Updated 1 week ago
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { initializeTable, getShortlink, updateIcalContent } from "./services/shortener-simple.ts";
3import { fetchAndExtractEvents, generateIcal } from "./services/ical.ts";
4import shortenerRoutes from "./routes/shortener.ts";
5import { readFile, serveFile } from "https://esm.town/v/std/utils/index.ts";
59
60// This is the entry point for HTTP vals
61export default app.fetch;

icalEventsindex.js1 match

@conrad•Updated 1 week ago
44
45 try {
46 const response = await fetch('/shorten', {
47 method: 'POST',
48 headers: {

mcp-addmain.ts1 match

@dthyresson•Updated 1 week ago
41})
42
43export default app.fetch

cp-rootread-vals.tsx10 matches

@chadparker•Updated 1 week ago
6 }
7
8 const vals = await fetchAllVals(apiKey);
9
10 // Process all vals in parallel for better performance
64interface CpFile {
65 path: string;
66 fetch: string;
67}
68
69async function fetchAllVals(apiKey: string): Promise<Val[]> {
70 const valsResponse = await fetch("https://api.val.town/v2/me/vals", {
71 headers: {
72 "Authorization": `Bearer ${apiKey}`,
79 console.log("API Error response:", errorText);
80 throw new Error(
81 `Failed to fetch vals: ${valsResponse.status} ${valsResponse.statusText}. Response: ${errorText}`,
82 );
83 }
89async function findCpFiles(val: Val, apiKey: string): Promise<CpFile[]> {
90 try {
91 const files = await fetchValFiles(val.id, apiKey);
92 const cpFiles = filterCpFiles(files);
93
110 return {
111 path: `/${val.name}/${trimmed_filename}`,
112 fetch: httpUrl,
113 todo: "find TODO comment",
114 };
120}
121
122async function fetchValFiles(valId: string, apiKey: string): Promise<ValFile[]> {
123 const filesResponse = await fetch(
124 `https://api.val.town/v2/vals/${valId}/files?path=&recursive=true&limit=100`,
125 {
178): Promise<FileWithInfo | null> {
179 try {
180 const fileContentResponse = await fetch(
181 `https://api.val.town/v2/vals/${val.id}/files?path=${encodeURIComponent(file.path)}`,
182 {

cp-rootold-scan-vals.tsx12 matches

@chadparker•Updated 1 week ago
6 }
7
8 const vals = await fetchAllVals(apiKey);
9
10 // Process all vals in parallel for better performance
84}
85
86async function fetchAllVals(apiKey: string): Promise<Val[]> {
87 const valsResponse = await fetch("https://api.val.town/v2/me/vals", {
88 headers: {
89 "Authorization": `Bearer ${apiKey}`,
96 console.log("API Error response:", errorText);
97 throw new Error(
98 `Failed to fetch vals: ${valsResponse.status} ${valsResponse.statusText}. Response: ${errorText}`,
99 );
100 }
108async function processVal(val: Val, apiKey: string): Promise<ValWithEndpoints | null> {
109 try {
110 const files = await fetchValFiles(val.id, apiKey);
111 const endpointsFiles = filterEndpointsFiles(files);
112
134}
135
136async function fetchValFiles(valId: string, apiKey: string): Promise<ValFile[]> {
137 const filesResponse = await fetch(
138 `https://api.val.town/v2/vals/${valId}/files?path=&recursive=true&limit=100`,
139 {
173): Promise<EndpointFile> {
174 try {
175 const fileContentResponse = await fetch(
176 `https://api.val.town/v2/vals/${val.id}/files?path=${encodeURIComponent(endpointsFile.path)}`,
177 {
186 return {
187 ...endpointsFile,
188 http_response: "Failed to fetch file metadata",
189 error: `HTTP ${fileContentResponse.status}: ${fileContentResponse.statusText}`,
190 };
212
213 const httpUrl = constructHttpUrl(val, endpointsFile, fileInfo);
214 const { status, response } = await fetchEndpointResponse(httpUrl);
215
216 return {
243}
244
245async function fetchEndpointResponse(httpUrl: string): Promise<{ status: number | string; response: string }> {
246 try {
247 const endpointResponse = await fetch(httpUrl, {
248 method: "GET",
249 headers: {

cp-rootold-get_vals_endpoints.tsx8 matches

@chadparker•Updated 1 week ago
11
12 // Get my vals using the authenticated /me/vals endpoint
13 const valsResponse = await fetch("https://api.val.town/v2/me/vals", {
14 headers: {
15 "Authorization": `Bearer ${apiKey}`,
22 console.log("API Error response:", errorText);
23 throw new Error(
24 `Failed to fetch vals: ${valsResponse.status} ${valsResponse.statusText}. Response: ${errorText}`,
25 );
26 }
43 try {
44 // Use the files API to get the actual file structure
45 const filesResponse = await fetch(
46 `https://api.val.town/v2/vals/${val.id}/files?path=&recursive=true&limit=100`,
47 {
73
74 if (endpointsFiles.length > 0) {
75 // Fetch HTTP responses from each endpoints file
76 const endpointsWithResponses = [];
77
79 try {
80 // First get the file metadata to get the HTTP URL
81 const fileContentResponse = await fetch(
82 `https://api.val.town/v2/vals/${val.id}/files?path=${encodeURIComponent(endpointsFile.path)}`,
83 {
115 try {
116 // Make HTTP request to the endpoint
117 const endpointResponse = await fetch(httpUrl, {
118 method: "GET",
119 headers: {
161 });
162 } else {
163 console.log(`Failed to fetch metadata for file ${endpointsFile.name} in val ${val.name}`);
164 endpointsWithResponses.push({
165 name: endpointsFile.name,
168 updatedAt: endpointsFile.updatedAt,
169 type: endpointsFile.type,
170 http_response: "Failed to fetch file metadata",
171 error: `HTTP ${fileContentResponse.status}: ${fileContentResponse.statusText}`,
172 });

cp-rootcheck-file.tsx1 match

@chadparker•Updated 1 week ago
5): Promise<FileWithInfo | null> {
6 try {
7 const fileContentResponse = await fetch(
8 `https://api.val.town/v2/vals/${val.id}/files?path=${
9 encodeURIComponent(file.path)

inndexmain.tsx1 match

@git•Updated 1 week ago
2
3export default {
4 fetch: () => new Response(indexPage),
5};

val-uploaderapi.ts1 match

@fiammanda•Updated 1 week ago
24 }
25
26 const res = await fetch(
27 `https://api.val.town/v1/vals/${encodeURIComponent(name)}`,
28 {

manual-fetcher

@miz•Updated 3 days ago

fake-https1 file match

@blazemcworld•Updated 1 week ago
simple proxy to fetch http urls using https