using Microsoft.AspNetCore.Mvc;
using Nexus.Api.Services;

namespace Nexus.Api.Controllers;

[ApiController]
[Route("api/v1/docs")]
public class DocsController(IDocService docService) : ControllerBase
{
    [HttpGet]
    public IResult GetAll()
        => Results.Ok(docService.GetAll());

    [HttpGet("{**path}")]
    public async Task<IResult> GetFile(string path)
    {
        if (string.IsNullOrWhiteSpace(path))
            return Results.BadRequest("Path required.");

        var file = await docService.GetFileAsync(path);
        return file is null ? Results.NotFound() : Results.Ok(file);
    }
}
