Some checks failed
Release / build-and-push (map[dockerfile:FictionArchive.API/Dockerfile name:api]) (pull_request) Has been cancelled
Release / build-and-push (map[dockerfile:FictionArchive.Service.AuthenticationService/Dockerfile name:authentication-service]) (pull_request) Has been cancelled
Release / build-and-push (map[dockerfile:FictionArchive.Service.FileService/Dockerfile name:file-service]) (pull_request) Has been cancelled
Release / build-and-push (map[dockerfile:FictionArchive.Service.NovelService/Dockerfile name:novel-service]) (pull_request) Has been cancelled
Release / build-and-push (map[dockerfile:FictionArchive.Service.SchedulerService/Dockerfile name:scheduler-service]) (pull_request) Has been cancelled
Release / build-and-push (map[dockerfile:FictionArchive.Service.TranslationService/Dockerfile name:translation-service]) (pull_request) Has been cancelled
Release / build-and-push (map[dockerfile:FictionArchive.Service.UserService/Dockerfile name:user-service]) (pull_request) Has been cancelled
Release / build-frontend (pull_request) Has been cancelled
Build Gateway / build-subgraphs (map[name:novel-service project:FictionArchive.Service.NovelService subgraph:Novel]) (pull_request) Failing after 51s
Build Gateway / build-subgraphs (map[name:translation-service project:FictionArchive.Service.TranslationService subgraph:Translation]) (pull_request) Has been cancelled
Build Gateway / build-subgraphs (map[name:user-service project:FictionArchive.Service.UserService subgraph:User]) (pull_request) Has been cancelled
Build Gateway / build-gateway (pull_request) Has been cancelled
Build Gateway / build-subgraphs (map[name:scheduler-service project:FictionArchive.Service.SchedulerService subgraph:Scheduler]) (pull_request) Has been cancelled
CI / build-frontend (pull_request) Has been cancelled
CI / build-backend (pull_request) Has been cancelled
96 lines
3.4 KiB
C#
96 lines
3.4 KiB
C#
using FictionArchive.Common.Extensions;
|
|
using FictionArchive.Service.NovelService.GraphQL;
|
|
using FictionArchive.Service.NovelService.Models.Configuration;
|
|
using FictionArchive.Service.NovelService.Models.IntegrationEvents;
|
|
using FictionArchive.Service.NovelService.Services;
|
|
using FictionArchive.Service.NovelService.Services.EventHandlers;
|
|
using FictionArchive.Service.NovelService.Services.SourceAdapters;
|
|
using FictionArchive.Service.NovelService.Services.SourceAdapters.Novelpia;
|
|
using FictionArchive.Service.Shared;
|
|
using FictionArchive.Service.Shared.Extensions;
|
|
using FictionArchive.Service.Shared.Services.EventBus.Implementations;
|
|
using FictionArchive.Service.Shared.Services.GraphQL;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace FictionArchive.Service.NovelService;
|
|
|
|
public class Program
|
|
{
|
|
public static void Main(string[] args)
|
|
{
|
|
var isSchemaExport = SchemaExportDetector.IsSchemaExportMode(args);
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
builder.AddLocalAppsettings();
|
|
|
|
builder.Services.AddMemoryCache();
|
|
|
|
#region Event Bus
|
|
|
|
if (!isSchemaExport)
|
|
{
|
|
builder.Services.AddRabbitMQ(opt =>
|
|
{
|
|
builder.Configuration.GetSection("RabbitMQ").Bind(opt);
|
|
})
|
|
.Subscribe<TranslationRequestCompletedEvent, TranslationRequestCompletedEventHandler>()
|
|
.Subscribe<NovelUpdateRequestedEvent, NovelUpdateRequestedEventHandler>()
|
|
.Subscribe<ChapterPullRequestedEvent, ChapterPullRequestedEventHandler>()
|
|
.Subscribe<FileUploadRequestStatusUpdateEvent, FileUploadRequestStatusUpdateEventHandler>();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region GraphQL
|
|
|
|
builder.Services.AddDefaultGraphQl<Query, Mutation>();
|
|
|
|
#endregion
|
|
|
|
#region Database
|
|
|
|
builder.Services.RegisterDbContext<NovelServiceDbContext>(
|
|
builder.Configuration.GetConnectionString("DefaultConnection"),
|
|
skipInfrastructure: isSchemaExport);
|
|
|
|
#endregion
|
|
|
|
#region Source Adapters
|
|
|
|
builder.Services.Configure<NovelpiaConfiguration>(builder.Configuration.GetSection("Novelpia"));
|
|
builder.Services.AddHttpClient<NovelpiaAuthMessageHandler>(client =>
|
|
{
|
|
client.BaseAddress = new Uri("https://novelpia.com");
|
|
});
|
|
builder.Services.AddHttpClient<ISourceAdapter, NovelpiaAdapter>(client =>
|
|
{
|
|
client.BaseAddress = new Uri("https://novelpia.com");
|
|
})
|
|
.AddHttpMessageHandler<NovelpiaAuthMessageHandler>();
|
|
|
|
builder.Services.Configure<NovelUpdateServiceConfiguration>(builder.Configuration.GetSection("UpdateService"));
|
|
builder.Services.AddTransient<NovelUpdateService>();
|
|
|
|
#endregion
|
|
|
|
builder.Services.AddHealthChecks();
|
|
|
|
var app = builder.Build();
|
|
|
|
// Update database (skip in schema export mode)
|
|
if (!isSchemaExport)
|
|
{
|
|
using var scope = app.Services.CreateScope();
|
|
var dbContext = scope.ServiceProvider.GetRequiredService<NovelServiceDbContext>();
|
|
dbContext.UpdateDatabase();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
app.MapHealthChecks("/healthz");
|
|
|
|
app.MapGraphQL();
|
|
|
|
app.RunWithGraphQLCommands(args);
|
|
}
|
|
} |