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
29 lines
806 B
TypeScript
29 lines
806 B
TypeScript
import {type Handler} from "@netlify/functions";
|
|
import {api} from "./shared/api.js";
|
|
import {type HacktheboxInfo} from "../../src/components/Info/Hacking.js";
|
|
|
|
const handler: Handler = async () => {
|
|
const hackthebox: {profile: {activity: HacktheboxInfo[]}} = await api<{
|
|
profile: {
|
|
activity: HacktheboxInfo[];
|
|
};
|
|
}>("https://www.hackthebox.com/api/v4/profile/activity/1063999");
|
|
|
|
const pwn = hackthebox.profile.activity.find((a: HacktheboxInfo) => a!.object_type === "machine");
|
|
if (!pwn) {
|
|
return {
|
|
statusCode: 404,
|
|
body: "",
|
|
};
|
|
}
|
|
|
|
pwn.machine_avatar = `https://www.hackthebox.com${pwn.machine_avatar}`;
|
|
pwn.date = pwn.date.substring(0, pwn.date.indexOf("T"));
|
|
|
|
return {
|
|
statusCode: 200,
|
|
body: JSON.stringify(pwn),
|
|
};
|
|
};
|
|
|
|
export {handler};
|