2024-04-27 18:45:18 +02:00
|
|
|
import {type Handler} from "@netlify/functions";
|
|
|
|
import {api} from "./shared/api.js";
|
|
|
|
import {type HacktheboxInfo} from "../../src/components/Info/Hackthebox.js";
|
2023-05-08 03:00:11 +02:00
|
|
|
|
2023-11-05 21:01:24 +01:00
|
|
|
const handler: Handler = async () => {
|
|
|
|
const hackthebox: {profile: {activity: HacktheboxInfo[]}} = await api<{
|
2023-05-08 03:00:11 +02:00
|
|
|
profile: {
|
2024-04-27 18:45:18 +02:00
|
|
|
activity: HacktheboxInfo[];
|
|
|
|
};
|
2023-05-08 03:00:11 +02:00
|
|
|
}>
|
2024-04-27 18:45:18 +02:00
|
|
|
("https://www.hackthebox.com/api/v4/profile/activity/1063999");
|
2023-05-08 03:00:11 +02:00
|
|
|
|
2024-04-27 18:45:18 +02:00
|
|
|
const pwn = hackthebox.profile.activity.find((a: HacktheboxInfo) => a!.object_type === "machine");
|
2023-05-08 03:00:11 +02:00
|
|
|
if (!pwn) {
|
|
|
|
return {
|
|
|
|
statusCode: 404,
|
2024-04-27 18:45:18 +02:00
|
|
|
body: "",
|
|
|
|
};
|
2023-05-08 03:00:11 +02:00
|
|
|
}
|
|
|
|
|
2024-04-27 18:45:18 +02:00
|
|
|
pwn.machine_avatar = `https://www.hackthebox.com${pwn.machine_avatar}`;
|
|
|
|
pwn.date = pwn.date.substring(0, pwn.date.indexOf("T"));
|
2023-05-08 03:00:11 +02:00
|
|
|
|
|
|
|
return {
|
|
|
|
statusCode: 200,
|
2024-04-27 18:45:18 +02:00
|
|
|
body: JSON.stringify(pwn),
|
|
|
|
};
|
|
|
|
};
|
2023-05-08 03:00:11 +02:00
|
|
|
|
2024-04-27 18:45:18 +02:00
|
|
|
export {handler};
|