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");
|
2025-08-09 04:09:17 -05:00
|
|
|
group.MapGet("/", async (DataContext dbContext, CancellationToken token) =>
|
2025-07-31 12:57:47 -05:00
|
|
|
{
|
2025-08-09 04:09:17 -05:00
|
|
|
await dbContext.CleanupChangeLogAsync(token);
|
|
|
|
|
var dict = new { AppVersion = "0.1.5" };
|
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 };
|
2025-08-09 04:09:17 -05:00
|
|
|
await dbContext.CleanupChangeLogAsync(token);
|
2025-07-31 12:57:47 -05:00
|
|
|
return Results.Ok(dict);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|