using System.IO.Compression; using Microsoft.AspNetCore.ResponseCompression; using TaxBaik.Application; using TaxBaik.Infrastructure; var builder = WebApplication.CreateBuilder(args); builder.Services.AddRazorPages(); builder.Services.AddMemoryCache(); builder.Services.AddResponseCompression(opts => { opts.Providers.Add(); }); builder.Services.AddInfrastructure(); builder.Services.AddApplication(); var app = builder.Build(); // Run migrations on startup using (var scope = app.Services.CreateScope()) { var connectionFactory = scope.ServiceProvider.GetRequiredService(); var cs = builder.Configuration.GetConnectionString("Default") ?? throw new InvalidOperationException("Missing connection string"); var migrationRunner = new TaxBaik.Infrastructure.Data.MigrationRunner(cs, connectionFactory); await migrationRunner.RunAsync(); } app.UsePathBase("/taxbaik"); app.UseResponseCompression(); app.UseStaticFiles(); app.UseRouting(); if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Error"); app.UseHsts(); } app.MapRazorPages(); app.Run();