Skip to content

Commit

Permalink
Merge pull request #122 from Lilypad-Tech/noryev/fix-webui
Browse files Browse the repository at this point in the history
Noryev/fix webui
  • Loading branch information
noryev authored Jan 21, 2025
2 parents 3b2cd09 + 1742b1f commit 7bbec7f
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 10 deletions.
3 changes: 2 additions & 1 deletion apps/info-dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"start": "next start",
"lint": "next lint",
"test": "vitest",
"preview": "pnpm dlx http-server out"
"preview": "pnpm dlx http-server out",
"boot": "doppler run --preserve-env --command=\"pnpm i && pnpm -r build\""
},
"dependencies": {
"@floating-ui/react": "^0.26.17",
Expand Down
19 changes: 15 additions & 4 deletions apps/info-dashboard/src/lib/fetchers/leaderboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,21 @@ import {
import { NodesEndpointReturnType } from "./nodes";

export async function fetchLeaderboard() {
const API_HOST = process.env.NEXT_PUBLIC_API_HOST;
const leaderboard_url = `${API_HOST}metrics-dashboard/leaderboard`;
const raw = await fetch(leaderboard_url);
return (await raw.json()) as LeaderboardReturnType;
// Add default value and trim any trailing slashes
const API_HOST = (process.env.NEXT_PUBLIC_API_HOST || '').replace(/\/$/, '');
// Add error handling and logging
try {
const leaderboard_url = `${API_HOST}/metrics-dashboard/leaderboard`;
console.log('Fetching from:', leaderboard_url); // Debug log
const raw = await fetch(leaderboard_url);
if (!raw.ok) {
throw new Error(`HTTP error! status: ${raw.status}`);
}
return (await raw.json()) as LeaderboardReturnType;
} catch (error) {
console.error('Error fetching leaderboard:', error);
throw error;
}
}

export function toTableData({
Expand Down
19 changes: 14 additions & 5 deletions apps/info-dashboard/src/lib/fetchers/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,20 @@ export type NodesEndpointReturnElement = {
export type NodesEndpointReturnType = NodesEndpointReturnElement[];

export async function fetchNodes() {
const API_HOST = process.env.NEXT_PUBLIC_API_HOST;
const URL = `${API_HOST}metrics-dashboard/nodes`;
const raw = await fetch(URL);
const res = (await raw.json()) as NodesEndpointReturnType;
return res;
const API_HOST = (process.env.NEXT_PUBLIC_API_HOST || '').replace(/\/$/, '');
try {
const URL = `${API_HOST}/metrics-dashboard/nodes`;
console.log('Fetching nodes from:', URL); // Debug log
const raw = await fetch(URL);
if (!raw.ok) {
throw new Error(`HTTP error! status: ${raw.status}`);
}
const res = (await raw.json()) as NodesEndpointReturnType;
return res;
} catch (error) {
console.error('Error fetching nodes:', error);
throw error;
}
}

export function toGeoJson(data: NodesEndpointReturnType) {
Expand Down
102 changes: 102 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7bbec7f

Please sign in to comment.