Search
Code212
try { // GitHub API URL for repo contents const apiUrl = `https://api.github.com/repos/${owner}/${repo}/contents/${path}`; console.log(`Fetching from: ${apiUrl}`);
try { // GitHub API URL for repo contents const apiUrl = `https://api.github.com/repos/${owner}/${repo}/contents/${path}`; console.log(`Fetching from: ${apiUrl}`);
if (url.pathname === "/contributions") { const username = url.searchParams.get("username") || "Joshuakibwage"; const GITHUB_API_URL = `https://api.github.com/users/${username}/events`; try {
const { access_token } = await tokenResponse.json(); const userResponse = await fetch("https://api.github.com/user", { headers: { "Authorization": `token ${access_token}`,
async function fetchRepositoryContent(owner, repo, specifiedBranch = null, ignoredPatterns, selectedTypes = null) { // First, try to get the default branch or use the specified branch const repoInfoUrl = `https://api.github.com/repos/${owner}/${repo}`; const repoInfoResponse = await fetch(repoInfoUrl, { headers: { const defaultBranch = specifiedBranch || repoInfo.default_branch; const apiUrl = `https://api.github.com/repos/${owner}/${repo}/git/trees/${defaultBranch}?recursive=1`; const response = await fetch(apiUrl, { headers: {async function fetchFileContent(owner, repo, path, branch) { const apiUrl = `https://api.github.com/repos/${owner}/${repo}/contents/${path}`; const response = await fetch(apiUrl, { headers: {// Add new function to get repository file typesasync function getRepositoryFileTypes(owner, repo, specifiedBranch = null) { const repoInfoUrl = `https://api.github.com/repos/${owner}/${repo}`; const repoInfoResponse = await fetch(repoInfoUrl, { headers: { const defaultBranch = specifiedBranch || repoInfo.default_branch; const apiUrl = `https://api.github.com/repos/${owner}/${repo}/git/trees/${defaultBranch}?recursive=1`; const response = await fetch(apiUrl, { headers: {
const { access_token } = await tokenResponse.json(); const userResponse = await fetch("https://api.github.com/user", { headers: { "Authorization": `token ${access_token}`,
);const fetcher = () => { const gistUrl = "https://api.github.com/gists/979a41207cb789364e2c78181bafc331"; return fetch(gistUrl)
// Note: This is a mock implementation as actual GitHub API requires authentication // In a real-world scenario, you'd need a GitHub Personal Access Token const response = await fetch('https://api.github.com/repos/USERNAME/REPO/contents/content.txt', { method: 'PUT', headers: {
const workflow = url.searchParams.get("workflow"); let github_api_url = `https://api.github.com/repos/${user}/${repository}/actions/runs?branch=${branch}`; // Reduce data if (!workflow) github_api_url += "&per_page=1";
const { access_token } = await tokenResponse.json(); const userResponse = await fetch("https://api.github.com/user", { headers: { "Authorization": `token ${access_token}`,