1import { exportedKeys } from "https://esm.town/v/stevekrouse/exportedKeys";
2import { runValAPIAuth } from "https://esm.town/v/stevekrouse/runValAPIAuth";
3
4export const authRequestEx = runValAPIAuth({
5 val: "@stevekrouse.exampleAuthApi",
6 args: [1, 3],
7 keys: exportedKeys,
46 //
47 const limit = await fetchJSON(
48 `https://api.rlimit.com/limit/${namespaceId}/${type}/${max}/${interval}/${key}?cost=${cost}&subNamespace=${subNamespace}&password=${pass}`,
49 );
50 return limit;
3export const getPublicVals = async (username) => {
4 let { id } = await fetchJSON(
5 `https://api.val.town/v1/alias/${username}`,
6 );
7 return fetchJSON(
8 `https://api.val.town/v1/users/${id}/vals`,
9 );
10};
1import { TEST_API } from "https://esm.town/v/stevekrouse/TEST_API";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3
16}) {
17 const { data: last } = await fetchJSON(
18 `${TEST_API}/eval/${stateName}`
19 );
20 const now = Date.now();
21 await fetchJSON(
22 `${TEST_API}/eval/${mutator(now)}`
23 );
24 const { data: next } = await fetchJSON(
25 `${TEST_API}/eval/${stateName}`
26 );
27 const mutated = next === now;
8 for (let i = 0; i < count; i++) {
9 let start = Date.now();
10 await fetch("https://api.val.town/eval/(()=%3E1+1)()");
11 evalTimes.push(Date.now() - start);
12 }
23 for (let i = 0; i < count; i++) {
24 let start = Date.now();
25 await fetch("https://api.val.town/eval/@healeycodes.addOnes()");
26 userFuncTimes.push(Date.now() - start);
27 }
5 throw new Error(`${fetchJSON.impl.toString()}`);
6 return fetchJSON(
7 "https://api.github.com/users/stevekrouse/following"
8 );
9})();
6 // Fetch a YAML file
7 const yaml = await fetch(
8 "https://raw.githubusercontent.com/docker/engine/8955d8da8951695a98eb7e15bead19d402c6eb27/api/swagger.yaml",
9 ).then((r) => r.text());
10 // parse the fetched file
5 const response =
6 (await fetch(
7 "https://api.val.town/v1/run/politelyinvinciblepointer.handleForm",
8 {
9 method: "POST",
1let { twitterAPIDown } = await import("https://esm.town/v/stevekrouse/twitterAPIDown");
2import process from "node:process";
3import { msHour } from "https://esm.town/v/stevekrouse/msHour";
4import { twitterSearch } from "https://esm.town/v/stevekrouse/twitterSearch";
5
6// let's poll the elevated v2 twitter api
7// until it's down, and store the state in
8// @stevekrouse.twitterAPIDown ({ down: boolean, reason: string})
9export async function checkIfTwitterAPIIsDown() {
10 try {
11 // query for something we know will return results
16 });
17 if (results.length) {
18 // if we get results, the API is still up
19 twitterAPIDown = {
20 down: false,
21 reason: `search returned ${results.length} results at ${new Date()}`,
22 };
23 } else {
24 // no results = API down
25 twitterAPIDown = {
26 down: true,
27 reason: `search returned ${results.length} results at ${new Date()}`,
29 }
30 } catch (e) {
31 // if there's an error, the API is also likely down
32 twitterAPIDown = {
33 down: false,
34 reason: `search errored ${e.message} at ${new Date()}`,
1export function myApi(name) {
2 return "hi " + name;
3}