using Phenix.Services; var builder = WebApplication.CreateBuilder(new WebApplicationOptions { Args = args, WebRootPath = "static", }); builder.Services .AddControllersWithViews() .AddRazorOptions(o => { o.ViewLocationFormats.Clear(); o.ViewLocationFormats.Add("/Views/{1}/{0}.cshtml"); o.ViewLocationFormats.Add("/Views/Shared/{0}.cshtml"); o.ViewLocationFormats.Add("/Views/{0}.cshtml"); }); builder.Services.AddSingleton(sp => { var config = sp.GetRequiredService(); var connStr = config.GetConnectionString("Default") ?? "Data Source=phenix.db"; var provider = config["DatabaseProvider"] ?? "Sqlite"; IGameService svc = provider.ToLowerInvariant() switch { "postgres" or "postgresql" => new PostgresGameService(connStr), _ => new SqliteGameService(connStr), }; svc.Init().GetAwaiter().GetResult(); return svc; }); builder.Services.AddSingleton(sp => { var key = sp.GetRequiredService()["SessionKey"] ?? "dev-only"; return new LoginService(key); }); var app = builder.Build(); app.UseStaticFiles(); app.MapControllers(); app.Run();