mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-22 03:07:04 +02:00
feat: website apis
This commit is contained in:
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;
|
||||
}
|
||||
Reference in new issue
Block a user