using AccessQueuePlayground.Components; using AccessQueuePlayground.Services; using AccessQueueService.Data; using AccessQueueService.Services; using Serilog; var builder = WebApplication.CreateBuilder(args); // Add Serilog configuration for console logging only builder.Host.UseSerilog((context, services, configuration) => { configuration .WriteTo.Console() .ReadFrom.Configuration(context.Configuration) .ReadFrom.Services(services) .Enrich.FromLogContext(); }); // Add services to the container. builder.Services.AddRazorComponents() .AddInteractiveServerComponents(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddHostedService(); var app = builder.Build(); // Configure TakeANumberAccessQueueRepo active users cache using (var scope = app.Services.CreateScope()) { var config = scope.ServiceProvider.GetRequiredService(); var repo = scope.ServiceProvider.GetRequiredService() as TakeANumberAccessQueueRepo; if (repo != null) { int activeSeconds = config.GetValue("AccessQueue:ActivitySeconds", 2); int updateInterval = config.GetValue("AccessQueue:ActiveUsersUpdateIntervalSeconds", 2); repo.ConfigureActiveUsersCache(activeSeconds, updateInterval); } } // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Error", createScopeForErrors: true); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseAntiforgery(); app.MapRazorComponents() .AddInteractiveServerRenderMode(); app.Run();