Also apply basic linting to Netlify functions
This commit is contained in:
parent
3d38ba1768
commit
eb85319f73
11 changed files with 272 additions and 258 deletions
|
@ -1,30 +1,30 @@
|
|||
import { Handler } from '@netlify/functions'
|
||||
import { api } from "./shared/api"
|
||||
import { HacktheboxInfo } from '../../src/components/infos/Hackthebox'
|
||||
import {type Handler} from "@netlify/functions";
|
||||
import {api} from "./shared/api.js";
|
||||
import {type HacktheboxInfo} from "../../src/components/Info/Hackthebox.js";
|
||||
|
||||
const handler: Handler = async () => {
|
||||
const hackthebox: {profile: {activity: HacktheboxInfo[]}} = await api<{
|
||||
profile: {
|
||||
activity: HacktheboxInfo[]
|
||||
}
|
||||
activity: HacktheboxInfo[];
|
||||
};
|
||||
}>
|
||||
(`https://www.hackthebox.com/api/v4/profile/activity/1063999`)
|
||||
("https://www.hackthebox.com/api/v4/profile/activity/1063999");
|
||||
|
||||
const pwn = hackthebox.profile.activity.find((a: HacktheboxInfo) => a!.object_type === "machine")
|
||||
const pwn = hackthebox.profile.activity.find((a: HacktheboxInfo) => a!.object_type === "machine");
|
||||
if (!pwn) {
|
||||
return {
|
||||
statusCode: 404,
|
||||
body: ""
|
||||
}
|
||||
body: "",
|
||||
};
|
||||
}
|
||||
|
||||
pwn.machine_avatar = `https://www.hackthebox.com${pwn.machine_avatar}`
|
||||
pwn.date = pwn.date.substring(0, pwn.date.indexOf("T"))
|
||||
pwn.machine_avatar = `https://www.hackthebox.com${pwn.machine_avatar}`;
|
||||
pwn.date = pwn.date.substring(0, pwn.date.indexOf("T"));
|
||||
|
||||
return {
|
||||
statusCode: 200,
|
||||
body: JSON.stringify(pwn)
|
||||
}
|
||||
}
|
||||
body: JSON.stringify(pwn),
|
||||
};
|
||||
};
|
||||
|
||||
export { handler }
|
||||
export {handler};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue