feat: moved to C# thanks to deepseek
This commit is contained in:
1 parent
ab81a1c4be
commit
29ed46aa7f
34 files changed
+1583
-14
No files matched your search
+47
@@ -0,0 +1,47 @@
|
||||
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<IGameService>(sp =>
|
||||
{
|
||||
var config = sp.GetRequiredService<IConfiguration>();
|
||||
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<IConfiguration>()["SessionKey"] ?? "dev-only";
|
||||
return new LoginService(key);
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
app.UseStaticFiles();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
Reference in new issue
Block a user