summaryrefslogtreecommitdiff
path: root/Program.cs
diff options
context:
space:
mode:
authorJake Mannens <jake@asger.xyz>2026-05-22 00:52:16 +1000
committerJake Mannens <jake@asger.xyz>2026-05-23 22:22:55 +1000
commit12eaa5814ef20b0910e8d64a753378b6f6797989 (patch)
tree062cf477c29054e0f089cb80f0cd79a9f3b7ccd9 /Program.cs
parent6de5d7f5364fe1d54703da6d6b7cb08ea26e939f (diff)
Initial commitwasm-initial
Diffstat (limited to 'Program.cs')
-rw-r--r--Program.cs67
1 files changed, 0 insertions, 67 deletions
diff --git a/Program.cs b/Program.cs
deleted file mode 100644
index 5863368..0000000
--- a/Program.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-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;
-
-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<JsonOptions>(o => {
- o.SerializerOptions.TypeInfoResolverChain.Insert(0, new ExceptionJsonResolver());
- });
- builder.Services.AddRazorPages();
- builder.Services.AddServerSideBlazor();
-
- // Add our custom services
- builder.Services.AddSingleton<IConfigService, ConfigService>();
- builder.Services.AddDbContextFactory<HBContext>();
- builder.Services.AddScoped<IFeedService, FeedService>();
- builder.Services.AddScoped<ITagService, TagService>();
- builder.Services.AddScoped<IMediaService, MediaService>();
- 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()
- .PersistKeysToFileSystem(new(
- builder.Services.BuildServiceProvider()
- .GetRequiredService<IConfigService>()
- .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<HBContext>();
- db.Database.Migrate();
-
- app.UseRouting();
- app.UseSession();
- app.UseAuthentication();
- app.UseAuthorization();
- app.UseHsts();
- app.UseHttpsRedirection();
- app.UseStaticFiles();
- app.UseMiddleware<ExceptionMiddleware>();
- app.MapBlazorHub();
- app.MapControllers();
- app.MapFallbackToPage("/_Host");
-
- app.Run();
- }
-}