using Elastic.CommonSchema.Serilog;
using PARR.DAL;
using PARR.EsppApi;
using PARR.TemplateMatcher;
using PARR.Test;
using PARR.Test.NextRun;
using Serilog;


var builder = Host.CreateApplicationBuilder();

builder.Services.AddLogging(config =>
{
    config.ClearProviders();

    var logger = new LoggerConfiguration();

    if (builder.Environment.IsProduction())
        logger.WriteTo.Console(new EcsTextFormatter());
    else
        logger.WriteTo.Console();

    logger.ReadFrom.Configuration(builder.Configuration);

    config.AddSerilog(logger.CreateLogger());
});


builder.Services.InstallTemplateMatcherSerivces(builder.Configuration);
// builder.Services.AddDalServices(builder.Configuration);
// builder.Services.AddCoreServices(builder.Configuration);
// builder.Services.AddInfrastructureServices(builder.Configuration);
builder.Services.InstallEsppApiServices(builder.Configuration);

builder.Configuration.AddTemplateMatcherConfigurations(builder.Services);
builder.Configuration.AddDalConfigurations(builder.Services);

builder.Services.AddTemplateMatcherSettings(builder.Configuration);
builder.Services.AddDallSettings(builder.Configuration);

builder.Services.AddTransient<NextRunTest>();

builder.Services.AddHostedService<Worker>();

var host = builder.Build();

host.Run();
