adding gitea service

This commit is contained in:
2026-03-26 19:36:25 -03:00
parent 76cdb9654e
commit 83b1cb397d
16 changed files with 658 additions and 166 deletions

View File

@@ -1,5 +1,21 @@
const BASE_URL = import.meta.env.VITE_API_BASE_URL || 'http://localhost:5123';
export interface FileTreeNode {
name: string;
path: string;
type: 'file' | 'folder';
children?: FileTreeNode[];
}
export interface RepositoryInfo {
name: string;
}
export interface FileContentResponse {
path: string;
content: string;
}
export interface CheckFileRequest {
fileContent: string;
fileName: string;
@@ -52,5 +68,23 @@ export const MindforgeApiService = {
throw new Error(`Error generating flashcards: ${response.statusText}`);
}
return response.json();
}
},
async getRepositoryInfo(): Promise<RepositoryInfo> {
const response = await fetch(`${BASE_URL}/api/v1/repository/info`);
if (!response.ok) throw new Error(`Error fetching repository info: ${response.statusText}`);
return response.json();
},
async getRepositoryTree(): Promise<FileTreeNode[]> {
const response = await fetch(`${BASE_URL}/api/v1/repository/tree`);
if (!response.ok) throw new Error(`Error fetching repository tree: ${response.statusText}`);
return response.json();
},
async getFileContent(path: string): Promise<FileContentResponse> {
const response = await fetch(`${BASE_URL}/api/v1/repository/file?path=${encodeURIComponent(path)}`);
if (!response.ok) throw new Error(`Error fetching file ${path}: ${response.statusText}`);
return response.json();
},
};