1
0
Fork 0
taevas.xyz/backend/api/infos/website/kitsudev.ts
Taevas d781f7138f
Make backend/frontend distinction clearer
Helps with eventually adding other pages
Also makes it clear it's the backend that decides what data to send to the frontend
2025-07-08 14:40:35 +02:00

49 linhas
1,3 KiB
TypeScript

import { headers, parseJson, type Handler } from "../..";
export type Info = {
url: string,
message: string,
author: string,
date: string,
files_modified: number,
lines_added: number,
lines_removed: number,
} | undefined;
const username = "Taevas";
const repository = "taevas.xyz";
export const kitsudev: Handler = async () => {
/** https://kitsunes.dev/api/swagger#/repository/repoGetAllCommits */
const kitsudev = await parseJson(await fetch(`https://kitsunes.dev/api/v1/repos/${username}/${repository}/commits?limit=1`, {headers})) as [{
html_url: string
commit: {
author: {
name: string
date: string
}
message: string
}
files: {
filename: string
status: string
}[]
stats: {
total: number
additions: number
deletions: number
}
}];
const info: Info = {
url: kitsudev[0].html_url,
message: kitsudev[0].commit.message.substring(0, kitsudev[0].commit.message.indexOf("\n")),
author: kitsudev[0].commit.author.name,
date: kitsudev[0].commit.author.date,
files_modified: kitsudev[0].files.length,
lines_added: kitsudev[0].stats.additions,
lines_removed: kitsudev[0].stats.deletions,
};
return Response.json(info, {status: 200});
};