This commit is contained in:
lumijiez
2025-05-05 00:37:41 +03:00
parent 505ba226ea
commit a9bee630e6
5 changed files with 23 additions and 8 deletions

View File

@@ -7,6 +7,9 @@
dockerfile: src/Printbase.WebApi/Dockerfile
ports:
- "${WEBAPI_PORT}:8080"
environment:
- ConnectionStrings__DefaultConnection=Server=db;Database=PrintbaseDb;User Id=sa;Password=${SA_PASSWORD};TrustServerCertificate=True;
- ASPNETCORE_ENVIRONMENT=Development
depends_on:
- db
@@ -29,4 +32,4 @@
SA_PASSWORD: "${SA_PASSWORD}"
ACCEPT_EULA: "Y"
ports:
- "${SQL_PORT}:1433"
- "${SQL_PORT}:1433"

View File

@@ -12,6 +12,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Swashbuckle.AspNetCore" Version="8.1.1" />
</ItemGroup>
<ItemGroup>

View File

@@ -1,5 +1,6 @@
using System.Reflection;
using Microsoft.EntityFrameworkCore;
using Printbase.Application.Products.Commands.CreateProduct;
using Printbase.Domain.Repositories;
using Printbase.Infrastructure.Database;
using Printbase.Infrastructure.Mapping;
@@ -18,7 +19,11 @@ public static class Startup
builder.Configuration.GetConnectionString("DefaultConnection"),
b => b.MigrationsAssembly(typeof(ApplicationDbContext).Assembly.FullName)));
services.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly()));
services.AddMediatR(cfg => {
cfg.RegisterServicesFromAssembly(typeof(CreateProductCommand).Assembly);
cfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly());
});
services.AddScoped<IProductRepository, ProductRepository>();
services.AddScoped<IProductVariantRepository, ProductVariantRepository>();
@@ -26,7 +31,8 @@ public static class Startup
services.AddScoped<IProductGroupRepository, ProductGroupRepository>();
services.AddAutoMapper(typeof(ProductMappingProfile).Assembly);
services.AddSwaggerGen();
services.AddControllers();
services.AddOpenApi();
}
@@ -47,13 +53,16 @@ public static class Startup
}
}
if (env.IsDevelopment())
{
Console.WriteLine("Development environment variables applied");
app.UseSwagger();
app.UseSwaggerUI();
app.UseDeveloperExceptionPage();
}
else
{
Console.WriteLine("Production environment variables applied");
app.UseExceptionHandler("/Error");
app.UseHsts();
app.UseHttpsRedirection();

View File

@@ -2,11 +2,12 @@
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
"Microsoft.AspNetCore": "Debug",
"Microsoft.EntityFrameworkCore": "Information"
}
},
"ConnectionStrings": {
"DefaultConnection": "Server=localhost,${SQL_PORT};Database=PrintbaseDb;User Id=sa;Password=${SA_PASSWORD};TrustServerCertificate=True;"
"DefaultConnection": "Server=db;Database=PrintbaseDb;User Id=sa;Password=Str0ng!Passw0rd383838@@@$23;TrustServerCertificate=True;"
},
"DatabaseOptions": {
"ApplyMigrationsAtStartup": true

View File

@@ -2,11 +2,12 @@
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
"Microsoft.AspNetCore": "Debug",
"Microsoft.EntityFrameworkCore": "Information"
}
},
"ConnectionStrings": {
"DefaultConnection": "Server=localhost,${SQL_PORT};Database=PrintbaseDb;User Id=sa;Password=${SA_PASSWORD};TrustServerCertificate=True;"
"DefaultConnection": "Server=db;Database=PrintbaseDb;User Id=sa;Password=Str0ng!Passw0rd383838@@@$23;TrustServerCertificate=True;"
},
"DatabaseOptions": {
"ApplyMigrationsAtStartup": true