using Blog.Components; using Blog.Services; var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddRazorComponents(); builder.Services.AddHttpClient(); builder.Services.AddHybridCache(); builder.Services.AddHttpClient( client => { client.BaseAddress = new Uri("https://brp.bes.is/"); }); // /Warframe searches Digital Extremes' published drop tables. warframe.com blocks requests from // the server, so the 4 MB page ships in Blog/Resources and scripts/update-droptables.sh refreshes // it before a publish. Singleton: the parsed tables live in the service, so a transient one would // re-parse per request - see WarframeDropService. builder.Services.Configure(builder.Configuration.GetSection(WarframeOptions.Section)); builder.Services.AddSingleton(); // /rvrb reads the rvrb bot's stats straight off its BEAM, over Erlang distribution. The node this // site dials with is started on the first request, not here - see RvrbService. builder.Services.Configure(builder.Configuration.GetSection(RvrbOptions.Section)); builder.Services.AddSingleton(); // builder.Services.AddTransient(); // builder.Services.AddTransient(); var app = builder.Build(); // 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.UseAntiforgery(); app.MapStaticAssets(); app.MapRazorComponents(); // Item names matching what has been typed, for the search box's suggestion list. app.MapGet("/api/warframe/names", async (string? q, WarframeDropService drops, CancellationToken cancellationToken) => { var status = await drops.GetTablesAsync(cancellationToken).ConfigureAwait(false); return status.Tables?.Search(q ?? "", 10) ?? []; }); app.Run();