Merge branch 'eliminate-public-api' into dev

This commit is contained in:
Daniel Harvey
2026-05-25 17:48:56 -04:00
13 changed files with 30 additions and 281 deletions
+16 -11
View File
@@ -17,32 +17,37 @@ public class TrackClient
}
public async Task<ApiResult<PagedResult<TrackDto>>> GetPage(
int pageNumber,
int pageSize,
string? sortColumn = null,
int pageNumber,
int pageSize,
string? sortColumn = null,
bool sortDescending = false)
{
var queryArgs = new Dictionary<string, string?>(){
["pageNumber"] = pageNumber.ToString(),
["page"] = pageNumber.ToString(),
["pageSize"] = pageSize.ToString()
};
if (!string.IsNullOrEmpty(sortColumn))
queryArgs["sortColumn"] = sortColumn;
if (sortDescending)
queryArgs["sortDescending"] = "true";
string query = QueryString.Create(queryArgs).ToString();
var response = await _http.GetAsync($"api/track/page{query}");
if (!response.IsSuccessStatusCode)
return ApiResult<PagedResult<TrackDto>>.CreateFailResult($"HTTP {(int)response.StatusCode}");
var json = await response.Content.ReadAsStringAsync();
var dto = JsonSerializer.Deserialize<ApiResultDto<PagedResult<TrackDto>>>(json, new JsonSerializerOptions
var paged = JsonSerializer.Deserialize<PagedResult<TrackDto>>(json, new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
});
return dto?.From() ?? ApiResult<PagedResult<TrackDto>>.CreateFailResult("Failed to deserialize response");
return paged is not null
? ApiResult<PagedResult<TrackDto>>.CreatePassResult(paged)
: ApiResult<PagedResult<TrackDto>>.CreateFailResult("Failed to deserialize response");
}
}
+2 -1
View File
@@ -7,10 +7,11 @@ var builder = WebAssemblyHostBuilder.CreateDefault(args);
Console.WriteLine(builder.HostEnvironment.BaseAddress);
var contentApiUrl = builder.Configuration["ApiUrls:ContentApi"] ?? "https://localhost:7001";
var sqlApiUrl = builder.Configuration["ApiUrls:SqlApi"] ?? "https://localhost:5002";
builder.Services.AddMudServices();
Startup.ConfigureApiHttpClient(builder.Services, builder.HostEnvironment.BaseAddress);
Startup.ConfigureApiHttpClient(builder.Services, sqlApiUrl);
Startup.ConfigureContentServices(builder.Services, contentApiUrl);
Startup.ConfigureDomainServices(builder.Services);
@@ -5,13 +5,9 @@ using NetBlocks.Models;
namespace DeepDrftPublic.Client.Services;
/// <summary>
/// Track metadata fetch abstraction with two render-mode-specific implementations:
///
/// - Server prerender pass: <c>TrackDirectDataService</c> in the DeepDrftPublic host
/// resolves <see cref="DeepDrftData.ITrackService"/> in-process (EF Core / SQL) and
/// avoids a loopback HTTP hop.
/// - WASM interactive pass: <c>TrackClientDataService</c> in this assembly delegates
/// to <see cref="Clients.TrackClient"/> over HTTP.
/// Track metadata fetch abstraction. Both SSR and WASM passes are served by
/// <c>TrackClientDataService</c> in this assembly, which delegates to
/// <see cref="Clients.TrackClient"/> over HTTP.
///
/// Components inject this single seam so they do not branch on render mode.
/// </summary>
+2 -3
View File
@@ -14,9 +14,8 @@ public static class Startup
services.AddScoped<DarkModeSettings>();
services.AddScoped<DarkModeCookieService>();
// Track Client. The HTTP-backed ITrackDataService registration here is the WASM
// default; the server host overrides it with an in-process implementation after
// this method runs, so SSR prerender skips the loopback hop.
// Track Client. The HTTP-backed ITrackDataService is used by both WASM and SSR
// prerender — both call DeepDrftAPI over the "DeepDrft.API" client.
services.AddScoped<TrackClient>();
services.AddScoped<ITrackDataService, TrackClientDataService>();
services.AddScoped<TracksViewModel>();
@@ -6,6 +6,7 @@
}
},
"ApiUrls": {
"ContentApi": "https://media.deepdrft.com/"
"ContentApi": "https://media.deepdrft.com/",
"SqlApi": "https://api.deepdrft.com/"
}
}