Files
fristydev/lib/gitea.ts
T
fristy ad943fff8c
Build & Push / Lint & Build (push) Successful in 1m15s
Build & Push / Build & Push Image (push) Successful in 52s
Initial commit: fristy.net personal site
2026-09-10 04:59:12 +03:00

62 lines
1.7 KiB
TypeScript

const GITEA_API = "https://git.fristy.net/api/v1";
const GITEA_USER = "fristy";
const EXCLUDED_REPOS = new Set([".profile"]);
export interface GiteaRepo {
id: number;
name: string;
fullName: string;
description: string | null;
language: string | null;
htmlUrl: string;
website: string | null;
stars: number;
forks: number;
updatedAt: string;
}
interface GiteaApiRepo {
id: number;
name: string;
full_name: string;
description: string | null;
language: string | null;
html_url: string;
website: string;
stars_count: number;
forks_count: number;
updated_at: string;
}
export async function getRepos(): Promise<GiteaRepo[]> {
try {
const response = await fetch(
`${GITEA_API}/users/${GITEA_USER}/repos?limit=50&sort=updated&order=desc`,
{ next: { revalidate: 3600 } },
);
if (!response.ok) {
console.error(`cannot fetch gitea repos: ${response.status}`);
return [];
}
const data = (await response.json()) as GiteaApiRepo[];
return data
.filter((repo) => !EXCLUDED_REPOS.has(repo.name))
.map((repo) => ({
id: repo.id,
name: repo.name,
fullName: repo.full_name,
description: repo.description,
language: repo.language,
htmlUrl: repo.html_url,
website: repo.website || null,
stars: repo.stars_count,
forks: repo.forks_count,
updatedAt: repo.updated_at,
}));
} catch (error) {
console.error("cannot fetch gitea repos:", error);
return [];
}
}