Remove debug logging from admin function

GitHub API working correctly with fine-grained PAT.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Neeldhara Misra 2026-04-17 03:58:55 +05:30
parent 9f5fbd99aa
commit 0c9940485d

View file

@ -10,28 +10,17 @@ const DEFAULT_DATA = { statusOverrides: {}, notes: {}, ideas: [], todos: {} };
// --- GitHub API helpers --- // --- GitHub API helpers ---
async function githubGetFile(path: string): Promise<{ content: string; sha: string } | null> { async function githubGetFile(path: string): Promise<{ content: string; sha: string } | null> {
if (!GITHUB_TOKEN) { if (!GITHUB_TOKEN) return null;
console.log("[admin] No GITHUB_TOKEN set");
return null;
}
try { try {
const url = `https://api.github.com/repos/${GITHUB_REPO}/contents/${path}?ref=${GITHUB_BRANCH}`; const res = await fetch(
console.log("[admin] Fetching:", url); `https://api.github.com/repos/${GITHUB_REPO}/contents/${path}?ref=${GITHUB_BRANCH}`,
const res = await fetch(url, { { headers: { Authorization: `Bearer ${GITHUB_TOKEN}`, Accept: "application/vnd.github.v3+json" } }
headers: { Authorization: `Bearer ${GITHUB_TOKEN}`, Accept: "application/vnd.github.v3+json" }, );
}); if (!res.ok) return null;
if (!res.ok) {
console.log("[admin] GitHub API error:", res.status, await res.text().catch(() => ""));
return null;
}
const data = await res.json(); const data = await res.json();
const content = Buffer.from(data.content, "base64").toString("utf-8"); const content = Buffer.from(data.content, "base64").toString("utf-8");
console.log("[admin] Read file OK, length:", content.length);
return { content, sha: data.sha }; return { content, sha: data.sha };
} catch (e) { } catch { return null; }
console.log("[admin] githubGetFile error:", e);
return null;
}
} }
async function githubPutFile(path: string, content: string, message: string, sha?: string): Promise<boolean> { async function githubPutFile(path: string, content: string, message: string, sha?: string): Promise<boolean> {