feat(backend): start authentication controllers

This commit is contained in:
sam 2024-06-12 03:47:20 +02:00
parent 493a6e4d29
commit 25540f2de2
15 changed files with 777 additions and 17 deletions

View file

@ -2,9 +2,11 @@ using Foxnouns.Backend;
using Foxnouns.Backend.Database;
using Serilog;
using Foxnouns.Backend.Extensions;
using Foxnouns.Backend.Services;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using NodaTime;
// Read version information from .version in the repository root
await BuildInfo.ReadBuildInfo();
@ -60,6 +62,23 @@ app.MapControllers();
app.Urls.Clear();
app.Urls.Add(config.Address);
app.Run();
// Fire off the periodic tasks loop in the background
_ = new Timer(_ =>
{
var __ = RunPeriodicTasksAsync();
}, null, TimeSpan.FromSeconds(30), TimeSpan.FromMinutes(1));
Log.CloseAndFlush();
app.Run();
Log.CloseAndFlush();
return;
async Task RunPeriodicTasksAsync()
{
await using var scope = app.Services.CreateAsyncScope();
var logger = scope.ServiceProvider.GetRequiredService<ILogger>();
logger.Debug("Running periodic tasks");
var keyCacheSvc = scope.ServiceProvider.GetRequiredService<KeyCacheService>();
await keyCacheSvc.DeleteExpiredKeysAsync();
}