Search
Code212
} const apiUrl = `https://api.github.com/repos/${user}/${repo}/contents`; const response = await fetch(apiUrl); const contents = await response.json();
// GitHub gistsexport let githubGists = fetchJSON( "https://api.github.com/users/stevekrouse/gists",);
const threeMonthsAgo = new Date(Date.now() - 90 * 24 * 60 * 60 * 1000).toISOString(); const response = await fetch( `https://api.github.com/users/${username}/events?per_page=100&since=${threeMonthsAgo}`, ); const data = await response.json();
async function fetchUserActivity(username: string) { const oneYearAgo = new Date(Date.now() - 365 * 24 * 60 * 60 * 1000).toISOString(); const response = await fetch(`https://api.github.com/users/${username}/events?per_page=100&since=${oneYearAgo}`); const data = await response.json(); if (!Array.isArray(data)) {
async function fetchGitHubEvents(username: string) { const response = await fetch(`https://api.github.com/users/${username}/events/public`, { headers: { "User-Agent": "Val-Town-Script",
} const response = await fetch(`https://api.github.com/users/${userName}/events`); const events = await response.json();
async function getGithubReleases(repo: string): Promise<GithubRelease[]> { const response = await fetch(`https://api.github.com/repos/${repo}/releases`); if (!response.ok) { throw new Error(`Failed to fetch releases from ${repo}`);
async function getGithubReleases(repo: string): Promise<GithubRelease[]> { const response = await fetch(`https://api.github.com/repos/${repo}/releases`); if (!response.ok) { throw new Error(`Failed to fetch releases from ${repo}`);
async getRepoContent(repo: string, path: string, branch: string) { const response = await fetch(`https://api.github.com/repos/${repo}/contents/${path}?ref=${branch}`, { method: 'GET', headers: { async getFileSHA(repo: string, path: string, branch: string) { const response = await fetch(`https://api.github.com/repos/${repo}/contents/${path}?ref=${branch}`, { method: 'GET', headers: { async updateFile(repo: string, path: string, content: string, sha: string, message: string, branch: string) { const response = await fetch(`https://api.github.com/repos/${repo}/contents/${path}`, { method: 'PUT', headers: { async createFile(repo: string, path: string, content: string, message: string, branch: string) { const url = `https://api.github.com/repos/${repo}/contents/${path}`; let body: any = { async getCommitHistory(repo: string, path: string, branch: string) { const response = await fetch(`https://api.github.com/repos/${repo}/commits?path=${path}&sha=${branch}`, { method: 'GET', headers: {
if (url.pathname == "/search") { const query = url.searchParams.get("q"); const resp = await fetch(`https://api.github.com/search/code?q=${githubQuery(query)}`, { headers: { "Accept": "application/vnd.github.text-match+json",