feat: add setup wizard and proper seeder
All checks were successful
Update changelog / changelog (push) Successful in 26s
All checks were successful
Update changelog / changelog (push) Successful in 26s
This commit is contained in:
10
Program.cs
10
Program.cs
@@ -1,8 +1,8 @@
|
||||
using Microsoft.AspNetCore.Mvc.Formatters;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.OpenApi;
|
||||
using Shadow.Controllers;
|
||||
using Shadow.Data;
|
||||
using Shadow.Tools;
|
||||
using System.Reflection;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
@@ -66,12 +66,13 @@ builder.Services.AddSwaggerGen(options =>
|
||||
var xmlFilename = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
|
||||
options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename));
|
||||
});
|
||||
builder.Services.AddHttpLogging();
|
||||
|
||||
var app = builder.Build();
|
||||
bool shutdown = false;
|
||||
if (args.FirstOrDefault() is not null)
|
||||
{
|
||||
// Handle CLI if arguments have been passed.
|
||||
bool shutdown = false;
|
||||
using (IServiceScope scope = app.Services.CreateScope())
|
||||
{
|
||||
ApplicationDbContext db = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
|
||||
@@ -87,9 +88,9 @@ using (IServiceScope scope = app.Services.CreateScope())
|
||||
ApplicationDbContext db = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
|
||||
GeneralUseHelpers guhf = scope.ServiceProvider.GetRequiredService<GeneralUseHelpers>();
|
||||
Seeder seeder = new(db, guhf);
|
||||
seeder.Seed();
|
||||
shutdown = seeder.Seed();
|
||||
}
|
||||
|
||||
if (shutdown) return;
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
@@ -97,6 +98,7 @@ if (app.Environment.IsDevelopment())
|
||||
app.MapOpenApi();
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
app.UseHttpLogging();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
Reference in New Issue
Block a user