using lilos_stitcher;

var builder = WebApplication.CreateBuilder(args);

NetVips.NetVips.Init();
NetVips.NetVips.Concurrency = 3;

builder.Services.AddControllers().AddJsonOptions(o => o.JsonSerializerOptions.PropertyNameCaseInsensitive = true);

builder.Services.AddMemoryCache(o => o.SizeLimit = 128L * 1024 * 1024);

string assetDir = Environment.GetEnvironmentVariable("ASSET_PATH_RO") ?? throw new InvalidOperationException("dir not found");

builder.Services.AddSingleton<TileCache>();
builder.Services.AddSingleton(provider => new TileLoader(provider.GetRequiredService<TileCache>(), assetDir));
builder.Services.AddSingleton<lilos_stitcher.LiloStitcher>();

var app = builder.Build();
app.MapControllers();
app.Run();