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.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using GrpcShared;
  2. using IdentityProvider.Services;
  3. using Microsoft.AspNetCore.Server.Kestrel.Core;
  4. using ProtoBuf.Grpc.Server;
  5. using Microsoft.Extensions.Options;
  6. using GrpcShared.DTO.Auth;
  7. using SpotifyService.Services;
  8. using Blazored.SessionStorage;
  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.AddHttpClient("HttpClient", c =>
  20. {
  21. c.BaseAddress = new Uri(SpotifyService.GLOBALS.SPOTIFYURL);
  22. c.DefaultRequestHeaders.Add("Accept", SpotifyService.GLOBALS.MEDIATYPE);
  23. });
  24. builder.Services.AddOptions();
  25. // Additional configuration is required to successfully run gRPC on macOS.
  26. // For instructions on how to configure Kestrel and gRPC clients on macOS, visit https://go.microsoft.com/fwlink/?linkid=2099682
  27. builder.Services.Configure<CodeRequest>(builder.Configuration.GetSection("AuthParams"));
  28. builder.Services.AddControllersWithViews();
  29. builder.Services.AddRazorPages();
  30. builder.Services.AddEndpointsApiExplorer();
  31. builder.Services.AddGrpc();
  32. builder.Services.AddCodeFirstGrpc();
  33. builder.Services.AddCodeFirstGrpcReflection();
  34. builder.Services.AddBlazoredSessionStorage();
  35. //call spotify api
  36. builder.Services.AddHttpClient();
  37. var app = builder.Build();
  38. // Configure the HTTP request pipeline.
  39. if (app.Environment.IsDevelopment())
  40. {
  41. app.UseWebAssemblyDebugging();
  42. }
  43. else
  44. {
  45. app.UseExceptionHandler("/Error");
  46. // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
  47. app.UseHsts();
  48. }
  49. app.UseHttpsRedirection();
  50. //run blazor project by running grpc server
  51. app.UseBlazorFrameworkFiles();
  52. app.UseStaticFiles();
  53. app.UseRouting();
  54. //for http2 -> http conversion
  55. app.UseGrpcWeb();
  56. app.MapRazorPages();
  57. app.MapControllers();
  58. //app.MapGrpcService<WeatherService>();
  59. app.MapGrpcService<AuthService>().EnableGrpcWeb();
  60. app.MapGrpcService<TrackService>().EnableGrpcWeb();
  61. app.MapGrpcService<StatsService>().EnableGrpcWeb();
  62. app.MapCodeFirstGrpcReflectionService();
  63. app.MapFallbackToFile("index.html");
  64. app.Run();