Skip to content

Commit 21f2798

Browse files
committed
Enhance Azure setup, null safety, and code quality
Added `helloworld.bicep` to define Azure resources including a storage account, an App Service Plan, and a web app. Updated project files (`Genocs.Auth.csproj`, `Genocs.Common.csproj`, `Genocs.Core.csproj`, `Genocs.Discovery.Consul.csproj`, `Genocs.HTTP.csproj`) to modify `<PackageTags>`, adding tags like `genocs`, `authentication`, `service-discovery`, and `http-client`. Removed unused `using` directives in `IQueryDispatcher.cs`. Modified `DispatcherEndpointsBuilder.cs` to allow `afterDispatch` function to accept nullable `TResult`. Updated `Extensions.cs` to make the `middleware` parameter nullable in `UseDispatcherEndpoints`. Changed `IDispatcher.cs` and `InMemoryDispatcher.cs` to make the return type of `QueryAsync` nullable. Refactored `IDispatcherEndpointsBuilder.cs` to improve formatting and make `afterDispatch` function accept nullable `TResult`. Updated `PublicContractsMiddleware.cs` to add null checks and improve command and event registration handling. Refactored `CertificateMiddleware.cs` to initialize dictionaries inline and added null checks for `options.Certificate`. Updated `SecurityOptions.cs` to improve formatting of the `GetHeaderName` method. Enhanced `Extensions.cs` to add null checks and default value handling for `sectionName` in `AddCertificateAuthentication`.
2 parents 52b5851 + 4bbbe88 commit 21f2798

File tree

16 files changed

+160
-60
lines changed

16 files changed

+160
-60
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Get the resource group location
2+
param location string = 'East US'
3+
4+
@description('The name of you Web Site.')
5+
param webSiteName string = 'gnx-website'
6+
7+
param uniqueString string = '{uniqueString(resourceGroup().id)}'
8+
9+
// Generate a unique storage account name
10+
param storageAccountName string = 'helloworldstorage${uniqueString}'
11+
12+
// Create a storage account
13+
resource storageAccount 'Microsoft.Storage/storageAccounts@2023-05-01' = {
14+
name: storageAccountName
15+
location: location
16+
sku: {
17+
name: 'Standard_LRS'
18+
}
19+
kind: 'StorageV2'
20+
properties: {
21+
accessTier: 'Hot'
22+
}
23+
}
24+
25+
// Create an App Service Plan
26+
resource appServicePlan 'Microsoft.Web/serverfarms@2023-12-01' = {
27+
name: 'asp-${uniqueString}'
28+
location: location
29+
sku: {
30+
name: 'F1'
31+
tier: 'Free'
32+
}
33+
}
34+
35+
// Create a web app
36+
resource webApp 'Microsoft.Web/sites@2023-12-01' = {
37+
name: webSiteName
38+
location: location
39+
properties: {
40+
serverFarmId: appServicePlan.id
41+
siteConfig: {
42+
appSettings: [
43+
{
44+
name: 'STORAGE_ACCOUNT_NAME'
45+
value: storageAccount.name
46+
}
47+
]
48+
}
49+
}
50+
}

src/Genocs.Auth/Genocs.Auth.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<Version>6.1.0</Version>
1212
<MinClientVersion>5.0.0</MinClientVersion>
1313
<Authors>Nocco Giovanni Emanuele</Authors>
14-
<PackageTags>aggregate architecture boilerplate ddd ddd-architecture design-patterns domain-driven-design dotnet dotnetcore dotnet-core microservice microservices solid solid-principles</PackageTags>
14+
<PackageTags>microservice microservices solid solid-principles authentication genocs</PackageTags>
1515
<PackageReadmeFile>README_NUGET.md</PackageReadmeFile>
1616
<PackageReleaseNotes>Aligned to the ecosystem</PackageReleaseNotes>
1717
<EnableNETAnalyzers>True</EnableNETAnalyzers>

src/Genocs.Common/Genocs.Common.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<Version>6.1.0</Version>
1212
<MinClientVersion>5.0.0</MinClientVersion>
1313
<Authors>Nocco Giovanni Emanuele</Authors>
14-
<PackageTags>aggregate architecture boilerplate ddd ddd-architecture design-patterns domain-driven-design dotnet dotnetcore dotnet-core microservice microservices solid solid-principles</PackageTags>
14+
<PackageTags>microservice microservices solid solid-principles genocs</PackageTags>
1515
<PackageReadmeFile>README_NUGET.md</PackageReadmeFile>
1616
<PackageReleaseNotes>Aligned to the ecosystem</PackageReleaseNotes>
1717
<EnableNETAnalyzers>True</EnableNETAnalyzers>

