2026-04-27 02:24:51 +00:00
|
|
|
using ControlCenter.Api.Data;
|
|
|
|
|
using ControlCenter.Api.Hubs;
|
2026-04-27 04:10:18 +00:00
|
|
|
using ControlCenter.Api.Repositories;
|
2026-04-27 02:24:51 +00:00
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
|
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
|
|
|
|
|
|
// Add services to the container.
|
|
|
|
|
builder.Services.AddOpenApi();
|
|
|
|
|
|
|
|
|
|
// Register SignalR for real-time agent status updates
|
|
|
|
|
builder.Services.AddSignalR();
|
|
|
|
|
|
2026-04-27 04:10:18 +00:00
|
|
|
// Register Agent State Repository
|
|
|
|
|
builder.Services.AddScoped<IAgentStateRepository, AgentStateRepository>();
|
|
|
|
|
|
2026-04-27 02:24:51 +00:00
|
|
|
// Register DbContext with PostgreSQL
|
|
|
|
|
builder.Services.AddDbContext<AppDbContext>(options =>
|
|
|
|
|
{
|
|
|
|
|
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection")
|
|
|
|
|
?? "Host=localhost;Database=control_center;Username=postgres;Password=postgres";
|
|
|
|
|
|
|
|
|
|
options.UseNpgsql(connectionString, npgsqlOptions =>
|
|
|
|
|
{
|
|
|
|
|
npgsqlOptions.MigrationsAssembly(typeof(AppDbContext).Assembly.FullName);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var app = builder.Build();
|
|
|
|
|
|
|
|
|
|
// Configure the HTTP request pipeline.
|
|
|
|
|
if (app.Environment.IsDevelopment())
|
|
|
|
|
{
|
|
|
|
|
app.MapOpenApi();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
|
|
|
|
|
|
// Map SignalR hubs
|
|
|
|
|
app.MapHub<AgentStatusHub>("/hubs/agent-status");
|
|
|
|
|
|
|
|
|
|
app.Run();
|