WIP: refactoring pour déploiement

Non testé en conditions réelles. À valider avant de pousser.
This commit is contained in:
Paul Schneider 2026-06-14 04:55:18 +01:00
commit 9415521bcb
14 changed files with 125 additions and 28 deletions

View file

@ -19,6 +19,7 @@ using Yavsc.Abstract.Interfaces;
using Yavsc.Helpers;
using Yavsc.Interface;
using Yavsc.Models;
using Yavsc.Server.Helpers;
using Yavsc.Services;
internal class Program
@ -29,10 +30,8 @@ internal class Program
var builder = WebApplication.CreateBuilder(args);
builder.Configuration
.AddJsonFile("appsettings-api.json", optional: false, reloadOnChange: false)
.AddJsonFile($"appsettings-api.{builder.Environment.EnvironmentName}.json", optional: false, reloadOnChange: false)
.AddEnvironmentVariables();
builder.AddConfiguration("api");
var services = builder.Services;
// Anthropic client

View file

@ -10,7 +10,7 @@
"Kestrel": {
"Endpoints": {
"Https":{
"Url": "https://localhost:6001"
"Url": "https://localhost:3004"
}
}
}

View file

@ -29,10 +29,8 @@ internal class Program
Console.Title = "Yavsc.Blogs";
var builder = WebApplication.CreateBuilder(args);
builder.Configuration
.AddJsonFile("appsettings-blogs.json", optional: false, reloadOnChange: false)
.AddJsonFile($"appsettings-blogs.{builder.Environment.EnvironmentName}.json", optional: false, reloadOnChange: false)
.AddEnvironmentVariables();
builder.AddConfiguration("blogs");
var services = builder.Services;

View file

@ -17,7 +17,7 @@
"Kestrel": {
"Endpoints": {
"Https": {
"Url": "https://localhost:5005"
"Url": "https://localhost:3003"
}
}
}

View file

@ -1,6 +1,7 @@
using Anthropic.SDK;
using Yavsc.Abstract.Interfaces;
using Yavsc.Extensions;
using Yavsc.Server.Helpers;
namespace Yavsc
{
@ -9,15 +10,14 @@ namespace Yavsc
public static async Task Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
builder.Configuration
.AddJsonFile("appsettings-org.json", optional: false, reloadOnChange: false)
.AddJsonFile($"appsettings-org.{builder.Environment.EnvironmentName}.json", optional: false, reloadOnChange: false)
.AddEnvironmentVariables();
builder.AddConfiguration("org");
var app = await builder
.ConfigureWebAppServices()
.ConfigurePipeline();
app.Run();
}
}
}

View file

@ -2,14 +2,14 @@
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning" ,
"Microsoft.AspNetCore": "Warning",
"Microsoft.AspNetCore.SignalR": "Debug",
"Microsoft.AspNetCore.Http.Connections": "Debug"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"YavscConnection": "Server=[YOURSERVERNAME];Port=5432;Database=[YOURDBNAME];Username=[YOURDBUSERNAME];Password=[YOURDBPASSW];"
"YavscConnection": "*** via dotnet user-secrets ou variable d'environnement *** Server=[YOURSERVERNAME];Port=5432;Database=[YOURDBNAME];Username=[YOURDBUSERNAME];Password=[YOURDBPASSW];"
},
"Site": {
"Title": "yavsc",
@ -81,5 +81,12 @@
"Moderation": {
"AutoApproveThreshold": 0.7,
"AutoRejectThreshold": 0.9
},
"Kestrel": {
"Endpoints": {
"Http": {
"Url": "http://localhost:3002"
}
}
}
}

View file

@ -0,0 +1,18 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
namespace Yavsc.Server.Helpers;
public static class ConfigHelpers
{
public static void AddConfiguration(this WebApplicationBuilder builder, string appName )
{
var rootConfig = builder.Configuration
.AddJsonFile($"appsettings-{appName}.json", optional: false, reloadOnChange: false);
if (!String.IsNullOrWhiteSpace(builder.Environment.EnvironmentName))
rootConfig.AddJsonFile($"appsettings-{appName}.{builder.Environment.EnvironmentName}.json", optional: true, reloadOnChange: false);
;
rootConfig.AddEnvironmentVariables();
}
}

View file

@ -12,14 +12,12 @@
using System.IdentityModel.Tokens.Jwt;
using Microsoft.AspNetCore.Authentication;
using Yavsc.Server.Helpers;
JwtSecurityTokenHandler.DefaultMapInboundClaims = true;
var builder = WebApplication.CreateBuilder(args);
builder.Configuration
.AddJsonFile("appsettings-web.json", optional: false, reloadOnChange: false)
.AddJsonFile($"appsettings-blogs.{builder.Environment.EnvironmentName}.json", optional: false, reloadOnChange: false)
.AddEnvironmentVariables();
builder.AddConfiguration("web");
var authSection = builder.Configuration.GetSection("Authentication");
var issuer = authSection.GetValue<String>("Issuer");

View file

@ -6,6 +6,7 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Yavsc.Abstract\Yavsc.Abstract.csproj" />
<ProjectReference Include="..\Yavsc.Abstract\Yavsc.Server.csproj" />
<PackageReference Include="IdentityModel.AspNetCore" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" />
</ItemGroup>
@ -15,4 +16,4 @@
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>
</Project>
</Project>