From eb4f00b3268644ab14b618c8b507d277d815b7dc Mon Sep 17 00:00:00 2001 From: Rodrigo Pombo Date: Sun, 25 Jan 2026 17:58:19 +0100 Subject: [PATCH] Add sponsors endpoint --- apps/web/app/api/sponsors/latest/route.ts | 13 +++++++++ apps/web/app/landing/sponsors.tsx | 32 ++++++++++++++++------- 2 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 apps/web/app/api/sponsors/latest/route.ts diff --git a/apps/web/app/api/sponsors/latest/route.ts b/apps/web/app/api/sponsors/latest/route.ts new file mode 100644 index 00000000..7d7158be --- /dev/null +++ b/apps/web/app/api/sponsors/latest/route.ts @@ -0,0 +1,13 @@ +import { fetchLatestSponsors } from "@/app/landing/sponsors" + +export async function GET() { + try { + const sponsors = await fetchLatestSponsors(5) + return Response.json(sponsors) + } catch (error: any) { + return Response.json( + { error: error.message || "Failed to fetch sponsors" }, + { status: 500 } + ) + } +} diff --git a/apps/web/app/landing/sponsors.tsx b/apps/web/app/landing/sponsors.tsx index 1747c074..fc01af0f 100644 --- a/apps/web/app/landing/sponsors.tsx +++ b/apps/web/app/landing/sponsors.tsx @@ -86,7 +86,7 @@ export function Pricing() { ) } -export async function LatestSponsor({ className }: { className?: string }) { +export async function fetchLatestSponsors(limit: number = 5) { const GITHUB_TOKEN = process.env.GITHUB_TOKEN if (!GITHUB_TOKEN) { throw new Error("Missing process.env.GITHUB_TOKEN") @@ -110,11 +110,27 @@ export async function LatestSponsor({ className }: { className?: string }) { throw new Error("No sponsors found") } - const latest = sponsors[0].node + return sponsors.slice(0, limit).map((edge: any) => { + const node = edge.node + const entity = node.sponsorEntity + return { + login: entity.login, + name: entity.name || entity.login, + avatarUrl: entity.avatarUrl, + createdAt: node.createdAt, + tierName: node.tier.name, + websiteUrl: entity.websiteUrl, + } + }) +} + +export async function LatestSponsor({ className }: { className?: string }) { + const sponsors = await fetchLatestSponsors(1) + const latest = sponsors[0] return ( {latest.sponsorEntity.name} Latest sponsor ยท -
- {latest.sponsorEntity.name || latest.sponsorEntity.login} -
+
{latest.name}
- Sponsoring {latest.tier.name}{" "} + Sponsoring {latest.tierName}{" "}
{/*
{JSON.stringify(latest, null, 2)}
*/}