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

@@ -0,0 +1,40 @@
using Microsoft.AspNetCore.Mvc;
using Mindforge.API.Services.Interfaces;
namespace Mindforge.API.Controllers
{
[ApiController]
[Route("api/v1/repository")]
public class RepositoryController : ControllerBase
{
private readonly IGiteaService _giteaService;
public RepositoryController(IGiteaService giteaService)
{
_giteaService = giteaService;
}
[HttpGet("info")]
public IActionResult GetInfo()
{
return Ok(new { name = _giteaService.GetRepositoryName() });
}
[HttpGet("tree")]
public async Task<IActionResult> GetTree()
{
var tree = await _giteaService.GetFileTreeAsync();
return Ok(tree);
}
[HttpGet("file")]
public async Task<IActionResult> GetFile([FromQuery] string path)
{
if (string.IsNullOrWhiteSpace(path))
return BadRequest(new { error = "path query parameter is required." });
var content = await _giteaService.GetFileContentAsync(path);
return Ok(new { path, content });
}
}
}