FirstProjectindex.js21 matches
55};
5657// Fetch job listings
58const fetchJobs = async () => {
59try {
60const response = await fetch('/api/jobs');
61if (!response.ok) throw new Error('Failed to fetch jobs');
62
63const jobs = await response.json();
81`).join('');
82} catch (error) {
83console.error('Error fetching jobs:', error);
84jobListings.innerHTML = '<p class="text-red-500">Failed to load jobs. Please try again later.</p>';
85}
104};
105
106const response = await fetch('/api/jobs', {
107method: 'POST',
108headers: {
119// Reset form and refresh job listings
120jobForm.reset();
121await fetchJobs();
122
123// Show success message
132});
133134// Fetch chat messages
135const fetchChatMessages = async () => {
136try {
137const response = await fetch('/api/chat');
138if (!response.ok) throw new Error('Failed to fetch chat messages');
139
140const messages = await response.json();
166chatMessages.scrollTop = chatMessages.scrollHeight;
167} catch (error) {
168console.error('Error fetching chat messages:', error);
169chatMessages.innerHTML = '<p class="text-red-500">Failed to load messages. Please try again later.</p>';
170}
188document.getElementById('message').focus();
189
190// Fetch messages and start polling
191fetchChatMessages();
192startPolling();
193});
202
203try {
204const response = await fetch('/api/chat', {
205method: 'POST',
206headers: {
218}
219
220// Clear input and fetch new messages
221messageInput.value = '';
222await fetchChatMessages();
223} catch (error) {
224console.error('Error sending message:', error);
231if (pollingInterval) clearInterval(pollingInterval);
232
233pollingInterval = setInterval(fetchChatMessages, 3000);
234};
235243const init = async () => {
244setViewSourceLink();
245await fetchJobs();
246
247// If on chat tab and username is set, fetch messages and start polling
248if (currentUsername && !chatContent.classList.contains('hidden')) {
249await fetchChatMessages();
250startPolling();
251}
FirstProjectchat.ts2 matches
12return c.json(messages);
13} catch (error) {
14console.error("Error fetching chat messages:", error);
15return c.json({ error: "Failed to fetch chat messages" }, 500);
16}
17});
FirstProjectjobs.ts2 matches
11return c.json(jobPostings);
12} catch (error) {
13console.error("Error fetching job postings:", error);
14return c.json({ error: "Failed to fetch job postings" }, 500);
15}
16});
3233try {
34// 1. Fetch suggestions
35const suggestUrl = `https://api.lyrics.ovh/suggest/${encodeURIComponent(query)}`;
36console.log(`Fetching suggestions from: ${suggestUrl}`);
37const suggestResponse = await fetch(suggestUrl);
3839if (!suggestResponse.ok) {
40console.error(`Error fetching suggestions: ${suggestResponse.status} ${suggestResponse.statusText}`);
41const errorBody = await suggestResponse.text();
42console.error(`Error body: ${errorBody}`);
43return c.json({ error: 'Failed to fetch song suggestions', details: errorBody }, suggestResponse.status);
44}
4558console.log(`Found song: Title - ${actualTitle}, Artist - ${actualArtist}`);
5960// 3. Fetch lyrics
61const lyricsUrl = `https://api.lyrics.ovh/v1/${encodeURIComponent(actualArtist)}/${encodeURIComponent(actualTitle)}`;
62console.log(`Fetching lyrics from: ${lyricsUrl}`);
63const lyricsResponse = await fetch(lyricsUrl);
6465if (!lyricsResponse.ok) {
66console.error(`Error fetching lyrics: ${lyricsResponse.status} ${lyricsResponse.statusText}`);
67const errorBody = await lyricsResponse.text();
68console.error(`Error body: ${errorBody}`);
72return c.json({ error: errorJson.error || 'Lyrics not found for this song' }, 404);
73}
74return c.json({ error: 'Failed to fetch lyrics', details: errorBody }, lyricsResponse.status);
75}
76125});
126127// Export the fetch handler for the worker
128export default app.fetch;
JobPlatformindex.ts1 match
4142// This is the entry point for HTTP vals
43export default app.fetch;
JobPlatformapp.js8 matches
85async function loadJobs() {
86try {
87const response = await fetch('/api/jobs');
88if (!response.ok) throw new Error('Failed to fetch jobs');
89
90const jobs = await response.json();
120};
121
122const response = await fetch('/api/jobs', {
123method: 'POST',
124headers: {
187async function loadChatMessages() {
188try {
189const response = await fetch('/api/chat');
190if (!response.ok) throw new Error('Failed to fetch chat messages');
191
192const messages = await response.json();
235if (lastChatTimestamp) {
236try {
237const response = await fetch(`/api/chat/recent?since=${lastChatTimestamp}`);
238if (!response.ok) throw new Error('Failed to fetch recent messages');
239
240const newMessages = await response.json();
278
279try {
280const response = await fetch('/api/chat', {
281method: 'POST',
282headers: {
JobPlatformchat.ts4 matches
12return c.json(messages);
13} catch (error) {
14console.error("Error fetching chat messages:", error);
15return c.json({ error: "Failed to fetch chat messages" }, 500);
16}
17});
28return c.json(messages);
29} catch (error) {
30console.error("Error fetching recent chat messages:", error);
31return c.json({ error: "Failed to fetch recent chat messages" }, 500);
32}
33});
JobPlatformjobs.ts4 matches
11return c.json(jobsList);
12} catch (error) {
13console.error("Error fetching jobs:", error);
14return c.json({ error: "Failed to fetch jobs" }, 500);
15}
16});
31return c.json(job);
32} catch (error) {
33console.error("Error fetching job:", error);
34return c.json({ error: "Failed to fetch job" }, 500);
35}
36});
lyristlyricsProcessor.ts8 matches
23*/
2425import { fetch as proxiedFetch } from "https://esm.town/v/std/fetch";
26import * as cheerio from "npm:cheerio";
27import { fetchLyricsMetadata } from "./lyrics";
2829/**
55}
5657const res = await fetchLyricsMetadata(query);
5859if (res.status === 200 && res.url !== "Not found") {
63"Accept-Language": "en-US,en;q=0.9",
64"Cache-Control": "max-age=0",
65"Sec-Fetch-Dest": "document",
66"Sec-Fetch-Mode": "navigate",
67"Sec-Fetch-Site": "none",
68"Sec-Fetch-User": "?1",
69"Sec-Gpc": "1",
70"Upgrade-Insecure-Requests": "1",
80}
8182const response = await fetch(res.url, { headers: headers });
83const targetHtml = await response.text();
84let $ = cheerio.load(targetHtml);
23*/
2425import { fetch as proxiedFetch } from "https://esm.town/v/std/fetch";
2627interface LyricsResponse {
53}
5455export const fetchLyricsMetadata = async (
56searchTerm: string,
57): Promise<LyricsResponse> => {
7374// Make the API request
75const response = await proxiedFetch(target, { headers });
76const data = await response.json();
77