Add missing endpoint for getting tools per game

Ref #414
This commit is contained in:
Pat Hartl 2026-06-25 02:05:15 -05:00
parent a9f74ef78f
commit 33e6d0f4a3

View file

@ -25,6 +25,7 @@ public static class GameEndpoints
group.MapGet("/{id:guid}/Manifest", GetManifestByIdAsync);
group.MapGet("/{id:guid}/Actions", GetActionsByIdAsync);
group.MapGet("/{id:guid}/Addons", GetAddonsByIdAsync);
group.MapGet("/{id:guid}/Tools", GetToolsByIdAsync);
group.MapGet("/{id:guid}/Scripts", GetScriptsByIdAsync);
group.MapGet("/{id:guid}/Started", StartedAsync);
group.MapGet("/{id:guid}/Stopped", StoppedAsync);
@ -220,6 +221,26 @@ public static class GameEndpoints
return TypedResults.Ok(addons);
}
internal static async Task<IResult> GetToolsByIdAsync(
[FromServices] ToolService toolService,
[FromServices] IFusionCache cache,
[FromServices] IMapper mapper,
Guid id)
{
var tools = await cache.GetOrSetAsync($"Games/{id}/Tools", async _ =>
{
var results = await toolService
.Include(t => t.Archives)
.AsSplitQuery()
.AsNoTracking()
.GetAsync(t => t.Games.Any(g => g.Id == id));
return mapper.Map<IEnumerable<SDK.Models.Tool>>(results);
}, tags: ["Tools", "Games", $"Games/{id}"]);
return TypedResults.Ok(tools);
}
internal static async Task<IResult> GetScriptsByIdAsync(
[FromServices] ScriptService scriptService,
[FromServices] IFusionCache cache,