Add Application configuration #11

Merged
Wesser merged 128 commits from feat/add-setup into release/v1.0.0 2024-06-01 07:35:30 +03:00
Showing only changes of commit 35eb1eab39 - Show all commits

View File

@ -12,6 +12,7 @@ using Mirea.Api.Endpoint.Common.Interfaces;
using Mirea.Api.Endpoint.Common.Services; using Mirea.Api.Endpoint.Common.Services;
using Mirea.Api.Endpoint.Configuration; using Mirea.Api.Endpoint.Configuration;
using Mirea.Api.Endpoint.Configuration.General; using Mirea.Api.Endpoint.Configuration.General;
using Mirea.Api.Endpoint.Configuration.General.Validators;
using Mirea.Api.Endpoint.Configuration.Swagger; using Mirea.Api.Endpoint.Configuration.Swagger;
using Mirea.Api.Endpoint.Middleware; using Mirea.Api.Endpoint.Middleware;
using Swashbuckle.AspNetCore.SwaggerGen; using Swashbuckle.AspNetCore.SwaggerGen;
@ -100,8 +101,25 @@ public class Program
Console.WriteLine($"{item.Key}:{item.Value}"); Console.WriteLine($"{item.Key}:{item.Value}");
#endif #endif
var uber = app.Services.CreateScope().ServiceProvider.GetService<UberDbContext>(); using (var scope = app.Services.CreateScope())
DbInitializer.Initialize(uber!); {
var serviceProvider = scope.ServiceProvider;
var optionsSnapshot = serviceProvider.GetRequiredService<IOptionsSnapshot<GeneralConfig>>();
var settingsValidator = new SettingsRequiredValidator(optionsSnapshot);
var isDoneConfig = settingsValidator.AreSettingsValid();
if (isDoneConfig)
{
var uberDbContext = serviceProvider.GetRequiredService<UberDbContext>();
var maintenanceModeService = serviceProvider.GetRequiredService<IMaintenanceModeNotConfigureService>();
maintenanceModeService.DisableMaintenanceMode();
DbInitializer.Initialize(uberDbContext);
// todo: if admin not found
}
}
// Configure the HTTP request pipeline. // Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment()) if (app.Environment.IsDevelopment())