using CoreUpload.BlazorDemo.Components;
using CoreUpload.Configuration;
using CoreUpload.Endpoints;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddRazorComponents()
    .AddInteractiveServerComponents();

// The uploader's server half: same registration as any ASP.NET Core app.
builder.Services.AddCoreUpload(options =>
{
    options.TempDirectory = Path.Combine(builder.Environment.ContentRootPath, "UploaderTemp");
    options.MaxFileSizeBytes = 1024L * 1024 * 1024;
    options.EnableInstantUpload = true;   // powers the dedupe demo below
});

var app = builder.Build();

app.UseStaticFiles();
app.UseAntiforgery();

// Upload endpoints (/api/upload/*). Antiforgery is disabled on the group by
// default, which is what the browser client expects.
app.MapCoreUploadEndpoints();

app.MapRazorComponents<App>()
    .AddInteractiveServerRenderMode();

app.Run();
