feat: add Gitea support with new widgets and API integration

This commit is contained in:
Kayela Claybon
2026-01-15 17:29:27 -06:00
parent 7725cd75a4
commit 22666529d7
14 changed files with 738 additions and 78 deletions

77
src/utils/giteaApi.ts Normal file
View File

@@ -0,0 +1,77 @@
import axios from 'axios';
// Gitea API configuration
const createGiteaApi = (baseUrl, token = null) => {
const headers = {
'Content-Type': 'application/json',
};
if (token) {
headers.Authorization = `token ${token}`;
}
const api = axios.create({
baseURL: `${baseUrl}/api/v1`,
headers,
});
return {
// Fetch commits for a repository
fetchCommits: async (owner, repo, limit = 10, branch = 'main') => {
try {
const response = await api.get(
`/repos/${owner}/${repo}/commits`,
{
params: {
limit,
page: 1,
sha: branch, // Optional branch parameter
}
}
);
return response.data;
} catch (error) {
console.error('Error fetching Gitea commits:', error);
throw error;
}
},
// Fetch user repositories
fetchUserRepos: async (username) => {
try {
const response = await api.get(`/users/${username}/repos`);
return response.data;
} catch (error) {
console.error('Error fetching user repos:', error);
throw error;
}
},
// Fetch repository information
fetchRepoInfo: async (owner, repo) => {
try {
const response = await api.get(`/repos/${owner}/${repo}`);
return response.data;
} catch (error) {
console.error('Error fetching repo info:', error);
throw error;
}
},
// Search repositories
searchRepos: async (query) => {
try {
const response = await api.get('/repos/search', {
params: { q: query, limit: 10 }
});
return response.data.data;
} catch (error) {
console.error('Error searching repos:', error);
throw error;
}
}
};
};
export default createGiteaApi;