Frontend gaps fill work. Testing fixes work. Auditing in progress.
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using StellaOps.Integrations.Persistence;
|
||||
using StellaOps.Integrations.WebService;
|
||||
using StellaOps.Integrations.WebService.Infrastructure;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen(options =>
|
||||
{
|
||||
options.SwaggerDoc("v1", new() { Title = "StellaOps Integration Catalog API", Version = "v1" });
|
||||
});
|
||||
|
||||
// Database
|
||||
var connectionString = builder.Configuration.GetConnectionString("IntegrationsDb")
|
||||
?? "Host=localhost;Database=stellaops_integrations;Username=postgres;Password=postgres";
|
||||
|
||||
builder.Services.AddDbContext<IntegrationDbContext>(options =>
|
||||
options.UseNpgsql(connectionString));
|
||||
|
||||
// Repository
|
||||
builder.Services.AddScoped<IIntegrationRepository, PostgresIntegrationRepository>();
|
||||
|
||||
// Plugin loader
|
||||
builder.Services.AddSingleton<IntegrationPluginLoader>(sp =>
|
||||
{
|
||||
var logger = sp.GetRequiredService<ILogger<IntegrationPluginLoader>>();
|
||||
var loader = new IntegrationPluginLoader(logger);
|
||||
|
||||
// Load from plugins directory
|
||||
var pluginsDir = builder.Configuration.GetValue<string>("Integrations:PluginsDirectory")
|
||||
?? Path.Combine(AppContext.BaseDirectory, "plugins");
|
||||
|
||||
if (Directory.Exists(pluginsDir))
|
||||
{
|
||||
loader.LoadFromDirectory(pluginsDir);
|
||||
}
|
||||
|
||||
// Also load from current assembly (for built-in plugins)
|
||||
loader.LoadFromAssemblies([typeof(Program).Assembly]);
|
||||
|
||||
return loader;
|
||||
});
|
||||
|
||||
// Infrastructure
|
||||
builder.Services.AddScoped<IIntegrationEventPublisher, LoggingEventPublisher>();
|
||||
builder.Services.AddScoped<IIntegrationAuditLogger, LoggingAuditLogger>();
|
||||
builder.Services.AddScoped<IAuthRefResolver, StubAuthRefResolver>();
|
||||
|
||||
// Core service
|
||||
builder.Services.AddScoped<IntegrationService>();
|
||||
|
||||
// CORS for Angular dev server
|
||||
builder.Services.AddCors(options =>
|
||||
{
|
||||
options.AddDefaultPolicy(policy =>
|
||||
{
|
||||
policy.WithOrigins("http://localhost:4200", "https://localhost:4200")
|
||||
.AllowAnyHeader()
|
||||
.AllowAnyMethod();
|
||||
});
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure pipeline
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
|
||||
app.UseCors();
|
||||
|
||||
// Map endpoints
|
||||
app.MapIntegrationEndpoints();
|
||||
|
||||
// Health endpoint
|
||||
app.MapGet("/health", () => Results.Ok(new { Status = "Healthy", Timestamp = DateTimeOffset.UtcNow }))
|
||||
.WithTags("Health")
|
||||
.WithName("HealthCheck");
|
||||
|
||||
// Ensure database is created (dev only)
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
using var scope = app.Services.CreateScope();
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<IntegrationDbContext>();
|
||||
await dbContext.Database.EnsureCreatedAsync();
|
||||
}
|
||||
|
||||
app.Run();
|
||||
|
||||
public partial class Program { }
|
||||
Reference in New Issue
Block a user