223
224 // Use BinList.net free API (no API key required)
225 const response = await fetch(`https://lookup.binlist.net/${cleanBin}`);
226
227 if (!response.ok) {
276app.get("/api/marketplace/products", async c => {
277 try {
278 // In a real application, this would fetch from a database
279 const products = [
280 {
347 });
348 } catch (error) {
349 return c.json({ error: "Failed to fetch products" }, 500);
350 }
351});
355 const id = c.req.param("id");
356
357 // In a real application, this would fetch from a database
358 const products = [
359 {
400 });
401 } catch (error) {
402 return c.json({ error: "Failed to fetch product" }, 500);
403 }
404});
431});
432
433export default app.fetch;
42
43 try {
44 const response = await fetch(`/api/bin-lookup`, {
45 method: "POST",
46 headers: {
14 const databaseId = "16e2c190bff080fd9ea8d2a8c21548b0";
15
16 // Use database query with filter instead of direct page fetch
17 const response = await fetch(`https://api.notion.com/v1/databases/${databaseId}/query`, {
18 method: "POST",
19 headers: {
56
57 let keyword = "";
58 console.log(`Fetched ${data.results.length} pages from Notion API:`);
59 for (const page of data.results) {
60 // console.log("Checking page", page.properties.ID);
5 const camera = (url.pathname == "/") ? "camera1" : url.pathname.slice(1);
6
7 const response = await fetch("https://gliderport.thilenius.com/api/getLastFiveSmallImages");
8 const json = await response.json();
9
57 const credentials = btoa(`${this.clientId}:${this.clientSecret}`);
58
59 const response = await fetch(`${KROGER_BASE_URL}/v1/connect/oauth2/token`, {
60 method: "POST",
61 headers: {
84 const credentials = btoa(`${this.clientId}:${this.clientSecret}`);
85
86 const response = await fetch(`${KROGER_BASE_URL}/v1/connect/oauth2/token`, {
87 method: "POST",
88 headers: {
108 */
109 async getUserProfile(accessToken: string): Promise<KrogerProfileResponse> {
110 const response = await fetch(`${KROGER_BASE_URL}/v1/identity/profile`, {
111 headers: {
112 Authorization: `Bearer ${accessToken}`,
117 if (!response.ok) {
118 const errorText = await response.text();
119 throw new Error(`Profile fetch failed: ${response.status} ${errorText}`);
120 }
121
179 });
180
181 const response = await fetch(
182 `${KROGER_BASE_URL}/v1/locations?${params.toString()}`,
183 {
206 locationId: string
207 ): Promise<KrogerLocationResponse> {
208 const response = await fetch(
209 `${KROGER_BASE_URL}/v1/locations/${locationId}`,
210 {
218 if (!response.ok) {
219 const errorText = await response.text();
220 throw new Error(`Location fetch failed: ${response.status} ${errorText}`);
221 }
222
142 const upstream = `${targetUrl.origin}/${path}${upstreamSearch ? "?" + upstreamSearch : ""}`;
143
144 const resp = await fetch(upstream, {
145 method: req.method,
146 headers: req.headers,
42
43 useEffect(() => {
44 async function fetchQuote() {
45 try {
46 const known = await getKnownTexts();
52 let waited = 0;
53 while (value === undefined && waited <= 10) {
54 const response = await fetch(`https://simplevalueapi.val.run/getValue?id=${uuid}`);
55 const responseData = await response.json();
56 if (responseData?.value?.cipher === undefined) {
93 });
94 }
95 console.log("new uuid, fetching new quote");
96 let keyword = "";
97 let quote = "";
98 let author = "";
99 while (quote === "") {
100 const response = await fetch(`/quote`);
101 const responseData = await response.json();
102 if ((responseData?.quote?.length ?? 0) >= 5) {
132 }
133 } catch (error) {
134 console.error("Failed to fetch quote:", error);
135 setLoadingError(`${error}`);
136 setIsLoading(false);
138 }
139
140 fetchQuote();
141 }, []);
142
76
77// Helper function to make authenticated requests
78async function authenticatedFetch(url: string, session: LibrarySession, options: RequestInit = {}) {
79 return fetch(url, {
80 ...options,
81 client: session.client,
137 });
138
139 const loginResp = await fetch(LOGIN_URL, {
140 method: "POST",
141 client,
166
167 // Follow the redirect to get to the main page
168 const mainPageResp = await authenticatedFetch(redirectUrl, session);
169 const mainPageHtml = await mainPageResp.text();
170
260 }
261
262 const resp = await authenticatedFetch(session.currentLoansUrl, session);
263 const html = await resp.text();
264 const { books, renewAllUrl } = await parseBooks(html, session.currentLoansUrl);
284 }
285
286 const resp = await authenticatedFetch(session.renewAllUrl, session, {
287 method: "GET", // Most library systems use GET for renew all
288 });
12
13app.get("/", (c) => {
14 return app.fetch(new Request(`./blog`));
15});
16
45});
46
47export default app.fetch;
135 const lastSunday = today.startOf("week").minus({ days: 1 });
136
137 // Fetch relevant memories using the utility function
138 const memories = await getRelevantMemories();
139