52```
5354Cli vals don't have access to val town tokens. Instead of trying to replicate your valtown secrets locally, you can configure your cli vals to call your http endpoints using `fetch`.
6import {
7init,
8traced_fetch,
9traced_handler,
10} from "https://esm.town/v/saolsen/tracing";
39val_req_url = `${val_req_url}?v=${version}`;
40}
41const val_resp: Response = await traced_fetch(val_req_url);
42const val_version = Number(val_resp.url.split("?v=")[1]);
43const val_body: string = await val_resp.text();
166async function handler(req: Request): Promise<Response> {
167await track("saolsen.changes", req);
168return await app.fetch(req);
169}
170
siversRssEmailNotificationmain.tsx2 matches
1import { email } from "https://esm.town/v/std/email?v=11";
2import { fetchRSS } from "https://esm.town/v/stevekrouse/fetchRSS";
3import { newRSSItems } from "https://esm.town/v/stevekrouse/newRSSItems?v=6";
4import { parseXML } from "https://esm.town/v/stevekrouse/parseXML";
8const lastRunAt = interval.lastRunAt;
910const response = await fetch("https://sive.rs/en.atom");
11const xml = await response.text();
12const data = await parseXML(xml);
2import { email } from "https://esm.town/v/std/email?v=9";
3import { set } from "https://esm.town/v/std/set?v=11";
4import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
56export const runner = async () => {
14];
15const promises = ALERT_STRINGS.map(async function(keyword) {
16let posts = await fetchJSON(
17`https://search.bsky.social/search/posts?q=${keyword}`,
18);
testFetchCommentsValmain.tsx4 matches
1import { ConstructReadTangleUrl } from "https://esm.town/v/willthereader/ConstructReadTangleUrl";
2import { fetchComments } from "https://esm.town/v/willthereader/fetchComments";
3import { logMessage } from "https://esm.town/v/willthereader/logMessage";
4import { testUrlConstructionVal } from "https://esm.town/v/willthereader/testUrlConstructionVal";
56export const testFetchCommentsVal = async () => {
7const urls = [
8"https://www.readtangle.com/members/api/comments/?post_id=0%3A6",
22"https://www.readtangle.com/members/api/comments/?post_id=0%3A6",
23]; // Await the resolution of the promise from testUrlConstructionVal
24await fetchComments(urls); // Now urls is an array, so it can be passed to fetchComments
25};
2627testFetchCommentsVal();
1import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=42";
34export default async function (req: Request) {
27}
2829const gist = await fetchJSON(`https://api.github.com/gists/${id}`);
30if (gist.owner.login != author) {
31return new Response("Unauthorized", {
untitled_cyanLampreymain.tsx1 match
3import { timed } from "https://esm.town/v/stevekrouse/timed";
45const dateme_html_cache = await (await fetch("https://stevekrouse-dateme.web.val.run/")).text();
67await blob.delete("dateme_html_cache");
1import { fetch } from "https://esm.town/v/std/fetch";
2export default async function(req: Request): Promise<Response> {
3const p = Object.fromEntries(new URL(req.url).searchParams);
4if (!p.url) return Response.json("missing url");
5console.log("checking", p.url);
6const res = await fetch(p.url);
7if (!res.ok) return Response.json(res.status);
8const txt = await res.text();
gptMemoryManagermain.tsx1 match
458});
459460return app.fetch(req);
461};
youtubeEndpointmain.tsx10 matches
2import { YouTube } from 'https://deno.land/x/youtube@v0.3.0/mod.ts';
34export async function fetchVideoDetails(req) {
5const url = new URL(req.url);
6let yturl = url.searchParams.get("yturl") || "";
2930try {
31let response = await fetch(apiUrl);
32let data = await response.json();
33if (!data.items || data.items.length === 0) {
84const categoryId = item.snippet.categoryId;
85apiUrl = `https://www.googleapis.com/youtube/v3/videoCategories?part=snippet&id=${categoryId}&key=${apiKey}`;
86response = await fetch(apiUrl);
87data = await response.json();
88const category = data.items && data.items.length > 0 ? data.items[0].snippet.title : 'N/A';
94break;
95case 'transcript':
96async function fetchcaptions(videoId) {
97const WATCH_URL = `https://www.youtube.com/watch?v=${videoId}`;
9899try {
100const response = await fetch(WATCH_URL);
101const html = await response.text();
102const jsonMatch = html.match(/"captions":({.*?}), "videoDetails"/);
110111const captionsUrl = captionsJson.captionTracks[0].baseUrl;
112const captionsResponse = await fetch(captionsUrl);
113const captionsText = await captionsResponse.text();
114return captionsText;
115} catch (error) {
116console.error('Failed to fetch Youtube captions:', error);
117throw error;
118}
119}
120121fetchcaptions(videoId).then(captions => {
122return new Response(captions);
123}).catch(error => {
124console.error('Error fetching captions:', error)
125});
126130return new Response(responseContent);
131} catch (error) {
132console.error("Error fetching video details:", error);
133throw error;
134}