Strongly type everything

This commit is contained in:
Taevas 2023-05-10 19:55:11 +02:00
parent 842a627cac
commit fee3766c2b
18 changed files with 221 additions and 109 deletions

View file

@ -1,8 +1,9 @@
import { Handler } from '@netlify/functions'
import { api } from "./shared/api"
import { HacktheboxInfo } from '../../src/components/Hackthebox'
const handler: Handler = async (event, context) => {
let hackthebox = await api<{
let hackthebox: {profile: {activity: HacktheboxInfo[]}} = await api<{
profile: {
activity: {
id: string
@ -16,7 +17,7 @@ const handler: Handler = async (event, context) => {
}>
(`https://www.hackthebox.com/api/v4/profile/activity/1063999`)
let pwn = hackthebox.profile.activity.find((a) => a.object_type === "machine")
let pwn = hackthebox.profile.activity.find((a: HacktheboxInfo) => a!.object_type === "machine")
if (!pwn) {
return {
statusCode: 404,