-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from SplittyDev/feat/codeberg-stargazer-badge
web: Add codeberg stars endpoint
- Loading branch information
Showing
2 changed files
with
23 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
badgers-web/src/app/codeberg/stars/[owner]/[repo]/route.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { NextRequest } from 'next/server' | ||
|
||
import Badge from '@/utils/Badge' | ||
import Codeberg from '@/utils/Codeberg' | ||
|
||
interface Params { | ||
params: { | ||
owner: string | ||
repo: string | ||
} | ||
} | ||
|
||
export async function GET(request: NextRequest, { params: { owner, repo } }: Params) { | ||
const repository = await Codeberg.getClient().getRepository({ owner, repo }) | ||
const stargazers = repository?.stars_count | ||
|
||
return await Badge.generate(request, 'stars', stargazers?.toString() ?? 'None', { | ||
color: !!stargazers ? 'blue' : 'yellow' | ||
}) | ||
} | ||
|
||
export const runtime = 'edge' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters