Compare commits

..

4 Commits

Author SHA1 Message Date
khwezi 44df489406 Merge pull request 'Refactored manifest' (#84) from cart into main
Reviewed-on: #84
2026-06-14 23:57:35 +02:00
Khwezi Mngoma 1bb1b0d476 Refactored manifest
continuous-integration/drone/pr Build is failing
2026-06-14 23:57:06 +02:00
khwezi 0ea31a33ae Merge pull request 'Updates app pipelining and cleaned up service registration' (#83) from cart into main
Reviewed-on: #83
2026-06-14 23:41:44 +02:00
Khwezi Mngoma 0bb5da3513 Updates app pipelining and cleaned up service registration
continuous-integration/drone/pr Build is passing
2026-06-14 23:40:47 +02:00
4 changed files with 86 additions and 89 deletions
+3 -2
View File
@@ -18,13 +18,13 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="LiteCharms.Features" Version="1.134.0" />
<PackageReference Include="LiteCharms.Features" Version="1.135.0" />
</ItemGroup>
<!-- UI -->
<ItemGroup>
<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 -->
<Using Include="Blazored.Toast.Services" />
@@ -62,6 +62,7 @@
<Using Include="Microsoft.AspNetCore.Components.Web" />
<Using Include="Microsoft.AspNetCore.WebUtilities" />
<Using Include="Microsoft.AspNetCore.Components" />
<Using Include="System.Security.Cryptography.X509Certificates" />
</ItemGroup>
</Project>
+25 -83
View File
@@ -1,109 +1,51 @@
using LiteCharms.Features.Extensions;
using LiteCharms.Features.Mediator;
using LiteCharms.Features.MidrandBooks.Extensions;
using LiteCharms.Features.MidrandBooks.Payments;
using LiteCharms.Features.Postgres;
using MidrandBookshop;
using MidrandBookshop.Components;
using System.Security.Cryptography.X509Certificates;
using static LiteCharms.Features.Extensions.Quartz;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddAntiforgery();
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
builder.AddMonitoring();
builder.Services.AddEndpointsApiExplorer();
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);
});
builder.Services.RegisterServices(builder.Configuration);
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())
{
app.UseExceptionHandler("/Error", createScopeForErrors: true);
app.UseHsts();
}
app.UseForwardedHeaders();
app.UseHttpsRedirection();
app.UseStatusCodePagesWithReExecute("/not-found", createScopeForStatusCodePages: true);
app.UseHealthChecks("/health", new HealthCheckOptions
{
ResponseWriter = HealthChecks.UI.Client.UIResponseWriter.WriteHealthCheckUIResponse
});
app.UseStatusCodePagesWithReExecute("/not-found", createScopeForStatusCodePages: true);
app.UseHttpsRedirection();
app.UseAntiforgery();
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>()
.AddInteractiveServerRenderMode();
+53
View File
@@ -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;
}
}
+5 -4
View File
@@ -11,7 +11,7 @@ metadata:
namespace: midrandbooks-uat
data:
ASPNETCORE_ENVIRONMENT: "Development"
ASPNETCORE_URLS: "https://0.0.0.0:8443"
ASPNETCORE_URLS: "http://0.0.0.0:8443"
Monitoring__Address: "http://aspire-dashboard-service.aspire.svc.cluster.local:18889"
Monitoring__ServiceName: "MidrandBooks.Uat"
HasherSettings__MinHashLength: "11"
@@ -194,14 +194,14 @@ spec:
httpGet:
path: /health
port: 8443
scheme: HTTPS
scheme: HTTP
initialDelaySeconds: 5
periodSeconds: 10
readinessProbe:
httpGet:
path: /health
port: 8443
scheme: HTTPS
scheme: HTTP
initialDelaySeconds: 3
periodSeconds: 5
volumes:
@@ -236,6 +236,7 @@ metadata:
name: midrandbooks-web-secure
namespace: midrandbooks-uat
spec:
insecureSkipVerify: true
entryPoints:
- websecure
routes:
@@ -244,6 +245,6 @@ spec:
services:
- name: midrandbooks-service
port: 443
scheme: https
scheme: http
serversTransport: midrandbooks-bypass-backend-validation
tls: {}