using Serilog;
using Serilog.Events;
using Tiku.Api.Configuration;

Log.Logger = new LoggerConfiguration()
    .MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
    .Enrich.FromLogContext()
    .WriteTo.Console()
    .CreateBootstrapLogger();

try
{
    Log.Information("Starting TIKU API");

    var builder = WebApplication.CreateBuilder(args);
    builder.AddApiServices();

    var app = builder.Build();
    app.UseApiPipeline();
    app.Run();
}
catch (Exception exception)
{
    Log.Fatal(exception, "TIKU API terminated unexpectedly");
    throw;
}
finally
{
    Log.CloseAndFlush();
}

public partial class Program;
