import { NextApiRequest , NextApiResponse } from "next" ; import { octokit } from "@/domains/github" ; /**
 * Get the stars and forks of a repository
 */ export default async ( req , res ) => { try { const { owner , repo } = req . body ; const { data : { stargazers_count : stars = 0 , forks = 0 } , } = await octokit . request ( "GET /repos/{owner}/{repo}" , { owner , repo , } ) ; res . status ( 200 ) . send ( { stars , forks } ) ; } catch ( error ) { console . error ( "Request using @octokit/core failed" ) ; res . status ( 200 ) . send ( { stars : 69 , forks : 69 } ) ; } } ;