using Microsoft.AspNetCore.Mvc; using Nexus.Api.Services; namespace Nexus.Api.Controllers; [ApiController] [Route("api/v1/memory")] public class MemoryController(IMemoryService memoryService) : ControllerBase { [HttpGet] public async Task GetAll() => Results.Ok(await memoryService.GetAllAsync()); [HttpGet("search")] public async Task Search([FromQuery] string q) { if (string.IsNullOrWhiteSpace(q) || q.Length < 2) return Results.BadRequest("Query must be at least 2 characters."); return Results.Ok(await memoryService.SearchAsync(q)); } [HttpGet("{name}")] public async Task GetFile(string name) { var file = await memoryService.GetFileAsync(name); return file is null ? Results.NotFound() : Results.Ok(file); } }