2023-05-08 03:00:11 +02:00
|
|
|
import { Handler } from '@netlify/functions'
|
|
|
|
import { api } from "./shared/api"
|
2023-05-29 14:47:53 +02:00
|
|
|
import { HacktheboxInfo } from '../../src/components/infos/Hackthebox'
|
2023-05-08 03:00:11 +02:00
|
|
|
|
|
|
|
const handler: Handler = async (event, context) => {
|
2023-05-10 19:55:11 +02:00
|
|
|
let hackthebox: {profile: {activity: HacktheboxInfo[]}} = await api<{
|
2023-05-08 03:00:11 +02:00
|
|
|
profile: {
|
2023-05-14 14:26:27 +02:00
|
|
|
activity: HacktheboxInfo[]
|
2023-05-08 03:00:11 +02:00
|
|
|
}
|
|
|
|
}>
|
|
|
|
(`https://www.hackthebox.com/api/v4/profile/activity/1063999`)
|
|
|
|
|
2023-05-10 19:55:11 +02:00
|
|
|
let pwn = hackthebox.profile.activity.find((a: HacktheboxInfo) => a!.object_type === "machine")
|
2023-05-08 03:00:11 +02:00
|
|
|
if (!pwn) {
|
|
|
|
return {
|
|
|
|
statusCode: 404,
|
|
|
|
body: ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pwn.machine_avatar = `https://www.hackthebox.com${pwn.machine_avatar}`
|
2023-05-14 14:26:27 +02:00
|
|
|
pwn.date = pwn.date.substring(0, pwn.date.indexOf("T"))
|
2023-05-08 03:00:11 +02:00
|
|
|
|
|
|
|
return {
|
|
|
|
statusCode: 200,
|
|
|
|
body: JSON.stringify(pwn)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export { handler }
|