src/Genocs.Core/CQRS/Queries/IQueryDispatcher.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System.Threading.Tasks;
2-
using System.Threading;
3-
4-
namespace Genocs.Core.CQRS.Queries;
1+
namespace Genocs.Core.CQRS.Queries;
52

63
/// <summary>
74
/// The query dispatcher interface.

src/Genocs.Core/Genocs.Core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<Version>6.1.0</Version>
1212
<MinClientVersion>5.0.0</MinClientVersion>
1313
<Authors>Nocco Giovanni Emanuele</Authors>
14-
<PackageTags>aggregate architecture boilerplate ddd ddd-architecture design-patterns domain-driven-design dotnet dotnetcore dotnet-core microservice microservices solid solid-principles</PackageTags>
14+
<PackageTags>microservice microservices solid solid-principles genocs</PackageTags>
1515
<PackageReadmeFile>README_NUGET.md</PackageReadmeFile>
1616
<PackageReleaseNotes>Updated to NET8</PackageReleaseNotes>
1717
<EnableNETAnalyzers>True</EnableNETAnalyzers>

src/Genocs.Discovery.Consul/Genocs.Discovery.Consul.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<Version>6.1.0</Version>
1212
<MinClientVersion>5.0.0</MinClientVersion>
1313
<Authors>Nocco Giovanni Emanuele</Authors>
14-
<PackageTags>aggregate architecture boilerplate ddd ddd-architecture design-patterns domain-driven-design dotnet dotnetcore dotnet-core microservice microservices solid solid-principles</PackageTags>
14+
<PackageTags>microservice microservices solid solid-principles genocs service-discovery</PackageTags>
1515
<PackageReadmeFile>README_NUGET.md</PackageReadmeFile>
1616
<PackageReleaseNotes>Aligned to the ecosystem</PackageReleaseNotes>
1717
<EnableNETAnalyzers>True</EnableNETAnalyzers>

src/Genocs.HTTP/Genocs.HTTP.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<Version>6.1.0</Version>
1212
<MinClientVersion>5.0.0</MinClientVersion>
1313
<Authors>Nocco Giovanni Emanuele</Authors>
14-
<PackageTags>aggregate architecture boilerplate ddd ddd-architecture design-patterns domain-driven-design dotnet dotnetcore dotnet-core microservice microservices solid solid-principles</PackageTags>
14+
<PackageTags>microservice microservices solid solid-principles genocs http-client</PackageTags>
1515
<PackageReadmeFile>README_NUGET.md</PackageReadmeFile>
1616
<PackageReleaseNotes>Aligned to the ecosystem</PackageReleaseNotes>
1717
<EnableNETAnalyzers>True</EnableNETAnalyzers>

src/Genocs.WebApi.CQRS/Builders/DispatcherEndpointsBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public IDispatcherEndpointsBuilder Get(
3131
public IDispatcherEndpointsBuilder Get<TQuery, TResult>(
3232
string path,
3333
Func<TQuery, HttpContext, Task>? beforeDispatch = null,
34-
Func<TQuery, TResult, HttpContext, Task>? afterDispatch = null,
34+
Func<TQuery, TResult?, HttpContext, Task>? afterDispatch = null,
3535
Action<IEndpointConventionBuilder>? endpoint = null,
3636
bool auth = false,
3737
string? roles = null,

src/Genocs.WebApi.CQRS/Extensions.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ public static IGenocsBuilder AddInMemoryDispatcher(this IGenocsBuilder builder)
1919
return builder;
2020
}
2121

22-
public static IApplicationBuilder UseDispatcherEndpoints(this IApplicationBuilder app,
23-
Action<IDispatcherEndpointsBuilder> builder, bool useAuthorization = true,
24-
Action<IApplicationBuilder> middleware = null)
22+
public static IApplicationBuilder UseDispatcherEndpoints(
23+
this IApplicationBuilder app,
24+
Action<IDispatcherEndpointsBuilder> builder,
25+
bool useAuthorization = true,
26+
Action<IApplicationBuilder>? middleware = null)
2527
{
2628
var definitions = app.ApplicationServices.GetRequiredService<WebApiEndpointDefinitions>();
2729
app.UseRouting();

src/Genocs.WebApi.CQRS/IDispatcher.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ Task SendAsync<T>(T command, CancellationToken cancellationToken = default)
1212
Task PublishAsync<T>(T @event, CancellationToken cancellationToken = default)
1313
where T : class, IEvent;
1414

15-
Task<TResult> QueryAsync<TResult>(IQuery<TResult> query, CancellationToken cancellationToken = default);
15+
Task<TResult?> QueryAsync<TResult>(IQuery<TResult> query, CancellationToken cancellationToken = default);
1616
}

0 commit comments

Comments
 (0)