diff --git a/src/Mobile/App.xaml.cs b/src/Mobile/App.xaml.cs index e3ed6d6..baf6dac 100644 --- a/src/Mobile/App.xaml.cs +++ b/src/Mobile/App.xaml.cs @@ -21,9 +21,4 @@ public partial class App : Application Routing.RegisterRoute(nameof(CategoriesPage), typeof(CategoriesPage)); Routing.RegisterRoute(nameof(CategoryPage), typeof(CategoryPage)); } - - protected override Window CreateWindow(IActivationState activationState) - { - return new MauiWindow(MainPage); - } } diff --git a/src/Mobile/Config.cs b/src/Mobile/Config.cs index ec97578..31bd2fb 100644 --- a/src/Mobile/Config.cs +++ b/src/Mobile/Config.cs @@ -18,6 +18,6 @@ public static class Config public static string BaseWeb = $"{Base}:5002/"; public static string Base = DeviceInfo.Platform == DevicePlatform.Android ? "http://10.0.2.2" : "http://localhost"; - public static string APIUrl = $"{Base}:5000/v1/"; + public static string APIUrl = $"{Base}:5000/"; public static string ListenTogetherUrl = $"{Base}:5001/listentogether"; } diff --git a/src/Mobile/Pages/CategoriesPage.xaml b/src/Mobile/Pages/CategoriesPage.xaml index 3a3a199..cef9194 100644 --- a/src/Mobile/Pages/CategoriesPage.xaml +++ b/src/Mobile/Pages/CategoriesPage.xaml @@ -25,7 +25,7 @@ Margin="32" HorizontalOptions="Center" FontAttributes="Bold" - FontSize="{OnPlatform UWP=24, Android=14,iOS=14}" + FontSize="{OnPlatform WinUI=24, Android=14,iOS=14}" Style="{StaticResource H5LabelStyle}" /> (client => { client.BaseAddress = new Uri(APIUrl); + client.DefaultRequestHeaders.Add("api-version", "1.0"); }); #if WINDOWS diff --git a/src/Services/ListenTogether/ListenTogether.Infrastructure/Http/EpisodesHttpClient.cs b/src/Services/ListenTogether/ListenTogether.Infrastructure/Http/EpisodesHttpClient.cs index cfb2427..b2b2ce4 100644 --- a/src/Services/ListenTogether/ListenTogether.Infrastructure/Http/EpisodesHttpClient.cs +++ b/src/Services/ListenTogether/ListenTogether.Infrastructure/Http/EpisodesHttpClient.cs @@ -15,6 +15,6 @@ public class EpisodesHttpClient : IEpisodesClient public async Task GetEpisodeByIdAsync(Guid episodeId, CancellationToken cancellationToken) { - return (await _httpClient.GetFromJsonAsync($"v1/episodes/{episodeId}", cancellationToken))!; + return (await _httpClient.GetFromJsonAsync($"episodes/{episodeId}", cancellationToken))!; } } \ No newline at end of file diff --git a/src/Services/ListenTogether/ListenTogether.Infrastructure/ServiceCollectionsExtensions.cs b/src/Services/ListenTogether/ListenTogether.Infrastructure/ServiceCollectionsExtensions.cs index 2d948f0..f13403a 100644 --- a/src/Services/ListenTogether/ListenTogether.Infrastructure/ServiceCollectionsExtensions.cs +++ b/src/Services/ListenTogether/ListenTogether.Infrastructure/ServiceCollectionsExtensions.cs @@ -16,6 +16,7 @@ namespace ListenTogether.Infrastructure serviceCollection.AddHttpClient(opt => { opt.BaseAddress = new Uri(configuration["NetPodcastApi:BaseAddress"]); + opt.DefaultRequestHeaders.Add("api-version", "1.0"); }); return serviceCollection; diff --git a/src/Services/Podcasts/Podcast.MinimalAPI/Podcast.MinimalAPI.csproj b/src/Services/Podcasts/Podcast.MinimalAPI/Podcast.MinimalAPI.csproj index 314e6f5..212c1e9 100644 --- a/src/Services/Podcasts/Podcast.MinimalAPI/Podcast.MinimalAPI.csproj +++ b/src/Services/Podcasts/Podcast.MinimalAPI/Podcast.MinimalAPI.csproj @@ -36,13 +36,13 @@ + + - - diff --git a/src/Services/Podcasts/Podcast.MinimalAPI/Routes/CategoriesApi.cs b/src/Services/Podcasts/Podcast.MinimalAPI/Routes/CategoriesApi.cs index c2350db..e0d9bbc 100644 --- a/src/Services/Podcasts/Podcast.MinimalAPI/Routes/CategoriesApi.cs +++ b/src/Services/Podcasts/Podcast.MinimalAPI/Routes/CategoriesApi.cs @@ -10,7 +10,7 @@ public static class CategoriesApi { public static RouteGroupBuilder MapCategoriesApi(this RouteGroupBuilder group) { - group.MapPost("/", GetAllCategories); + group.MapGet("/", GetAllCategories).WithName("GetCategories"); return group; } diff --git a/src/Services/Podcasts/Podcast.MinimalAPI/Routes/EpisodesApi.cs b/src/Services/Podcasts/Podcast.MinimalAPI/Routes/EpisodesApi.cs index f8cb682..4fc8194 100644 --- a/src/Services/Podcasts/Podcast.MinimalAPI/Routes/EpisodesApi.cs +++ b/src/Services/Podcasts/Podcast.MinimalAPI/Routes/EpisodesApi.cs @@ -10,7 +10,7 @@ public static class EpisodesApi { public static RouteGroupBuilder MapEpisodesApi(this RouteGroupBuilder group) { - group.MapPost("/{id}", GetEpisodeById); + group.MapGet("/{id}", GetEpisodeById).WithName("GetEpisodeById"); return group; } diff --git a/src/Services/Podcasts/Podcast.MinimalAPI/Routes/FeedsApi.cs b/src/Services/Podcasts/Podcast.MinimalAPI/Routes/FeedsApi.cs index cdd5132..8f4d380 100644 --- a/src/Services/Podcasts/Podcast.MinimalAPI/Routes/FeedsApi.cs +++ b/src/Services/Podcasts/Podcast.MinimalAPI/Routes/FeedsApi.cs @@ -6,6 +6,7 @@ using Podcast.Infrastructure.Data; using Podcast.Infrastructure.Data.Models; using Podcast.Infrastructure.Http.Feeds; using Microsoft.OpenApi.Models; +using Microsoft.AspNetCore.Authentication.JwtBearer; namespace Podcast.API.Routes; @@ -13,10 +14,16 @@ public static class FeedsApi { public static RouteGroupBuilder MapFeedsApi(this RouteGroupBuilder group) { - group.MapPost("/", CreateFeed); - group.MapGet("/", GetAllFeeds); - group.MapPut("/{id}", UpdateFeed).RequireAuthorization().AddOpenApiSecurityRequirement(); - group.MapDelete("/{id}", DeleteFeed).RequireAuthorization().AddOpenApiSecurityRequirement(); + group.MapPost("/", CreateFeed).WithName("CreateFeed"); + group.MapGet("/", GetAllFeeds).WithName("GetFeeds"); + group.MapPut("/{id}", UpdateFeed) + .RequireAuthorization("modify_feeds") + .AddOpenApiSecurityRequirement() + .WithName("UpdateFeedById"); + group.MapDelete("/{id}", DeleteFeed) + .RequireAuthorization("modify_feeds") + .AddOpenApiSecurityRequirement() + .WithName("DeleteFeedById"); return group; } diff --git a/src/Services/Podcasts/Podcast.MinimalAPI/Routes/ShowsApi.cs b/src/Services/Podcasts/Podcast.MinimalAPI/Routes/ShowsApi.cs index 1f342b8..188fc96 100644 --- a/src/Services/Podcasts/Podcast.MinimalAPI/Routes/ShowsApi.cs +++ b/src/Services/Podcasts/Podcast.MinimalAPI/Routes/ShowsApi.cs @@ -10,8 +10,8 @@ public static class ShowsApi { public static RouteGroupBuilder MapShowsApi(this RouteGroupBuilder group) { - group.MapGet("/", GetAllShows); - group.MapGet("/{id}", GetShowById); + group.MapGet("/", GetAllShows).WithName("GetShows"); + group.MapGet("/{id}", GetShowById).WithName("GetShowsById"); return group; } diff --git a/src/Services/Podcasts/Podcast.MinimalAPI/appsettings.Development.json b/src/Services/Podcasts/Podcast.MinimalAPI/appsettings.Development.json index 1edf043..ebf4186 100644 --- a/src/Services/Podcasts/Podcast.MinimalAPI/appsettings.Development.json +++ b/src/Services/Podcasts/Podcast.MinimalAPI/appsettings.Development.json @@ -7,7 +7,7 @@ } }, "ConnectionStrings": { - "PodcastDb": "", + "PodcastDb": "Server=localhost, 5433;Database=Podcast;User Id=sa;Password=Pass@word", "FeedQueue": "UseDevelopmentStorage=true" }, "Authentication": { @@ -17,7 +17,8 @@ "http://localhost:56906", "https://localhost:44385", "https://localhost:5001", - "http://localhost:5000" + "http://localhost:5000", + "1ba2c41d-3a54-414a-9700-1f9393cfafca" ], "ValidIssuer": "dotnet-user-jwts" } diff --git a/src/Web/Client/Program.cs b/src/Web/Client/Program.cs index 25e550c..ef90182 100644 --- a/src/Web/Client/Program.cs +++ b/src/Web/Client/Program.cs @@ -8,7 +8,7 @@ var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.Services.AddHttpClient( client => { client.BaseAddress = new Uri(builder.Configuration["PodcastApi:BaseAddress"]!); - client.DefaultRequestHeaders.Add("api-supported-versions", "1.0,2.0"); + client.DefaultRequestHeaders.Add("api-version", "1.0"); }); builder.Services.AddScoped(); builder.Services.AddScoped(); diff --git a/src/Web/Components/ListenTogether/ListenTogether.razor b/src/Web/Components/ListenTogether/ListenTogether.razor index dfa822d..c1e077e 100644 --- a/src/Web/Components/ListenTogether/ListenTogether.razor +++ b/src/Web/Components/ListenTogether/ListenTogether.razor @@ -128,21 +128,27 @@ { isRoomHost = true; roomCode = room.Code; - await OnJoinRoom.InvokeAsync(room.Code); - await OnRoomCreated.InvokeAsync(); + await InvokeAsync(async () => + { + await OnJoinRoom.InvokeAsync(room.Code); + await OnRoomCreated.InvokeAsync(); + }); } private async void OnRoomUpdated(Room room) { - if (currentRoom == null && !isRoomHost) + await InvokeAsync(async () => { - await SetPlayerState(room); - } - currentRoom = room; - await InvokeAsync(StateHasChanged); + if (currentRoom == null && !isRoomHost) + { + await SetPlayerState(room); + } + currentRoom = room; + StateHasChanged(); + }); } - private async void OnPlayerStateUpdated(Room room) => await SetPlayerState(room); + private async void OnPlayerStateUpdated(Room room) => await InvokeAsync(() => SetPlayerState(room)); private async Task SetPlayerState(Room room) {