blob: e0e1b2ddca6537221d2ce0eb3debd68114ab2458 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
using Microsoft.EntityFrameworkCore;
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.Migrate();
#if DEBUG
app.UseSwagger();
app.UseSwaggerUI();
#endif
app.MapRazorPages();
app.UseStaticFiles();
app.UseHttpsRedirection();
app.MapControllers();
app.Run();
}
}
|