1import { set } from "https://esm.town/v/std/set?v=11";
2import { spacexLemmyDb } from "https://esm.town/v/pdebie/spacexLemmyDb";
3import { fetchRss } from "https://esm.town/v/pdebie/fetchRss";
4
5export async function syncCommentToLemmy(
21 const { LemmyHttp } = await import("npm:lemmy-js-client@0.18.1");
22 let client = new LemmyHttp(`https://${instance}`, {
23 fetchFunction: fetch,
24 });
25 // (client as any)["#fetchFunction"] = fetch;
26 let comments = (await fetchRss(redditUrl)).filter((i) =>
27 new Date(i.isoDate) >= new Date(Date.now() - 1000 * 60 * 60 * 24)
28 )
1import { fetch } from "https://esm.town/v/std/fetch";
2import process from "node:process";
3
43 redirect: "follow",
44 };
45 let openApiResponse = await fetch(
46 "https://api.openai.com/v1/chat/completions",
47 requestOptions,
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export async function fetchHtmlDom(url: string) {
4 const { DOMParser } = await import(
5 "https://deno.land/x/deno_dom/deno-dom-wasm.ts"
6 );
7 const response = await fetch(url);
8 const html = await response.text();
9 const parser = new DOMParser();
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3// Github following
4export let githubFollowing = fetchJSON(
5 "https://api.github.com/users/stevekrouse/following"
6);
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export const nearestOpenStation = async ({ lon, lat }) => {
9 );
10 }
11 const { data: { stations: stationInfo } } = await fetch(
12 "https://gbfs.citibikenyc.com/gbfs/en/station_status.json",
13 ).then((r) => r.json());
15 stationInfo.map((info) => [info.station_id, info]),
16 );
17 const { data: { stations } } = await fetch(
18 "https://gbfs.citibikenyc.com/gbfs/en/station_information.json",
19 ).then((r) => r.json());
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3export const telegramSetWebhook = async (botToken: string, options: {
9 secret_token?: string;
10}) =>
11 fetchJSON(
12 `https://api.telegram.org/bot${botToken}/setWebhook`,
13 {
1import { fetchText } from "https://esm.town/v/stevekrouse/fetchText?v=5";
2
3export const exampleExpressPOST = fetchText(
4 "https://api.val.town/v1/express/stevekrouse.expressHTMLExample",
5 { method: "POST", body: JSON.stringify({ name: "Docs" }) },
1import process from "node:process";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
3
4export const browserlessScrapeExample = (async () => {
5 const res = await fetchJSON(
6 `https://chrome.browserless.io/scrape?token=${process.env.browserlessKey}`,
7 {
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export const handlePost = async (req: express.Request, res: express.Response) => {
4 const { url = "http://example.com", method = "GET", headers = {} } = req.body;
5 const resp = await fetch(url, {
6 redirect: "follow",
7 });
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3export function valVersion({ token, id, version }: {
30 }
31 : {};
32 return fetchJSON(
33 `https://api.val.town/v1/vals/${id}/versions/${version}`,
34 { headers },