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..1a12465 100644 --- a/src/ApiGateway/Dockerfile +++ b/src/ApiGateway/Dockerfile @@ -5,8 +5,10 @@ EXPOSE 5000 FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build WORKDIR /src COPY ["ApiGateway/ApiGateway.csproj", "ApiGateway/"] +COPY ["Shared/Shared.Infrastructure/Shared.Infrastructure.csproj", "Shared/Shared.Infrastructure/"] RUN dotnet restore "ApiGateway/ApiGateway.csproj" COPY ApiGateway/ ApiGateway/ +COPY Shared/Shared.Infrastructure/ Shared/Shared.Infrastructure/ 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..c1a5407 100644 --- a/src/ApiGateway/Program.cs +++ b/src/ApiGateway/Program.cs @@ -7,6 +7,8 @@ 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..c8faa0f 100644 --- a/src/Services/Customer/Customer.API/Program.cs +++ b/src/Services/Customer/Customer.API/Program.cs @@ -13,6 +13,23 @@ var app = builder.Build(); +for (var retries = 0; ; retries++) +{ + try + { + using var scope = app.Services.CreateScope(); + var db = scope.ServiceProvider.GetRequiredService(); + db.Database.EnsureCreated(); + break; + } + catch (Exception) when (retries < 5) + { + Thread.Sleep(2000); + } +} + +app.UseMiddleware(); + if (app.Environment.IsDevelopment()) { app.UseSwagger(); 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..9ee5a6a 100644 --- a/src/Services/Identity/Identity.API/Program.cs +++ b/src/Services/Identity/Identity.API/Program.cs @@ -13,6 +13,23 @@ var app = builder.Build(); +for (var retries = 0; ; retries++) +{ + try + { + using var scope = app.Services.CreateScope(); + var db = scope.ServiceProvider.GetRequiredService(); + db.Database.EnsureCreated(); + break; + } + catch (Exception) when (retries < 5) + { + Thread.Sleep(2000); + } +} + +app.UseMiddleware(); + if (app.Environment.IsDevelopment()) { app.UseSwagger(); 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..94ddf15 100644 --- a/src/Services/Notification/Notification.API/Program.cs +++ b/src/Services/Notification/Notification.API/Program.cs @@ -20,12 +20,23 @@ var app = builder.Build(); -using (var scope = app.Services.CreateScope()) +for (var retries = 0; ; retries++) { - var db = scope.ServiceProvider.GetRequiredService(); - db.Database.EnsureCreated(); + try + { + using var scope = app.Services.CreateScope(); + var db = scope.ServiceProvider.GetRequiredService(); + db.Database.EnsureCreated(); + break; + } + catch (Exception) when (retries < 5) + { + Thread.Sleep(2000); + } } +app.UseMiddleware(); + if (app.Environment.IsDevelopment()) { app.UseSwagger(); 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..1435f8c 100644 --- a/src/Services/Order/Order.API/Program.cs +++ b/src/Services/Order/Order.API/Program.cs @@ -13,6 +13,23 @@ var app = builder.Build(); +for (var retries = 0; ; retries++) +{ + try + { + using var scope = app.Services.CreateScope(); + var db = scope.ServiceProvider.GetRequiredService(); + db.Database.EnsureCreated(); + break; + } + catch (Exception) when (retries < 5) + { + Thread.Sleep(2000); + } +} + +app.UseMiddleware(); + if (app.Environment.IsDevelopment()) { app.UseSwagger(); 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..ee00179 100644 --- a/src/Services/Product/Product.API/Program.cs +++ b/src/Services/Product/Product.API/Program.cs @@ -13,6 +13,23 @@ var app = builder.Build(); +for (var retries = 0; ; retries++) +{ + try + { + using var scope = app.Services.CreateScope(); + var db = scope.ServiceProvider.GetRequiredService(); + db.Database.EnsureCreated(); + break; + } + catch (Exception) when (retries < 5) + { + Thread.Sleep(2000); + } +} + +app.UseMiddleware(); + if (app.Environment.IsDevelopment()) { app.UseSwagger();