Initial commit
This commit is contained in:
50
FictionArchive.Service.TranslationService/Program.cs
Normal file
50
FictionArchive.Service.TranslationService/Program.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user