using HyperBooru.PrincipalProviders; using HyperBooru.Services; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.EntityFrameworkCore; using System.Text.Json.Serialization; namespace HyperBooru; public class Program { public static void Main(string[] args) { var builder = WebApplication.CreateBuilder(args); builder.Services.AddHttpContextAccessor(); builder.Services.AddAuthentication( CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(); builder.Services.AddControllers().AddJsonOptions(o => { var converter = new JsonStringEnumConverter(); o.JsonSerializerOptions.Converters.Add(converter); }); builder.Services.AddRazorPages(); builder.Services.AddServerSideBlazor(); // Add our custom services builder.Services.AddSingleton(); builder.Services.AddDbContextFactory(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddHostedService(); 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.UseHsts(); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.MapBlazorHub(); app.MapControllers(); app.MapFallbackToPage("/_Host"); app.Run(); } }