From e57bd2473283bce1e2cd73d5e674f19cefeef1d7 Mon Sep 17 00:00:00 2001 From: Resi Respati Date: Wed, 15 May 2024 14:22:46 +0700 Subject: [PATCH] feat: update DD2 API interface with new data (#186) --- .../modules/deepdip/get-global-leaderboard.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/server/modules/deepdip/get-global-leaderboard.ts b/src/server/modules/deepdip/get-global-leaderboard.ts index 8de2945..fe60770 100644 --- a/src/server/modules/deepdip/get-global-leaderboard.ts +++ b/src/server/modules/deepdip/get-global-leaderboard.ts @@ -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;