feat(api+web): merge REST API and Blazor UI into single process
Previously the API (heimdall-central) and Blazor UI (heimdall-web) ran as separate containers with the Blazor Server making internal HTTP calls to the API. This caused the Blazor circuit to disconnect when the API was unreachable (network error → "Une erreur réseau est survenue"). Now both serve from the same .NET process on the same port: - All 16 API controllers, ExceptionFilter, and SignalR hubs integrated into Heimdall.Web - JWT auth, CORS, rate limiting configured in the unified Program.cs - Dockerfile.central entrypoint runs web/Heimdall.Web.dll - docker-compose simplified: heimdall-central service removed - CI publishes heimdall-web image instead of heimdall-central Also fixes timezone validation on Alpine/tzdata-less environments and enables FluentValidation auto-validation in the API project.
This commit is contained in:
1 parent
892ca88de8
commit
562aabdfc8
30 files changed
+1969
-99
No files matched your search
@@ -0,0 +1,86 @@
|
||||
using Heimdall.Application.DTOs;
|
||||
using Heimdall.Application.Services;
|
||||
using Heimdall.Infrastructure.Security;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.RateLimiting;
|
||||
|
||||
namespace Heimdall.Api.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/cameras")]
|
||||
[EnableRateLimiting("Api")]
|
||||
public class CamerasController : ControllerBase
|
||||
{
|
||||
private readonly ICameraService _cameraService;
|
||||
|
||||
public CamerasController(ICameraService cameraService) => _cameraService = cameraService;
|
||||
|
||||
/// <summary>Create a new camera.</summary>
|
||||
[Authorize(AuthenticationSchemes = "JwtBearer", Policy = AppPermissions.CameraWrite)]
|
||||
[HttpPost]
|
||||
[ProducesResponseType(typeof(CameraResponse), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status400BadRequest)]
|
||||
public async Task<IActionResult> Create([FromBody] CreateCameraRequest request, CancellationToken ct)
|
||||
{
|
||||
var result = await _cameraService.CreateAsync(request, ct);
|
||||
return result.IsSuccess
|
||||
? Ok(result.Data)
|
||||
: StatusCode(result.StatusCode ?? 400, new { error = result.Error });
|
||||
}
|
||||
|
||||
/// <summary>Get a camera by ID.</summary>
|
||||
[Authorize(AuthenticationSchemes = "JwtBearer", Policy = AppPermissions.CameraRead)]
|
||||
[HttpGet("{id:guid}")]
|
||||
[ProducesResponseType(typeof(CameraResponse), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status404NotFound)]
|
||||
public async Task<IActionResult> GetById(Guid id, CancellationToken ct)
|
||||
{
|
||||
var result = await _cameraService.GetByIdAsync(id, ct);
|
||||
return result.IsSuccess
|
||||
? Ok(result.Data)
|
||||
: NotFound(new { error = result.Error });
|
||||
}
|
||||
|
||||
/// <summary>List cameras by site.</summary>
|
||||
[Authorize(AuthenticationSchemes = "JwtBearer", Policy = AppPermissions.CameraRead)]
|
||||
[HttpGet("by-site/{siteId:guid}")]
|
||||
[ProducesResponseType(typeof(PagedResult<CameraResponse>), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status400BadRequest)]
|
||||
public async Task<IActionResult> ListBySite(
|
||||
Guid siteId, [FromQuery] int page = 1, [FromQuery] int pageSize = 20, CancellationToken ct = default)
|
||||
{
|
||||
var result = await _cameraService.ListBySiteAsync(siteId, page, pageSize, ct);
|
||||
if (!result.IsSuccess)
|
||||
return StatusCode(result.StatusCode ?? 400, new { error = result.Error });
|
||||
return Ok(result.Data);
|
||||
}
|
||||
|
||||
/// <summary>Update a camera.</summary>
|
||||
[Authorize(AuthenticationSchemes = "JwtBearer", Policy = AppPermissions.CameraWrite)]
|
||||
[HttpPut("{id:guid}")]
|
||||
[ProducesResponseType(typeof(CameraResponse), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status404NotFound)]
|
||||
public async Task<IActionResult> Update(Guid id, [FromBody] UpdateCameraRequest request, CancellationToken ct)
|
||||
{
|
||||
var result = await _cameraService.UpdateAsync(id, request, ct);
|
||||
return result.IsSuccess
|
||||
? Ok(result.Data)
|
||||
: StatusCode(result.StatusCode ?? 400, new { error = result.Error });
|
||||
}
|
||||
|
||||
/// <summary>Delete a camera.</summary>
|
||||
[Authorize(AuthenticationSchemes = "JwtBearer", Policy = AppPermissions.CameraWrite)]
|
||||
[HttpDelete("{id:guid}")]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status404NotFound)]
|
||||
public async Task<IActionResult> Delete(Guid id, CancellationToken ct)
|
||||
{
|
||||
var result = await _cameraService.DeleteAsync(id, ct);
|
||||
return result.IsSuccess
|
||||
? NoContent()
|
||||
: StatusCode(result.StatusCode ?? 400, new { error = result.Error });
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user