AnimateHeight
for Info
, error handling for the Osu
Info
(#4)
This commit is contained in:
parent
cca62c093f
commit
dad037bed0
5 changed files with 88 additions and 82 deletions
|
@ -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: "",
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -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),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue