Makes it so: - An `Info`'s `Website` doesn't need to wait for other `Website`s of that same `Info` to load to show up - An `Info`s `Website` not working won't prevent other `Website`s of that same `Info` from showing up - Code is more split and organized Furthermore, the token for the osu! API is now stored, and used for ALL osu! requests for 24 hours instead of being revoked Overall, it's a lot of future-proofing so things on working even if I'm no longer there to maintain them Also so `Info`s can be added, changed, and removed more easily
24 lines
695 B
TypeScript
24 lines
695 B
TypeScript
import {type Handler} from "@netlify/functions";
|
|
import * as osu from "osu-api-v2-js";
|
|
import {type ManiaInfo} from "../../src/components/Info/RhythmGames/OsuMania.js";
|
|
|
|
const handler: Handler = async () => {
|
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
const api = new osu.API({access_token: process.env["OSU_TOKEN"]});
|
|
const profile = await api.getUser(7276846, osu.Ruleset.mania);
|
|
|
|
const info: ManiaInfo = {
|
|
country: profile.country.name,
|
|
ranks: {
|
|
global: profile.statistics.global_rank ?? 0,
|
|
country: profile.statistics.country_rank ?? 0,
|
|
},
|
|
};
|
|
|
|
return {
|
|
statusCode: 200,
|
|
body: JSON.stringify(info),
|
|
};
|
|
};
|
|
|
|
export {handler};
|