mirror of
https://github.com/System-End/site.git
synced 2026-04-19 19:45:07 +00:00
41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
import { graphql } from '@octokit/graphql'
|
|
|
|
export async function fetchStars() {
|
|
if (!process.env.GITHUB_TOKEN) {
|
|
console.warn("Note - GITHUB_TOKEN not defined, stars will not be fetched from github")
|
|
return { sprig:"?", sinerider:"?", sprigHardware:"?", hackclub:"?", hackathons:"?"};
|
|
}
|
|
const { organization } = await graphql(
|
|
`
|
|
{
|
|
organization(login: "hackclub") {
|
|
sinerider: repository(name: "sinerider") {
|
|
stargazerCount
|
|
}
|
|
sprig: repository(name: "sprig") {
|
|
stargazerCount
|
|
}
|
|
hackclub: repository(name: "hackclub") {
|
|
stargazerCount
|
|
}
|
|
hackathons: repository(name: "hackathons") {
|
|
stargazerCount
|
|
}
|
|
sprigHardware: repository(name: "sprig-hardware") {
|
|
stargazerCount
|
|
}
|
|
}
|
|
}
|
|
`,
|
|
{
|
|
headers: {
|
|
authorization: `token ${process.env.GITHUB_TOKEN}`
|
|
}
|
|
}
|
|
)
|
|
return organization
|
|
}
|
|
|
|
export default async function Stars(req, res) {
|
|
res.status(200).json(await fetchStars())
|
|
}
|