Initial Commit

Inital Commit of Code base, nothing tested.
This commit is contained in:
Mario Steele 2025-07-19 04:02:09 -05:00
commit 0144221712
31 changed files with 1304 additions and 0 deletions

View file

@ -0,0 +1,35 @@
using FreeTubeSync.Model;
namespace FreeTubeSync.EndPoints;
public static class HistoryEndpoint
{
public static void MapHistoryEndpoints(this WebApplication app)
{
var group = app.MapGroup("history");
group.MapGet("/", async (IRepository<History> repository, CancellationToken ct) =>
{
var results = await repository.GetAllAsync(ct);
return Results.Ok(results);
});
group.MapPost("/", async (IRepository<History> repository, CancellationToken ct, History history) =>
{
var results = await repository.GetByIdAsync(history._id, ct);
if (results == null)
await repository.AddAsync(history, ct);
else
await repository.UpdateAsync(history, ct);
return Results.Ok();
});
group.MapDelete("/{id}", async (IRepository<History> repository, CancellationToken ct, string id) =>
{
var result = await repository.GetByIdAsync(id, ct);
if (result == null) return Results.NotFound();
await repository.DeleteAsync(result, ct);
return Results.Ok();
});
}
}

View file

@ -0,0 +1,35 @@
using FreeTubeSync.Model;
namespace FreeTubeSync.EndPoints;
public static class PlaylistEndpoint
{
public static void MapPlaylistEndpoints(this WebApplication app)
{
var group = app.MapGroup("playlists");
group.MapGet("/", async (IRepository<Playlist> repository, CancellationToken ct) =>
{
var results = await repository.GetAllAsync(ct);
return Results.Ok(results);
});
group.MapPost("/", async (IRepository<Playlist> repository, CancellationToken ct, Playlist playlist) =>
{
var results = await repository.GetByIdAsync(playlist._id, ct);
if (results == null)
await repository.AddAsync(playlist, ct);
else
await repository.UpdateAsync(playlist, ct);
return Results.Ok();
});
group.MapDelete("/{id}", async (IRepository<Playlist> repository, CancellationToken ct, string id) =>
{
var result = await repository.GetByIdAsync(id, ct);
if (result == null) return Results.NotFound();
await repository.DeleteAsync(result, ct);
return Results.Ok();
});
}
}

View file

@ -0,0 +1,35 @@
using FreeTubeSync.Model;
namespace FreeTubeSync.EndPoints;
public static class ProfileEndpoint
{
public static void MapProfileEndpoints(this WebApplication app)
{
var group = app.MapGroup("profile");
group.MapGet("/", async (IRepository<Profile> repository, CancellationToken ct) =>
{
var results = await repository.GetAllAsync(ct);
return Results.Ok(results);
});
group.MapPost("/", async (IRepository<Profile> repository, CancellationToken ct, Profile profile) =>
{
var res = await repository.GetByIdAsync(profile._id, ct);
if (res == null)
await repository.AddAsync(profile, ct);
else
await repository.UpdateAsync(profile, ct);
return Results.Ok();
});
group.MapDelete("/{id}", async (IRepository<Profile> repository, CancellationToken ct, string id) =>
{
var result = await repository.GetByIdAsync(id, ct);
if (result == null) return Results.NotFound();
await repository.DeleteAsync(result, ct);
return Results.Ok();
});
}
}

View file

@ -0,0 +1,36 @@
using FreeTubeSync.Model;
namespace FreeTubeSync.EndPoints;
public static class SearchHistoryEndpoint
{
public static void MapSearchHistoryEndpoints(this WebApplication app)
{
var group = app.MapGroup("searchHistory");
group.MapGet("/", async (IRepository<History> repository, CancellationToken ct) =>
{
var result = await repository.GetAllAsync(ct);
return Results.Ok(result);
});
group.MapPost("/", async (IRepository<History> repository, CancellationToken ct, History history) =>
{
var result = await repository.GetByIdAsync(history._id, ct);
if (result != null)
await repository.UpdateAsync(history, ct);
else
await repository.AddAsync(history, ct);
return Results.Ok();
});
group.MapDelete("/{id}", async (IRepository<History> repository, CancellationToken ct, string id) =>
{
var result = await repository.GetByIdAsync(id, ct);
if (result == null) return Results.NotFound();
await repository.DeleteAsync(result, ct);
return Results.Ok();
});
}
}

View file

@ -0,0 +1,37 @@
using FreeTubeSync.Model;
using FreeTubeSync.SpecialResponses;
namespace FreeTubeSync.EndPoints;
public static class SettingEndpoint
{
public static void MapSettingEndpoints(this WebApplication app)
{
var group = app.MapGroup("settings");
group.MapGet("/", async (IRepository<Setting> repository, CancellationToken ct) =>
{
var settings = await repository.GetAllAsync(ct);
var response = settings.MapToResponse();
return Results.Ok(response);
});
group.MapPost("/", async (IRepository<Setting> repository, CancellationToken ct, Setting setting) =>
{
var res = await repository.GetByIdAsync(setting._id, ct);
if (res == null)
await repository.AddAsync(setting, ct);
else
await repository.UpdateAsync(setting, ct);
return Results.Ok();
});
group.MapDelete("/{id}", async (IRepository<Setting> repository, CancellationToken ct, string id) =>
{
var result = await repository.GetByIdAsync(id, ct);
if (result == null) return Results.NotFound();
await repository.DeleteAsync(result, ct);
return Results.Ok();
});
}
}