feat: ajustes e refinamentos

This commit is contained in:
Jean Gatto
2023-09-16 12:33:10 -03:00
parent 963eb15426
commit 1674b21276
7 changed files with 22 additions and 93 deletions
-34
View File
@@ -1,34 +0,0 @@
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/src/Shop.PublicApi/bin/Debug/net7.0/Shop.PublicApi.dll",
"args": [],
"cwd": "${workspaceFolder}/src/Shop.PublicApi",
"stopAtEntry": false,
"console": "internalConsole",
"logging": { "moduleLoad": false },
"serverReadyAction": {
"action": "openExternally",
"pattern": "^\\s*Now listening on:\\s+(https?://\\S+)",
"uriFormat": "%s/swagger/"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
-42
View File
@@ -1,42 +0,0 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/src/Shop.PublicApi/Shop.PublicApi.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/src/Shop.PublicApi/Shop.PublicApi.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"${workspaceFolder}/src/Shop.PublicApi/Shop.PublicApi.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}
]
}
+1
View File
@@ -24,6 +24,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.editorconfig = .editorconfig
.gitattributes = .gitattributes
.gitignore = .gitignore
img\cqrs-pattern.png = img\cqrs-pattern.png
Directory.Build.props = Directory.Build.props
Directory.Packages.props = Directory.Packages.props
global.json = global.json
@@ -21,7 +21,7 @@ internal static class ServicesCollectionExtensions
{
private static readonly string[] DatabaseTags = { "database" };
public static void AddSwagger(this IServiceCollection services)
public static void AddSwagger(this IServiceCollection services, IConfiguration configuration)
{
services.AddSwaggerGen(swaggerOptions =>
{
@@ -34,16 +34,12 @@ internal static class ServicesCollectionExtensions
{
Name = "Jean Gatto",
Email = "jean_gatto@hotmail.com",
#pragma warning disable S1075
Url = new Uri("https://www.linkedin.com/in/jeangatto/")
#pragma warning restore S1075
Url = new Uri(configuration.GetValue<string>("Urls:LinkedIn"))
},
License = new OpenApiLicense
{
Name = "MIT License",
#pragma warning disable S1075
Url = new Uri("https://github.com/jeangatto/ASP.NET-Core-Clean-Architecture-CQRS-Event-Sourcing/blob/main/LICENSE")
#pragma warning restore S1075
Url = new Uri(configuration.GetValue<string>("Urls:Github"))
}
});
@@ -55,16 +51,16 @@ internal static class ServicesCollectionExtensions
public static void AddHealthChecks(this IServiceCollection services, IConfiguration configuration)
{
var connectionOptions = configuration.GetOptions<ConnectionOptions>();
var options = configuration.GetOptions<ConnectionOptions>();
var healthCheckBuilder = services
.AddHealthChecks()
.AddDbContextCheck<WriteDbContext>(tags: DatabaseTags)
.AddDbContextCheck<EventStoreDbContext>(tags: DatabaseTags)
.AddMongoDb(connectionOptions.NoSqlConnection, tags: DatabaseTags);
.AddMongoDb(options.NoSqlConnection, tags: DatabaseTags);
if (!connectionOptions.CacheConnectionInMemory())
healthCheckBuilder.AddRedis(connectionOptions.CacheConnection);
if (!options.CacheConnectionInMemory())
healthCheckBuilder.AddRedis(options.CacheConnection);
}
public static IServiceCollection AddWriteDbContext(this IServiceCollection services)
@@ -80,8 +76,8 @@ internal static class ServicesCollectionExtensions
public static IServiceCollection AddCacheService(this IServiceCollection services, IConfiguration configuration)
{
var connectionOptions = configuration.GetOptions<ConnectionOptions>();
if (connectionOptions.CacheConnectionInMemory())
var options = configuration.GetOptions<ConnectionOptions>();
if (options.CacheConnectionInMemory())
{
services
.AddMemoryCache() // ASP.NET Core Memory Cache.
@@ -94,7 +90,7 @@ internal static class ServicesCollectionExtensions
services.AddStackExchangeRedisCache(redisOptions =>
{
redisOptions.InstanceName = "master";
redisOptions.Configuration = connectionOptions.CacheConnection;
redisOptions.Configuration = options.CacheConnection;
}).AddDistributedCacheService(); // Shop Infrastructure Service.
}
@@ -107,10 +103,10 @@ internal static class ServicesCollectionExtensions
QueryTrackingBehavior queryTrackingBehavior) where TContext : DbContext
{
var logger = serviceProvider.GetRequiredService<ILogger<TContext>>();
var connectionOptions = serviceProvider.GetOptions<ConnectionOptions>();
var options = serviceProvider.GetOptions<ConnectionOptions>();
optionsBuilder
.UseSqlServer(connectionOptions.SqlConnection, sqlServerOptions =>
.UseSqlServer(options.SqlConnection, sqlServerOptions =>
{
sqlServerOptions.MigrationsAssembly(Assembly.GetExecutingAssembly().GetName().Name);
sqlServerOptions.EnableRetryOnFailure(3);
+1 -1
View File
@@ -45,7 +45,7 @@ builder.Services
explorerOptions.GroupNameFormat = "'v'VVV";
explorerOptions.SubstituteApiVersionInUrl = true;
})
.AddSwagger();
.AddSwagger(builder.Configuration);
builder.Services.AddControllers()
.ConfigureApiBehaviorOptions(behaviorOptions =>
@@ -6,6 +6,10 @@
"Microsoft.Hosting.Lifetime": "Information"
}
},
"Urls": {
"LinkedIn": "https://www.linkedin.com/in/jeangatto/",
"Github": "https://github.com/jeangatto/ASP.NET-Core-Clean-Architecture-CQRS-Event-Sourcing/blob/main/LICENSE"
},
"ConnectionStrings": {
"SqlConnection": "",
"NoSqlConnection": "",
@@ -6,6 +6,10 @@
"Microsoft.Hosting.Lifetime": "Information"
}
},
"Urls": {
"LinkedIn": "https://www.linkedin.com/in/jeangatto/",
"Github": "https://github.com/jeangatto/ASP.NET-Core-Clean-Architecture-CQRS-Event-Sourcing/blob/main/LICENSE"
},
"ConnectionStrings": {
"SqlConnection": "Server=sqlserver;Integrated Security=true;Initial Catalog=ShopContext;User Id=sa;Password=pMA63033n6tF;Trusted_Connection=false;MultipleActiveResultSets=true;Encrypt=True;TrustServerCertificate=True;",
"NoSqlConnection": "mongodb://mongoserver",