summaryrefslogtreecommitdiff
path: root/HyperBooru.cs
diff options
context:
space:
mode:
authorJake Mannens <jake@asger.xyz>2023-08-08 13:20:21 +1000
committerJake Mannens <jake@asger.xyz>2023-08-08 13:20:21 +1000
commit701d474949e5cb72b8ed7b29fec45ad74580f570 (patch)
tree0eea7adfdd9d7dde4dd44535cd172d7e6a4f8737 /HyperBooru.cs
Initial commit
Diffstat (limited to 'HyperBooru.cs')
-rw-r--r--HyperBooru.cs36
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