Eliminate DeepDrftPublic internal track API

This commit is contained in:
Daniel Harvey
2026-05-25 12:55:30 -04:00
parent 068205a84e
commit e334886022
11 changed files with 27 additions and 150 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);
+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/"
}
}