This commit is contained in:
Meysam Hadeli 2024-09-16 01:58:31 +03:30
parent 31db8aa1ba
commit 6da82e39ce
223 changed files with 1771 additions and 438 deletions

1
.husky/pre-commit Normal file
View File

@ -0,0 +1 @@
npm run format

View File

@ -1,8 +1,45 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project> <Project>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<GlobalPackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.0" /> <PackageReference Include="StyleCop.Analyzers" PrivateAssets="all" Version="1.1.118">
<GlobalPackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" /> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<GlobalPackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435" /> </PackageReference>
<PackageReference Include="Meziantou.Analyzer" PrivateAssets="all" Version="2.0.163">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Roslynator.Analyzers" PrivateAssets="all" Version="4.12.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Roslynator.CodeAnalysis.Analyzers" PrivateAssets="all" Version="4.12.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Roslynator.Formatting.Analyzers" PrivateAssets="all" Version="4.12.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" PrivateAssets="all" Version="17.11.20">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="AsyncAwaitBestPractices" PrivateAssets="all" Version="8.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="SerilogAnalyzer" PrivateAssets="all" Version="0.15.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="CSharpGuidelinesAnalyzer" PrivateAssets="all" Version="3.8.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup> </ItemGroup>
<PropertyGroup>
<RunAnalyzersDuringBuild>true</RunAnalyzersDuringBuild>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<AnalysisMode>All</AnalysisMode>
</PropertyGroup>
</Project> </Project>

3
commitlint.config.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = {
extends: ["@commitlint/config-conventional"],
}

View File

@ -1,6 +1,6 @@
{ {
"sdk": { "sdk": {
"version": "8.0.303", "version": "8.0.401",
"rollForward": "latestFeature" "rollForward": "latestFeature"
} }
} }

1346
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

18
package.json Normal file
View File

@ -0,0 +1,18 @@
{
"name": "booking-microservices",
"version": "1.0.0",
"description": "",
"author": "Meysam Hadeli",
"license": "MIT",
"main": "index.js",
"scripts": {
"prepare": "husky && dotnet tool restore",
"format": "dotnet format booking-microservices-sample.sln --severity error --verbosity detailed",
"upgrade-packages": "dotnet outdated --upgrade"
},
"devDependencies": {
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0",
"husky": "^9.1.6"
}
}

View File

