Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update DD2 API interface with new data #186

Merged
merged 1 commit into from
May 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/server/modules/deepdip/get-global-leaderboard.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
import fetch from 'isomorphic-unfetch';

export interface LeaderboardResult {
/** Current player rank */
rank: number;
/** Player's account ID from Trackmania's live services */
wsid: string;
/** Personal best height (in meters) */
height: number;
/** Unix timestamp of when the personal best was recorded */
ts: number;
/** Player's display name */
name: string;
/** Number of times player's personal best is updated */
update_count: number;
/** Player's selected colour in-game (in RGB percentage) */
color: number[];
}

const DD2_API_ENDPOINT = 'https://dips-plus-plus.xk.io';

export async function getGlobalLeaderboard() {
const response = await fetch('https://dips-plus-plus.xk.io/leaderboard/global');
const response = await fetch(`${DD2_API_ENDPOINT}/leaderboard/global`);
const data: LeaderboardResult[] = await response.json();

return data;
}

export async function getCurrentProgress(accountId = '15d23e07-07ac-4093-bbfd-28d393daf0c0') {
const response = await fetch(`https://dips-plus-plus.xk.io/leaderboard/${accountId}`);
const response = await fetch(`${DD2_API_ENDPOINT}/leaderboard/${accountId}`);
const data: LeaderboardResult = await response.json();

return data;
Expand Down
Loading