From 14622b310f170daa7d720da85c65a68dc6784702 Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Sun, 28 Feb 2021 21:22:48 -0600 Subject: fix constant cache --- src/constants.ts | 3 ++- src/database.ts | 2 +- src/index.ts | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/constants.ts b/src/constants.ts index c78b7ea..1792b94 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -66,11 +66,12 @@ async function fetchFile(path: string): Promise { }, ) const data = await r.json() - return { + const file = { path: data.path, content: Buffer.from(data.content, data.encoding).toString(), sha: data.sha } + fileCache.set(path, file) } /** diff --git a/src/database.ts b/src/database.ts index e1fec7e..d3e2291 100644 --- a/src/database.ts +++ b/src/database.ts @@ -78,7 +78,7 @@ function getMemberLeaderboardAttributes(member: CleanMember) { } -export async function fetchAllLeaderboardsCategoriezed(): Promise<{ [ category: string ]: string[] }> { +export async function fetchAllLeaderboardsCategorized(): Promise<{ [ category: string ]: string[] }> { const memberLeaderboardAttributes = await fetchAllMemberLeaderboardAttributes() const categorizedLeaderboards: { [ category: string ]: string[] } = {} for (const leaderboard of memberLeaderboardAttributes) { diff --git a/src/index.ts b/src/index.ts index f35363a..fa3b75f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,6 @@ import { fetchMemberProfile, fetchUser } from './hypixel' import express from 'express' -import { fetchAllLeaderboardsCategoriezed, fetchMemberLeaderboard } from './database' +import { fetchAllLeaderboardsCategorized, fetchMemberLeaderboard } from './database' const app = express() @@ -42,7 +42,7 @@ app.get('/leaderboard/:name', async(req, res) => { app.get('/leaderboards', async(req, res) => { res.json( - await fetchAllLeaderboardsCategoriezed() + await fetchAllLeaderboardsCategorized() ) }) -- cgit