Add endpoint for querying systems by Discord snowflake

This commit is contained in:
Ske
2019-07-17 13:45:36 +02:00
parent 1c48cb2fc7
commit e28ed585ce
2 changed files with 48 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
namespace PluralKit.API.Controllers
{
[ApiController]
[Route("a")]
[Route("v1/a")]
public class AccountController: ControllerBase
{
private SystemStore _systems;
public AccountController(SystemStore systems)
{
_systems = systems;
}
[HttpGet("{aid}")]
public async Task<ActionResult<PKSystem>> GetSystemByAccount(ulong aid)
{
var system = await _systems.GetByAccount(aid);
if (system == null) return NotFound("Account not found.");
return Ok(system);
}
}
}