29 };
30 }
31 const res = await fetch(url);
32 if (!res.ok)
33 throw Object.assign(new Error(res.statusText + " " + url), { res });
3import ky from "npm:ky";
4
5export async function fetchPost(url: string | URL) {
6 const postURL = new URL(url);
7 if (postURL.hostname !== "bsky.app") {
1import { fetchPaginatedData } from "https://esm.town/v/nbbaier/fetchPaginatedData";
2import { deleteVal } from "https://esm.town/v/neverstew/deleteVal";
3
4export async function listEmptyVals(id: string) {
5 const token = Deno.env.get("valtown");
6 const res = await fetchPaginatedData(`https://api.val.town/v1/users/${id}/vals`, {
7 headers: { Authorization: `Bearer ${token}` },
8 });
12export async function deleteEmptyVals(id: string) {
13 const token = Deno.env.get("valtown");
14 const res = await fetchPaginatedData(`https://api.val.town/v1/users/${id}/vals`, {
15 headers: { Authorization: `Bearer ${token}` },
16 });
82});
83
84export const blog = app.fetch;
1Migrated from folder: signed_fetch/activityPubAgent
1Migrated from folder: signed_fetch/signedFetch
1import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=46";
2import dateme from "https://esm.town/v/stevekrouse/dateme";
3
4export default modifyFetchHandler(dateme);
24});
25
26export default app.fetch;
43});
44
45export default app.fetch;
1// import { fetchTweet } from "https://esm.town/v/dpetrouk/fetchTweet?v=35";
2import { eval_ } from "https://esm.town/v/stevekrouse/eval_";
3import { fetchPost as fetchBskyPost } from "https://esm.town/v/vladimyr/fetchBlueskyPost";
4import { fetchTweet } from "https://esm.town/v/vladimyr/fetchTweet";
5
6export default async function(req: Request): Promise<Response> {
14 let post, code, result;
15 try {
16 post = await fetchPost(`https://${query}`);
17 result = await postEval(post, [req]);
18 return result;
31}
32
33export async function fetchPost(url: string | URL) {
34 const postURL = new URL(url);
35 if (["x.com", "twitter.com"].includes(postURL.hostname)) {
36 const tweet = await fetchTweet(postURL.href);
37 return { text: tweet.text };
38 }
39 if (postURL.hostname === "bsky.app") {
40 const bskyPost = await fetchBskyPost(postURL);
41 return { text: bskyPost.record.text };
42 }