Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/llms-txt-hub / apps/web/lib/github.ts |
| Date | Not specified in source |
| Repository | Janady13/llms-txt-hub |
| Revision | e0f4bf978d4df168369c7601d9c5f5ea89e84377 |
| Branch | main |
| Path or archive member | apps/web/lib/github.ts |
| Original SHA-256 | ee9f748ce42c6de471601678cc21fd5439a36c5ce9e2ca2fe867d3bfdec4d9f7 |
| Git blob SHA | 041f7f4440707d3adfad234a14bb0b78b7427a24 |
| Reading-copy SHA-256 | ee9f748ce42c6de471601678cc21fd5439a36c5ce9e2ca2fe867d3bfdec4d9f7 |
Recovered source transcript
Download complete source text ↓55 lines · 1.4 KB
import { Octokit } from '@octokit/rest'
import { logger } from '@thedaviddias/logging'
const octokit = process.env.GITHUB_TOKEN
? new Octokit({
auth: process.env.GITHUB_TOKEN
})
: new Octokit() // Will work with rate-limited public access
export interface GitHubProject {
name: string
fullName: string
description: string
url: string
stars: number
lastUpdated: string
}
/**
* Fetches GitHub repositories matching a specific topic tag
* @param tag - The GitHub topic to search for
* @returns Promise resolving to array of GitHubProject objects
*/
export async function fetchGitHubProjects(tag: string): Promise<GitHubProject[]> {
if (!process.env.GITHUB_TOKEN) {
logger.warn('GITHUB_TOKEN not set - GitHub API requests will be rate-limited')
}
try {
const response = await octokit.search.repos({
q: `topic:${tag}`,
sort: 'stars',
order: 'desc',
per_page: 10
})
return response.data.items
.filter(
(item): item is typeof item & { owner: NonNullable<typeof item.owner> } =>
item.owner !== null
)
.map(item => ({
name: item.name,
fullName: item.full_name,
description: item.description || '',
url: item.html_url,
stars: item.stargazers_count,
lastUpdated: item.updated_at
}))
} catch (error) {
logger.error('Error fetching GitHub projects:', { data: error, tags: { type: 'library' } })
return []
}
}