WORKS
This commit is contained in:
@@ -7,6 +7,9 @@
|
|||||||
dockerfile: src/Printbase.WebApi/Dockerfile
|
dockerfile: src/Printbase.WebApi/Dockerfile
|
||||||
ports:
|
ports:
|
||||||
- "${WEBAPI_PORT}:8080"
|
- "${WEBAPI_PORT}:8080"
|
||||||
|
environment:
|
||||||
|
- ConnectionStrings__DefaultConnection=Server=db;Database=PrintbaseDb;User Id=sa;Password=${SA_PASSWORD};TrustServerCertificate=True;
|
||||||
|
- ASPNETCORE_ENVIRONMENT=Development
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
|
|
||||||
@@ -29,4 +32,4 @@
|
|||||||
SA_PASSWORD: "${SA_PASSWORD}"
|
SA_PASSWORD: "${SA_PASSWORD}"
|
||||||
ACCEPT_EULA: "Y"
|
ACCEPT_EULA: "Y"
|
||||||
ports:
|
ports:
|
||||||
- "${SQL_PORT}:1433"
|
- "${SQL_PORT}:1433"
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="8.1.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Printbase.Application.Products.Commands.CreateProduct;
|
||||||
using Printbase.Domain.Repositories;
|
using Printbase.Domain.Repositories;
|
||||||
using Printbase.Infrastructure.Database;
|
using Printbase.Infrastructure.Database;
|
||||||
using Printbase.Infrastructure.Mapping;
|
using Printbase.Infrastructure.Mapping;
|
||||||
@@ -18,7 +19,11 @@ public static class Startup
|
|||||||
builder.Configuration.GetConnectionString("DefaultConnection"),
|
builder.Configuration.GetConnectionString("DefaultConnection"),
|
||||||
b => b.MigrationsAssembly(typeof(ApplicationDbContext).Assembly.FullName)));
|
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<IProductRepository, ProductRepository>();
|
||||||
services.AddScoped<IProductVariantRepository, ProductVariantRepository>();
|
services.AddScoped<IProductVariantRepository, ProductVariantRepository>();
|
||||||
@@ -26,7 +31,8 @@ public static class Startup
|
|||||||
services.AddScoped<IProductGroupRepository, ProductGroupRepository>();
|
services.AddScoped<IProductGroupRepository, ProductGroupRepository>();
|
||||||
|
|
||||||
services.AddAutoMapper(typeof(ProductMappingProfile).Assembly);
|
services.AddAutoMapper(typeof(ProductMappingProfile).Assembly);
|
||||||
|
services.AddSwaggerGen();
|
||||||
|
services.AddControllers();
|
||||||
services.AddOpenApi();
|
services.AddOpenApi();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,13 +53,16 @@ public static class Startup
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (env.IsDevelopment())
|
if (env.IsDevelopment())
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("Development environment variables applied");
|
||||||
|
app.UseSwagger();
|
||||||
|
app.UseSwaggerUI();
|
||||||
app.UseDeveloperExceptionPage();
|
app.UseDeveloperExceptionPage();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("Production environment variables applied");
|
||||||
app.UseExceptionHandler("/Error");
|
app.UseExceptionHandler("/Error");
|
||||||
app.UseHsts();
|
app.UseHsts();
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
|
|||||||
@@ -2,11 +2,12 @@
|
|||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Information",
|
"Default": "Information",
|
||||||
"Microsoft.AspNetCore": "Warning"
|
"Microsoft.AspNetCore": "Debug",
|
||||||
|
"Microsoft.EntityFrameworkCore": "Information"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ConnectionStrings": {
|
"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": {
|
"DatabaseOptions": {
|
||||||
"ApplyMigrationsAtStartup": true
|
"ApplyMigrationsAtStartup": true
|
||||||
|
|||||||
@@ -2,11 +2,12 @@
|
|||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Information",
|
"Default": "Information",
|
||||||
"Microsoft.AspNetCore": "Warning"
|
"Microsoft.AspNetCore": "Debug",
|
||||||
|
"Microsoft.EntityFrameworkCore": "Information"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ConnectionStrings": {
|
"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": {
|
"DatabaseOptions": {
|
||||||
"ApplyMigrationsAtStartup": true
|
"ApplyMigrationsAtStartup": true
|
||||||
|
|||||||
Reference in New Issue
Block a user