Add onboard project count

This commit is contained in:
Max Wofford 2024-04-02 00:00:30 -04:00
parent 0b89afb0b2
commit a7478ad1b4

View file

@ -0,0 +1,16 @@
async function onboardProjectCount() {
const url = 'https://api.github.com/repos/hackclub/onboard/contents/projects'
const response = await fetch(url).then(r => r.json())
const countedProjects = response.filter(
folder =>
folder.type === 'dir' && folder.name[0] !== '.' && folder.name[0] !== '!'
)
return countedProjects.length
}
export default async function handler(req, res) {
const count = await onboardProjectCount()
res.json({ count })
}