@ -1,39 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Ardalis.GuardClauses" Version="4.6.0" /> <PackageReference Include="Ardalis.GuardClauses" Version="4.6.0" />
<PackageReference Include="Asp.Versioning.Abstractions" Version="8.1.0" /> <PackageReference Include="Asp.Versioning.Abstractions" Version="8.1.0" />
<PackageReference Include="Asp.Versioning.Http" Version="8.1.0" /> <PackageReference Include="Asp.Versioning.Http" Version="8.1.0" />
<PackageReference Include="Asp.Versioning.Mvc" Version="8.1.0" /> <PackageReference Include="Asp.Versioning.Mvc" Version="8.1.0" />
<PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.1.0" /> <PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.1.0" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="8.0.7" /> <PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="8.0.8" />
<PackageReference Include="AspNetCore.HealthChecks.UI" Version="8.0.1" /> <PackageReference Include="AspNetCore.HealthChecks.UI" Version="8.0.2" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="8.0.1" /> <PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="8.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.UI.InMemory.Storage" Version="8.0.1" /> <PackageReference Include="AspNetCore.HealthChecks.UI.InMemory.Storage" Version="8.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.Elasticsearch" Version="8.0.1" /> <PackageReference Include="AspNetCore.HealthChecks.Elasticsearch" Version="8.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.EventStore" Version="8.0.1" /> <PackageReference Include="AspNetCore.HealthChecks.EventStore" Version="8.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.NpgSql" Version="8.0.1" /> <PackageReference Include="AspNetCore.HealthChecks.NpgSql" Version="8.0.2" />
<PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="8.0.1" /> <PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="8.0.2" />
<PackageReference Include="AspNetCore.HealthChecks.UI.SQLite.Storage" Version="8.0.1" /> <PackageReference Include="AspNetCore.HealthChecks.UI.SQLite.Storage" Version="8.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.MongoDb" Version="8.0.1" /> <PackageReference Include="AspNetCore.HealthChecks.MongoDb" Version="8.1.0" />
<PackageReference Include="Grpc.Core.Testing" Version="2.46.6" /> <PackageReference Include="Grpc.Core.Testing" Version="2.46.6" />
<PackageReference Include="EasyCaching.Core" Version="1.9.2" /> <PackageReference Include="EasyCaching.Core" Version="1.9.2" />
<PackageReference Include="EasyCaching.InMemory" Version="1.9.2" /> <PackageReference Include="EasyCaching.InMemory" Version="1.9.2" />
<PackageReference Include="EasyNetQ.Management.Client" Version="2.0.0" /> <PackageReference Include="EasyNetQ.Management.Client" Version="2.0.0" />
<PackageReference Include="EFCore.NamingConventions" Version="8.0.3" /> <PackageReference Include="EFCore.NamingConventions" Version="8.0.3" />
<PackageReference Include="Figgle" Version="0.5.1" /> <PackageReference Include="Figgle" Version="0.5.1" />
<PackageReference Include="FluentValidation" Version="11.9.2" /> <PackageReference Include="FluentValidation" Version="11.10.0" />
<PackageReference Include="FluentValidation.AspNetCore" Version="11.3.0" /> <PackageReference Include="FluentValidation.AspNetCore" Version="11.3.0" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.7" /> <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.7" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.8" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="8.0.1" /> <PackageReference Include="Microsoft.Extensions.DependencyModel" Version="8.0.1" />
<PackageReference Include="Npgsql" Version="8.0.3" /> <PackageReference Include="Npgsql" Version="8.0.4" />
<PackageReference Include="NSubstitute" Version="5.1.0" /> <PackageReference Include="NSubstitute" Version="5.1.0" />
<PackageReference Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" Version="1.9.0-beta.2" /> <PackageReference Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" Version="1.9.0-beta.2" />
<PackageReference Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="1.9.0-beta.1" /> <PackageReference Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="1.9.0-beta.1" />
@ -42,25 +35,25 @@
<PackageReference Include="IdGen" Version="3.0.7" /> <PackageReference Include="IdGen" Version="3.0.7" />
<PackageReference Include="Mapster" Version="7.4.0" /> <PackageReference Include="Mapster" Version="7.4.0" />
<PackageReference Include="Mapster.DependencyInjection" Version="1.0.1" /> <PackageReference Include="Mapster.DependencyInjection" Version="1.0.1" />
<PackageReference Include="MediatR" Version="12.4.0" /> <PackageReference Include="MediatR" Version="12.4.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.7" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.7" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.7" /> <PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.7" /> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.8" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.2" /> <PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.2" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" /> <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="8.0.7" /> <PackageReference Include="Microsoft.Extensions.Http.Polly" Version="8.0.8" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" /> <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="MongoDB.Driver" Version="2.24.0" /> <PackageReference Include="MongoDB.Driver" Version="2.28.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="OpenTelemetry.Contrib.Instrumentation.MassTransit" Version="1.0.0-beta2" /> <PackageReference Include="OpenTelemetry.Contrib.Instrumentation.MassTransit" Version="1.0.0-beta2" />
<PackageReference Include="Scrutor" Version="4.2.2" /> <PackageReference Include="Scrutor" Version="4.2.2" />
<PackageReference Include="Sentry.Serilog" Version="4.9.0" /> <PackageReference Include="Sentry.Serilog" Version="4.9.0" />
<PackageReference Include="Serilog" Version="4.0.0" /> <PackageReference Include="Serilog" Version="4.0.1" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" /> <PackageReference Include="Serilog.AspNetCore" Version="8.0.2" />
<PackageReference Include="Serilog.Enrichers.Span" Version="3.1.0" /> <PackageReference Include="Serilog.Enrichers.Span" Version="3.1.0" />
<PackageReference Include="Serilog.Exceptions" Version="8.4.0" /> <PackageReference Include="Serilog.Exceptions" Version="8.4.0" />
<PackageReference Include="Serilog.Formatting.Elasticsearch" Version="10.0.0" /> <PackageReference Include="Serilog.Formatting.Elasticsearch" Version="10.0.0" />
@ -70,25 +63,25 @@
<PackageReference Include="Serilog.Sinks.SpectreConsole" Version="0.3.3" /> <PackageReference Include="Serilog.Sinks.SpectreConsole" Version="0.3.3" />
<PackageReference Include="Serilog.Sinks.XUnit" Version="3.0.5" /> <PackageReference Include="Serilog.Sinks.XUnit" Version="3.0.5" />
<PackageReference Include="Sieve" Version="2.5.5" /> <PackageReference Include="Sieve" Version="2.5.5" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.7.3" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.6.2" /> <PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.7.3" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.6.2" /> <PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.7.3" />
<PackageReference Include="MassTransit" Version="8.2.3" /> <PackageReference Include="MassTransit" Version="8.2.5" />
<PackageReference Include="MassTransit.RabbitMQ" Version="8.2.3" /> <PackageReference Include="MassTransit.RabbitMQ" Version="8.2.5" />
<PackageReference Include="Duende.IdentityServer" Version="7.0.5" /> <PackageReference Include="Duende.IdentityServer" Version="7.0.6" />
<PackageReference Include="Duende.IdentityServer.AspNetIdentity" Version="7.0.5" /> <PackageReference Include="Duende.IdentityServer.AspNetIdentity" Version="7.0.6" />
<PackageReference Include="Duende.IdentityServer.EntityFramework" Version="7.0.5" /> <PackageReference Include="Duende.IdentityServer.EntityFramework" Version="7.0.6" />
<PackageReference Include="Duende.IdentityServer.EntityFramework.Storage" Version="7.0.5" /> <PackageReference Include="Duende.IdentityServer.EntityFramework.Storage" Version="7.0.6" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.7" /> <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.8" />
<PackageReference Include="System.Linq.Async" Version="6.0.1" /> <PackageReference Include="System.Linq.Async" Version="6.0.1" />
<PackageReference Include="System.Linq.Async.Queryable" Version="6.0.1" /> <PackageReference Include="System.Linq.Async.Queryable" Version="6.0.1" />
<PackageReference Include="Testcontainers" Version="3.9.0" /> <PackageReference Include="Testcontainers" Version="3.10.0" />
<PackageReference Include="Testcontainers.EventStoreDb" Version="3.9.0" /> <PackageReference Include="Testcontainers.EventStoreDb" Version="3.10.0" />
<PackageReference Include="Testcontainers.MongoDb" Version="3.9.0" /> <PackageReference Include="Testcontainers.MongoDb" Version="3.10.0" />
<PackageReference Include="Testcontainers.PostgreSql" Version="3.9.0" /> <PackageReference Include="Testcontainers.PostgreSql" Version="3.10.0" />
<PackageReference Include="Testcontainers.RabbitMq" Version="3.9.0" /> <PackageReference Include="Testcontainers.RabbitMq" Version="3.10.0" />
<PackageReference Include="Unchase.Swashbuckle.AspNetCore.Extensions" Version="2.7.1" /> <PackageReference Include="Unchase.Swashbuckle.AspNetCore.Extensions" Version="2.7.1" />
<PackageReference Include="Yarp.ReverseProxy" Version="2.1.0" /> <PackageReference Include="Yarp.ReverseProxy" Version="2.2.0" />
<PackageReference Include="prometheus-net" Version="8.2.1" /> <PackageReference Include="prometheus-net" Version="8.2.1" />
<PackageReference Include="prometheus-net.AspNetCore" Version="8.2.1" /> <PackageReference Include="prometheus-net.AspNetCore" Version="8.2.1" />
@ -99,30 +92,19 @@
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.9.0" /> <PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.9.0" /> <PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.9.0" />
<PackageReference Include="EventStore.Client.Grpc.Streams" Version="23.3.3" /> <PackageReference Include="EventStore.Client.Grpc.Streams" Version="23.3.5" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4" /> <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4" />
<PackageReference Include="AutoBogus" Version="2.13.1" /> <PackageReference Include="AutoBogus" Version="2.13.1" />
<PackageReference Include="Bogus" Version="35.6.0" /> <PackageReference Include="Bogus" Version="35.6.1" />
<PackageReference Include="FluentAssertions" Version="6.12.0" /> <PackageReference Include="FluentAssertions" Version="6.12.1" />
<PackageReference Include="Respawn" Version="6.2.1" /> <PackageReference Include="Respawn" Version="6.2.1" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="8.0.7" /> <PackageReference Include="Microsoft.AspNetCore.TestHost" Version="8.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.7" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.8" />
<PackageReference Include="WebMotions.Fake.Authentication.JwtBearer" Version="8.0.1" /> <PackageReference Include="WebMotions.Fake.Authentication.JwtBearer" Version="8.0.1" />
<PackageReference Include="Google.Protobuf" Version="3.27.2" /> <PackageReference Include="Google.Protobuf" Version="3.28.1" />
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.64.0" /> <PackageReference Include="Grpc.Net.ClientFactory" Version="2.65.0" />
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.10.48">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Update="Meziantou.Analyzer" Version="2.0.146" />
<PackageReference Update="AsyncFixer" Version="1.6.0" />
<PackageReference Update="Roslynator.Analyzers" Version="4.12.0" />
<PackageReference Update="Roslynator.CodeAnalysis.Analyzers" Version="4.11.0" />
<PackageReference Update="Roslynator.Formatting.Analyzers" Version="4.12.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -1,4 +1,4 @@
using EasyCaching.Core; using EasyCaching.Core;
using MediatR; using MediatR;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;

