import { fetch } from "https://esm.town/v/std/fetch";
export let fetchJSON = async (url: string, options?: any) => {
let f = await fetch(url, {
...options,
headers: {
"Content-Type": "application/json",
import { normalizeURL } from "https://esm.town/v/stevekrouse/normalizeURL";
export const fetchJSON = async (
url: string | URL,
options?: RequestInit & {
bearer?: string;
fetch?: typeof fetch;
}
// Utility function for fetching JSON data
async function fetchJSON(url: string) {
try {
const response = await fetch(url);
if (!response.ok) {
import { h } from "https://esm.sh/[email protected]";
// Function to fetch JSON data from URL
async function fetchJSON(url: string) {
try {
console.log(`Attempting to fetch data from: ${url}`);
const response = await fetch(url);
}];
}
async function fetchJson(id: string) {
const headers = new Headers([
["Accept-Profile", "edm"],
["Accept", "application/rdf+xml"],
import { fetch } from "https://esm.town/v/std/fetch";
import { normalizeURL } from "https://esm.town/v/stevekrouse/normalizeURL?v=3";
export const fetchJSON = async (url: string, options?: any) => {
let f = await fetch(normalizeURL(url), {
redirect: "follow",
...options,
import { fetch } from "https://esm.town/v/std/fetch?v=4";
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
console.log(await fetchJSON("https://pie.dev/get"));
console.log(await fetchJSON("https://pie.dev/get", { fetch }));
import { email } from "https://esm.town/v/std/email";
import { fetch } from "https://esm.town/v/std/fetch";
function fetchJSON(url) {
return fetch(url).then(res => res.json());
}
export let currency = async (desired, base = "usd", amount = 1) => {
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
export let aqi = async () => {
let pm25 = (
await fetchJSON(
"https://api.openaq.org/v2/latest?" +
new URLSearchParams({
import { fetchJSON } from "https://esm.town/v/axelav/fetchJSON";
import process from "node:process";
export async function home(req: express.Request, res: express.Response) {
interface Artist {
name: string;
join: string;
import { fetchJSON } from "https://esm.town/v/mgruel/fetchJSON";
type UserParams = {
username: string;
};
type ValParams = {
username: string;
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
// Use this to get the Bluesky posts from any user.
// Just pass in their username (like "vgr.bsky.social")
export const bskyPosts = async (repo = "scottraymond.com") => {
const { records } = await fetchJSON(
`https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=${repo}&collection=app.bsky.feed.post`
import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo";
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=42";
export default async function (req: Request) {
const url = new URL(req.url);
const [, id, action] = url.pathname.split("/");
if (!id) {
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
let { boredActivities } = await import("https://esm.town/v/valbee/boredActivities");
export const imBored = async () => {
return (boredActivities = fetchJSON(
"https://www.boredapi.com/api/activity"
));
import { fetchJSON } from "https://esm.town/v/axelav/fetchJSON";
import process from "node:process";
export async function discogs(
request: express.Request,
response: express.Response
) {
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
// Explore the Star Wars universe, from StarWarsAPI
export let starWars = fetchJSON(
"https://swapi.dev/api/people/1/",
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
export const mil = async () => {
const json = await fetchJSON(
"https://www.coingecko.com/nft/milady-maker/chart.json?currency=eth&days=1",
);
return json.stats[json.stats.length - 1];
import process from "node:process";
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
export let getMe = fetchJSON(`https://api.val.town/v1/me`, {
headers: {
Authorization: `Bearer ${process.env.valtownToken}`,
},
import { handle } from "https://esm.town/v/stevekrouse/handle";
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
export let uid =
(await fetchJSON(
`https://api.val.town/v1/alias/${handle}`,
import { API_URL } from "https://esm.town/v/std/API_URL?v=5";
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=42";
import { Octokit } from "npm:@octokit/rest";
import { DateTime } from "npm:luxon";
async function getLatestCommit(ghUser: string, ghRepo: string, branch: string, client: Octokit)
{
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
const { env } = Deno;
const SLACK_BOT_TOKEN = env.get("SLACK_BOT_TOKEN");
const SLACK_SIGNING_SECRET = env.get("SLACK_SIGNING_SECRET");
const SLACK_VERIFICATION_TOKEN = env.get("SLACK_VERIFICATION_TOKEN");
// Altered from https://github.com/ericclemmons/medium-to-markdown
const fetchJSON = async (url, startAt = 0) => {
const response = await fetch(url);
const text = await response.text();
const json = JSON.parse(text.slice(startAt));
import process from "node:process";
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
import { rimeRateLimitExceeded } from "https://esm.town/v/stevekrouse/rimeRateLimitExceeded";
// We provide some amount of free usage to this API
// Callable with my API key via api(@stevekrosue.rime, {text: "blah blah", ...})
export async function rime({ text, speaker, key }: {
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
// Public holidays in the US in 2023
export let holidaysUS = fetchJSON(
"https://date.nager.at/api/v2/publicholidays/2023/US"
import { fetchJSON } from "https://esm.town/v/radu/fetchJSON?v=3";
export let currency = async (base = "usd", desired?: string = "php") => {
let { rates } = await fetchJSON(
`https://open.er-api.com/v6/latest/${base}`,
);
return rates;
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
import { getGoogleAccessTokenFromRefreshToken } from "https://esm.town/v/mihir/getGoogleAccessTokenFromRefreshToken";
export let forceUnsub = async (emails: string[]) => {
const { access_token } =
await getGoogleAccessTokenFromRefreshToken();
/** @jsxImportSource https://esm.sh/react */
import React, { useEffect, useState } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
const subreddits = ["Battletops", "AverageBattlestations", "desksetup"];
import { parentReference } from "https://esm.town/v/stevekrouse/parentReference?v=3";
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
import { runVal } from "https://esm.town/v/std/runVal";
export let ratelimit = async (limit: string, key?: string = "default", namespaceId?: string, namespacePassword?: string) : Promise<{
ok: boolean,
status: number,
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
export const myIP = () =>
fetchJSON("https://api.ipify.org?format=json");
import { searchParams } from "https://esm.town/v/stevekrouse/searchParams";
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
export function runs({ token, error, source, since, until, offset, limit }: {
token: string;
error?: boolean;
source?: ("api" | "ui" | "interval" | "email")[];