using PosterMaker.Interfaces.Services;
using PosterMaker.Services;
using Serilog;

var builder = WebApplication.CreateBuilder(args);
var logger = new LoggerConfiguration()
    .ReadFrom.Configuration(builder.Configuration)
    .Enrich.FromLogContext()
    .WriteTo.Seq("http://localhost:5341")
    .CreateLogger();
builder.Logging.ClearProviders();
builder.Logging.AddSerilog(logger);
// Add services to the container.
builder.Services.AddCors(options =>
{
    options.AddPolicy("DisableCORS",
        corsPolicyBuilder =>
        {
            corsPolicyBuilder.AllowAnyOrigin()
                .AllowAnyMethod()
                .AllowAnyHeader();
        });
});

builder.Services.AddControllers();

builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

builder.Services.AddTransient<IMoviePosterMakerService, MoviePosterMakerService>();
builder.Services.AddTransient<IMovieLogoService, MovieLogoService>();
builder.Services.AddTransient<ICollectionPosterMakerService, CollectionPosterMakerService>();
builder.Services.AddTransient<ISeriesPosterMakerService, SeriesPosterMakerService>();

var app = builder.Build();
app.UseCors("DisableCORS");

if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}

app.UseHttpsRedirection();

app.UseAuthorization();

app.MapControllers();

app.Run();
