diff options
author | mat <27899617+mat-1@users.noreply.github.com> | 2021-02-28 16:03:55 -0600 |
---|---|---|
committer | mat <27899617+mat-1@users.noreply.github.com> | 2021-02-28 16:03:55 -0600 |
commit | f54b3b138db5eb566e5027c458ba77ef5f3560c7 (patch) | |
tree | 0effc0726f2663080798117b035acd7c4f9ce056 | |
parent | 13985abd157d8339dc9db7137dc9b86ee7a0a616 (diff) | |
download | skyblock-api-f54b3b138db5eb566e5027c458ba77ef5f3560c7.tar.gz skyblock-api-f54b3b138db5eb566e5027c458ba77ef5f3560c7.tar.bz2 skyblock-api-f54b3b138db5eb566e5027c458ba77ef5f3560c7.zip |
add /leaderboards
-rw-r--r-- | src/database.ts | 2 | ||||
-rw-r--r-- | src/index.ts | 9 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/database.ts b/src/database.ts index d1ad8e6..7cc2f46 100644 --- a/src/database.ts +++ b/src/database.ts @@ -76,7 +76,7 @@ function getMemberLeaderboardAttributes(member: CleanMember) { } /** Fetch the names of all the leaderboards */ -async function fetchAllMemberLeaderboardAttributes(): Promise<string[]> { +export async function fetchAllMemberLeaderboardAttributes(): Promise<string[]> { return [ // we use the raw stat names rather than the clean stats in case hypixel adds a new stat and it takes a while for us to clean it ...await constants.fetchStats(), diff --git a/src/index.ts b/src/index.ts index 0c33930..a1da3e1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,6 @@ import { fetchMemberProfile, fetchUser } from './hypixel' import express from 'express' -import { fetchMemberLeaderboard } from './database' +import { fetchAllMemberLeaderboardAttributes, fetchMemberLeaderboard } from './database' const app = express() @@ -40,5 +40,12 @@ app.get('/leaderboard/:name', async(req, res) => { ) }) +app.get('/leaderboards', async(req, res) => { + res.json( + await fetchAllMemberLeaderboardAttributes() + ) +}) + + app.listen(8080, () => console.log('App started :)')) |