Updates app pipelining and cleaned up service registration
continuous-integration/drone/pr Build is passing
continuous-integration/drone/pr Build is passing
This commit is contained in:
@@ -18,13 +18,13 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="LiteCharms.Features" Version="1.134.0" />
|
<PackageReference Include="LiteCharms.Features" Version="1.135.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- UI -->
|
<!-- UI -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="ANM.Blazored.Toast" Version="0.1.1" />
|
<PackageReference Include="ANM.Blazored.Toast" Version="0.1.1" />
|
||||||
<PackageReference Include="LiteCharms.Features.MidrandBooks" Version="1.134.0" />
|
<PackageReference Include="LiteCharms.Features.MidrandBooks" Version="1.135.0" />
|
||||||
|
|
||||||
<!-- Global Usings -->
|
<!-- Global Usings -->
|
||||||
<Using Include="Blazored.Toast.Services" />
|
<Using Include="Blazored.Toast.Services" />
|
||||||
@@ -62,6 +62,7 @@
|
|||||||
<Using Include="Microsoft.AspNetCore.Components.Web" />
|
<Using Include="Microsoft.AspNetCore.Components.Web" />
|
||||||
<Using Include="Microsoft.AspNetCore.WebUtilities" />
|
<Using Include="Microsoft.AspNetCore.WebUtilities" />
|
||||||
<Using Include="Microsoft.AspNetCore.Components" />
|
<Using Include="Microsoft.AspNetCore.Components" />
|
||||||
|
<Using Include="System.Security.Cryptography.X509Certificates" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
+25
-83
@@ -1,109 +1,51 @@
|
|||||||
using LiteCharms.Features.Extensions;
|
using LiteCharms.Features.Extensions;
|
||||||
using LiteCharms.Features.Mediator;
|
|
||||||
using LiteCharms.Features.MidrandBooks.Extensions;
|
|
||||||
using LiteCharms.Features.MidrandBooks.Payments;
|
|
||||||
using LiteCharms.Features.Postgres;
|
using LiteCharms.Features.Postgres;
|
||||||
|
using MidrandBookshop;
|
||||||
using MidrandBookshop.Components;
|
using MidrandBookshop.Components;
|
||||||
using System.Security.Cryptography.X509Certificates;
|
|
||||||
using static LiteCharms.Features.Extensions.Quartz;
|
using static LiteCharms.Features.Extensions.Quartz;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
builder.Services.AddAntiforgery();
|
|
||||||
|
|
||||||
builder.Services.AddRazorComponents()
|
|
||||||
.AddInteractiveServerComponents();
|
|
||||||
|
|
||||||
builder.AddMonitoring();
|
builder.AddMonitoring();
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
builder.Services.RegisterServices(builder.Configuration);
|
||||||
|
|
||||||
builder.Services.AddScoped(typeof(IPipelineBehavior<,>), typeof(TelemetryPipelineBehavior<,>));
|
|
||||||
builder.Services.AddScoped(typeof(IPipelineBehavior<,>), typeof(LoggingPipelineBehavior<,>));
|
|
||||||
|
|
||||||
builder.Services.AddQuartzSchedulerClient(MidrandShopSchedulerName, builder.Configuration);
|
|
||||||
|
|
||||||
builder.Services.AddMediator();
|
|
||||||
builder.Services.AddEmailServices(builder.Configuration);
|
|
||||||
builder.Services.AddEmailServiceBus();
|
|
||||||
|
|
||||||
builder.Services.AddHttpClient();
|
|
||||||
builder.Services.AddScoped<CartService>();
|
|
||||||
builder.Services.AddShopServices(includeLocalStorage: true);
|
|
||||||
builder.Services.AddHashServices(builder.Configuration);
|
|
||||||
builder.Services.AddPayfastServices(builder.Configuration);
|
|
||||||
|
|
||||||
builder.Services.AddDataProtectionDatabase(builder.Configuration);
|
|
||||||
builder.Services.AddMidrandShopDatabase(builder.Configuration);
|
|
||||||
|
|
||||||
builder.Services.AddSecurityApiSdk(builder.Configuration);
|
|
||||||
builder.Services.AddLiteCharmsWebSecurity(builder.Configuration);
|
|
||||||
|
|
||||||
builder.Services.AddMidrandShopPostgresHealthCheck();
|
|
||||||
builder.Services.AddMidrandShopQuartzHealthCheck();
|
|
||||||
builder.Services.AddHealthChecksSupport(builder.Configuration);
|
|
||||||
|
|
||||||
builder.Services.Configure<ForwardedHeadersOptions>(options =>
|
|
||||||
{
|
|
||||||
options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
|
|
||||||
options.KnownProxies.Clear();
|
|
||||||
});
|
|
||||||
|
|
||||||
builder.WebHost.ConfigureKestrel(options =>
|
|
||||||
{
|
|
||||||
var certBase64 = builder.Configuration["DataProtection:Certificate"];
|
|
||||||
var certPassword = builder.Configuration["DataProtection:Password"];
|
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(certBase64))
|
|
||||||
{
|
|
||||||
var rawBytes = Convert.FromBase64String(certBase64);
|
|
||||||
var kestrelCert = X509CertificateLoader.LoadPkcs12(rawBytes, certPassword);
|
|
||||||
|
|
||||||
options.ListenAnyIP(8443, listenOptions =>
|
|
||||||
{
|
|
||||||
listenOptions.UseHttps(kestrelCert);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
options.ListenAnyIP(8080);
|
|
||||||
});
|
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
app.UseForwardedHeaders();
|
|
||||||
app.UseCookiePolicy();
|
|
||||||
|
|
||||||
using var security = app.Services.CreateScope();
|
|
||||||
{
|
|
||||||
var dataProtectionContext = security.ServiceProvider.GetRequiredService<DataProtectionDbContext>();
|
|
||||||
|
|
||||||
await dataProtectionContext.Database.MigrateAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
app.AddSecurityEndpoints();
|
|
||||||
|
|
||||||
var schedulerFactory = app.Services.GetRequiredService<ISchedulerFactory>();
|
|
||||||
var scheduler = await schedulerFactory.GetScheduler(MidrandShopSchedulerName);
|
|
||||||
|
|
||||||
if (!scheduler!.IsStarted)
|
|
||||||
await scheduler.Start();
|
|
||||||
|
|
||||||
if (!app.Environment.IsDevelopment())
|
if (!app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
app.UseExceptionHandler("/Error", createScopeForErrors: true);
|
app.UseExceptionHandler("/Error", createScopeForErrors: true);
|
||||||
app.UseHsts();
|
app.UseHsts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app.UseForwardedHeaders();
|
||||||
|
app.UseHttpsRedirection();
|
||||||
|
|
||||||
|
app.UseStatusCodePagesWithReExecute("/not-found", createScopeForStatusCodePages: true);
|
||||||
app.UseHealthChecks("/health", new HealthCheckOptions
|
app.UseHealthChecks("/health", new HealthCheckOptions
|
||||||
{
|
{
|
||||||
ResponseWriter = HealthChecks.UI.Client.UIResponseWriter.WriteHealthCheckUIResponse
|
ResponseWriter = HealthChecks.UI.Client.UIResponseWriter.WriteHealthCheckUIResponse
|
||||||
});
|
});
|
||||||
|
|
||||||
app.UseStatusCodePagesWithReExecute("/not-found", createScopeForStatusCodePages: true);
|
|
||||||
app.UseHttpsRedirection();
|
|
||||||
|
|
||||||
app.UseAntiforgery();
|
|
||||||
|
|
||||||
app.MapStaticAssets();
|
app.MapStaticAssets();
|
||||||
|
app.UseCookiePolicy();
|
||||||
|
|
||||||
|
app.UseAuthentication();
|
||||||
|
app.UseAuthorization();
|
||||||
|
app.UseAntiforgery();
|
||||||
|
app.AddSecurityEndpoints();
|
||||||
|
|
||||||
|
using (var security = app.Services.CreateScope())
|
||||||
|
{
|
||||||
|
var dataProtectionContext = security.ServiceProvider.GetRequiredService<DataProtectionDbContext>();
|
||||||
|
|
||||||
|
await dataProtectionContext.Database.MigrateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
var schedulerFactory = app.Services.GetRequiredService<ISchedulerFactory>();
|
||||||
|
var scheduler = await schedulerFactory.GetScheduler(MidrandShopSchedulerName);
|
||||||
|
|
||||||
|
if (!scheduler!.IsStarted) await scheduler.Start();
|
||||||
|
|
||||||
app.MapRazorComponents<App>()
|
app.MapRazorComponents<App>()
|
||||||
.AddInteractiveServerRenderMode();
|
.AddInteractiveServerRenderMode();
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
using LiteCharms.Features.Mediator;
|
||||||
|
using LiteCharms.Features.MidrandBooks.Payments;
|
||||||
|
using LiteCharms.Features.Extensions;
|
||||||
|
using LiteCharms.Features.MidrandBooks.Extensions;
|
||||||
|
using static LiteCharms.Features.Extensions.Quartz;
|
||||||
|
|
||||||
|
namespace MidrandBookshop;
|
||||||
|
|
||||||
|
public static class Setup
|
||||||
|
{
|
||||||
|
public static IServiceCollection RegisterServices(this IServiceCollection services, IConfiguration configuration)
|
||||||
|
{
|
||||||
|
services.AddAntiforgery();
|
||||||
|
|
||||||
|
services.AddRazorComponents()
|
||||||
|
.AddInteractiveServerComponents();
|
||||||
|
|
||||||
|
services.AddEndpointsApiExplorer();
|
||||||
|
|
||||||
|
services.AddScoped(typeof(IPipelineBehavior<,>), typeof(TelemetryPipelineBehavior<,>));
|
||||||
|
services.AddScoped(typeof(IPipelineBehavior<,>), typeof(LoggingPipelineBehavior<,>));
|
||||||
|
|
||||||
|
services.AddQuartzSchedulerClient(MidrandShopSchedulerName, configuration);
|
||||||
|
|
||||||
|
services.AddMediator();
|
||||||
|
services.AddEmailServices(configuration);
|
||||||
|
services.AddEmailServiceBus();
|
||||||
|
|
||||||
|
services.AddHttpClient();
|
||||||
|
services.AddScoped<CartService>();
|
||||||
|
services.AddShopServices(includeLocalStorage: true);
|
||||||
|
services.AddHashServices(configuration);
|
||||||
|
services.AddPayfastServices(configuration);
|
||||||
|
|
||||||
|
services.AddDataProtectionDatabase(configuration);
|
||||||
|
services.AddMidrandShopDatabase(configuration);
|
||||||
|
|
||||||
|
services.AddSecurityApiSdk(configuration);
|
||||||
|
services.AddLiteCharmsWebSecurity(configuration);
|
||||||
|
|
||||||
|
services.AddMidrandShopPostgresHealthCheck();
|
||||||
|
services.AddMidrandShopQuartzHealthCheck();
|
||||||
|
services.AddHealthChecksSupport(configuration);
|
||||||
|
|
||||||
|
services.Configure<ForwardedHeadersOptions>(options =>
|
||||||
|
{
|
||||||
|
options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
|
||||||
|
options.KnownProxies.Clear();
|
||||||
|
});
|
||||||
|
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user