- Cameras API: CRUD with service/controller/DTOs + Blazor page - Docker: production-grade compose with healthchecks, .env, Makefile, networks - Healthchecks: /healthz (liveness) and /readyz (readiness) endpoints - Testing: 13 integration tests (Auth, Sites, Users, Cameras controllers) - Users: create, list, lock, reset-password - Cameras: create with site, list by site - Environment: .env.example, docker-compose.override.yml for dev - Infrastructure: ICameraService registered in DI
35 lines
970 B
C#
35 lines
970 B
C#
using Heimdall.Infrastructure.Data;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace Heimdall.Api.Controllers;
|
|
|
|
[ApiController]
|
|
[AllowAnonymous]
|
|
public class HealthController : ControllerBase
|
|
{
|
|
[HttpGet("/healthz")]
|
|
public IActionResult Health()
|
|
{
|
|
return Ok(new { status = "healthy", timestamp = DateTime.UtcNow });
|
|
}
|
|
|
|
[HttpGet("/readyz")]
|
|
public async Task<IActionResult> Readiness([FromServices] AppDbContext db)
|
|
{
|
|
try
|
|
{
|
|
var canConnect = await db.Database.CanConnectAsync();
|
|
if (!canConnect)
|
|
return StatusCode(503, new { status = "unhealthy", database = "disconnected" });
|
|
|
|
return Ok(new { status = "ready", database = "connected" });
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(503, new { status = "unhealthy", database = ex.Message });
|
|
}
|
|
}
|
|
}
|