33 lines
730 B
C#
Raw Normal View History

2026-06-02 10:30:05 +08:00
using Microsoft.AspNetCore.Mvc;
using YD_TrainingCompetition_Api.Services;
namespace YD_TrainingCompetition_Api.Controllers;
[ApiController]
[Route("api/[controller]")]
public class HealthController : ControllerBase
{
private readonly IDeviceStateStore _store;
public HealthController(IDeviceStateStore store)
{
_store = store;
}
[HttpGet]
public IActionResult Get()
{
var devices = _store.GetAll();
return Ok(new
{
status = "ok",
service = "YD_TrainingCompetition_Api",
totalDevices = devices.Count,
onlineDevices = devices.Count(x => x.Online),
timestamp = DateTimeOffset.UtcNow
});
}
}