17 return c.json({ success: true, data: jobs });
18 } catch (error) {
19 console.error("Error fetching jobs:", error);
20 return c.json({ success: false, error: "Failed to fetch jobs" }, 500);
21 }
22});
37 return c.json({ success: true, data: job });
38 } catch (error) {
39 console.error("Error fetching job:", error);
40 return c.json({ success: false, error: "Failed to fetch job" }, 500);
41 }
42});
62
63 useEffect(() => {
64 const fetchYCCompanies = async () => {
65 const storedCompanies = localStorage.getItem("ycCompanies");
66 if (storedCompanies) {
69 setDebugInfo(prevInfo => prevInfo + `\nLoaded ${companies.length} companies from localStorage`);
70 } else {
71 const response = await fetch("/companies.json");
72 const companies = await response.json();
73 setYcCompanies(companies);
74 localStorage.setItem("ycCompanies", JSON.stringify(companies));
75 setDebugInfo(prevInfo =>
76 prevInfo + `\nFetched ${companies.length} companies from server and stored in localStorage`
77 );
78 }
79 };
80 fetchYCCompanies();
81 }, []);
82
226
227export default async function server(request: Request): Promise<Response> {
228 const companies = await fetch("https://stevekrouse-yc_database.web.val.run").then(res => res.json());
229 const url = new URL(request.url);
230 if (url.pathname === "/companies.json") {
62
63 useEffect(() => {
64 const fetchYCCompanies = async () => {
65 const storedCompanies = localStorage.getItem("ycCompanies");
66 if (storedCompanies) {
69 setDebugInfo(prevInfo => prevInfo + `\nLoaded ${companies.length} companies from localStorage`);
70 } else {
71 const response = await fetch("/companies.json");
72 const companies = await response.json();
73 setYcCompanies(companies);
74 localStorage.setItem("ycCompanies", JSON.stringify(companies));
75 setDebugInfo(prevInfo =>
76 prevInfo + `\nFetched ${companies.length} companies from server and stored in localStorage`
77 );
78 }
79 };
80 fetchYCCompanies();
81 }, []);
82
226
227export default async function server(request: Request): Promise<Response> {
228 const companies = await fetch("https://stevekrouse-yc_database.web.val.run").then(res => res.json());
229 const url = new URL(request.url);
230 if (url.pathname === "/companies.json") {
6
7- Bluesky authentication using the AT Protocol
8- Fetch and display user's liked posts
9- Search functionality to filter through likes
10- Responsive design
27
28### POST /api/likes
29Fetches a user's likes, with optional search filtering.
30
31**Request Body:**
75 useEffect(() => {
76 if (isLoggedIn && sessionToken) {
77 fetchLikes(true);
78 }
79 }, [isLoggedIn, sessionToken]);
94 setCursor(undefined);
95 setHasMore(true);
96 fetchLikes(true);
97 }
98 }, [debouncedSearchQuery]);
104
105 try {
106 const response = await fetch("/api/login", {
107 method: "POST",
108 headers: {
138 };
139
140 const fetchLikes = async (reset = false) => {
141 if (isLoading || !sessionToken) return;
142
145
146 try {
147 const response = await fetch("/api/likes", {
148 method: "POST",
149 headers: {
172 setHasMore(!!data.cursor);
173 } else {
174 setError(data.error || "Failed to fetch likes");
175 }
176 } catch (err) {
185 try {
186 // Call logout API to clear session on server
187 await fetch("/api/logout", {
188 method: "POST",
189 headers: {
220
221 if (scrollTop + clientHeight >= scrollHeight - 100) {
222 fetchLikes();
223 }
224 }, [isLoading, hasMore, cursor, sessionToken]);
88
89// This is the entry point for HTTP vals
90export default app.fetch;
81
82 // Load tasks on page load
83 document.addEventListener('DOMContentLoaded', fetchTasks);
84
85 // Add task form submission
91
92 try {
93 const response = await fetch(API_URL, {
94 method: 'POST',
95 headers: {
113 });
114
115 // Fetch all tasks
116 async function fetchTasks() {
117 try {
118 const response = await fetch(API_URL);
119
120 if (!response.ok) {
121 throw new Error('Failed to fetch tasks');
122 }
123
135 }
136 } catch (error) {
137 console.error('Error fetching tasks:', error);
138 alert('Failed to load tasks. Please refresh the page.');
139 }
176 async function toggleTaskStatus(taskId, completed) {
177 try {
178 const response = await fetch(`${API_URL}/${taskId}`, {
179 method: 'PUT',
180 headers: {
213
214 try {
215 const response = await fetch(`${API_URL}/${taskId}`, {
216 method: 'DELETE'
217 });
83});
84
85// API endpoint to fetch user likes
86app.post("/api/likes", async c => {
87 try {
108 });
109
110 // Fetch likes
111 const likesResponse = await agent.getLikes({
112 actor: sessionData.did,
139 });
140 } catch (error) {
141 console.error("Fetch likes error:", error);
142 return c.json({
143 success: false,
173
174// Export the Hono app for HTTP vals
175export default app.fetch;
50 files={project.data?.files}
51 branchId={branchId}
52 refetch={project.refetch}
53 />
54 </ProjectContext>
60 files,
61 branchId,
62 refetch,
63}: {
64 project: any;
65 files: any[];
66 branchId: string;
67 refetch: () => void;
68}) {
69 const [images, setImages] = useState<(string|null)[]>([]);
94 if (!messages?.length) return;
95 let last = messages.at(-1);
96 if (shouldRefetch(last)) {
97 refetch();
98 }
99 }, [messages]);
177}
178
179function shouldRefetch (message) {
180 for (let i = 0; i < message?.parts?.length; i++) {
181 let part = message.parts[i];