50 lines
1.5 KiB
C#
50 lines
1.5 KiB
C#
using DeepL;
|
|
using FictionArchive.Service.Shared.Services.GraphQL;
|
|
using FictionArchive.Service.TranslationService.GraphQL;
|
|
using FictionArchive.Service.TranslationService.Services.TranslationEngines;
|
|
using FictionArchive.Service.TranslationService.Services.TranslationEngines.DeepLTranslate;
|
|
|
|
namespace FictionArchive.Service.TranslationService;
|
|
|
|
public class Program
|
|
{
|
|
public static void Main(string[] args)
|
|
{
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
builder.Services.AddHealthChecks();
|
|
|
|
#region GraphQL
|
|
|
|
builder.Services.AddGraphQLServer()
|
|
.AddQueryType<Query>()
|
|
.AddMutationType<Mutation>()
|
|
.AddType<UnsignedIntType>()
|
|
.AddMutationConventions(applyToAllMutations: true)
|
|
.AddFiltering(opt => opt.AddDefaults().BindRuntimeType<uint, UnsignedIntOperationFilterInputType>())
|
|
.AddSorting()
|
|
.AddProjections();
|
|
|
|
#endregion
|
|
|
|
#region Translation Adapter
|
|
|
|
builder.Services.AddTransient<DeepLClient>(provider =>
|
|
{
|
|
return new DeepLClient(builder.Configuration["DeepL:ApiKey"]);
|
|
});
|
|
builder.Services.AddTransient<ITranslationEngineAdapter, DeepLTranslationAdapater>();
|
|
|
|
#endregion
|
|
|
|
var app = builder.Build();
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
app.MapHealthChecks("/healthz");
|
|
|
|
app.MapGraphQL();
|
|
|
|
app.Run();
|
|
}
|
|
} |