feat: add activity view

This commit is contained in:
2024-08-24 22:12:16 -07:00
parent a137511c99
commit 4cba941389
6 changed files with 1041 additions and 1 deletions
+17
View File
@@ -0,0 +1,17 @@
import { getCodebergData } from "@/lib/codeberg";
import { getGithubData } from "@/lib/github";
import { NextResponse } from "next/server";
export async function GET() {
const codeberg = await getCodebergData();
const github = await getGithubData();
const normalised: {
type: string;
date: Date;
repo: string;
repoName: string;
}[] = [...codeberg.map(i => ({ type: i.op_type, date: new Date(i.created), repo: i.repo.html_url, repoName: i.repo.full_name })), ...github.map(i => ({ type: i.type, date: new Date(i.created_at), repo: i.repo.url.replace("api.github.com/repos", "github.com"), repoName: i.repo.name }))]
return NextResponse.json(normalised.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime()).slice(0, 100))
}