using Management.Data; using Management.Security; var builder = WebApplication.CreateBuilder(args); // Container-friendly HTTP binding var port = Environment.GetEnvironmentVariable("PORT") ?? "8080"; builder.WebHost.UseUrls($"http://0.0.0.0:{port}"); // Services builder.Services.AddControllers(); builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new() { Title = "AdPlatform Management API", Version = "v1" }); }); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddHttpClient(); var app = builder.Build(); // Middleware pipeline app.UseSwagger(); app.UseSwaggerUI(); // Health check (before auth) app.MapGet("/health", () => Results.Ok(new { ok = true, service = "Management", timestamp = DateTimeOffset.UtcNow })); // Root endpoint app.MapGet("/", () => Results.Ok(new { service = "AdPlatform Management API", version = "1.0.0", status = "running", endpoints = new { onboarding = new[] { "GET /api/onboarding/status", "POST /api/onboarding/register" }, monitoring = new[] { "GET /api/monitoring/health", "GET /api/monitoring/stats" }, admin = new { clients = new[] { "GET/POST /api/admin/clients", "GET/PUT/DELETE /api/admin/clients/{id}" }, users = new[] { "GET/POST /api/admin/users", "GET/PUT/DELETE /api/admin/users/{id}" }, sessions = new[] { "GET /api/admin/sessions", "POST /api/admin/sessions/{id}/revoke" } } } })); // Authentication middleware app.UseMiddleware(); app.UseAuthorization(); app.MapControllers(); app.Run();