Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
NielsPilgaard committed Dec 17, 2023
1 parent 4719f27 commit 3cdeab6
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public static IServiceCollection AddWasmAuthentication(this IServiceCollection s
services.AddAuthorizationCore();
services.AddScoped<AuthStateProvider>();
services.AddScoped<AuthenticationStateProvider>(provider => provider.GetRequiredService<AuthStateProvider>());
services.AddCascadingAuthenticationState();
return services;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@foreach (var (title, body, buttonText) in _cardContents)
{
<MudItem xs="12" sm="6">
<MudCard Style="width: 310px;">
<MudCard Style="width: 300px;">
<MudCardContent>
<MudText>@title</MudText>
<MudText Typo="Typo.body2">@body</MudText>
Expand Down
1 change: 0 additions & 1 deletion src/web/Jordnaer.Client/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
builder.Services.AddMudExtensions();

builder.Services.AddWasmAuthentication();
builder.Services.AddCascadingAuthenticationState();

builder.Services.AddBlazoredLocalStorage();
builder.Services.AddBlazoredSessionStorage();
Expand Down
11 changes: 7 additions & 4 deletions src/web/Jordnaer/Extensions/AzureAppConfigurationExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Microsoft.FeatureManagement;

namespace Jordnaer.Server.Extensions;

public static class AzureAppConfigurationExtensions
Expand All @@ -10,12 +12,13 @@ public static WebApplicationBuilder AddAzureAppConfiguration(this WebApplication
throw new InvalidOperationException("Failed to find connection string to Azure App Configuration. Keys checked: 'ConnectionStrings:AppConfig'");
}

builder.Services.AddFeatureManagement();
builder.Services.AddAzureAppConfiguration();
builder.Configuration.AddAzureAppConfiguration(options =>
options.Connect(connectionString)
// Load all keys that have no label
.Select("*")
// Configure to reload builder if the registered sentinel key is modified
options.Connect(connectionString)
// Load all keys that have no label
.Select("*")
// Configure to reload builder if the registered sentinel key is modified
.ConfigureRefresh(refreshOptions =>
{
refreshOptions.Register("Sentinel", refreshAll: true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,16 @@ public static WebApplicationBuilder AddMassTransit(this WebApplicationBuilder bu
return builder;
}

public static WebApplicationBuilder AddAzureSignalR(this WebApplicationBuilder builder)
public static WebApplicationBuilder AddSignalR(this WebApplicationBuilder builder)
{
builder.Services.AddSignalR(options =>
{
options.ClientTimeoutInterval = TimeSpan.FromMinutes(5);
options.KeepAliveInterval = TimeSpan.FromMinutes(1);
});
//.AddAzureSignalR(options =>

// Azure SignalR Service is expensive. Let's try without
//.AddSignalR(options =>
//{
// options.ConnectionString = builder.Configuration.GetConnectionString("AzureSignalR");
// options.ServerStickyMode = ServerStickyMode.Required;
Expand Down
157 changes: 75 additions & 82 deletions src/web/Jordnaer/Program.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System.Text.Json.Serialization;
using Azure.Storage.Blobs;
using Jordnaer.Server;
using Jordnaer.Client;
using Jordnaer.Server.Authentication;
using Jordnaer.Server.Authorization;
using Jordnaer.Server.Components;
using Jordnaer.Server.Database;
using Jordnaer.Server.Extensions;
using Jordnaer.Server.Features.Category;
Expand All @@ -17,126 +18,118 @@
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.FeatureManagement;
using Serilog;
using _Imports = Jordnaer.Client._Imports;

Log.Logger = new LoggerConfiguration()
.WriteTo.Console()
.CreateBootstrapLogger();

try
{
var builder = WebApplication.CreateBuilder(args);

builder.Services.AddRazorComponents()
.AddInteractiveWebAssemblyComponents();
var builder = WebApplication.CreateBuilder(args);

builder.AddAzureAppConfiguration();
builder.Services.AddRazorComponents()
.AddInteractiveWebAssemblyComponents()
.AddInteractiveServerComponents();

builder.AddSerilog();
builder.AddAzureAppConfiguration();

builder.Services.AddProblemDetails();
builder.AddSerilog();

builder.AddDatabase();
builder.AddDatabase();

builder.Services.AddCurrentUser();
builder.Services.AddCurrentUser();

builder.AddAuthentication();
builder.Services.AddAuthorizationBuilder().AddCurrentUserHandler();
builder.AddAuthentication();
builder.Services.AddAuthorizationBuilder().AddCurrentUserHandler();

builder.Services.AddRateLimiting();
builder.Services.AddRateLimiting();

builder.Services.AddFeatureManagement();
builder.Services.AddMediator(options => options.ServiceLifetime = ServiceLifetime.Scoped);

builder.Services.AddMediator(options => options.ServiceLifetime = ServiceLifetime.Scoped);
builder.Services.AddResilientHttpClient();

builder.Services.AddResilientHttpClient();
builder.Services.AddUserSearchFeature();

builder.Services.AddUserSearchFeature();
builder.Services.AddOutputCache();

builder.Services.AddOutputCache();
builder.Services.ConfigureHttpJsonOptions(options =>
options.SerializerOptions.Converters.Add(new JsonStringEnumConverter()));

builder.Services.ConfigureHttpJsonOptions(options =>
options.SerializerOptions.Converters.Add(new JsonStringEnumConverter()));
builder.AddEmailServices();

builder.AddEmailServices();
builder.AddDeleteUserFeature();

builder.AddDeleteUserFeature();
builder.Services.AddSingleton(_ =>
new BlobServiceClient(builder.Configuration.GetConnectionString("AzureBlobStorage")));

builder.Services.AddSingleton(_ =>
new BlobServiceClient(builder.Configuration.GetConnectionString("AzureBlobStorage")));
builder.Services.AddHttpContextAccessor();

builder.Services.AddHttpContextAccessor();
builder.AddMassTransit();

builder.AddMassTransit();
builder.AddSignalR();

builder.AddAzureSignalR();
builder.Services.AddScoped<IImageService, ImageService>();

builder.Services.AddScoped<IImageService, ImageService>();
builder.AddGroupServices();
builder.AddGroupSearchServices();

builder.AddGroupServices();
builder.AddGroupSearchServices();
var app = builder.Build();

var app = builder.Build();

if (!app.Environment.IsDevelopment())
{
app.UseResponseCompression();
}

app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});
if (app.Environment.IsDevelopment())
{
app.UseWebAssemblyDebugging();
await app.InitializeDatabaseAsync();
}
else
{
app.UseResponseCompression();
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}

app.UseSerilog();
app.UseHttpsRedirection();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseWebAssemblyDebugging();
await app.InitializeDatabaseAsync();
}
else
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseStaticFiles();
app.UseRouting();
app.UseAntiforgery();

app.UseAzureAppConfiguration();
app.UseSerilog();

app.UseHttpsRedirection();
app.UseAzureAppConfiguration();

app.UseStaticFiles();
app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});

app.UseRouting();
app.UseAntiforgery();
app.UseRateLimiter();
app.UseOutputCache();
app.UseRateLimiter();
app.UseOutputCache();

app.UseAuthentication();
app.UseAuthorization();
app.UseAuthentication();
app.UseAuthorization();

// Configure the APIs
app.MapAuthentication();
app.MapProfiles();
app.MapCategories();
app.MapUserSearch();
app.MapEmail();
app.MapImages();
app.MapDeleteUsers();
app.MapChat();
app.MapGroups();
app.MapGroupSearch();
app.MapRazorComponents<App>()
.AddInteractiveWebAssemblyRenderMode()
.AddAdditionalAssemblies(typeof(Routes).Assembly)
.AddInteractiveServerRenderMode();

app.MapHealthChecks("/health").AllowAnonymous().RequireHealthCheckRateLimit();
// Configure the APIs
app.MapAuthentication();
app.MapProfiles();
app.MapCategories();
app.MapUserSearch();
app.MapEmail();
app.MapImages();
app.MapDeleteUsers();
app.MapChat();
app.MapGroups();
app.MapGroupSearch();

app.MapHub<ChatHub>("/hubs/chat");
app.MapHealthChecks("/health").AllowAnonymous().RequireHealthCheckRateLimit();

app.MapRazorComponents<App>()
.AddInteractiveWebAssemblyRenderMode()
.AddAdditionalAssemblies(typeof(_Imports).Assembly);
app.MapHub<ChatHub>("/hubs/chat");

try
{
app.Run();
}
catch (Exception exception)
Expand Down

0 comments on commit 3cdeab6

Please sign in to comment.