添加健康检查相关包并配置NpgSql健康检查和UI

This commit is contained in:
罗澜大帅哥 2025-07-16 22:25:39 +08:00
parent 0589c29e5d
commit 5117927e5e
2 changed files with 6 additions and 1 deletions

View File

@ -10,6 +10,10 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="AspNetCore.HealthChecks.NpgSql" Version="9.0.0" />
<PackageReference Include="AspNetCore.HealthChecks.UI" Version="9.0.0" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="9.0.0" />
<PackageReference Include="AspNetCore.HealthChecks.UI.PostgreSQL.Storage" Version="9.0.0" />
<PackageReference Include="Auth0.ManagementApi" Version="7.38.0" /> <PackageReference Include="Auth0.ManagementApi" Version="7.38.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.17" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.17" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.MicrosoftAccount" Version="9.0.6" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.MicrosoftAccount" Version="9.0.6" />

View File

@ -66,7 +66,8 @@ builder.Services.Configure<JwtBearerOptions>(options =>
{ {
options.TokenValidationParameters.RoleClaimType = ClaimTypes.Role; options.TokenValidationParameters.RoleClaimType = ClaimTypes.Role;
}); });
builder.Services.AddHealthChecks().AddNpgSql(builder.Configuration.GetConnectionString("DBContext"));
builder.Services.AddHealthChecksUI();
builder.Services.Configure<JWTOptions>(builder.Configuration.GetSection("JWT")); builder.Services.Configure<JWTOptions>(builder.Configuration.GetSection("JWT"));
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)