1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3export const telegramSendMessage = async (botToken: string, options: TelegramSendMessageOptions) =>
4 fetchJSON(
5 `https://api.telegram.org/bot${botToken}/sendMessage`,
6 {
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3export const telegramSendPhoto = async (botToken: string, options: TelegramSendPhotoOptions) =>
4 fetchJSON(
5 `https://api.telegram.org/bot${botToken}/sendPhoto`,
6 {
298 return c.json("success");
299});
300export default app.fetch;
1import { fetchText } from "https://esm.town/v/stevekrouse/fetchText?v=5";
2
3export const letterboxd = async (username: string) => {
5 const URL = `https://letterboxd.com/${username}/films/diary/`;
6 const getTotalPages = async () => {
7 const html = await fetchText(URL);
8 const $ = cheerio.load(html);
9 return +$(".paginate-page a").last().text();
10 };
11 const getFilmsForPage = async (page) => {
12 const html = await fetchText(URL + "page/" + page);
13 const $ = cheerio.load(html);
14 return $(".diary-entry-edit a").map((i, metadata) => {
9 let reason: string;
10 try {
11 const res = await fetch(URL, { redirect: "follow" });
12 if (res.status !== 200) {
13 reason = `(status code: ${res.status})`;
15 }
16 } catch (e) {
17 reason = `couldn't fetch: ${e}`;
18 ok = false;
19 }
61
62 async transaction(stmts: InStatement[]): Promise<DatabaseResultSet[]> {
63 const r = await fetch(`/api/batch`, {
64 method: "POST",
65 headers: {
81
82 async query(stmt: InStatement): Promise<DatabaseResultSet> {
83 const r = await fetch(`/api/execute`, {
84 method: "POST",
85 headers: {
4
5export let isBoeing = async (airline, number) => {
6 const response = await fetch("https://www.flightstats.com/v2/flight-tracker/" + airline + "/" + number);
7 const body = await response.text();
8 const $ = cheerio.load(body);
4
5export let isBoeing = async (airline, number) => {
6 const response = await fetch("https://www.flightstats.com/v2/flight-tracker/" + airline + "/" + number);
7 const body = await response.text();
8 const $ = cheerio.load(body);
1// import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3// export let comments = ["hello world!"];
4
5// export let twitterJSON = ({ url, bearerToken }) =>
6// fetchJSON(
7// "https://felt.com/api/v1/maps/SssjclTrScGmH4TfPHzNjD/elements",
8// { headers: { authorization: `Bearer ${"felt_pat_ZAqb6bBSE2Na1wDVtZQE17p/sK/+odCnpa1CqLMkcXA"}` } },
10
11// export function handler(request: Request) {
12// let elements = fetchJSON(
13// "https://felt.com/api/v1/maps/SssjclTrScGmH4TfPHzNjD/elements",
14// { headers: { authorization: `Bearer ${"felt_pat_ZAqb6bBSE2Na1wDVtZQE17p/sK/+odCnpa1CqLMkcXA"}` } },
19
20export default async function(req: Request): Promise<Response> {
21 return fetch(
22 "https://felt.com/api/v1/maps/SssjclTrScGmH4TfPHzNjD/elements",
23 // headers: { authorization: `Bearer ${"felt_pat_ZAqb6bBSE2Na1wDVtZQE17p/sK/+odCnpa1CqLMkcXA"}` }
2import { blob } from "https://esm.town/v/std/blob?v=11";
3import { email } from "https://esm.town/v/std/email?v=9";
4import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
5
6let currency = async (desired, base = "usd", amount = 1) => {
7 // let { rates } = await fetchJSON(`https://open.er-api.com/v6/latest/${base}`);
8 // if (rates && rates[desired.toUpperCase()]) return amount * (rates[desired.toUpperCase()]);
9 // else {
10 let { rates } = await fetchJSON("https://api.coingecko.com/api/v3/exchange_rates");
11 return amount * rates[desired.toLowerCase()]?.value / rates[base.toLowerCase()]?.value;
12};