| 98 | } |
| 99 | |
| 100 | async function fetchGitHubUser(username) { |
| 101 | const headers = { |
| 102 | Accept: "application/vnd.github+json", |
| 103 | "User-Agent": "awesome-cursorrules-pr-author-check", |
| 104 | }; |
| 105 | const token = process.env.GITHUB_TOKEN ?? process.env.GH_TOKEN; |
| 106 | if (token) { |
| 107 | headers.Authorization = `Bearer ${token}`; |
| 108 | } |
| 109 | |
| 110 | const response = await fetch(`https://api.github.com/users/${encodeURIComponent(username)}`, { |
| 111 | headers, |
| 112 | }); |
| 113 | |
| 114 | if (!response.ok) { |
| 115 | throw new Error(`Unable to fetch GitHub user ${username}: HTTP ${response.status}.`); |
| 116 | } |
| 117 | |
| 118 | return response.json(); |
| 119 | } |
| 120 | |
| 121 | function parseMinimumAge(value) { |
| 122 | const days = Number.parseInt(value, 10); |