refactoring for integration

This commit is contained in:
Paul Schneider 2026-06-06 21:10:48 +01:00
commit 070f41ac7e
48 changed files with 100 additions and 46 deletions

View file

@ -10,10 +10,12 @@
copies or substantial portions of the Software.
*/
using Anthropic.SDK;
using IdentityModel;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Yavsc;
using Yavsc.Abstract.Interfaces;
using Yavsc.Helpers;
using Yavsc.Interface;
using Yavsc.Models;
@ -28,7 +30,23 @@ internal class Program
var builder = WebApplication.CreateBuilder(args);
var services = builder.Services;
// builder.Services.AddDistributedMemoryCache();
// Anthropic client
builder.Services.AddSingleton<AnthropicClient>(_ =>
new AnthropicClient(
new APIAuthentication(
builder.Configuration["ANTHROPIC_API_KEY"]
?? throw new InvalidOperationException("ANTHROPIC_API_KEY manquante")
)
)
);
// Service de modération
if (builder.Environment.IsDevelopment())
builder.Services.AddScoped<IModerationService, MockModerationService>();
else
builder.Services.AddScoped<IModerationService, ClaudeModerationService>();
// accepts any access token issued by identity server
// adds an authorization policy for scope 'scope1'

View file

@ -10,4 +10,4 @@
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" />
<ProjectReference Include="../Yavsc.Server/Yavsc.Server.csproj" />
</ItemGroup>
</Project>
</Project>

View file

@ -10,22 +10,6 @@ namespace Yavsc
{
var builder = WebApplication.CreateBuilder(args);
// Anthropic client
builder.Services.AddSingleton<AnthropicClient>(_ =>
new AnthropicClient(
new APIAuthentication(
builder.Configuration["ANTHROPIC_API_KEY"]
?? throw new InvalidOperationException("ANTHROPIC_API_KEY manquante")
)
)
);
// Service de modération
if (builder.Environment.IsDevelopment())
builder.Services.AddScoped<IModerationService, MockModerationService>();
else
builder.Services.AddScoped<IModerationService, ClaudeModerationService>();
var app = await builder
.ConfigureWebAppServices()
.ConfigurePipeline();