Export controller
This commit is contained in:
parent
a22122e824
commit
bb6fba1087
34
NostrServices/Controllers/ExportController.cs
Normal file
34
NostrServices/Controllers/ExportController.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using Nostr.Client.Json;
|
||||
using NostrServices.Services;
|
||||
|
||||
namespace NostrServices.Controllers;
|
||||
|
||||
[Route("/api/v1/export")]
|
||||
public class ExportController : Controller
|
||||
{
|
||||
private readonly RedisStore _store;
|
||||
|
||||
public ExportController(RedisStore store)
|
||||
{
|
||||
_store = store;
|
||||
}
|
||||
|
||||
[HttpGet("profile/{id}")]
|
||||
[Produces("application/json")]
|
||||
public async Task<IActionResult> GetProfile([FromRoute] string id)
|
||||
{
|
||||
var nid = await Extensions.TryParseIdentifier(id);
|
||||
if (nid != default)
|
||||
{
|
||||
if (nid.Hrp is "npub" or "nprofile")
|
||||
{
|
||||
var px = await _store.GetProfile(nid.Special);
|
||||
return Content(JsonConvert.SerializeObject(px, NostrSerializer.Settings), "application/json");
|
||||
}
|
||||
}
|
||||
|
||||
return BadRequest();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user