From f67f5eaf53c4d4abf47ccbffb478b0bfac641b9f Mon Sep 17 00:00:00 2001 From: Khwezi Mngoma Date: Sun, 24 May 2026 13:38:47 +0200 Subject: [PATCH] Added MidrandBooks project --- .drone.yml | 4 +- .../Extensions/HealthChecks.cs | 13 +- .../Extensions/Postgres.cs | 16 ++ .../MidrandShopQuartzHealthCheck.cs | 2 +- .../PostgresMidrandShopHealthCheck.cs | 4 +- .../LiteCharms.Features.MidrandBooks.csproj | 166 ++++++++++++++++++ .../Postgres/MidrandShopDbContext.cs | 2 +- .../Postgres/MidrandShopDbContextFactory.cs | 4 +- .../appsettings.json | 22 +++ .../Extensions/HealthChecks.cs | 2 +- .../Extensions/Postgres.cs | 4 +- .../HealthChecks/PostgresShopHealthCheck.cs | 6 +- .../HealthChecks/ShopQuartzHealthCheck.cs | 10 +- .../Postgres/ShopDbContextFactory.cs | 2 +- LiteCharms.Features/Extensions/Postgres.cs | 13 +- LiteCharms.Features/Extensions/Quartz.cs | 4 +- LiteCharmsShared.slnx | 13 +- 17 files changed, 241 insertions(+), 46 deletions(-) rename {LiteCharms.Features => LiteCharms.Features.MidrandBooks}/Extensions/HealthChecks.cs (67%) create mode 100644 LiteCharms.Features.MidrandBooks/Extensions/Postgres.cs rename {LiteCharms.Features => LiteCharms.Features.MidrandBooks}/HealthChecks/MidrandShopQuartzHealthCheck.cs (95%) rename {LiteCharms.Features => LiteCharms.Features.MidrandBooks}/HealthChecks/PostgresMidrandShopHealthCheck.cs (88%) create mode 100644 LiteCharms.Features.MidrandBooks/LiteCharms.Features.MidrandBooks.csproj rename {LiteCharms.Features/MidrandShop => LiteCharms.Features.MidrandBooks}/Postgres/MidrandShopDbContext.cs (66%) rename {LiteCharms.Features/MidrandShop => LiteCharms.Features.MidrandBooks}/Postgres/MidrandShopDbContextFactory.cs (85%) create mode 100644 LiteCharms.Features.MidrandBooks/appsettings.json diff --git a/.drone.yml b/.drone.yml index 49e0b2b..12c4fd6 100644 --- a/.drone.yml +++ b/.drone.yml @@ -21,6 +21,8 @@ steps: - dotnet nuget push dist/LiteCharms.Features.$VERSION.nupkg --api-key $NEXUS_KEY --source $NEXUS_URL - dotnet pack LiteCharms.Features.TechShop/LiteCharms.Features.TechShop.csproj -c Release -p:PackageVersion=$VERSION -o dist/ - dotnet nuget push dist/LiteCharms.Features.TechShop.$VERSION.nupkg --api-key $NEXUS_KEY --source $NEXUS_URL + - dotnet pack LiteCharms.Features.MidrandBooks/LiteCharms.Features.MidrandBooks.csproj -c Release -p:PackageVersion=$VERSION -o dist/ + - dotnet nuget push dist/LiteCharms.Features.MidrandBooks.$VERSION.nupkg --api-key $NEXUS_KEY --source $NEXUS_URL - name: gitea-tag-release image: alpine/git @@ -43,7 +45,7 @@ steps: \"tag_name\": \"$VERSION\", \"target_commitish\": \"${DRONE_COMMIT_SHA}\", \"name\": \"Library Suite $VERSION\", - \"body\": \"### Published NuGet Packages\nAll packages versioned as **$VERSION**:\n* LiteCharms.Features\n* LiteCharms.Features.TechShop\n\n[View in Nexus](https://nexus.khongisa.co.za/repository/nuget-group/)\", + \"body\": \"### Published NuGet Packages\nAll packages versioned as **$VERSION**:\n* LiteCharms.Features\n* LiteCharms.Features.TechShop\n* LiteCharms.Features.MidrandBooks\n\n[View in Nexus](https://nexus.khongisa.co.za/repository/nuget-group/)\", \"draft\": false, \"prerelease\": false }" diff --git a/LiteCharms.Features/Extensions/HealthChecks.cs b/LiteCharms.Features.MidrandBooks/Extensions/HealthChecks.cs similarity index 67% rename from LiteCharms.Features/Extensions/HealthChecks.cs rename to LiteCharms.Features.MidrandBooks/Extensions/HealthChecks.cs index 2b9ab08..fbc3e1f 100644 --- a/LiteCharms.Features/Extensions/HealthChecks.cs +++ b/LiteCharms.Features.MidrandBooks/Extensions/HealthChecks.cs @@ -1,13 +1,14 @@ -using LiteCharms.Features.HealthChecks; +using LiteCharms.Features.MidrandBooks.HealthChecks; using static LiteCharms.Features.Extensions.Postgres; +using static LiteCharms.Features.MidrandBooks.Extensions.Postgres; -namespace LiteCharms.Features.Extensions; +namespace LiteCharms.Features.MidrandBooks.Extensions; public static class HealthChecks { public static IServiceCollection AddMidrandShopQuartzHealthCheck(this IServiceCollection services) { - services.AddHealthChecks().AddCheck("MidrandShopQuartz"); + services.AddHealthChecks().AddCheck(SchedulerDbConfigName); return services; } @@ -24,12 +25,6 @@ public static class HealthChecks services.AddHealthChecks() .AddCheck("Self", () => HealthCheckResult.Healthy()); - //services.AddHealthChecksUI(setup => - //{ - // setup.AddHealthCheckEndpoint("Lead Generator", $"{configuration["ASPNETCORE_URLS"]}/health"); - // setup.SetEvaluationTimeInSeconds(15); - //}).AddInMemoryStorage(databaseName: "healthuidb"); - return services; } } diff --git a/LiteCharms.Features.MidrandBooks/Extensions/Postgres.cs b/LiteCharms.Features.MidrandBooks/Extensions/Postgres.cs new file mode 100644 index 0000000..11e81b0 --- /dev/null +++ b/LiteCharms.Features.MidrandBooks/Extensions/Postgres.cs @@ -0,0 +1,16 @@ +using LiteCharms.Features.MidrandBooks.Postgres; + +namespace LiteCharms.Features.MidrandBooks.Extensions; + +public static class Postgres +{ + public const string MidrandShopDbConfigName = "PostgresMidrandShop"; + + public static IServiceCollection AddMidrandShopDatabase(this IServiceCollection services, IConfiguration configuration) + { + services.AddPooledDbContextFactory(options => + options.UseNpgsql(configuration.GetConnectionString(MidrandShopDbConfigName))); + + return services; + } +} diff --git a/LiteCharms.Features/HealthChecks/MidrandShopQuartzHealthCheck.cs b/LiteCharms.Features.MidrandBooks/HealthChecks/MidrandShopQuartzHealthCheck.cs similarity index 95% rename from LiteCharms.Features/HealthChecks/MidrandShopQuartzHealthCheck.cs rename to LiteCharms.Features.MidrandBooks/HealthChecks/MidrandShopQuartzHealthCheck.cs index 9588d24..23bdf5a 100644 --- a/LiteCharms.Features/HealthChecks/MidrandShopQuartzHealthCheck.cs +++ b/LiteCharms.Features.MidrandBooks/HealthChecks/MidrandShopQuartzHealthCheck.cs @@ -1,6 +1,6 @@ using static LiteCharms.Features.Extensions.Quartz; -namespace LiteCharms.Features.HealthChecks; +namespace LiteCharms.Features.MidrandBooks.HealthChecks; public class MidrandShopQuartzHealthCheck(ISchedulerFactory schedulerFactory) : IHealthCheck { diff --git a/LiteCharms.Features/HealthChecks/PostgresMidrandShopHealthCheck.cs b/LiteCharms.Features.MidrandBooks/HealthChecks/PostgresMidrandShopHealthCheck.cs similarity index 88% rename from LiteCharms.Features/HealthChecks/PostgresMidrandShopHealthCheck.cs rename to LiteCharms.Features.MidrandBooks/HealthChecks/PostgresMidrandShopHealthCheck.cs index f88b22e..e60ef2c 100644 --- a/LiteCharms.Features/HealthChecks/PostgresMidrandShopHealthCheck.cs +++ b/LiteCharms.Features.MidrandBooks/HealthChecks/PostgresMidrandShopHealthCheck.cs @@ -1,6 +1,6 @@ -using static LiteCharms.Features.Extensions.Postgres; +using static LiteCharms.Features.MidrandBooks.Extensions.Postgres; -namespace LiteCharms.Features.HealthChecks; +namespace LiteCharms.Features.MidrandBooks.HealthChecks; public class PostgresMidrandShopHealthCheck(IConfiguration configuration) : IHealthCheck { diff --git a/LiteCharms.Features.MidrandBooks/LiteCharms.Features.MidrandBooks.csproj b/LiteCharms.Features.MidrandBooks/LiteCharms.Features.MidrandBooks.csproj new file mode 100644 index 0000000..552ce45 --- /dev/null +++ b/LiteCharms.Features.MidrandBooks/LiteCharms.Features.MidrandBooks.csproj @@ -0,0 +1,166 @@ + + + + net10.0 + enable + enable + True + ..\LiteCharms.snk + 5be62f49-3ed0-4468-884e-1b04e048b45a + + + + + LiteCharms.Features.MidrandBooks + 1.0.20 + Khwezi Mngoma + Lite Charms (PTY) Ltd + MidrandBooks feature components for Lite Charms applications. + https://gitea.khongisa.co.za/litecharms/components + https://gitea.khongisa.co.za/litecharms/components.git + git + LICENSE + utility;dotnet + icon.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PreserveNewest + + + + diff --git a/LiteCharms.Features/MidrandShop/Postgres/MidrandShopDbContext.cs b/LiteCharms.Features.MidrandBooks/Postgres/MidrandShopDbContext.cs similarity index 66% rename from LiteCharms.Features/MidrandShop/Postgres/MidrandShopDbContext.cs rename to LiteCharms.Features.MidrandBooks/Postgres/MidrandShopDbContext.cs index efa8047..19e6697 100644 --- a/LiteCharms.Features/MidrandShop/Postgres/MidrandShopDbContext.cs +++ b/LiteCharms.Features.MidrandBooks/Postgres/MidrandShopDbContext.cs @@ -1,4 +1,4 @@ -namespace LiteCharms.Features.MidrandShop.Postgres; +namespace LiteCharms.Features.MidrandBooks.Postgres; public class MidrandShopDbContext(DbContextOptions options) : DbContext(options) { diff --git a/LiteCharms.Features/MidrandShop/Postgres/MidrandShopDbContextFactory.cs b/LiteCharms.Features.MidrandBooks/Postgres/MidrandShopDbContextFactory.cs similarity index 85% rename from LiteCharms.Features/MidrandShop/Postgres/MidrandShopDbContextFactory.cs rename to LiteCharms.Features.MidrandBooks/Postgres/MidrandShopDbContextFactory.cs index deb8ff4..6aca9e4 100644 --- a/LiteCharms.Features/MidrandShop/Postgres/MidrandShopDbContextFactory.cs +++ b/LiteCharms.Features.MidrandBooks/Postgres/MidrandShopDbContextFactory.cs @@ -1,6 +1,6 @@ -using static LiteCharms.Features.Extensions.Postgres; +using static LiteCharms.Features.MidrandBooks.Extensions.Postgres; -namespace LiteCharms.Features.MidrandShop.Postgres; +namespace LiteCharms.Features.MidrandBooks.Postgres; public class MidrandShopDbContextFactory : IDesignTimeDbContextFactory { diff --git a/LiteCharms.Features.MidrandBooks/appsettings.json b/LiteCharms.Features.MidrandBooks/appsettings.json new file mode 100644 index 0000000..aec5c2e --- /dev/null +++ b/LiteCharms.Features.MidrandBooks/appsettings.json @@ -0,0 +1,22 @@ +{ + "Email": { + "Credentials": { + "Username": "shop@litecharms.co.za" + }, + "Port": 465, + "Host": "mail.litecharms.co.za", + "UseSsl": true + }, + "Monitoring": { + "ApiKey": "", + "Address": "http://aspire-dashboard-service.aspire.svc.cluster.local:18889", + "ServiceName": "LiteCharms.LeadGenerator" + }, + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/LiteCharms.Features.TechShop/Extensions/HealthChecks.cs b/LiteCharms.Features.TechShop/Extensions/HealthChecks.cs index ee2a4a4..a09ffec 100644 --- a/LiteCharms.Features.TechShop/Extensions/HealthChecks.cs +++ b/LiteCharms.Features.TechShop/Extensions/HealthChecks.cs @@ -15,7 +15,7 @@ public static class HealthChecks public static IServiceCollection AddShopPostgresHealthCheck(this IServiceCollection services) { - services.AddHealthChecks().AddCheck(ShopDbConfigName); + services.AddHealthChecks().AddCheck(TechShopDbConfigName); return services; } diff --git a/LiteCharms.Features.TechShop/Extensions/Postgres.cs b/LiteCharms.Features.TechShop/Extensions/Postgres.cs index a264fa2..fdf8555 100644 --- a/LiteCharms.Features.TechShop/Extensions/Postgres.cs +++ b/LiteCharms.Features.TechShop/Extensions/Postgres.cs @@ -4,12 +4,12 @@ namespace LiteCharms.Features.TechShop.Extensions; public static class Postgres { - public const string ShopDbConfigName = "PostgresShop"; + public const string TechShopDbConfigName = "PostgresShop"; public static IServiceCollection AddTechShopDatabase(this IServiceCollection services, IConfiguration configuration) { services.AddPooledDbContextFactory(options => - options.UseNpgsql(configuration.GetConnectionString(ShopDbConfigName))); + options.UseNpgsql(configuration.GetConnectionString(TechShopDbConfigName))); return services; } diff --git a/LiteCharms.Features.TechShop/HealthChecks/PostgresShopHealthCheck.cs b/LiteCharms.Features.TechShop/HealthChecks/PostgresShopHealthCheck.cs index db55287..6e69231 100644 --- a/LiteCharms.Features.TechShop/HealthChecks/PostgresShopHealthCheck.cs +++ b/LiteCharms.Features.TechShop/HealthChecks/PostgresShopHealthCheck.cs @@ -4,7 +4,7 @@ namespace LiteCharms.Features.TechShop.HealthChecks; public class PostgresShopHealthCheck(IConfiguration configuration) : IHealthCheck { - private readonly string connectionString = configuration.GetConnectionString(ShopDbConfigName)!; + private readonly string connectionString = configuration.GetConnectionString(TechShopDbConfigName)!; public async Task CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default) { @@ -18,11 +18,11 @@ public class PostgresShopHealthCheck(IConfiguration configuration) : IHealthChec await command.ExecuteScalarAsync(cancellationToken); - return HealthCheckResult.Healthy($"{ShopDbConfigName} is responsive."); + return HealthCheckResult.Healthy($"{TechShopDbConfigName} is responsive."); } catch (Exception ex) { - return HealthCheckResult.Unhealthy($"{ShopDbConfigName} is unreachable.", ex); + return HealthCheckResult.Unhealthy($"{TechShopDbConfigName} is unreachable.", ex); } } } \ No newline at end of file diff --git a/LiteCharms.Features.TechShop/HealthChecks/ShopQuartzHealthCheck.cs b/LiteCharms.Features.TechShop/HealthChecks/ShopQuartzHealthCheck.cs index 5599d26..3fd4e20 100644 --- a/LiteCharms.Features.TechShop/HealthChecks/ShopQuartzHealthCheck.cs +++ b/LiteCharms.Features.TechShop/HealthChecks/ShopQuartzHealthCheck.cs @@ -8,21 +8,21 @@ public class ShopQuartzHealthCheck(ISchedulerFactory schedulerFactory) : IHealth { try { - var scheduler = await schedulerFactory.GetScheduler(ShopSchedulerName, cancellationToken); + var scheduler = await schedulerFactory.GetScheduler(TechShopSchedulerName, cancellationToken); if(scheduler == null) - return HealthCheckResult.Unhealthy($"Scheduler with name '{ShopSchedulerName}' not found."); + return HealthCheckResult.Unhealthy($"Scheduler with name '{TechShopSchedulerName}' not found."); if (!scheduler.IsStarted) - return HealthCheckResult.Unhealthy($"{ShopSchedulerName} Quartz scheduler is not running"); + return HealthCheckResult.Unhealthy($"{TechShopSchedulerName} Quartz scheduler is not running"); await scheduler.CheckExists(new JobKey(Guid.NewGuid().ToString()), cancellationToken); - return HealthCheckResult.Healthy($"{ShopSchedulerName} Quartz scheduler is ready"); + return HealthCheckResult.Healthy($"{TechShopSchedulerName} Quartz scheduler is ready"); } catch (SchedulerException) { - return HealthCheckResult.Unhealthy($"{ShopSchedulerName} Quartz scheduler cannot connect to the store"); + return HealthCheckResult.Unhealthy($"{TechShopSchedulerName} Quartz scheduler cannot connect to the store"); } } } diff --git a/LiteCharms.Features.TechShop/Postgres/ShopDbContextFactory.cs b/LiteCharms.Features.TechShop/Postgres/ShopDbContextFactory.cs index e1e64fd..eda522c 100644 --- a/LiteCharms.Features.TechShop/Postgres/ShopDbContextFactory.cs +++ b/LiteCharms.Features.TechShop/Postgres/ShopDbContextFactory.cs @@ -14,7 +14,7 @@ public class ShopDbContextFactory : IDesignTimeDbContextFactory .Build(); var optionsBuilder = new DbContextOptionsBuilder(); - optionsBuilder.UseNpgsql(configuration.GetConnectionString(ShopDbConfigName)); + optionsBuilder.UseNpgsql(configuration.GetConnectionString(TechShopDbConfigName)); return new ShopDbContext(optionsBuilder.Options); } diff --git a/LiteCharms.Features/Extensions/Postgres.cs b/LiteCharms.Features/Extensions/Postgres.cs index 549c5a0..8a9541a 100644 --- a/LiteCharms.Features/Extensions/Postgres.cs +++ b/LiteCharms.Features/Extensions/Postgres.cs @@ -1,17 +1,6 @@ -using LiteCharms.Features.MidrandShop.Postgres; - -namespace LiteCharms.Features.Extensions; +namespace LiteCharms.Features.Extensions; public static class Postgres { - public const string MidrandShopDbConfigName = "PostgresMidrandShop"; public const string SchedulerDbConfigName = "PostgresScheduler"; - - public static IServiceCollection AddMidrandShopDatabase(this IServiceCollection services, IConfiguration configuration) - { - services.AddPooledDbContextFactory(options => - options.UseNpgsql(configuration.GetConnectionString(MidrandShopDbConfigName))); - - return services; - } } diff --git a/LiteCharms.Features/Extensions/Quartz.cs b/LiteCharms.Features/Extensions/Quartz.cs index 7db12a8..6c4c32e 100644 --- a/LiteCharms.Features/Extensions/Quartz.cs +++ b/LiteCharms.Features/Extensions/Quartz.cs @@ -6,8 +6,8 @@ namespace LiteCharms.Features.Extensions; public static class Quartz { - public const string ShopSchedulerName = "shop"; - public const string MidrandShopSchedulerName = "midrandshop"; + public const string TechShopSchedulerName = "tech-shop"; + public const string MidrandShopSchedulerName = "midrand-shop"; public static IServiceCollection AddQuartzSchedulerClient(this IServiceCollection services, string schedulerName, IConfiguration configuration) { diff --git a/LiteCharmsShared.slnx b/LiteCharmsShared.slnx index a8a890a..3546fc5 100644 --- a/LiteCharmsShared.slnx +++ b/LiteCharmsShared.slnx @@ -2,8 +2,13 @@ - - - - + + + + + + + + +