taevas.xyz/api/infos/hacking/hackthebox.ts

24 lines
853 B
TypeScript
Raw Normal View History

2025-03-06 22:18:15 +01:00
import {type HacktheboxInfo} from "#Infos/Hacking/Hackthebox.tsx";
import { headers, parseJson, type Handler } from "../..";
2023-05-08 03:00:11 +02:00
2025-04-03 15:16:59 +02:00
const user_id = 1063999;
export const hackthebox: Handler = async () => {
/** https://documenter.getpostman.com/view/13129365/TVeqbmeq#1b0b22fc-2e45-456a-9a8f-42888375d1a9 */
const hackthebox = await parseJson(await fetch(`https://www.hackthebox.com/api/v4/profile/activity/${user_id}`, {headers})) as {
2023-05-08 03:00:11 +02:00
profile: {
activity: HacktheboxInfo[];
};
};
2023-05-08 03:00:11 +02:00
const pwn = hackthebox.profile.activity.find((a: HacktheboxInfo) => a?.object_type === "machine");
2023-05-08 03:00:11 +02:00
if (!pwn) {
2025-03-06 22:18:15 +01:00
return new Response("Not Found", {status: 404});
2023-05-08 03:00:11 +02:00
}
pwn.machine_avatar = `https://www.hackthebox.com${pwn.machine_avatar}`;
pwn.date = pwn.date.substring(0, pwn.date.indexOf("T"));
2025-03-07 17:43:41 +01:00
return Response.json(pwn, {status: 200});
};