Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/sxzz/my-pull-requests.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132import type { H3Event } from 'h3'import { Octokit } from 'octokit'
let _octokit: Octokit
export function useOctokit() { if (!_octokit) { _octokit = new Octokit({ auth: process.env.NUXT_GITHUB_TOKEN, }) } return _octokit}
// Read more about caching functions https://hub.nuxt.com/docs/features/cache#server-functions-cachingexport const fetchRepo = defineCachedFunction(async (event: H3Event, owner: string, name: string) => { // Fetch repository details to get owner type console.log(`Fetching repository details for ${owner}/${name}`) const { data } = await useOctokit().request('GET /repos/{owner}/{name}', { owner, name, })
return data}, { maxAge: 60 * 10, // 10 minutes swr: true, group: 'functions', name: 'getRepoDetails', getKey: (_event: H3Event, owner: string, repo: string) => `${owner}/${repo}`,})