(endpoint: string, token: string, method: string = 'GET', body?: any)
| 24 | } |
| 25 | |
| 26 | async function githubRequest<T>(endpoint: string, token: string, method: string = 'GET', body?: any): Promise<T> { |
| 27 | const response = await fetch(`https://api.github.com${endpoint}`, { |
| 28 | method, |
| 29 | headers: { |
| 30 | Authorization: `Bearer ${token}`, |
| 31 | Accept: "application/vnd.github.v3+json", |
| 32 | "User-Agent": "backfill-duplicate-comments-script", |
| 33 | ...(body && { "Content-Type": "application/json" }), |
| 34 | }, |
| 35 | ...(body && { body: JSON.stringify(body) }), |
| 36 | }); |
| 37 | |
| 38 | if (!response.ok) { |
| 39 | throw new Error( |
| 40 | `GitHub API request failed: ${response.status} ${response.statusText}` |
| 41 | ); |
| 42 | } |
| 43 | |
| 44 | return response.json(); |
| 45 | } |
| 46 | |
| 47 | async function triggerDedupeWorkflow( |
| 48 | owner: string, |
no outgoing calls
no test coverage detected