Skip to content

Commit

Permalink
feat: update DD2 API interface with new data (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
resir014 authored May 15, 2024
1 parent 3691c9f commit e57bd24
Showing 1 changed file with 13 additions and 2 deletions.
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

0 comments on commit e57bd24

Please sign in to comment.