feat(api): separate private endpoints from public API versioning
This commit is contained in:
parent
eb4f53c69e
commit
9f7c47b78e
35
PluralKit.API/Controllers/PrivateController.cs
Normal file
35
PluralKit.API/Controllers/PrivateController.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
using PluralKit.Core;
|
||||
|
||||
namespace PluralKit.API;
|
||||
|
||||
// Internal API definitions
|
||||
// I would prefer if you do not use any of these APIs in your own integrations.
|
||||
// It is unstable and subject to change at any time (which is why it's not versioned)
|
||||
|
||||
// If for some reason you do need access to something defined here,
|
||||
// let us know in #api-support on the support server (https://discord.com/invite/PczBt78) and I'll see if it can be made public
|
||||
|
||||
[ApiController]
|
||||
[Route("private")]
|
||||
public class PrivateController: PKControllerBase
|
||||
{
|
||||
public PrivateController(IServiceProvider svc) : base(svc) { }
|
||||
|
||||
[HttpGet("meta")]
|
||||
public async Task<ActionResult<JObject>> Meta()
|
||||
{
|
||||
var shards = await _repo.GetShards();
|
||||
var stats = await _repo.GetStats();
|
||||
|
||||
var o = new JObject();
|
||||
o.Add("shards", shards.ToJSON());
|
||||
o.Add("stats", stats.ToJson());
|
||||
o.Add("version", BuildInfoService.Version);
|
||||
|
||||
return Ok(o);
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
using PluralKit.Core;
|
||||
|
||||
namespace PluralKit.API;
|
||||
|
||||
[ApiController]
|
||||
[Route("v1")]
|
||||
public class MetaController: ControllerBase
|
||||
{
|
||||
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();
|
||||
|
||||
var o = new JObject();
|
||||
o.Add("shards", shards.ToJSON());
|
||||
o.Add("version", BuildInfoService.Version);
|
||||
|
||||
return Ok(o);
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace PluralKit.API;
|
||||
|
||||
[ApiController]
|
||||
[Route("v2")]
|
||||
public class PrivateControllerV2: PKControllerBase
|
||||
{
|
||||
public PrivateControllerV2(IServiceProvider svc) : base(svc) { }
|
||||
|
||||
[HttpGet("meta")]
|
||||
public async Task<ActionResult<JObject>> Meta()
|
||||
{
|
||||
var shards = await _repo.GetShards();
|
||||
var stats = await _repo.GetStats();
|
||||
|
||||
var o = new JObject();
|
||||
o.Add("shards", shards.ToJSON());
|
||||
o.Add("stats", stats.ToJson());
|
||||
|
||||
return Ok(o);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user