View File

@ -1,4 +1,4 @@
using MediatR; using MediatR;
namespace BuildingBlocks.Core.CQRS; namespace BuildingBlocks.Core.CQRS;

View File

@ -1,4 +1,4 @@
using MediatR; using MediatR;
namespace BuildingBlocks.Core.CQRS; namespace BuildingBlocks.Core.CQRS;

View File

@ -1,4 +1,4 @@
using MediatR; using MediatR;
namespace BuildingBlocks.Core.CQRS; namespace BuildingBlocks.Core.CQRS;

View File

@ -1,4 +1,4 @@
using MediatR; using MediatR;
namespace BuildingBlocks.Core.CQRS; namespace BuildingBlocks.Core.CQRS;

View File

@ -1,4 +1,4 @@
namespace BuildingBlocks.Core.Event; namespace BuildingBlocks.Core.Event;
public interface IInternalCommand : IEvent public interface IInternalCommand : IEvent
{ {

View File

@ -1,4 +1,4 @@
using BuildingBlocks.Core.CQRS; using BuildingBlocks.Core.CQRS;
namespace BuildingBlocks.Core.Event; namespace BuildingBlocks.Core.Event;

View File

@ -1,4 +1,4 @@
using Google.Protobuf; using Google.Protobuf;
namespace BuildingBlocks.Core.Event; namespace BuildingBlocks.Core.Event;

View File

@ -83,7 +83,7 @@ public sealed class EventDispatcher : IEventDispatcher
public async Task SendAsync<T>(T @event, Type type = null, public async Task SendAsync<T>(T @event, Type type = null,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
where T : IEvent => where T : IEvent =>
await SendAsync(new[] {@event}, type, cancellationToken); await SendAsync(new[] { @event }, type, cancellationToken);
private Task<IReadOnlyList<IIntegrationEvent>> MapDomainEventToIntegrationEventAsync( private Task<IReadOnlyList<IIntegrationEvent>> MapDomainEventToIntegrationEventAsync(
@ -104,7 +104,8 @@ public sealed class EventDispatcher : IEventDispatcher
var integrationEvent = _eventMapper.MapToIntegrationEvent(@event); var integrationEvent = _eventMapper.MapToIntegrationEvent(@event);
if (integrationEvent is null) continue; if (integrationEvent is null)
continue;
integrationEvents.Add(integrationEvent); integrationEvents.Add(integrationEvent);
} }
@ -129,7 +130,8 @@ public sealed class EventDispatcher : IEventDispatcher
var integrationEvent = _eventMapper.MapToInternalCommand(@event); var integrationEvent = _eventMapper.MapToInternalCommand(@event);
if (integrationEvent is null) continue; if (integrationEvent is null)
continue;
internalCommands.Add(integrationEvent); internalCommands.Add(integrationEvent);
} }

View File

@ -1,4 +1,4 @@
using BuildingBlocks.Core.Event; using BuildingBlocks.Core.Event;
namespace BuildingBlocks.Core.Model; namespace BuildingBlocks.Core.Model;

View File

@ -1,4 +1,4 @@
namespace BuildingBlocks.Core.Model; namespace BuildingBlocks.Core.Model;
public abstract record Entity<T> : IEntity<T> public abstract record Entity<T> : IEntity<T>
{ {

View File

@ -1,4 +1,4 @@
using BuildingBlocks.Core.Event; using BuildingBlocks.Core.Event;
namespace BuildingBlocks.Core.Model; namespace BuildingBlocks.Core.Model;

View File

@ -1,11 +1,11 @@
namespace BuildingBlocks.Core.Model; namespace BuildingBlocks.Core.Model;
public interface IEntity<T> : IEntity public interface IEntity<T> : IEntity
{ {
public T Id { get; set; } public T Id { get; set; }
} }
public interface IEntity: IVersion public interface IEntity : IVersion
{ {
public DateTime? CreatedAt { get; set; } public DateTime? CreatedAt { get; set; }
public long? CreatedBy { get; set; } public long? CreatedBy { get; set; }

View File

@ -1,4 +1,4 @@
namespace BuildingBlocks.Core.Model; namespace BuildingBlocks.Core.Model;
// For handling optimistic concurrency // For handling optimistic concurrency
public interface IVersion public interface IVersion

View File

@ -1,4 +1,4 @@
namespace BuildingBlocks.Core.Pagination; namespace BuildingBlocks.Core.Pagination;
using Sieve.Models; using Sieve.Models;
using Sieve.Services; using Sieve.Services;

View File

@ -1,4 +1,4 @@
namespace BuildingBlocks.Core.Pagination; namespace BuildingBlocks.Core.Pagination;
public interface IPageList<T> public interface IPageList<T>
where T : class where T : class

View File

@ -1,6 +1,7 @@
namespace BuildingBlocks.Core.Pagination; namespace BuildingBlocks.Core.Pagination;
using MediatR; using MediatR;
public interface IPageQuery<out TResponse> : IPageRequest, IRequest<TResponse> public interface IPageQuery<out TResponse> : IPageRequest, IRequest<TResponse>
where TResponse : class { } where TResponse : class
{ }

View File

@ -1,4 +1,4 @@
namespace BuildingBlocks.Core.Pagination; namespace BuildingBlocks.Core.Pagination;
public interface IPageRequest public interface IPageRequest
{ {

View File

@ -1,4 +1,4 @@
namespace BuildingBlocks.Core.Pagination; namespace BuildingBlocks.Core.Pagination;
public record PageList<T>(IReadOnlyList<T> Items, int PageNumber, int PageSize, int TotalCount) : IPageList<T> public record PageList<T>(IReadOnlyList<T> Items, int PageNumber, int PageSize, int TotalCount) : IPageList<T>
where T : class where T : class

View File

@ -32,7 +32,8 @@ public abstract class AppDbContextBase : DbContext, IDbContext
public async Task BeginTransactionAsync(CancellationToken cancellationToken = default) public async Task BeginTransactionAsync(CancellationToken cancellationToken = default)
{ {
if (_currentTransaction != null) return; if (_currentTransaction != null)
return;
_currentTransaction = await Database.BeginTransactionAsync(IsolationLevel.ReadCommitted, cancellationToken); _currentTransaction = await Database.BeginTransactionAsync(IsolationLevel.ReadCommitted, cancellationToken);
} }

View File

@ -6,7 +6,7 @@ using Microsoft.Extensions.Configuration;
namespace BuildingBlocks.EFCore namespace BuildingBlocks.EFCore
{ {
public abstract class DesignTimeDbContextFactoryBase<TContext> : IDesignTimeDbContextFactory<TContext> where TContext : DbContext public abstract class DesignTimeDbContextFactoryBase<TContext> : IDesignTimeDbContextFactory<TContext> where TContext : DbContext
{ {
public TContext CreateDbContext(string[] args) public TContext CreateDbContext(string[] args)
{ {

View File

@ -50,9 +50,9 @@ public class EfTxBehavior<TRequest, TResponse> : IPipelineBehavior<TRequest, TRe
typeof(TRequest).FullName); typeof(TRequest).FullName);
//ref: https://learn.microsoft.com/en-us/ef/core/saving/transactions#using-systemtransactions //ref: https://learn.microsoft.com/en-us/ef/core/saving/transactions#using-systemtransactions
using var scope = new TransactionScope(TransactionScopeOption.Required, using var scope = new TransactionScope(TransactionScopeOption.Required,
new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted }, new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted },
TransactionScopeAsyncFlowOption.Enabled); TransactionScopeAsyncFlowOption.Enabled);
var response = await next(); var response = await next();

View File

@ -1,4 +1,4 @@
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace BuildingBlocks.EventStoreDB.BackgroundWorkers; namespace BuildingBlocks.EventStoreDB.BackgroundWorkers;

View File

@ -29,7 +29,7 @@ public static class EventStoreDBConfigExtensions
{ {
services services
.AddSingleton(x=> .AddSingleton(x =>
{ {
var eventStoreOptions = services.GetOptions<EventStoreOptions>(nameof(EventStoreOptions)); var eventStoreOptions = services.GetOptions<EventStoreOptions>(nameof(EventStoreOptions));
return new EventStoreClient(EventStoreClientSettings.Create(eventStoreOptions.ConnectionString)); return new EventStoreClient(EventStoreClientSettings.Create(eventStoreOptions.ConnectionString));

View File

@ -1,4 +1,4 @@
using BuildingBlocks.Core.Event; using BuildingBlocks.Core.Event;
using BuildingBlocks.Core.Model; using BuildingBlocks.Core.Model;
namespace BuildingBlocks.EventStoreDB.Events namespace BuildingBlocks.EventStoreDB.Events

View File

@ -1,4 +1,4 @@
using BuildingBlocks.EventStoreDB.Serialization; using BuildingBlocks.EventStoreDB.Serialization;
using EventStore.Client; using EventStore.Client;
namespace BuildingBlocks.EventStoreDB.Events; namespace BuildingBlocks.EventStoreDB.Events;

View File

@ -1,4 +1,4 @@
using System.Collections.Concurrent; using System.Collections.Concurrent;
using BuildingBlocks.Utils; using BuildingBlocks.Utils;
namespace BuildingBlocks.EventStoreDB.Events; namespace BuildingBlocks.EventStoreDB.Events;

View File

@ -3,7 +3,7 @@ using MediatR;
namespace BuildingBlocks.EventStoreDB.Events; namespace BuildingBlocks.EventStoreDB.Events;
public interface IEventHandler<in TEvent>: INotificationHandler<TEvent> public interface IEventHandler<in TEvent> : INotificationHandler<TEvent>
where TEvent : IEvent where TEvent : IEvent
{ {
} }

View File

@ -2,6 +2,6 @@ using BuildingBlocks.Core.Event;
namespace BuildingBlocks.EventStoreDB.Events; namespace BuildingBlocks.EventStoreDB.Events;
public interface IExternalEvent: IEvent public interface IExternalEvent : IEvent
{ {
} }

View File

@ -1,4 +1,4 @@
namespace BuildingBlocks.EventStoreDB.Events; namespace BuildingBlocks.EventStoreDB.Events;
public interface IProjection public interface IProjection
{ {

View File

@ -1,4 +1,4 @@
using BuildingBlocks.Core.Event; using BuildingBlocks.Core.Event;
namespace BuildingBlocks.EventStoreDB.Events; namespace BuildingBlocks.EventStoreDB.Events;
@ -7,7 +7,7 @@ public record EventMetadata(
ulong LogPosition ulong LogPosition
); );
public class StreamEvent: IEvent public class StreamEvent : IEvent
{ {
public object Data { get; } public object Data { get; }
public EventMetadata Metadata { get; } public EventMetadata Metadata { get; }
@ -19,7 +19,7 @@ public class StreamEvent: IEvent
} }
} }
public class StreamEvent<T>: StreamEvent where T: notnull public class StreamEvent<T> : StreamEvent where T : notnull
{ {
public new T Data => (T)base.Data; public new T Data => (T)base.Data;

View File

@ -1,4 +1,4 @@
using System.Diagnostics.Eventing.Reader; using System.Diagnostics.Eventing.Reader;
using BuildingBlocks.EventStoreDB.Serialization; using BuildingBlocks.EventStoreDB.Serialization;
using EventStore.Client; using EventStore.Client;

View File

@ -1,4 +1,4 @@
using System.Collections.Concurrent; using System.Collections.Concurrent;
namespace BuildingBlocks.EventStoreDB.Events; namespace BuildingBlocks.EventStoreDB.Events;
@ -20,7 +20,7 @@ public class StreamNameMapper
public static string ToStreamId(Type streamType, object aggregateId, object? tenantId = null) public static string ToStreamId(Type streamType, object aggregateId, object? tenantId = null)
{ {
var tenantPrefix = tenantId != null ? $"{tenantId}_" : ""; var tenantPrefix = tenantId != null ? $"{tenantId}_" : "";
return $"{tenantPrefix}{streamType.Name}-{aggregateId}"; return $"{tenantPrefix}{streamType.Name}-{aggregateId}";
} }

View File

@ -1,4 +1,4 @@
using System.Reflection; using System.Reflection;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;

View File

@ -1,4 +1,4 @@
using BuildingBlocks.EventStoreDB.Events; using BuildingBlocks.EventStoreDB.Events;
using BuildingBlocks.EventStoreDB.Serialization; using BuildingBlocks.EventStoreDB.Serialization;
using EventStore.Client; using EventStore.Client;

View File

@ -28,6 +28,6 @@ public static class RepositoryExtensions
action(entity); action(entity);
return await repository.Update(entity, expectedVersion,cancellationToken); return await repository.Update(entity, expectedVersion, cancellationToken);
} }
} }

View File

@ -1,4 +1,4 @@
using System.Text; using System.Text;
using BuildingBlocks.EventStoreDB.Events; using BuildingBlocks.EventStoreDB.Events;
using EventStore.Client; using EventStore.Client;
using Newtonsoft.Json; using Newtonsoft.Json;

View File

@ -1,4 +1,4 @@
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Reflection; using System.Reflection;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Serialization;
@ -18,7 +18,8 @@ public static class JsonObjectContractProvider
{ {
var nonDefaultConstructor = GetNonDefaultConstructor(objectType); var nonDefaultConstructor = GetNonDefaultConstructor(objectType);
if (nonDefaultConstructor == null) return contract; if (nonDefaultConstructor == null)
return contract;
contract.OverrideCreator = GetObjectConstructor(nonDefaultConstructor); contract.OverrideCreator = GetObjectConstructor(nonDefaultConstructor);
contract.CreatorParameters.Clear(); contract.CreatorParameters.Clear();

View File

@ -1,8 +1,8 @@
using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Serialization;
namespace BuildingBlocks.EventStoreDB.Serialization; namespace BuildingBlocks.EventStoreDB.Serialization;
public class NonDefaultConstructorContractResolver: DefaultContractResolver public class NonDefaultConstructorContractResolver : DefaultContractResolver
{ {
protected override JsonObjectContract CreateObjectContract(Type objectType) protected override JsonObjectContract CreateObjectContract(Type objectType)
{ {

View File

@ -1,13 +1,13 @@
using BuildingBlocks.Core.Event; using BuildingBlocks.Core.Event;
using BuildingBlocks.EventStoreDB.Events; using BuildingBlocks.EventStoreDB.Events;
using BuildingBlocks.EventStoreDB.Serialization; using BuildingBlocks.EventStoreDB.Serialization;
using EventStore.Client; using EventStore.Client;
namespace BuildingBlocks.EventStoreDB.Subscriptions; namespace BuildingBlocks.EventStoreDB.Subscriptions;
public record CheckpointStored(string SubscriptionId, ulong? Position, DateTime CheckpointedAt): IEvent; public record CheckpointStored(string SubscriptionId, ulong? Position, DateTime CheckpointedAt) : IEvent;
public class EventStoreDBSubscriptionCheckpointRepository: ISubscriptionCheckpointRepository public class EventStoreDBSubscriptionCheckpointRepository : ISubscriptionCheckpointRepository
{ {
private readonly EventStoreClient eventStoreClient; private readonly EventStoreClient eventStoreClient;
@ -37,7 +37,7 @@ public class EventStoreDBSubscriptionCheckpointRepository: ISubscriptionCheckpoi
public async ValueTask Store(string subscriptionId, ulong position, CancellationToken ct) public async ValueTask Store(string subscriptionId, ulong position, CancellationToken ct)
{ {
var @event = new CheckpointStored(subscriptionId, position, DateTime.UtcNow); var @event = new CheckpointStored(subscriptionId, position, DateTime.UtcNow);
var eventToAppend = new[] {@event.ToJsonEventData()}; var eventToAppend = new[] { @event.ToJsonEventData() };
var streamName = GetCheckpointStreamName(subscriptionId); var streamName = GetCheckpointStreamName(subscriptionId);
try try

View File

@ -79,7 +79,8 @@ public class EventStoreDBSubscriptionToAll
{ {
try try
{ {
if (IsEventWithEmptyData(resolvedEvent) || IsCheckpointEvent(resolvedEvent)) return; if (IsEventWithEmptyData(resolvedEvent) || IsCheckpointEvent(resolvedEvent))
return;
var streamEvent = resolvedEvent.ToStreamEvent(); var streamEvent = resolvedEvent.ToStreamEvent();
@ -123,7 +124,7 @@ public class EventStoreDBSubscriptionToAll
reason reason
); );
if (exception is RpcException {StatusCode: StatusCode.Cancelled}) if (exception is RpcException { StatusCode: StatusCode.Cancelled })
return; return;
Resubscribe(); Resubscribe();
@ -172,7 +173,8 @@ public class EventStoreDBSubscriptionToAll
private bool IsEventWithEmptyData(ResolvedEvent resolvedEvent) private bool IsEventWithEmptyData(ResolvedEvent resolvedEvent)
{ {
if (resolvedEvent.Event.Data.Length != 0) return false; if (resolvedEvent.Event.Data.Length != 0)
return false;
logger.LogInformation("Event without data received"); logger.LogInformation("Event without data received");
return true; return true;
@ -180,7 +182,8 @@ public class EventStoreDBSubscriptionToAll
private bool IsCheckpointEvent(ResolvedEvent resolvedEvent) private bool IsCheckpointEvent(ResolvedEvent resolvedEvent)
{ {
if (resolvedEvent.Event.EventType != EventTypeMapper.ToName<CheckpointStored>()) return false; if (resolvedEvent.Event.EventType != EventTypeMapper.ToName<CheckpointStored>())
return false;
logger.LogInformation("Checkpoint event - ignoring"); logger.LogInformation("Checkpoint event - ignoring");
return true; return true;

View File

@ -1,4 +1,4 @@
namespace BuildingBlocks.EventStoreDB.Subscriptions; namespace BuildingBlocks.EventStoreDB.Subscriptions;
public interface ISubscriptionCheckpointRepository public interface ISubscriptionCheckpointRepository
{ {

View File

@ -1,4 +1,4 @@
using System.Collections.Concurrent; using System.Collections.Concurrent;
namespace BuildingBlocks.EventStoreDB.Subscriptions; namespace BuildingBlocks.EventStoreDB.Subscriptions;

View File

@ -17,7 +17,7 @@ public class AppException : CustomException
{ {
} }
public AppException(string message, System.Exception innerException, int? code = null) : base(message, innerException, code: code) public AppException(string message, System.Exception innerException, int? code = null) : base(message, innerException, code: code)
{ {
} }
} }

View File

@ -11,7 +11,7 @@ namespace BuildingBlocks.Exception
public InternalServerException(string message, int? code) : base(message, HttpStatusCode.InternalServerError, code: code) { } public InternalServerException(string message, int? code) : base(message, HttpStatusCode.InternalServerError, code: code) { }
public InternalServerException(string message, int? code = null, params object[] args) public InternalServerException(string message, int? code = null, params object[] args)
: base(message:String.Format(CultureInfo.CurrentCulture, message, args, HttpStatusCode.InternalServerError, code)) : base(message: String.Format(CultureInfo.CurrentCulture, message, args, HttpStatusCode.InternalServerError, code))
{ {
} }
} }

View File

@ -1,4 +1,4 @@
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
namespace BuildingBlocks.Exception; namespace BuildingBlocks.Exception;

View File

@ -1,4 +1,4 @@
using BuildingBlocks.EFCore; using BuildingBlocks.EFCore;
using BuildingBlocks.Logging; using BuildingBlocks.Logging;
using BuildingBlocks.MassTransit; using BuildingBlocks.MassTransit;
using BuildingBlocks.Mongo; using BuildingBlocks.Mongo;
@ -18,7 +18,8 @@ public static class Extensions
{ {
var healthOptions = services.GetOptions<HealthOptions>(nameof(HealthOptions)); var healthOptions = services.GetOptions<HealthOptions>(nameof(HealthOptions));
if (!healthOptions.Enabled) return services; if (!healthOptions.Enabled)
return services;
var appOptions = services.GetOptions<AppOptions>(nameof(AppOptions)); var appOptions = services.GetOptions<AppOptions>(nameof(AppOptions));
var postgresOptions = services.GetOptions<PostgresOptions>(nameof(PostgresOptions)); var postgresOptions = services.GetOptions<PostgresOptions>(nameof(PostgresOptions));
@ -51,7 +52,8 @@ public static class Extensions
{ {
var healthOptions = app.Configuration.GetOptions<HealthOptions>(nameof(HealthOptions)); var healthOptions = app.Configuration.GetOptions<HealthOptions>(nameof(HealthOptions));
if (!healthOptions.Enabled) return app; if (!healthOptions.Enabled)
return app;
app.UseHealthChecks("/healthz", app.UseHealthChecks("/healthz",
new HealthCheckOptions new HealthCheckOptions

View File

@ -1,4 +1,4 @@
namespace BuildingBlocks.HealthCheck; namespace BuildingBlocks.HealthCheck;
public class HealthOptions public class HealthOptions
{ {

View File

@ -13,10 +13,11 @@ public static class JwtExtensions
{ {
var jwtOptions = services.GetOptions<JwtBearerOptions>("Jwt"); var jwtOptions = services.GetOptions<JwtBearerOptions>("Jwt");
services.AddAuthentication(o => { services.AddAuthentication(o =>
o.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; {
o.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; o.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
}) o.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddCookie(cfg => cfg.SlidingExpiration = true) .AddCookie(cfg => cfg.SlidingExpiration = true)
.AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, options => .AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, options =>
{ {
@ -27,7 +28,7 @@ public static class JwtExtensions
ClockSkew = TimeSpan.FromSeconds(2) // For prevent add default value (5min) to life time token! ClockSkew = TimeSpan.FromSeconds(2) // For prevent add default value (5min) to life time token!
}; };
options.RequireHttpsMetadata = jwtOptions.RequireHttpsMetadata; options.RequireHttpsMetadata = jwtOptions.RequireHttpsMetadata;
options.MetadataAddress= jwtOptions.MetadataAddress; options.MetadataAddress = jwtOptions.MetadataAddress;
}); });
if (!string.IsNullOrEmpty(jwtOptions.Audience)) if (!string.IsNullOrEmpty(jwtOptions.Audience))

View File

@ -1,4 +1,4 @@
namespace BuildingBlocks.Logging; namespace BuildingBlocks.Logging;
public class ElasticOptions public class ElasticOptions
{ {

View File

@ -1,4 +1,4 @@
using System.Text; using System.Text;
using BuildingBlocks.Web; using BuildingBlocks.Web;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
@ -49,7 +49,7 @@ namespace BuildingBlocks.Logging
} }
if (logOptions?.Sentry is {Enabled: true}) if (logOptions?.Sentry is { Enabled: true })
{ {
var minimumBreadcrumbLevel = Enum.TryParse<LogEventLevel>(logOptions.Level, true, out var minBreadcrumbLevel) var minimumBreadcrumbLevel = Enum.TryParse<LogEventLevel>(logOptions.Level, true, out var minBreadcrumbLevel)
? minBreadcrumbLevel ? minBreadcrumbLevel

View File

@ -1,4 +1,4 @@
namespace BuildingBlocks.Logging; namespace BuildingBlocks.Logging;
public class FileOptions public class FileOptions
{ {

View File

@ -1,4 +1,4 @@
using System.Security.Claims; using System.Security.Claims;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Serilog; using Serilog;
@ -17,7 +17,7 @@ public static class LogEnrichHelper
diagnosticContext.Set("Scheme", request.Scheme); diagnosticContext.Set("Scheme", request.Scheme);
// Only set it if available. You're not sending sensitive data in a querystring right?! // Only set it if available. You're not sending sensitive data in a querystring right?!
if(request.QueryString.HasValue) if (request.QueryString.HasValue)
{ {
diagnosticContext.Set("QueryString", request.QueryString.Value); diagnosticContext.Set("QueryString", request.QueryString.Value);
} }

View File

@ -1,4 +1,4 @@
namespace BuildingBlocks.Logging namespace BuildingBlocks.Logging
{ {
public class LogOptions public class LogOptions
{ {

View File

@ -1,4 +1,4 @@
namespace BuildingBlocks.Logging; namespace BuildingBlocks.Logging;
public class SentryOptions public class SentryOptions
{ {

View File

@ -1,4 +1,4 @@
using BuildingBlocks.Core.Event; using BuildingBlocks.Core.Event;
using BuildingBlocks.PersistMessageProcessor; using BuildingBlocks.PersistMessageProcessor;
using MassTransit; using MassTransit;

View File

@ -1,4 +1,4 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace BuildingBlocks.PersistMessageProcessor.Data.Configurations; namespace BuildingBlocks.PersistMessageProcessor.Data.Configurations;

View File

@ -1,4 +1,4 @@
using BuildingBlocks.EFCore; using BuildingBlocks.EFCore;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace BuildingBlocks.PersistMessageProcessor.Data; namespace BuildingBlocks.PersistMessageProcessor.Data;

View File

@ -1,4 +1,4 @@
using BuildingBlocks.PersistMessageProcessor.Data; using BuildingBlocks.PersistMessageProcessor.Data;
using BuildingBlocks.Web; using BuildingBlocks.Web;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;

View File

@ -1,4 +1,4 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace BuildingBlocks.PersistMessageProcessor; namespace BuildingBlocks.PersistMessageProcessor;

View File

@ -1,4 +1,4 @@
using System.Linq.Expressions; using System.Linq.Expressions;
using BuildingBlocks.Core.Event; using BuildingBlocks.Core.Event;
namespace BuildingBlocks.PersistMessageProcessor; namespace BuildingBlocks.PersistMessageProcessor;

View File

@ -1,4 +1,4 @@
namespace BuildingBlocks.PersistMessageProcessor; namespace BuildingBlocks.PersistMessageProcessor;
[Flags] [Flags]
public enum MessageDeliveryType public enum MessageDeliveryType

View File

@ -1,4 +1,4 @@
namespace BuildingBlocks.PersistMessageProcessor; namespace BuildingBlocks.PersistMessageProcessor;
public enum MessageStatus public enum MessageStatus
{ {

View File

@ -1,8 +1,8 @@
namespace BuildingBlocks.PersistMessageProcessor; namespace BuildingBlocks.PersistMessageProcessor;
using Core.Model; using Core.Model;
public class PersistMessage: IVersion public class PersistMessage : IVersion
{ {
public PersistMessage(Guid id, string dataType, string data, MessageDeliveryType deliveryType) public PersistMessage(Guid id, string dataType, string data, MessageDeliveryType deliveryType)
{ {

View File

@ -1,4 +1,4 @@
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;

View File

@ -1,4 +1,4 @@
namespace BuildingBlocks.PersistMessageProcessor; namespace BuildingBlocks.PersistMessageProcessor;
public class PersistMessageOptions public class PersistMessageOptions
{ {

View File

@ -1,4 +1,4 @@
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Text.Json; using System.Text.Json;
using Ardalis.GuardClauses; using Ardalis.GuardClauses;
using BuildingBlocks.Core.Event; using BuildingBlocks.Core.Event;
@ -145,7 +145,8 @@ public class PersistMessageProcessor : IPersistMessageProcessor
await _publishEndpoint.Publish(data, context => await _publishEndpoint.Publish(data, context =>
{ {
foreach (var header in messageEnvelope.Headers) context.Headers.Set(header.Key, header.Value); foreach (var header in messageEnvelope.Headers)
context.Headers.Set(header.Key, header.Value);
}, cancellationToken); }, cancellationToken);
_logger.LogInformation( _logger.LogInformation(

View File

@ -1,4 +1,4 @@
namespace BuildingBlocks.Polly; namespace BuildingBlocks.Polly;
using global::Polly; using global::Polly;
using Serilog; using Serilog;

View File

@ -1,4 +1,4 @@
namespace BuildingBlocks.Polly; namespace BuildingBlocks.Polly;
using System.Net; using System.Net;
using Ardalis.GuardClauses; using Ardalis.GuardClauses;

View File

@ -1,4 +1,4 @@
namespace BuildingBlocks.Polly; namespace BuildingBlocks.Polly;
using System.Net; using System.Net;
using Ardalis.GuardClauses; using Ardalis.GuardClauses;

View File

@ -1,4 +1,4 @@
namespace BuildingBlocks.Polly; namespace BuildingBlocks.Polly;
using System.Net; using System.Net;
using Ardalis.GuardClauses; using Ardalis.GuardClauses;

View File

@ -1,4 +1,4 @@
namespace BuildingBlocks.Polly; namespace BuildingBlocks.Polly;
using System.Net; using System.Net;
using Ardalis.GuardClauses; using Ardalis.GuardClauses;

View File

@ -1,4 +1,4 @@
namespace BuildingBlocks.Polly; namespace BuildingBlocks.Polly;
public class PolicyOptions public class PolicyOptions
{ {

View File

@ -1,4 +1,4 @@
namespace BuildingBlocks.ProblemDetails; namespace BuildingBlocks.ProblemDetails;
using Exception; using Exception;
using Grpc.Core; using Grpc.Core;

View File

@ -1,4 +1,4 @@
using System.Text; using System.Text;
using Asp.Versioning; using Asp.Versioning;
using Asp.Versioning.ApiExplorer; using Asp.Versioning.ApiExplorer;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
@ -42,8 +42,8 @@ public class ConfigureSwaggerOptions : IConfigureOptions<SwaggerGenOptions>
Version = description.ApiVersion.ToString(), Version = description.ApiVersion.ToString(),
Title = _options?.Title ?? "APIs", Title = _options?.Title ?? "APIs",
Description = "An application with Swagger, Swashbuckle, and API versioning.", Description = "An application with Swagger, Swashbuckle, and API versioning.",
Contact = new OpenApiContact {Name = "", Email = ""}, Contact = new OpenApiContact { Name = "", Email = "" },
License = new OpenApiLicense {Name = "MIT", Url = new Uri("https://opensource.org/licenses/MIT")} License = new OpenApiLicense { Name = "MIT", Url = new Uri("https://opensource.org/licenses/MIT") }
}; };
if (description.IsDeprecated) if (description.IsDeprecated)

View File

@ -1,4 +1,4 @@
using System.Reflection; using System.Reflection;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
@ -33,7 +33,8 @@ public static class ServiceCollectionExtensions
{ {
var xmlFile = XmlCommentsFilePath(assembly); var xmlFile = XmlCommentsFilePath(assembly);
if (File.Exists(xmlFile)) options.IncludeXmlComments(xmlFile); if (File.Exists(xmlFile))
options.IncludeXmlComments(xmlFile);
} }
options.AddEnumsWithValuesFixFilters(); options.AddEnumsWithValuesFixFilters();

View File

@ -1,4 +1,4 @@
using System.Linq; using System.Linq;
using Humanizer; using Humanizer;
using Microsoft.AspNetCore.Mvc.ApiExplorer; using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models;
@ -59,7 +59,7 @@ namespace BuildingBlocks.Swagger
{ {
// REF: https://github.com/Microsoft/aspnet-api-versioning/issues/429#issuecomment-605402330 // REF: https://github.com/Microsoft/aspnet-api-versioning/issues/429#issuecomment-605402330
var json = JsonConvert.SerializeObject(description.DefaultValue, description.ModelMetadata var json = JsonConvert.SerializeObject(description.DefaultValue, description.ModelMetadata
.ModelType, new JsonSerializerSettings {ReferenceLoopHandling = ReferenceLoopHandling.Ignore}); .ModelType, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
parameter.Schema.Default = OpenApiAnyFactory.CreateFromJson(json); parameter.Schema.Default = OpenApiAnyFactory.CreateFromJson(json);
} }

View File

@ -1,4 +1,6 @@
using Ardalis.GuardClauses; using System.Net;
using System.Security.Claims;
using Ardalis.GuardClauses;
using BuildingBlocks.Core.Event; using BuildingBlocks.Core.Event;
using BuildingBlocks.Core.Model; using BuildingBlocks.Core.Model;
using BuildingBlocks.EFCore; using BuildingBlocks.EFCore;
@ -20,12 +22,10 @@ using MongoDB.Driver;
using NSubstitute; using NSubstitute;
using Respawn; using Respawn;
using Serilog; using Serilog;
using WebMotions.Fake.Authentication.JwtBearer;
using Xunit; using Xunit;
using Xunit.Abstractions; using Xunit.Abstractions;
using ILogger = Serilog.ILogger; using ILogger = Serilog.ILogger;
using System.Net;
using System.Security.Claims;
using WebMotions.Fake.Authentication.JwtBearer;
namespace BuildingBlocks.TestBase; namespace BuildingBlocks.TestBase;

View File

@ -1,4 +1,4 @@
namespace BuildingBlocks.TestBase; namespace BuildingBlocks.TestBase;
using Testcontainers.EventStoreDb; using Testcontainers.EventStoreDb;
using Testcontainers.MongoDb; using Testcontainers.MongoDb;

View File

@ -1,4 +1,4 @@
namespace BuildingBlocks.Utils; namespace BuildingBlocks.Utils;
public static class NoSynchronizationContextScope public static class NoSynchronizationContextScope
{ {
@ -9,7 +9,7 @@ public static class NoSynchronizationContextScope
return new Disposable(context); return new Disposable(context);
} }
public struct Disposable: IDisposable public struct Disposable : IDisposable
{ {
private readonly SynchronizationContext? synchronizationContext; private readonly SynchronizationContext? synchronizationContext;

View File

@ -1,4 +1,4 @@
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
namespace BuildingBlocks.Utils; namespace BuildingBlocks.Utils;

View File

@ -1,4 +1,4 @@
using Asp.Versioning; using Asp.Versioning;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
namespace BuildingBlocks.Web; namespace BuildingBlocks.Web;

View File

@ -1,4 +1,4 @@
using Asp.Versioning; using Asp.Versioning;
using MediatR; using MediatR;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;

View File

@ -1,4 +1,4 @@
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
namespace BuildingBlocks.Web namespace BuildingBlocks.Web
{ {

View File

@ -1,4 +1,4 @@
using System.Security.Claims; using System.Security.Claims;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
namespace BuildingBlocks.Web; namespace BuildingBlocks.Web;

View File

@ -1,4 +1,4 @@
using Asp.Versioning.Builder; using Asp.Versioning.Builder;
namespace BuildingBlocks.Web; namespace BuildingBlocks.Web;

View File

@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Routing; using Microsoft.AspNetCore.Routing;
namespace BuildingBlocks.Web; namespace BuildingBlocks.Web;

View File

@ -1,4 +1,4 @@
using System.Reflection; using System.Reflection;
using BuildingBlocks.Utils; using BuildingBlocks.Utils;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Routing; using Microsoft.AspNetCore.Routing;

View File

@ -1,4 +1,4 @@
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using NSubstitute; using NSubstitute;
namespace BuildingBlocks.Web; namespace BuildingBlocks.Web;

View File

@ -1,4 +1,4 @@
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
namespace BuildingBlocks.Web; namespace BuildingBlocks.Web;

View File

@ -1,11 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Booking\Booking.csproj" /> <ProjectReference Include="..\Booking\Booking.csproj" />
</ItemGroup> </ItemGroup>

View File

@ -12,7 +12,7 @@ builder.Host.UseDefaultServiceProvider((context, options) =>
options.ValidateOnBuild = true; options.ValidateOnBuild = true;
}); });
builder.AddMinimalEndpoints(assemblies:typeof(BookingRoot).Assembly); builder.AddMinimalEndpoints(assemblies: typeof(BookingRoot).Assembly);
builder.AddInfrastructure(); builder.AddInfrastructure();
var app = builder.Build(); var app = builder.Build();

View File

@ -1,21 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\..\BuildingBlocks\BuildingBlocks.csproj" /> <ProjectReference Include="..\..\..\..\BuildingBlocks\BuildingBlocks.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Grpc.Tools" Version="2.65.0"> <PackageReference Include="Grpc.Tools" Version="2.66.0">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.7"> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.8">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>

Some files were not shown because too many files have changed in this diff Show More