AnimateHeight for Info, error handling for the Osu Info (#4)

This commit is contained in:
Taevas 2024-05-01 19:12:02 +02:00
parent cca62c093f
commit dad037bed0
5 changed files with 88 additions and 82 deletions

View file

@ -13,19 +13,11 @@ const handler: Handler = async () => {
},
});
if (gitlab.status !== 200) {
return {
statusCode: 404,
body: "",
};
}
// eslint-disable-next-line @typescript-eslint/naming-convention
const {created_at} = (await gitlab.json() as Record<string, any>)[0];
if (typeof created_at !== "string") {
return {
statusCode: 404,
body: "",
};
}

View file

@ -20,24 +20,22 @@ const handler: Handler = async () => {
}),
]) as osu.User.Extended[];
void api.revokeToken();
const info: OsuInfo = {
country: (profile[0]).country.name || "Unknown",
osu: {global: 0, country: 0},
taiko: {global: 0, country: 0},
fruits: {global: 0, country: 0},
mania: {global: 0, country: 0},
country: (profile[0]).country.name ?? "Unknown",
};
for (const ruleset of profile) {
if (ruleset.rank_history) {
const stats = ruleset.statistics;
info[ruleset.rank_history.mode].global = stats.global_rank ?? 0;
info[ruleset.rank_history.mode].country = stats.country_rank ?? 0;
info[ruleset.rank_history.mode] = {
global: stats.global_rank ?? 0,
country: stats.country_rank ?? 0,
};
}
}
void api.revokeToken();
return {
statusCode: 200,
body: JSON.stringify(info),