From 4ea3ddb38d010c2f85c22b7f1c3f2d7e0c1355e3 Mon Sep 17 00:00:00 2001 From: Jake Mannens Date: Fri, 22 May 2026 12:46:00 +1000 Subject: Initial commit --- Program.cs | 31 ------------------------------- 1 file changed, 31 deletions(-) (limited to 'Program.cs') diff --git a/Program.cs b/Program.cs index 5863368..d159d2d 100644 --- a/Program.cs +++ b/Program.cs @@ -1,9 +1,5 @@ -using HyperBooru.Services; using Microsoft.AspNetCore.Authentication.Cookies; -using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Http.Json; -using Microsoft.EntityFrameworkCore; -using System.Text.Json.Serialization; namespace HyperBooru; @@ -11,14 +7,9 @@ public class Program { public static void Main(string[] args) { var builder = WebApplication.CreateBuilder(args); builder.Services.AddSession(); - builder.Services.AddHttpContextAccessor(); builder.Services.AddAuthentication( CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(); builder.Services.AddAuthorization(); - builder.Services.AddControllers().AddJsonOptions(o => { - var converter = new JsonStringEnumConverter(); - o.JsonSerializerOptions.Converters.Add(converter); - }); builder.Services.Configure(o => { o.SerializerOptions.TypeInfoResolverChain.Insert(0, new ExceptionJsonResolver()); }); @@ -26,30 +17,9 @@ public class Program { builder.Services.AddServerSideBlazor(); // Add our custom services - builder.Services.AddSingleton(); - builder.Services.AddDbContextFactory(); - builder.Services.AddScoped(); - builder.Services.AddScoped(); - builder.Services.AddScoped(); - builder.Services.AddSingleton(); - builder.Services.AddScoped(); - builder.Services.AddHostedService(); - builder.Services.AddSingleton(); - - // Ensure session keys are stored in a persistent location on all platforms - builder.Services.AddDataProtection() - .PersistKeysToFileSystem(new( - builder.Services.BuildServiceProvider() - .GetRequiredService() - .KeyPath)); var app = builder.Build(); - // Ensure database is created and it's schema is up to date - using var scope = app.Services.CreateScope(); - using var db = scope.ServiceProvider.GetRequiredService(); - db.Database.Migrate(); - app.UseRouting(); app.UseSession(); app.UseAuthentication(); @@ -59,7 +29,6 @@ public class Program { app.UseStaticFiles(); app.UseMiddleware(); app.MapBlazorHub(); - app.MapControllers(); app.MapFallbackToPage("/_Host"); app.Run(); -- cgit v1.3