13 setError("");
14 try {
15 const res = await fetch(`${window.location.href}api/map`, {
16 method: "POST",
17 headers: {
103 const url = new URL(req.url);
104
105 if (req.method === "POST" && url.pathname === "/api/map") {
106 const { domain } = await req.json();
107 if (!domain) {
110
111 try {
112 const response = await fetch("https://api.firecrawl.dev/v1/map", {
113 method: "POST",
114 headers: {
2
3const browser = await puppeteer.connect({
4 browserWSEndpoint: `wss://connect.browserbase.com?apiKey=${Deno.env.get("BROWSERBASE_API_KEY")}`,
5})
6
13 setError("");
14 try {
15 const res = await fetch(`${window.location.origin}/api`, {
16 method: 'POST',
17 headers: {
123 const url = new URL(req.url);
124
125 if (req.method === "POST" && url.pathname === "/api") {
126 try {
127 const { domain } = await req.json();
130 }
131
132 const firecrawlResponse = await fetch("https://api.firecrawl.dev/v1/map", {
133 method: "POST",
134 headers: {
26 setError("");
27 try {
28 const res = await fetch(`${window.location.href}api?city=${encodeURIComponent(city)}`);
29 const data = await res.json();
30 if (data.error) {
159 const url = new URL(req.url);
160
161 if (req.method === "GET" && url.pathname === "/api") {
162 const city = url.searchParams.get("city");
163 if (!city) {
167 try {
168 const weatherUrl =
169 `https://api.open-meteo.com/v1/forecast?latitude=52.52&longitude=13.41¤t_weather=true&daily=temperature_2m_max,weathercode&timezone=auto&forecast_days=5`;
170 const weatherRes = await fetch(weatherUrl);
171 const weatherData = await weatherRes.json();
16 const { provider, id } = c.req.param();
17 if (!["rabbit", "mega"].includes(provider)) {
18 return c.json({ error: "Invalid API request" }, 500);
19 }
20 // const cache = await blob.getJSON(id);
1Migrated from folder: GraphQL/graphqlAPIEndpoint
15 try {
16 const fal = createFalClient({
17 proxyUrl: "/api/fal/proxy",
18 });
19
139 }
140
141 if (url.pathname === "/api/fal/proxy") {
142 return falProxyRequest(req);
143 }
71 `;
72
73 console.log(`Making LSD API request for ${pageUrl}...`);
74 const response = await fetch(
75 `https://lsd.so/api?query=${encodeURIComponent(query)}`
76 );
77
15 try {
16 const fal = createFalClient({
17 proxyUrl: "/api/fal/proxy",
18 });
19
139 }
140
141 if (url.pathname === "/api/fal/proxy") {
142 return falProxyRequest(req);
143 }
332
333const css = `
334 @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600&display=swap');
335
336 :root {
664async function server(request: Request): Promise<Response> {
665 if (request.method === "POST" && new URL(request.url).pathname === "/generate-training") {
666 const YOUTUBE_API_KEY = Deno.env.get("YOUTUBE_API_KEY2");
667 const useApiKey = YOUTUBE_API_KEY !== undefined && YOUTUBE_API_KEY !== "";
668 if (!YOUTUBE_API_KEY) {
669 console.warn("YouTube API key (YOUTUBE_API_KEY2) is not set. Falling back to search URL method.");
670 }
671
722 for (const placeholder of videoPlaceholders) {
723 const searchQuery = placeholder.replace('[VIDEO: ', '').replace(']', '');
724 const videoId = await getYouTubeVideoId(searchQuery, sport, YOUTUBE_API_KEY);
725 if (videoId) {
726 const embedHtml = `
805}
806
807async function getYouTubeVideoId(query, sport, apiKey, useApiKey = true) {
808 if (useApiKey) {
809 try {
810 const searchUrl = `https://www.googleapis.com/youtube/v3/search?part=snippet&q=${encodeURIComponent(sport + ' ' + query)}&key=${apiKey}&type=video&maxResults=1`;
811 const response = await fetch(searchUrl);
812 const data = await response.json();
813 if (data.error) {
814 console.warn("YouTube API error:", data.error.message);
815 return getFallbackYouTubeLink(query, sport);
816 }
819 }
820 } catch (error) {
821 console.error("Error fetching from YouTube API:", error);
822 }
823 }