blob: b1732a01f4755bad4230c66777f6cbc30942172c [file] [log] [blame]
export interface GitHubRepository {
id: number;
name: string;
full_name: string;
html_url: string;
ssh_url: string;
description: string | null;
private: boolean;
default_branch: string;
}
export interface GitHubService {
/**
* Fetches a list of repositories for the authenticated user
* @returns Promise resolving to an array of GitHub repositories
*/
getRepositories(): Promise<GitHubRepository[]>;
}
export class GitHubServiceImpl implements GitHubService {
private projectId: string;
constructor(projectId: string) {
this.projectId = projectId;
}
async getRepositories(): Promise<GitHubRepository[]> {
const response = await fetch(`/api/project/${this.projectId}/repos/github`);
if (!response.ok) {
throw new Error(`Failed to fetch repositories: ${response.statusText}`);
}
return response.json();
}
}