Spaces:
Sleeping
Sleeping
| export const fetchGitLab = async (endpoint: string) => { | |
| const token = process.env.NEXT_PUBLIC_GITLAB_TOKEN; | |
| const baseUrl = "https://gitlab.com/api/v4"; | |
| const response = await fetch(`${baseUrl}${endpoint}`, { | |
| headers: { | |
| "PRIVATE-TOKEN": token || "", | |
| }, | |
| next: { revalidate: 3600 }, // Cache for 1 hour | |
| }); | |
| if (!response.ok) { | |
| throw new Error(`GitLab API error: ${response.statusText}`); | |
| } | |
| return response.json(); | |
| }; | |
| export const getProjects = () => fetchGitLab("/projects?membership=true&order_by=last_activity_at"); | |
| export const getProjectPipelines = (projectId: string) => fetchGitLab(`/projects/${projectId}/pipelines?per_page=5`); | |
| export const getMRDiscussions = (projectId: string, mrIid: string) => fetchGitLab(`/projects/${projectId}/merge_requests/${mrIid}/discussions`); | |
| export const getMRChanges = (projectId: string, mrIid: string) => fetchGitLab(`/projects/${projectId}/merge_requests/${mrIid}/changes`); | |