diff options
| author | Jake Mannens <jake@asger.xyz> | 2025-08-17 22:10:27 +1000 |
|---|---|---|
| committer | Jake Mannens <jake@asger.xyz> | 2025-08-18 10:59:28 +1000 |
| commit | 6c53f3dc43f072dce4ffe4a1bd306074dd20ff39 (patch) | |
| tree | 494335104504dca462a3837c3993e2add8e72bad /HyperBooru.cs | |
Initial commit
Diffstat (limited to 'HyperBooru.cs')
| -rw-r--r-- | HyperBooru.cs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/HyperBooru.cs b/HyperBooru.cs new file mode 100644 index 0000000..9ccd323 --- /dev/null +++ b/HyperBooru.cs @@ -0,0 +1,36 @@ +using System.Text.Json.Serialization; + +namespace HyperBooru; + +public class HyperBooru { + public static void Main(string[] args) { + var builder = WebApplication.CreateBuilder(); + builder.Services.AddEndpointsApiExplorer(); + builder.Services.AddSwaggerGen(); + builder.Services.AddControllers().AddJsonOptions(o => { + var converter = new JsonStringEnumConverter(); + o.JsonSerializerOptions.Converters.Add(converter); + }); + builder.Services.AddRazorPages(); + builder.Services.AddSingleton<IConfigService, ConfigService>(); + builder.Services.AddScoped<HyperBooruDbContext>(p => + new HyperBooruDbContext(p.GetRequiredService<IConfigService>())); + + var app = builder.Build(); + + using var scope = app.Services.CreateScope(); + using var db = scope.ServiceProvider.GetRequiredService<HyperBooruDbContext>(); + db.Database.EnsureCreated(); + + #if DEBUG + app.UseSwagger(); + app.UseSwaggerUI(); + #endif + + app.MapRazorPages(); + app.UseStaticFiles(); + app.UseHttpsRedirection(); + app.MapControllers(); + app.Run(); + } +}
\ No newline at end of file |
