feature/FA-misc_ReportingService #64

Merged
conco merged 14 commits from feature/FA-misc_ReportingService into master 2026-02-01 17:31:31 +00:00
Showing only changes of commit 1fda5ad440 - Show all commits

View File

@@ -1,3 +1,10 @@
using FictionArchive.Common.Extensions;
using FictionArchive.Service.ReportingService.Consumers;
using FictionArchive.Service.ReportingService.Services;
using FictionArchive.Service.ReportingService.GraphQL;
using FictionArchive.Service.Shared;
using FictionArchive.Service.Shared.Extensions;
namespace FictionArchive.Service.ReportingService;
public class Program
@@ -5,8 +12,68 @@ public class Program
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
var isSchemaExport = SchemaExportDetector.IsSchemaExportMode(args);
builder.AddLocalAppsettings();
builder.Services.AddHealthChecks();
#region MassTransit
if (!isSchemaExport)
{
builder.Services.AddFictionArchiveMassTransit(
builder.Configuration,
x =>
{
x.AddConsumer<JobStatusUpdateConsumer>();
});
}
#endregion
#region GraphQL
builder.Services.AddGraphQLServer()
.AddQueryConventions()
.AddTypeExtension(typeof(JobQueries))
.ApplySaneDefaults()
.AddAuthorization();
#endregion
#region Database
builder.Services.RegisterDbContext<ReportingDbContext>(
builder.Configuration.GetConnectionString("DefaultConnection"),
skipInfrastructure: isSchemaExport);
#endregion
// Authentication & Authorization
builder.Services.AddOidcAuthentication(builder.Configuration);
builder.Services.AddFictionArchiveAuthorization();
var app = builder.Build();
app.MapGet("/healthz", () => "ok");
app.Run();
// Update database (skip in schema export mode)
if (!isSchemaExport)
{
using var scope = app.Services.CreateScope();
var dbContext = scope.ServiceProvider.GetRequiredService<ReportingDbContext>();
dbContext.UpdateDatabase();
}
app.UseHttpsRedirection();
app.MapHealthChecks("/healthz");
app.UseAuthentication();
app.UseAuthorization();
app.MapGraphQL();
app.RunWithGraphQLCommands(args);
}
}