Strongly type everything
This commit is contained in:
parent
842a627cac
commit
fee3766c2b
18 changed files with 221 additions and 109 deletions
|
@ -1,5 +1,6 @@
|
|||
import { Handler } from '@netlify/functions'
|
||||
import fetch from "node-fetch"
|
||||
import { AnilistInfo } from '../../src/components/Anilist'
|
||||
|
||||
const handler: Handler = async (event, context) => {
|
||||
let anilist = await fetch("https://graphql.anilist.co", {
|
||||
|
@ -52,7 +53,7 @@ const handler: Handler = async (event, context) => {
|
|||
|
||||
let p_json = await anilist.json() as {[key: string]: any}
|
||||
let json = p_json.data.MediaList
|
||||
let anime = {
|
||||
let anime: AnilistInfo = {
|
||||
title: json.media.title.romaji,
|
||||
episodes: {
|
||||
watched: json.progress,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { Handler } from '@netlify/functions'
|
||||
import { Octokit } from '@octokit/core'
|
||||
import { GithubInfo } from '../../src/components/Github'
|
||||
|
||||
const handler: Handler = async (event, context) => {
|
||||
let octokit = new Octokit({auth: process.env.API_GITHUB})
|
||||
|
@ -20,7 +21,7 @@ const handler: Handler = async (event, context) => {
|
|||
}
|
||||
}
|
||||
|
||||
let info = {
|
||||
let info: GithubInfo = {
|
||||
public: {
|
||||
repo: public_push.repo.name,
|
||||
date: public_push.created_at.substring(0, public_push.created_at.indexOf("T"))
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { Handler } from '@netlify/functions'
|
||||
import fetch from "node-fetch"
|
||||
import { GitlabInfo } from '../../src/components/Gitlab'
|
||||
|
||||
const handler: Handler = async (event, context) => {
|
||||
let gitlab = await fetch("https://gitlab.com/api/v4/events?action=pushed", {
|
||||
|
@ -19,11 +20,13 @@ const handler: Handler = async (event, context) => {
|
|||
}
|
||||
|
||||
let json = await gitlab.json() as {[key: string]: any}
|
||||
let date = json[0].created_at.substring(0, json[0].created_at.indexOf("T"))
|
||||
let activity: GitlabInfo = {
|
||||
date: json[0].created_at.substring(0, json[0].created_at.indexOf("T"))
|
||||
}
|
||||
|
||||
return {
|
||||
statusCode: 200,
|
||||
body: JSON.stringify({date})
|
||||
body: JSON.stringify(activity)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { Handler } from '@netlify/functions'
|
||||
import { API, APIError, User } from 'osu-api-v2-js'
|
||||
import { OsuInfo } from '../../src/components/Osu'
|
||||
|
||||
const handler: Handler = async (event, context) => {
|
||||
let api = await API.createAsync({id: 11451, secret: process.env.API_OSU!})
|
||||
|
@ -24,7 +25,7 @@ const handler: Handler = async (event, context) => {
|
|||
}
|
||||
}
|
||||
|
||||
let ranks = {
|
||||
let ranks: OsuInfo = {
|
||||
osu: [0,0],
|
||||
taiko: [0,0],
|
||||
fruits: [0,0],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue