blob: 8537671153cfcb48c1180b07c2e3c17e41d05605 [file] [log] [blame]
gio7f98e772025-05-07 11:00:14 +00001export interface GitHubRepository {
2 id: number;
3 name: string;
4 full_name: string;
5 html_url: string;
6 ssh_url: string;
7 description: string | null;
8 private: boolean;
9 default_branch: string;
10}
11
12export interface GitHubService {
13 /**
14 * Fetches a list of repositories for the authenticated user
15 * @returns Promise resolving to an array of GitHub repositories
16 */
17 getRepositories(): Promise<GitHubRepository[]>;
18}
19
20export class GitHubServiceImpl implements GitHubService {
21 private projectId: string;
22
23 constructor(projectId: string) {
24 this.projectId = projectId;
25 }
26
27 async getRepositories(): Promise<GitHubRepository[]> {
28 const response = await fetch(`/api/project/${this.projectId}/repos/github`);
29
30 if (!response.ok) {
31 throw new Error(`Failed to fetch repositories: ${response.statusText}`);
32 }
33
34 return response.json();
35 }
36}