From a7478ad1b4e773878a89a1c2109d0cf15c1ce9c9 Mon Sep 17 00:00:00 2001 From: Max Wofford Date: Tue, 2 Apr 2024 00:00:30 -0400 Subject: [PATCH] Add onboard project count --- pages/api/onboard/project-count.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 pages/api/onboard/project-count.js diff --git a/pages/api/onboard/project-count.js b/pages/api/onboard/project-count.js new file mode 100644 index 00000000..f31c319d --- /dev/null +++ b/pages/api/onboard/project-count.js @@ -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 }) +}