using System.Text.Json.Serialization;
using ImageConvertService.Biz;
using ImageConvertService.ExceptionHandling;
using Microsoft.AspNetCore.Server.Kestrel.Core;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

builder.Services
    .AddControllersWithViews(options => options.Filters.Add<UserFriendlyExceptionFilter>())
    .AddJsonOptions(options => options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()));

builder.Services.AddSingleton<ArchiveFileAccessor>();
builder.Services.AddSingleton<ArchiveEntrySkipper>();
builder.Services.AddSingleton<PdfImageReader>();
builder.Services.AddSingleton<ImageConverter>();


builder.Services.Configure<KestrelServerOptions>(options =>
{
    options.Limits.MaxRequestBodySize = null;
});

var app = builder.Build();

// Configure the HTTP request pipeline.
//if (app.Environment.IsDevelopment())
//{
app.UseSwagger();
app.UseSwaggerUI();
//}

//app.UseHttpsRedirection();

app.MapControllers().WithFormOptions(multipartBodyLengthLimit: long.MaxValue); 

app.Run();

