diff --git a/compose.yaml b/compose.yaml
index 3742a16..486fbe5 100644
--- a/compose.yaml
+++ b/compose.yaml
@@ -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"
\ No newline at end of file
diff --git a/src/Printbase.WebApi/Printbase.WebApi.csproj b/src/Printbase.WebApi/Printbase.WebApi.csproj
index b062d35..92ed393 100644
--- a/src/Printbase.WebApi/Printbase.WebApi.csproj
+++ b/src/Printbase.WebApi/Printbase.WebApi.csproj
@@ -12,6 +12,7 @@
runtime; build; native; contentfiles; analyzers; buildtransitive
all
+
diff --git a/src/Printbase.WebApi/Startup.cs b/src/Printbase.WebApi/Startup.cs
index bb593f5..ec24ff3 100644
--- a/src/Printbase.WebApi/Startup.cs
+++ b/src/Printbase.WebApi/Startup.cs
@@ -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();
services.AddScoped();
@@ -26,7 +31,8 @@ public static class Startup
services.AddScoped();
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();
diff --git a/src/Printbase.WebApi/appsettings.Development.json b/src/Printbase.WebApi/appsettings.Development.json
index 1ec280f..e5f79c5 100644
--- a/src/Printbase.WebApi/appsettings.Development.json
+++ b/src/Printbase.WebApi/appsettings.Development.json
@@ -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
diff --git a/src/Printbase.WebApi/appsettings.json b/src/Printbase.WebApi/appsettings.json
index 1ec280f..e5f79c5 100644
--- a/src/Printbase.WebApi/appsettings.json
+++ b/src/Printbase.WebApi/appsettings.json
@@ -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