1import { fetch } from "https://esm.town/v/std/fetch";
2
3export const bookReservationOnResy = async ({
145 )
146 }&password=${encodeURIComponent(params.password)}`;
147 const response = await fetch(`${RESY_API_URL}/3/auth/password`, {
148 method: "POST",
149 body: body,
167 }) => {
168 const url = `${RESY_API_URL}/3/details`;
169 const response = await fetch(url.toString(), {
170 method: "POST",
171 headers: RESY_DEFAULT_HEADERS,
192 searchParams.set("party_size", params.seats.toString());
193 searchParams.set("venue_id", params.venueId);
194 const response = await fetch(`${url}?${searchParams}`, {
195 method: "GET",
196 headers: RESY_DEFAULT_HEADERS,
212 searchParams.set("url_slug", params.slug);
213 searchParams.set("location", params.city);
214 const response = await fetch(`${url}?${searchParams}`, {
215 method: "GET",
216 headers: RESY_DEFAULT_HEADERS,
224 authToken: string;
225 }) => {
226 const response = await fetch(`${RESY_API_URL}/3/book`, {
227 method: "POST",
228 headers: {
252 venueId,
253 });
254 console.log("Fetched available slots for day", {
255 count: slots.length,
256 times: slots.map((slot) => `${slot.date.start} -> ${slot.date.end}`),
18 while (retries < maxRetries) {
19 try {
20 const response = await fetch("/scrape", {
21 method: "POST",
22 headers: { "Content-Type": "application/json" },
46 console.log(`Error occurred while scraping URL: ${url}. Error details: ${error.message}`);
47
48 if (error.name === "TypeError" && error.message === "Failed to fetch") {
49 setResult({ error: "Network error. Please check your internet connection and try again." });
50 } else if (retries === maxRetries - 1) {
204 console.log(`Sending request to ScrapingBee API for URL: ${url}`);
205 try {
206 const response = await fetch(
207 `https://app.scrapingbee.com/api/v1/?api_key=${apiKey}&url=${
208 encodeURIComponent(url)
11 if (!websiteUrl) return;
12
13 const response = await fetch("/generate-embed", {
14 method: "POST",
15 headers: { "Content-Type": "application/json" },
25
26 useEffect(() => {
27 const fetchVisitorCount = async () => {
28 if (websiteUrl) {
29 const response = await fetch(`/visitor-count?url=${encodeURIComponent(websiteUrl)}`);
30 if (response.ok) {
31 const { count } = await response.json();
35 };
36
37 fetchVisitorCount();
38 const interval = setInterval(fetchVisitorCount, 5000);
39 return () => clearInterval(interval);
40 }, [websiteUrl]);
96
97 useEffect(() => {
98 const fetchCount = async () => {
99 const response = await fetch('${url.origin}/count-visitor?url=${encodedUrl}');
100 if (response.ok) {
101 const { count } = await response.json();
104 };
105
106 fetchCount();
107 }, []);
108
61 }, [state.loading, state.hasMore]);
62
63 const fetchStories = async () => {
64 try {
65 const response = await fetch("/api/stories");
66 if (!response.ok) throw new Error("Failed to fetch dates");
67 const data = await response.json();
68 setStories(data);
70 }
71 catch (err) {
72 console.error("Error fetching stories:", err);
73 }
74 };
75
76 const fetchComments = async (query: string, story: string, page: number) => {
77 try {
78 dispatch({ type: "loading", value: true });
79 const response = await fetch(`/api/comments?query=${encodeURIComponent(query)}&story=${story}&page=${page}`);
80 if (!response.ok) throw new Error("Failed to fetch comments");
81 const data = await response.json();
82 setComments(prevComments => page === 1 ? data.hits : [...prevComments, ...data.hits]);
84 dispatch({ type: "loading", value: false });
85 } catch (err) {
86 console.error("Error fetching comments:", err);
87 dispatch({ type: "loading", value: false });
88 }
99 dispatch({ type: "hasMore", value: true });
100 dispatch({ type: "query", value: newQuery });
101 fetchComments(fullQuery, state.story, 1);
102 };
103
104 useEffect(() => {
105 fetchStories();
106
107 const handleScroll = () => {
122 : "";
123 const fullQuery = `${filtersQuery} ${state.query}`;
124 fetchComments(fullQuery, state.story, state.page);
125 }
126 }
391 tags: `comment, story_${story}`,
392 page: 0,
393 hitsPerPage: 100, // Fetch a moderate number of comments
394 });
395
147app.get('/main.js', serve(js, 'text/javascript'));
148
149export default app.fetch;
540);
541
542export default app.fetch;
139 db.subscribeQuery({ bikes: {} }, (resp) => {
140 if (resp.error) {
141 setError(`Error fetching bikes: ${resp.error.message}`);
142 return;
143 }
144 if (resp.data) {
145 console.log("Fetched bikes:", resp.data.bikes);
146 setBikes(resp.data.bikes || []);
147 }
1/** @jsxImportSource https://esm.sh/hono@latest/jsx **/
2
3import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
4import { iframeHandler } from "https://esm.town/v/nbbaier/iframeHandler";
5import { resetStyle } from "https://esm.town/v/nbbaier/resetStyle";
16import { verifyToken } from "https://esm.town/v/pomdtr/verifyToken";
17import { ResultSet, sqlite } from "https://esm.town/v/std/sqlite";
18import { reloadOnSaveFetchMiddleware } from "https://esm.town/v/stevekrouse/reloadOnSave";
19import { Hono } from "npm:hono";
20import type { FC } from "npm:hono/jsx";
175});
176
177export const handler = app.fetch;
178export default iframeHandler(modifyFetchHandler(passwordAuth(handler, { verifyPassword: verifyToken })));
31});
32
33export default lastlogin(app.fetch);
62 try {
63 const url = `${this.#contents}/${path}`;
64 const response = await fetch(url, { headers: this.headers() });
65 if (response.ok) return true;
66 this.error("exist", url, response);
74 try {
75 const url = `${this.#contents}/${path}`;
76 const response = await fetch(url, { headers: this.headers() });
77 if (!response.ok) {
78 return this.error("get: not found", url, response);
93 try {
94 const url = `${this.#raw}/${path}`;
95 const response = await fetch(url, { headers: this.headers() });
96 if (!response.ok) return this.error("raw", url, response);
97 const data = binary
114 const url = `${this.#contents}/${path}`;
115 console.log("delete", url);
116 const response = await fetch(url, {
117 method: "DELETE",
118 headers: this.headers(),
146 sha = data.sha;
147 }
148 const result = await fetch(url, {
149 method: "PUT",
150 headers: this.headers(),
166 ).toString("base64");
167 const url = `${this.#contents}/${path}`;
168 const result = await fetch(url, {
169 method: "PUT",
170 headers: this.headers(),
263});
264
265export default application.fetch;