in app/lib/githubService.ts [379:426]
static async createIssue(
repoUrl: string,
title: string,
body?: string,
labels?: string[]
): Promise<GitHubIssue | null> {
if (!this.isAuthenticated()) {
throw new Error("Authentication required to create issues");
}
const repoPath = this.extractRepoPath(repoUrl);
if (!repoPath) return null;
try {
const response = await this.makeAuthenticatedRequest(
`/repos/${repoPath}/issues`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
title,
body: body || "",
labels: labels || [],
}),
}
);
if (!response.ok) {
throw new Error(`Failed to create issue: ${response.status}`);
}
const issue: GitHubIssue = await response.json();
// Add to cache
const cacheKey = `${repoUrl}#${issue.number}`;
this.issueCache.set(cacheKey, issue);
// Clear repository issues cache to force refresh
this.clearRepositoryCache(repoUrl);
return issue;
} catch (error) {
console.error("Failed to create issue:", error);
return null;
}
}