Duo-Guardian / dashboard /src /lib /gitlab.ts
Daksh C Jain
fix: bypass FastMCP.run and use explicit uvicorn binding for SSE
875cd4d
raw
history blame contribute delete
959 Bytes
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`);