39 lines
902 B
C#
39 lines
902 B
C#
using backend.Auth;
|
|
using backend.Data;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
builder.Services.AddDbContext<AppDbContext>(opt =>
|
|
opt.UseSqlite(builder.Configuration.GetConnectionString("Default")));
|
|
|
|
builder.Services.AddAppIdentity();
|
|
builder.Services.AddAuthorization();
|
|
|
|
var app = builder.Build();
|
|
|
|
using (var scope = app.Services.CreateScope())
|
|
{
|
|
var sp = scope.ServiceProvider;
|
|
var db = sp.GetRequiredService<AppDbContext>();
|
|
db.Database.Migrate();
|
|
await IdentitySetup.SeedRolesAsync(sp);
|
|
|
|
if (!db.SystemSettings.Any())
|
|
{
|
|
db.SystemSettings.Add(new backend.Settings.SystemSettings());
|
|
await db.SaveChangesAsync();
|
|
}
|
|
}
|
|
|
|
app.UseAuthentication();
|
|
app.UseAuthorization();
|
|
|
|
app.MapAuthEndpoints();
|
|
|
|
app.MapGet("/health", () => Results.Ok(new { ok = true }));
|
|
|
|
app.Run();
|
|
|
|
public partial class Program { }
|