Blazor & WASM in combination to get statistics from Spotify API for performing the song analysis. With separate microservices for auth, Spotify, user data tracking, and application, connected through gRPC with Polly.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Program.cs 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. using GrpcShared;
  2. using Microsoft.AspNetCore.Server.Kestrel.Core;
  3. using ProtoBuf.Grpc.Server;
  4. using Microsoft.Extensions.Options;
  5. using GrpcShared.DTO.Auth;
  6. using Blazored.LocalStorage;
  7. using IdentityProvider.Models;
  8. using IdentityProvider.Services;
  9. var builder = WebApplication.CreateBuilder(args);
  10. #if DEBUG
  11. //builder.WebHost.ConfigureKestrel(options =>
  12. //{
  13. // options.ListenLocalhost(5050, o => o.Protocols =
  14. // HttpProtocols.Http2);
  15. // options.ListenLocalhost(5051, o => o.Protocols =
  16. // HttpProtocols.Http1AndHttp2);
  17. //});
  18. #endif
  19. builder.Services.AddOptions();
  20. // Additional configuration is required to successfully run gRPC on macOS.
  21. // For instructions on how to configure Kestrel and gRPC clients on macOS, visit https://go.microsoft.com/fwlink/?linkid=2099682
  22. builder.Services.AddControllersWithViews();
  23. builder.Services.AddRazorPages();
  24. builder.Services.AddEndpointsApiExplorer();
  25. builder.Services.AddGrpc();
  26. builder.Services.AddCodeFirstGrpc();
  27. builder.Services.AddCodeFirstGrpcReflection();
  28. builder.Services.AddBlazoredLocalStorage();
  29. //call spotify api
  30. builder.Services.AddHttpClient();
  31. //builder.Services.AddSingleton<SpotifyDbConfig>();
  32. builder.Services.Configure<SpotifyDbConfig>(
  33. builder.Configuration.GetSection("SpotifyDb"));
  34. //builder.Services.AddHttpClient("HttpClient", c =>
  35. //{
  36. // c.BaseAddress = new Uri(builder.Configuration.GetSection("SpotifyConfig:SpotifyURL").Value.ToString());
  37. // c.DefaultRequestHeaders.Add("Accept", builder.Configuration.GetSection("SpotifyConfig:MediaType").Value.ToString());
  38. //});
  39. var app = builder.Build();
  40. // Configure the HTTP request pipeline.
  41. if (app.Environment.IsDevelopment())
  42. {
  43. app.UseWebAssemblyDebugging();
  44. }
  45. else
  46. {
  47. app.UseExceptionHandler("/Error");
  48. // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
  49. app.UseHsts();
  50. }
  51. //app.UseHttpsRedirection();
  52. //run blazor project by running grpc server
  53. app.UseBlazorFrameworkFiles();
  54. app.UseStaticFiles();
  55. app.UseRouting();
  56. //for http2 -> http conversion
  57. app.UseGrpcWeb();
  58. app.MapRazorPages();
  59. app.MapControllers();
  60. //app.MapGrpcService<WeatherService>();
  61. //app.MapGrpcService<AuthService>().EnableGrpcWeb();
  62. //app.MapGrpcService<TrackService>().EnableGrpcWeb();
  63. //app.MapGrpcService<StatsService>().EnableGrpcWeb();
  64. app.MapGrpcService<IdentityService>();
  65. app.MapCodeFirstGrpcReflectionService();
  66. app.MapFallbackToFile("index.html");
  67. app.Run("http://127.0.0.1:5002");