add UserRendererService and improve errors

This commit is contained in:
sam 2024-05-28 17:09:50 +02:00
parent 6114f384a0
commit f674d059fd
14 changed files with 607 additions and 25 deletions

View file

@ -1,18 +1,19 @@
using System.Diagnostics;
using Foxnouns.Backend.Database;
using Foxnouns.Backend.Middleware;
using Foxnouns.Backend.Services;
using Microsoft.AspNetCore.Mvc;
namespace Foxnouns.Backend.Controllers;
[Route("/api/v2/users")]
public class UsersController(DatabaseContext db) : ApiControllerBase
public class UsersController(DatabaseContext db, UserRendererService userRendererService) : ApiControllerBase
{
[HttpGet("{userRef}")]
public async Task<IActionResult> GetUser(string userRef)
{
var user = await db.ResolveUserAsync(userRef);
return Ok(user);
return Ok(await userRendererService.RenderUserAsync(user));
}
[HttpGet("@me")]