using EntKube.Identity.Domain;
using EntKube.Identity.Features.CreateTenant;
using EntKube.Identity.Infrastructure;

namespace EntKube.Identity;

public class Program
{
    public static void Main(string[] args)
    {
        WebApplicationBuilder builder = WebApplication.CreateBuilder(args);

        // Register identity and tenant services. In production, this will also
        // integrate with Keycloak for authentication token validation and user management.

        builder.Services.AddSingleton<ITenantRepository, InMemoryTenantRepository>();
        builder.Services.AddScoped<CreateTenantHandler>();
        builder.Services.AddOpenApi();

        WebApplication app = builder.Build();

        if (app.Environment.IsDevelopment())
        {
            app.MapOpenApi();
        }

        app.UseHttpsRedirection();

        // Map feature endpoints.

        CreateTenantEndpoint.Map(app);

        app.Run();
    }
}
