1import { getGithubStars } from "https://esm.town/v/vtdocs/getGithubStars?v=2";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3
4// Github following
5export let githubFollowing =
6 (await fetchJSON(
7 "https://api.github.com/users/stevekrouse/following",
8 )).map((f) => f.login).map((h) => ({
1import process from "node:process";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3import { twitterJSON } from "https://esm.town/v/stevekrouse/twitterJSON";
4
6 let userId = 431200836; // stevekrouse
7 twitterJSON;
8 let resp = await fetchJSON(
9 `https://api.twitter.com/1.1/friends/ids.json?user_id=${userId}`,
10 {
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export const privateAPIUnauthenticated =
4 (await fetch("https://api.val.town/v1/run/stevekrouse.example3")).status;
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export let price = async (asset, base = "usd", amount = 1) => {
4 let { rates } = await fetchJSON(`https://open.er-api.com/v6/latest/${base}`)
5 if (rates && rates[asset.toUpperCase()]) return amount * (1 / rates[asset.toUpperCase()])
6 else {
7 let { rates } = await fetchJSON('https://api.coingecko.com/api/v3/exchange_rates')
8 return amount * rates[base.toLowerCase()]?.value / rates[asset.toLowerCase()]?.value
9 }
1import { githubFileCache } from "https://esm.town/v/stevekrouse/githubFileCache";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3
4export let githubFileChanged = async (owner, repo, file) => {
5 let handle = `${owner}/${repo}/${file}`
6 let current = await fetchJSON(`https://api.github.com/repos/${owner}/${repo}/contents/${file}`)
7 let previous = githubFileCache[handle]
8 if (previous?.content && current?.content && previous?.content !== current?.content) {
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export const atproto = async (domain) => {
4 const atRecord = `_atproto.${domain}`;
5 const res = await fetch(
6 `https://1.1.1.1/dns-query?name=${atRecord}&type=TXT`,
7 {
1import { fetchText } from "https://esm.town/v/stevekrouse/fetchText?v=5";
2
3// Random math fact
4export let mathFact = fetchText(
5 "http://numbersapi.com/random/math"
6);
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3// Public holidays in the US in 2023
4export let holidaysUS = fetchJSON(
5 "https://date.nager.at/api/v2/publicholidays/2023/US"
6);
1import { fetchGiphy as fetchGiphy2 } from "https://esm.town/v/simply_say_m/fetchGiphy";
2import { boredActivities } from "https://esm.town/v/simply_say_m/boredActivities";
3
5 (async (req: express.Request, res: express.Response) => {
6 const activity = await boredActivities();
7 const fetchGiphy = await fetchGiphy2(activity);
8 const { url } =
9 fetchGiphy[Math.floor(Math.random() * 10)].images.downsized_large;
10 return res.send(
11 `<div style='min-height:100vh; width: 100vw; margin:0; background: radial-gradient(circle, rgba(251,159,63,1) 54%, rgba(255,186,253,1) 100%);'>
1import { fetchText } from "https://esm.town/v/stevekrouse/fetchText?v=5";
2
3export let nameTopHNThreadUsingSomeonesVal = (async () => {
4 // Cheerio parses markup and provides an API to interact with the resulting data structure
5 const cheerio = await import("npm:cheerio"); // You can import NPM packages
6 const replyText = await fetchText(
7 "https://news.ycombinator.com/",
8 );