Split the backend into API host, Domain, Application and Infrastructure projects. Add Swagger/OpenAPI per API version, Asp.Versioning (query/header), ProblemDetails with a global exception handler and SurrealQL migrations applied at startup (namespace/database ensured). Infrastructure owns the SurrealDB client, settings and DI.
42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
using Asp.Versioning;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using TarninaHub.Application.Abstractions;
|
|
using TarninaHub.Application.Dtos;
|
|
|
|
namespace TarninaHub.Controllers;
|
|
|
|
[ApiController]
|
|
[ApiVersion("1.0")]
|
|
[Route("api/system")]
|
|
public class SystemController : ControllerBase
|
|
{
|
|
private readonly IStorageService _storageService;
|
|
|
|
public SystemController(IStorageService storageService)
|
|
{
|
|
_storageService = storageService;
|
|
}
|
|
|
|
[HttpGet("storage")]
|
|
public async Task<ActionResult<StorageStatusResponse>> GetStorage(CancellationToken cancellationToken)
|
|
{
|
|
var info = _storageService.GetInfo();
|
|
var probeCount = await _storageService.GetProbeCountAsync(cancellationToken);
|
|
|
|
return Ok(new StorageStatusResponse(
|
|
info.Engine,
|
|
info.DataDirectory,
|
|
info.Namespace,
|
|
info.Database,
|
|
probeCount));
|
|
}
|
|
|
|
[HttpPost("storage/probes")]
|
|
public async Task<ActionResult<StorageProbeResponse>> CreateProbe(CancellationToken cancellationToken)
|
|
{
|
|
var probe = await _storageService.AddProbeAsync(cancellationToken);
|
|
|
|
return Ok(new StorageProbeResponse(probe.Label, probe.CreatedAt));
|
|
}
|
|
}
|