diff --git a/netlify/functions/hackthebox.ts b/netlify/functions/hackthebox.ts new file mode 100644 index 0000000..bb48f16 --- /dev/null +++ b/netlify/functions/hackthebox.ts @@ -0,0 +1,35 @@ +import { Handler } from '@netlify/functions' +import { api } from "./shared/api" + +const handler: Handler = async (event, context) => { + let hackthebox = await api<{ + profile: { + activity: { + id: string + date_diff: string + object_type: string + type: string + name: string + machine_avatar: string + }[] + } + }> + (`https://www.hackthebox.com/api/v4/profile/activity/1063999`) + + let pwn = hackthebox.profile.activity.find((a) => a.object_type === "machine") + if (!pwn) { + return { + statusCode: 404, + body: "" + } + } + + pwn.machine_avatar = `https://www.hackthebox.com${pwn.machine_avatar}` + + return { + statusCode: 200, + body: JSON.stringify(pwn) + } +} + +export { handler } diff --git a/src/App.jsx b/src/App.jsx index 0b0b982..b106b4f 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -3,6 +3,7 @@ import "./App.css"; import Lastfm from "./components/Lastfm"; import Speedruncom from "./components/Speedruncom"; +import Hackthebox from "./components/hackthebox"; function App() { return ( @@ -10,6 +11,7 @@ function App() {
Latest machine pwned on HackTheBox:
+