diff options
| author | Jake Mannens <jake@asger.xyz> | 2026-05-24 00:10:01 +1000 |
|---|---|---|
| committer | Jake Mannens <jake@asger.xyz> | 2026-06-11 01:16:00 +1000 |
| commit | f78be44d0cd8f73510335bd543207d414b003d37 (patch) | |
| tree | 92d0ef1368b1ba729988c3f47aa0ec1f458fec86 /Program.cs | |
| parent | ee3fe6eeaa0ea3e847d1ba79d819e4701b31ab29 (diff) | |
Updated Program.cs and converted to WASM
Diffstat (limited to 'Program.cs')
| -rw-r--r-- | Program.cs | 27 |
1 files changed, 17 insertions, 10 deletions
@@ -1,3 +1,4 @@ +using HyperBooru.Server.Components; using HyperBooru.Services; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.DataProtection; @@ -5,12 +6,12 @@ using Microsoft.AspNetCore.Http.Json; using Microsoft.EntityFrameworkCore; using System.Text.Json.Serialization; -namespace HyperBooru; +namespace HyperBooru.Server; 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(); @@ -22,8 +23,8 @@ public class Program { builder.Services.Configure<JsonOptions>(o => { o.SerializerOptions.TypeInfoResolverChain.Insert(0, new ExceptionJsonResolver()); }); - builder.Services.AddRazorPages(); - builder.Services.AddServerSideBlazor(); + builder.Services.AddRazorComponents() + .AddInteractiveWebAssemblyComponents(); // Add our custom services builder.Services.AddSingleton<IConfigService, ConfigService>(); @@ -34,7 +35,6 @@ public class Program { builder.Services.AddSingleton<IGlobalUserService, GlobalUserService>(); builder.Services.AddScoped<IUserService, UserService>(); builder.Services.AddHostedService<OcrService>(); - builder.Services.AddSingleton<ISourceService, SourceService>(); // Ensure session keys are stored in a persistent location on all platforms builder.Services.AddDataProtection() @@ -50,17 +50,24 @@ public class Program { using var db = scope.ServiceProvider.GetRequiredService<HBContext>(); db.Database.Migrate(); - app.UseRouting(); - app.UseSession(); app.UseAuthentication(); app.UseAuthorization(); + if(app.Environment.IsDevelopment()) { + app.UseWebAssemblyDebugging(); + } else { + app.UseExceptionHandler("/Error"); + } + + app.UseStatusCodePagesWithReExecute("/not-found", createScopeForStatusCodePages: true); app.UseHsts(); app.UseHttpsRedirection(); - app.UseStaticFiles(); + app.MapStaticAssets(); app.UseMiddleware<ExceptionMiddleware>(); - app.MapBlazorHub(); + app.UseAntiforgery(); app.MapControllers(); - app.MapFallbackToPage("/_Host"); + app.MapRazorComponents<App>() + .AddInteractiveWebAssemblyRenderMode() + .AddAdditionalAssemblies(typeof(Client._Imports).Assembly); app.Run(); } |
