Add healthchecks to the api

This commit is contained in:
Zoe Roux
2023-04-01 23:24:43 +09:00
parent cbcc2f30b7
commit a554b7681f
6 changed files with 78 additions and 2 deletions
@@ -10,6 +10,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="5.0.7" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.7" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.8" />
</ItemGroup>
@@ -91,6 +91,8 @@ namespace Kyoo.Postgresql
if (_environment.IsDevelopment())
x.EnableDetailedErrors().EnableSensitiveDataLogging();
}, ServiceLifetime.Transient);
services.AddHealthChecks().AddDbContextCheck<DatabaseContext>();
}
}
}