using PTCMS.API.Infrastructure.Utils;
using PTCMS.API.Infrastructure.Utils.Extensions;
using PTCMS.API.Infrastructure.Utils.Helpers;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddSingleton(new AppSettingHelper());

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

builder.Services.AddFreeSql();
builder.Services.AddCustomServices();

builder.Services.AddCors(options =>
{
    options.AddPolicy
        (name: "cors",
            builde =>
            {
                builde.WithOrigins("*", "*", "*")
                .AllowAnyOrigin()
                .AllowAnyHeader()
                .AllowAnyMethod();
            }
        );
});

var app = builder.Build();

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

app.UseStaticFiles();
app.UseCors("cors");

app.UseAuthentication();
app.UseAuthorization();

app.MapControllers();

app.Run();