Add JWT auth, token service & Neutrino endpoint

This commit is contained in:
Holden
2026-06-19 12:25:45 -05:00
parent 608def3ac8
commit 3eebfc9ba2
27 changed files with 581 additions and 51 deletions

View File

@@ -0,0 +1,34 @@
using System.Text.Json;
using RecNet.Domain.Repositories;
using RecNet.Domain.Services.Configuration;
namespace RecNet.Infrastructure.Services.Configuration;
public class ConfigService(IServerConfigRepository repository) : IConfigService
{
private static readonly JsonSerializerOptions JsonOptions = new(JsonSerializerDefaults.Web);
public async Task<T?> GetAsync<T>(
string key,
T? defaultValue = default,
CancellationToken ct = default)
{
var config = await repository.GetAsync(key, ct);
if (config == null)
return defaultValue;
return JsonSerializer.Deserialize<T>(config.Value, JsonOptions);
}
public async Task SetAsync<T>(
string key,
T value,
CancellationToken ct = default)
{
var json = JsonSerializer.Serialize(value, JsonOptions);
await repository.SetAsync(key, json, ct);
await repository.SaveChangesAsync(ct);
}
}