Files
Hy2026/backend/Controllers/SystemController.cs
T
Rafał Tyński e8e1658b3a feat(backend): integrate SurrealDB storage with embedded RocksDB
Add StorageService backed by SurrealDB using the embedded RocksDB provider that persists to ./data (never in memory). Support an optional remote server via SurrealDb:RemoteUrl for frontend sync. Expose readiness and storage probe endpoints under /api/system and add a helper script to start a local SurrealDB server.

Set the backend version to 0.0.1.
2026-10-03 20:23:11 +02:00

40 lines
1.1 KiB
C#

using Microsoft.AspNetCore.Mvc;
using TarninaHub.Models;
using TarninaHub.Services;
namespace TarninaHub.Controllers;
[ApiController]
[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));
}
}