SupremeTechnopriest/react-idle-timer

View on GitHub
docs/src/utils/getGithubStars.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { Octokit } from '@octokit/rest'
import { numberFormatter } from '@utils/numberFormatter'

const octokit = new Octokit()

export async function getGithubStars () {
  let count: number

  try {
    const repo = await octokit.repos.get({
      owner: 'SupremeTechnopriest',
      repo: 'react-idle-timer'
    })
    count = repo.data.stargazers_count
  } catch {
    count = 19_700
  }

  return {
    count,
    prettyCount: numberFormatter.format(count)
  }
}