feat(api): add Health and Audit controllers
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MoneyMap.Services;
|
||||
|
||||
namespace MoneyMap.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class AuditController : ControllerBase
|
||||
{
|
||||
private readonly IFinancialAuditService _auditService;
|
||||
|
||||
public AuditController(IFinancialAuditService auditService) => _auditService = auditService;
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> Get(
|
||||
[FromQuery] DateTime? startDate,
|
||||
[FromQuery] DateTime? endDate,
|
||||
[FromQuery] bool includeTransactions = false)
|
||||
{
|
||||
var end = endDate ?? DateTime.Today;
|
||||
var start = startDate ?? end.AddDays(-90);
|
||||
|
||||
var result = await _auditService.GenerateAuditAsync(start, end, includeTransactions);
|
||||
return Ok(result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MoneyMap.Data;
|
||||
|
||||
namespace MoneyMap.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class HealthController : ControllerBase
|
||||
{
|
||||
private readonly MoneyMapContext _db;
|
||||
|
||||
public HealthController(MoneyMapContext db) => _db = db;
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> Get()
|
||||
{
|
||||
var canConnect = await _db.Database.CanConnectAsync();
|
||||
if (!canConnect)
|
||||
return StatusCode(503, new { status = "unhealthy", reason = "database unreachable" });
|
||||
|
||||
return Ok(new { status = "healthy" });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user