using PhilExampleCrawler.Common.Models;
using WebAPI.Interfaces;
using WebAPI.Services;

var builder = WebApplication.CreateBuilder(args);

//Configuring Services
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

builder.Services.AddSingleton<ICrawlScheduler<List<Insertion>>, CrawlScheduler<List<Insertion>>>();
builder.Services.AddSingleton<ITelegramDistributer, TelegramDistributer>();
builder.Services.AddHostedService(provider => provider.GetService<ITelegramDistributer>());
builder.Services.AddHttpClient();

var app = builder.Build();

//Configuring HTTP request pipeline
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}
else
{
    app.UseHttpsRedirection();
}

app.UseAuthorization();

app.MapControllers();

app.Run();
