2021-06-21 13:19:47 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
|
|
|
using PluralKit.Core;
|
|
|
|
|
|
|
|
namespace PluralKit.API
|
|
|
|
{
|
|
|
|
[ApiController]
|
|
|
|
[ApiVersion("1.0")]
|
2021-08-27 15:03:47 +00:00
|
|
|
[Route("v{version:apiVersion}")]
|
|
|
|
public class MetaController: ControllerBase
|
2021-06-21 13:19:47 +00:00
|
|
|
{
|
|
|
|
private readonly IDatabase _db;
|
|
|
|
private readonly ModelRepository _repo;
|
|
|
|
public MetaController(IDatabase db, ModelRepository repo)
|
|
|
|
{
|
|
|
|
_db = db;
|
|
|
|
_repo = repo;
|
|
|
|
}
|
|
|
|
|
|
|
|
[HttpGet("meta")]
|
|
|
|
public async Task<ActionResult<JObject>> GetMeta()
|
|
|
|
{
|
|
|
|
await using var conn = await _db.Obtain();
|
|
|
|
var shards = await _repo.GetShards(conn);
|
|
|
|
|
|
|
|
var o = new JObject();
|
|
|
|
o.Add("shards", shards.ToJSON());
|
2021-08-01 19:22:23 +00:00
|
|
|
o.Add("version", BuildInfoService.Version);
|
2021-08-27 15:03:47 +00:00
|
|
|
|
2021-06-21 13:19:47 +00:00
|
|
|
return Ok(o);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|