2025-07-31 12:57:47 -05:00
|
|
|
using FreeTubeSync.Database;
|
|
|
|
|
|
|
|
|
|
namespace FreeTubeSync.EndPoints;
|
|
|
|
|
|
|
|
|
|
public static class PingEndpoint
|
|
|
|
|
{
|
|
|
|
|
public static void MapPingEndpoints(this WebApplication app)
|
|
|
|
|
{
|
|
|
|
|
var group = app.MapGroup("ping");
|
|
|
|
|
group.MapGet("/", async (CancellationToken token) =>
|
|
|
|
|
{
|
|
|
|
|
await Task.Delay(10);
|
2025-08-05 11:38:55 -05:00
|
|
|
var dict = new { AppVersion = "0.1.4" };
|
2025-07-31 12:57:47 -05:00
|
|
|
return Results.Ok(dict);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
group.MapGet("/lastUpdated", async (DataContext dbContext, CancellationToken token) =>
|
|
|
|
|
{
|
|
|
|
|
var log = await dbContext.GetLatestChangeAsync(token);
|
|
|
|
|
|
|
|
|
|
if (log == null)
|
|
|
|
|
return Results.NotFound();
|
|
|
|
|
|
|
|
|
|
var dict = new { LastUpdated = log.ChangeTime };
|
|
|
|
|
return Results.Ok(dict);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|