58async function fetchContributions(username) {
59const contributionMap = {};
60const valsUrl = `https://api.val.town/v1/alias/${username}/vals`;
61const valsResponse = await fetch(valsUrl);
62if (!valsResponse.ok) {
65const valsData = await valsResponse.json();
6667console.log("API Response:", JSON.stringify(valsData, null, 2));
6869let valsToProcess = [];
74valsToProcess = [valsData];
75} else {
76console.log("Unexpected API response structure:", valsData);
77return contributionMap;
78}
9192async function fetchValVersions(valId, contributionMap, creationDate) {
93const versionsUrl = `https://api.val.town/v1/vals/${valId}/versions`;
94try {
95const versionsResponse = await fetch(versionsUrl);
112});
113} else {
114console.log(`Unexpected versions API response structure for val ${valId}:`, versionsData);
115}
116} catch (error) {
spacexcalendarmain.tsx1 match
1import { getLaunches } from "https://esm.town/v/moe/spacexapi"
2import ical from "npm:ical-generator"
3import moment from "npm:moment-timezone"
extremePlumCariboumain.tsx1 match
154}
155156const client = new ValTown({ apiKey: token });
157const user = await client.alias.username.retrieve(username);
158
allvalsindexmain.tsx1 match
96}
9798const client = new ValTown({ apiKey: token });
99const username = 'ejfox';
100const user = await client.alias.username.retrieve(username);
sqliteExplorerAppmain.tsx2 matches
27<head>
28<title>SQLite Explorer</title>
29<link rel="preconnect" href="https://fonts.googleapis.com" />
3031<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
32<link
33href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@300..700&family=Source+Sans+3:ital,wght@0,200..900;1,200..900&display=swap"
34rel="stylesheet"
35/>
sqliteExplorerAppREADME.md1 match
13## Authentication
1415Login to your SQLite Explorer with [password authentication](https://www.val.town/v/pomdtr/password_auth) with your [Val Town API Token](https://www.val.town/settings/api) as the password.
1617## Todos / Plans
blob_adminREADME.md1 match
9[](https://www.val.town/v/stevekrouse/blob_admin_app/fork)
1011It uses [basic authentication](https://www.val.town/v/pomdtr/basicAuth) with your [Val Town API Token](https://www.val.town/settings/api) as the password (leave the username field blank).
1213# TODO
3738## How it works
39The sketch function returns an http handler that sets up a basic page with p5.js added. It then imports your module from the browser and wires up all the exports so p5.js can see them. All the code in your val will run in the browser (except for the default `sketch` export) so you can't call any Deno functions, environment variables, or other server side apis.
40
910if (isImage) {
11const imageUrl = "https://charlypoly-httpapiscreenshotpageexample.web.val.run/?url=" + url.origin
12// return Response.redirect(imageUrl, 302)
13const res = await fetch(imageUrl)
calculateTransitAPImain.tsx18 matches
21}
2223const apiKey = Deno.env.get("GOOGLE_MAPS_API_KEY");
24if (!apiKey) {
25return new Response(JSON.stringify({ error: "API key is not configured" }), {
26status: 500,
27headers: { "Content-Type": "application/json" },
35const gyms = await blob.getJSON("SF_Gyms");
3637const nearestGrocery = await findNearest(origin, groceries, apiKey);
38const nearestGym = await findNearest(origin, gyms, apiKey);
3940const fidiDestination = "548 Market St, San Francisco, CA 94104";
41const fidiDrivingTime = await getDrivingTime(origin, fidiDestination, apiKey);
4243const robloxDestination = "910 Park Pl Ste 300, San Mateo, CA 94403";
44const robloxDrivingTime = await getDrivingTime(origin, robloxDestination, apiKey, "09:00:00", "Tuesday");
4546const samsaraDestination = "1 De Haro St, San Francisco, CA 94103";
47const samsaraTransitTime = await getTransitTime(origin, samsaraDestination, apiKey);
4849const zipCode = await getZipCode(origin, apiKey);
50const neighborhoodZipMap = await blob.getJSON("SF_Neighborhood_ZIP");
51const neighborhood = neighborhoodZipMap[zipCode] || "Unknown";
72}
7374async function findNearest(origin: string, locations: any[], apiKey: string): Promise<any> {
75const batchSize = 25;
76let nearestLocation = null;
80const batch = locations.slice(i, i + batchSize);
81const destinations = batch.map(location => `${location.gps.lat},${location.gps.lng}`).join('|');
82const distanceMatrixUrl = `https://maps.googleapis.com/maps/api/distancematrix/json?origins=${encodeURIComponent(origin)}&destinations=${encodeURIComponent(destinations)}&mode=driving&key=${apiKey}`;
83
84const response = await fetch(distanceMatrixUrl);
8687if (data.status !== "OK") {
88throw new Error(`Distance Matrix API failed. Status: ${data.status}`);
89}
90108}
109110async function getDrivingTime(origin: string, destination: string, apiKey: string, arrivalTime?: string, arrivalDay?: string): Promise<string> {
111let directionsUrl = `https://maps.googleapis.com/maps/api/directions/json?origin=${encodeURIComponent(origin)}&destination=${encodeURIComponent(destination)}&mode=driving&key=${apiKey}`;
112
113if (arrivalTime && arrivalDay) {
129}
130131async function getTransitTime(origin: string, destination: string, apiKey: string): Promise<string> {
132const directionsUrl = `https://maps.googleapis.com/maps/api/directions/json?origin=${encodeURIComponent(origin)}&destination=${encodeURIComponent(destination)}&mode=transit&key=${apiKey}`;
133134const directionsResponse = await fetch(directionsUrl);
144}
145146async function getZipCode(address: string, apiKey: string): Promise<string> {
147const geocodeUrl = `https://maps.googleapis.com/maps/api/geocode/json?address=${encodeURIComponent(address)}&key=${apiKey}`;
148const response = await fetch(geocodeUrl);
149const data = await response.json();