diff --git a/src/ApiGateway/ApiGateway.csproj b/src/ApiGateway/ApiGateway.csproj index 6ac003b..c9565a4 100644 --- a/src/ApiGateway/ApiGateway.csproj +++ b/src/ApiGateway/ApiGateway.csproj @@ -10,4 +10,8 @@ + + + + diff --git a/src/ApiGateway/Dockerfile b/src/ApiGateway/Dockerfile index abe6358..bcf4fa0 100644 --- a/src/ApiGateway/Dockerfile +++ b/src/ApiGateway/Dockerfile @@ -5,8 +5,11 @@ EXPOSE 5000 FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build WORKDIR /src COPY ["ApiGateway/ApiGateway.csproj", "ApiGateway/"] +COPY ["Shared/Shared.Contracts/Shared.Contracts.csproj", "Shared/Shared.Contracts/"] +COPY ["Shared/Shared.Infrastructure/Shared.Infrastructure.csproj", "Shared/Shared.Infrastructure/"] RUN dotnet restore "ApiGateway/ApiGateway.csproj" COPY ApiGateway/ ApiGateway/ +COPY Shared/ Shared/ WORKDIR "/src/ApiGateway" RUN dotnet build -c Release -o /app/build diff --git a/src/ApiGateway/Program.cs b/src/ApiGateway/Program.cs index 89d4860..7839b65 100644 --- a/src/ApiGateway/Program.cs +++ b/src/ApiGateway/Program.cs @@ -1,3 +1,5 @@ +using Shared.Infrastructure.Middleware; + var builder = WebApplication.CreateBuilder(args); builder.Services.AddReverseProxy() @@ -7,6 +9,7 @@ var app = builder.Build(); +app.UseMiddleware(); app.MapReverseProxy(); app.MapHealthChecks("/healthz"); diff --git a/src/ApiGateway/appsettings.json b/src/ApiGateway/appsettings.json index 74c7ae9..9ebc895 100644 --- a/src/ApiGateway/appsettings.json +++ b/src/ApiGateway/appsettings.json @@ -11,27 +11,27 @@ "identity-route": { "ClusterId": "identity-cluster", "Match": { "Path": "/api/identity/{**catch-all}" }, - "Transforms": [{ "PathRemovePrefix": "/api/identity" }] + "Transforms": [{ "PathPattern": "/api/identity/{**catch-all}" }] }, "customer-route": { "ClusterId": "customer-cluster", "Match": { "Path": "/api/customers/{**catch-all}" }, - "Transforms": [{ "PathRemovePrefix": "/api/customers" }] + "Transforms": [{ "PathPattern": "/api/customer/{**catch-all}" }] }, "order-route": { "ClusterId": "order-cluster", "Match": { "Path": "/api/orders/{**catch-all}" }, - "Transforms": [{ "PathRemovePrefix": "/api/orders" }] + "Transforms": [{ "PathPattern": "/api/order/{**catch-all}" }] }, "product-route": { "ClusterId": "product-cluster", "Match": { "Path": "/api/products/{**catch-all}" }, - "Transforms": [{ "PathRemovePrefix": "/api/products" }] + "Transforms": [{ "PathPattern": "/api/product/{**catch-all}" }] }, "notification-route": { "ClusterId": "notification-cluster", "Match": { "Path": "/api/notifications/{**catch-all}" }, - "Transforms": [{ "PathRemovePrefix": "/api/notifications" }] + "Transforms": [{ "PathPattern": "/api/notification/{**catch-all}" }] } }, "Clusters": { diff --git a/src/Services/Customer/Customer.API/Customer.API.csproj b/src/Services/Customer/Customer.API/Customer.API.csproj index 8c284d4..4a0b5b7 100644 --- a/src/Services/Customer/Customer.API/Customer.API.csproj +++ b/src/Services/Customer/Customer.API/Customer.API.csproj @@ -7,8 +7,8 @@ - - + + diff --git a/src/Services/Customer/Customer.API/Program.cs b/src/Services/Customer/Customer.API/Program.cs index e46940a..c85dfdd 100644 --- a/src/Services/Customer/Customer.API/Program.cs +++ b/src/Services/Customer/Customer.API/Program.cs @@ -1,5 +1,6 @@ using Customer.Infrastructure.Data; using Microsoft.EntityFrameworkCore; +using Shared.Infrastructure.Middleware; var builder = WebApplication.CreateBuilder(args); @@ -13,12 +14,19 @@ var app = builder.Build(); +using (var scope = app.Services.CreateScope()) +{ + var db = scope.ServiceProvider.GetRequiredService(); + db.Database.EnsureCreated(); +} + if (app.Environment.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUI(); } +app.UseMiddleware(); app.MapControllers(); app.MapHealthChecks("/healthz"); diff --git a/src/Services/Identity/Identity.API/Identity.API.csproj b/src/Services/Identity/Identity.API/Identity.API.csproj index 9b3e932..c4e24d9 100644 --- a/src/Services/Identity/Identity.API/Identity.API.csproj +++ b/src/Services/Identity/Identity.API/Identity.API.csproj @@ -7,8 +7,8 @@ - - + + diff --git a/src/Services/Identity/Identity.API/Program.cs b/src/Services/Identity/Identity.API/Program.cs index b475a08..7cda310 100644 --- a/src/Services/Identity/Identity.API/Program.cs +++ b/src/Services/Identity/Identity.API/Program.cs @@ -1,5 +1,6 @@ using Identity.Infrastructure.Data; using Microsoft.EntityFrameworkCore; +using Shared.Infrastructure.Middleware; var builder = WebApplication.CreateBuilder(args); @@ -13,12 +14,19 @@ var app = builder.Build(); +using (var scope = app.Services.CreateScope()) +{ + var db = scope.ServiceProvider.GetRequiredService(); + db.Database.EnsureCreated(); +} + if (app.Environment.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUI(); } +app.UseMiddleware(); app.MapControllers(); app.MapHealthChecks("/healthz"); diff --git a/src/Services/Notification/Notification.API/Notification.API.csproj b/src/Services/Notification/Notification.API/Notification.API.csproj index 25b5fb0..1518ca2 100644 --- a/src/Services/Notification/Notification.API/Notification.API.csproj +++ b/src/Services/Notification/Notification.API/Notification.API.csproj @@ -7,8 +7,8 @@ - - + + diff --git a/src/Services/Notification/Notification.API/Program.cs b/src/Services/Notification/Notification.API/Program.cs index 6219c9c..910bf88 100644 --- a/src/Services/Notification/Notification.API/Program.cs +++ b/src/Services/Notification/Notification.API/Program.cs @@ -3,6 +3,7 @@ using Notification.Infrastructure.Data; using Notification.Infrastructure.Repositories; using Microsoft.EntityFrameworkCore; +using Shared.Infrastructure.Middleware; var builder = WebApplication.CreateBuilder(args); @@ -32,6 +33,7 @@ app.UseSwaggerUI(); } +app.UseMiddleware(); app.MapControllers(); app.MapHealthChecks("/healthz"); diff --git a/src/Services/Order/Order.API/Order.API.csproj b/src/Services/Order/Order.API/Order.API.csproj index 54aad4b..12339d9 100644 --- a/src/Services/Order/Order.API/Order.API.csproj +++ b/src/Services/Order/Order.API/Order.API.csproj @@ -7,8 +7,8 @@ - - + + diff --git a/src/Services/Order/Order.API/Program.cs b/src/Services/Order/Order.API/Program.cs index 4512675..d32bd5a 100644 --- a/src/Services/Order/Order.API/Program.cs +++ b/src/Services/Order/Order.API/Program.cs @@ -1,5 +1,6 @@ using Order.Infrastructure.Data; using Microsoft.EntityFrameworkCore; +using Shared.Infrastructure.Middleware; var builder = WebApplication.CreateBuilder(args); @@ -13,12 +14,19 @@ var app = builder.Build(); +using (var scope = app.Services.CreateScope()) +{ + var db = scope.ServiceProvider.GetRequiredService(); + db.Database.EnsureCreated(); +} + if (app.Environment.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUI(); } +app.UseMiddleware(); app.MapControllers(); app.MapHealthChecks("/healthz"); diff --git a/src/Services/Product/Product.API/Product.API.csproj b/src/Services/Product/Product.API/Product.API.csproj index 68be876..5ff75f3 100644 --- a/src/Services/Product/Product.API/Product.API.csproj +++ b/src/Services/Product/Product.API/Product.API.csproj @@ -7,8 +7,8 @@ - - + + diff --git a/src/Services/Product/Product.API/Program.cs b/src/Services/Product/Product.API/Program.cs index 73146ef..c977782 100644 --- a/src/Services/Product/Product.API/Program.cs +++ b/src/Services/Product/Product.API/Program.cs @@ -1,5 +1,6 @@ using Product.Infrastructure.Data; using Microsoft.EntityFrameworkCore; +using Shared.Infrastructure.Middleware; var builder = WebApplication.CreateBuilder(args); @@ -13,12 +14,19 @@ var app = builder.Build(); +using (var scope = app.Services.CreateScope()) +{ + var db = scope.ServiceProvider.GetRequiredService(); + db.Database.EnsureCreated(); +} + if (app.Environment.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUI(); } +app.UseMiddleware(); app.MapControllers(); app.MapHealthChecks("/healthz");