feat: website apis

This commit is contained in:
TrèsAbhi committed 2023-10-31 12:58:24 -05:00
1 parent 3d9872a671
commit 3245284ecc
4 files changed
+65 -15

No files matched your search

@@ -0,0 +1,40 @@
import { RatingsInfo } from '../../commands/ratings';
import { Region } from '../../constants/regions';
const INFO_CACHE: Record<
Region,
Record<
number,
RatingsInfo & {
detail: undefined;
}
>
> = {
com: {},
eu: {},
asia: {},
};
export default async function getArchivedRatingsInfoAPI(
region: Region,
season: number,
) {
if (INFO_CACHE[region][season]) {
return INFO_CACHE[region][season];
}
const response = await fetch(
`/api/ratings/archives/${region}/${season}/info`,
);
const json = (await response.json()) as RatingsInfo;
if (json.detail) {
throw new Error(
`No ratings info found for season ${season}, region ${region}`,
);
}
INFO_CACHE[region][season] = json;
return json;
}