AdminPanel

This commit is contained in:
dingo
2025-12-24 20:34:48 -05:00
parent ddf9a4b8c5
commit ef3ce84aec
23 changed files with 1782 additions and 0 deletions
+24
View File
@@ -20,6 +20,24 @@ using VoidScavengers.Game;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
// ---- Razor Pages for Admin Panel ----
builder.Services.AddRazorPages()
.AddRazorPagesOptions(options =>
{
options.RootDirectory = "/Admin/Pages";
});
// ---- Session for Admin Auth ----
builder.Services.AddDistributedMemoryCache();
builder.Services.AddSession(options =>
{
options.IdleTimeout = TimeSpan.FromHours(8);
options.Cookie.HttpOnly = true;
options.Cookie.IsEssential = true;
options.Cookie.Name = ".VoidScavengers.Admin";
});
// ---- MySQL conn string from env ----
string mysqlConnectionString = ConnectionStringFactory.BuildMySqlFromEnv();
@@ -153,6 +171,9 @@ app.MapGet("/health/ready", async (IRedisManager rm, HealthCheckService hc) =>
catch { return Results.StatusCode(503); }
});
// ---- Session middleware (must be before routing) ----
app.UseSession();
// ---- WebSockets endpoint ----
app.UseWebSockets(new WebSocketOptions { KeepAliveInterval = TimeSpan.FromSeconds(20) });
@@ -197,4 +218,7 @@ app.Lifetime.ApplicationStopping.Register(() =>
// var leases = app.Services.GetRequiredService<IZoneLeaseService>();
// _ = leases.TryAcquireAsync(zoneId: 1);
app.MapControllers();
app.MapRazorPages();
app.Logger.LogInformation("Admin panel available at /admin");
await app.RunAsync();