untitled-8502index.ts1 match
33});
3435export default app.fetch;
untitled-8502api.ts4 matches
33return c.json(companies);
34} catch (error) {
35console.error("Error fetching companies:", error);
36return c.json({ error: "Failed to fetch companies" }, 500);
37}
38});
55return c.json(company);
56} catch (error) {
57console.error("Error fetching company:", error);
58return c.json({ error: "Failed to fetch company" }, 500);
59}
60});
crypto-web-appindex.ts13 matches
20// Inject initial data to avoid extra round-trips
21try {
22const initialCoins = await fetchCoins(20);
23const dataScript = `<script>
24window.__INITIAL_DATA__ = ${JSON.stringify({ coins: initialCoins })};
26html = html.replace("</head>", `${dataScript}</head>`);
27} catch (error) {
28console.error("Failed to fetch initial data:", error);
29}
30
38try {
39const limit = Math.min(parseInt(c.req.query("limit") || "50"), 250);
40const coins = await fetchCoins(limit);
41return c.json(coins);
42} catch (error) {
43console.error("Error fetching coins:", error);
44return c.json({ error: "Failed to fetch cryptocurrency data" }, 500);
45}
46});
52const days = c.req.query("days") || "7";
53
54const chartData = await fetchChartData(coinId, days);
55return c.json(chartData);
56} catch (error) {
57console.error("Error fetching chart data:", error);
58return c.json({ error: "Failed to fetch chart data" }, 500);
59}
60});
62// Helper functions
6364async function fetchCoins(limit: number = 50): Promise<CryptoCoin[]> {
65const response = await fetch(
66`https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&order=market_cap_desc&per_page=${limit}&page=1&sparkline=false&price_change_percentage=24h,7d,30d`
67);
74}
7576async function fetchChartData(coinId: string, days: string): Promise<ChartData> {
77// Add interval parameter for better data granularity
78let interval = '';
84}
85
86const response = await fetch(
87`https://api.coingecko.com/api/v3/coins/${coinId}/market_chart?vs_currency=usd&days=${days}${interval}`
88);
97}
9899export default app.fetch;
crypto-web-appCryptoChart.tsx5 matches
4243useEffect(() => {
44fetchChartData(selectedTimeRange);
45}, [coin.id, selectedTimeRange]);
4647const fetchChartData = async (timeRange: TimeRange) => {
48try {
49setLoading(true);
50setError(null);
51
52const response = await fetch(`/api/coins/${coin.id}/chart?days=${timeRange}`);
53if (!response.ok) {
54throw new Error('Failed to fetch chart data');
55}
56
247<p className="text-red-600 mb-4">{error}</p>
248<button
249onClick={() => fetchChartData(selectedTimeRange)}
250className="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-lg transition-colors"
251>
crypto-web-appApp.tsx6 matches
2223useEffect(() => {
24// Use initial data if available, otherwise fetch
25if (window.__INITIAL_DATA__?.coins) {
26setCoins(window.__INITIAL_DATA__.coins);
27setLoading(false);
28} else {
29fetchCoins();
30}
31}, []);
3233const fetchCoins = async () => {
34try {
35setLoading(true);
36setError(null);
37const response = await fetch('/api/coins?limit=50');
38if (!response.ok) {
39throw new Error('Failed to fetch cryptocurrency data');
40}
41const data = await response.json();
75<p className="text-gray-600 mb-4">{error}</p>
76<button
77onClick={fetchCoins}
78className="bg-blue-500 hover:bg-blue-600 text-white px-6 py-2 rounded-lg transition-colors"
79>
crypto-web-appREADME.md2 matches
3334- `GET /` - Serves the main application
35- `GET /api/coins` - Fetches list of cryptocurrencies
36- `GET /api/coins/:id/chart` - Fetches chart data for a specific coin
37- `GET /frontend/*` - Serves frontend assets
38- `GET /shared/*` - Serves shared utilities
JobChatRoom.tsx7 matches
16};
1718const fetchMessages = async () => {
19try {
20setLoading(true);
21const response = await fetch('/api/chat/messages');
22const result: ApiResponse<ChatMessage[]> = await response.json();
23
26setError(null);
27} else {
28setError(result.error || 'Failed to fetch messages');
29}
30} catch (err) {
31setError('Failed to fetch messages');
32} finally {
33setLoading(false);
51};
5253const response = await fetch('/api/chat/messages', {
54method: 'POST',
55headers: {
7778useEffect(() => {
79fetchMessages();
80
81// Load saved username
8687// Poll for new messages every 5 seconds
88const interval = setInterval(fetchMessages, 5000);
89return () => clearInterval(interval);
90}, []);
JobJobForm.tsx1 match
2526try {
27const response = await fetch('/api/jobs', {
28method: 'POST',
29headers: {
JobJobBoard.tsx6 matches
10const [error, setError] = useState<string | null>(null);
1112const fetchJobs = async () => {
13try {
14setLoading(true);
15const response = await fetch('/api/jobs');
16const result: ApiResponse<Job[]> = await response.json();
17
20setError(null);
21} else {
22setError(result.error || 'Failed to fetch jobs');
23}
24} catch (err) {
25setError('Failed to fetch jobs');
26} finally {
27setLoading(false);
4041try {
42const response = await fetch(`/api/jobs/${jobId}`, {
43method: 'DELETE'
44});
5758useEffect(() => {
59fetchJobs();
60}, []);
61