1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3// Github profile
4export let githubUser = fetchJSON(
5 "https://api.github.com/users/stevekrouse"
6);
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export let eval_ = (code, args?) =>
4 fetchJSON("https://api.val.town/v1/eval", {
5 method: "POST",
6 body: JSON.stringify({
1import { fetch } from "https://esm.town/v/std/fetch";
2
3// E.g. from a user's perspective (not the real execution time!)
7 for (let i = 0; i < count; i++) {
8 let start = Date.now();
9 await fetch("https://api.val.town/eval/(()=%3E1+1)()");
10 evalTimes.push(Date.now() - start);
11 }
22 for (let i = 0; i < count; i++) {
23 let start = Date.now();
24 await fetch("https://api.val.town/eval/@healeycodes.addOnes()");
25 userFuncTimes.push(Date.now() - start);
26 }
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export function weatherGovGrid({ lat, lon }): Promise<WeatherData> {
4 return fetchJSON(
5 `https://api.weather.gov/points/${lat},${lon}`,
6 );
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export let fetchHeaders = (await fetch("https://swapi.dev/api/people/1/")).headers;
1import { runValAPIAuth } from "https://esm.town/v/stevekrouse/runValAPIAuth";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3import { whoami } from "https://esm.town/v/stevekrouse/whoami";
4
8 let handle = whoami().at(-1).slice(1).split(".")[0]
9 .replace("@", "");
10 return fetchJSON(
11 `https://pub-6feb98c078874338b9a3bce6ab56e815.r2.dev/${handle}/${key}`,
12 { agent: null },
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export const untitled_B7XzWEHM = (
4 await fetch(
5 "https://api.val.town/v1/run/paulsun.parkingSpots" +
6 `?args=${JSON.stringify([lat, lng, radius])}`
1import { TEST_API } from "https://esm.town/v/stevekrouse/TEST_API";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3
4export async function runAllTests2({ names }: { names: string[] }) {
5 return names.map((name) =>
6 fetchJSON(`${TEST_API}/eval/@stevekrouse.${name}()`)
7 .then(({ data, error }) => (data ?? error?.message) + ` (${name})`)
8 );
1import { fetch } from "https://esm.town/v/std/fetch";
2import process from "node:process";
3
4export let catFact = async (request: Request): Promise<Response> => {
5 let cat = await fetch("https://catfact.ninja/fact");
6 let { fact } = await cat.json();
7 const prompt =
8 "Rewrite this fact about cats as if it was written for 3 year old:\n\n" +
9 fact;
10 const story = await fetch("https://api.openai.com/v1/chat/completions", {
11 method: "POST",
12 body: JSON.stringify({
32 console.log(
33 length
34 ? `Successfully fetched ${length} row${length === 1 ? "" : "s"}`
35 : "No rows found",
36 );