From e72ada31fb758f843dfc298527fdcbbc06f956d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduard=20Tom=C3=A0s?= Date: Thu, 11 Jan 2018 11:20:38 +0100 Subject: [PATCH 01/45] Create Ocelot project --- docker-compose.override.yml | 9 +++- docker-compose.yml | 7 +++ eShopOnContainers-ServicesAndWebApps.sln | 54 +++++++++++++++++++ src/Apigw/OcelotApiGw/Dockerfile | 20 +++++++ src/Apigw/OcelotApiGw/OcelotApiGw.csproj | 15 ++++++ src/Apigw/OcelotApiGw/Program.cs | 25 +++++++++ .../Properties/launchSettings.json | 27 ++++++++++ src/Apigw/OcelotApiGw/Startup.cs | 34 ++++++++++++ 8 files changed, 190 insertions(+), 1 deletion(-) create mode 100644 src/Apigw/OcelotApiGw/Dockerfile create mode 100644 src/Apigw/OcelotApiGw/OcelotApiGw.csproj create mode 100644 src/Apigw/OcelotApiGw/Program.cs create mode 100644 src/Apigw/OcelotApiGw/Properties/launchSettings.json create mode 100644 src/Apigw/OcelotApiGw/Startup.cs diff --git a/docker-compose.override.yml b/docker-compose.override.yml index f0ead3653..a4f1eff0c 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -219,4 +219,11 @@ services: rabbitmq: ports: - "15672:15672" - - "5672:5672" \ No newline at end of file + - "5672:5672" + + ocelotapigw: + environment: + - ASPNETCORE_ENVIRONMENT=Development + ports: + - "80" + diff --git a/docker-compose.yml b/docker-compose.yml index 7489c941f..82b9b1670 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -107,3 +107,10 @@ services: rabbitmq: image: rabbitmq:3-management-alpine + + ocelotapigw: + image: ocelotapigw + build: + context: . + dockerfile: src/Apigw/OcelotApiGw/Dockerfile + diff --git a/eShopOnContainers-ServicesAndWebApps.sln b/eShopOnContainers-ServicesAndWebApps.sln index e4ddff1c2..4a07ad380 100644 --- a/eShopOnContainers-ServicesAndWebApps.sln +++ b/eShopOnContainers-ServicesAndWebApps.sln @@ -97,6 +97,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WebHost", "WebHost", "{1815 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebHost.Customization", "src\BuildingBlocks\WebHostCustomization\WebHost.Customization\WebHost.Customization.csproj", "{15F4B3AA-89B6-4A0D-9051-414305974781}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ApiGw", "ApiGw", "{7A58AA20-67F3-48F3-88C8-24EBFE621792}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OcelotApiGw", "src\Apigw\OcelotApiGw\OcelotApiGw.csproj", "{E0C5162E-DF26-4341-9E51-14AE800D7505}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Ad-Hoc|Any CPU = Ad-Hoc|Any CPU @@ -1311,6 +1315,54 @@ Global {15F4B3AA-89B6-4A0D-9051-414305974781}.Release|x64.Build.0 = Release|Any CPU {15F4B3AA-89B6-4A0D-9051-414305974781}.Release|x86.ActiveCfg = Release|Any CPU {15F4B3AA-89B6-4A0D-9051-414305974781}.Release|x86.Build.0 = Release|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Ad-Hoc|x64.Build.0 = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Ad-Hoc|x86.Build.0 = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.AppStore|Any CPU.Build.0 = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.AppStore|ARM.ActiveCfg = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.AppStore|ARM.Build.0 = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.AppStore|iPhone.ActiveCfg = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.AppStore|iPhone.Build.0 = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.AppStore|x64.ActiveCfg = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.AppStore|x64.Build.0 = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.AppStore|x86.ActiveCfg = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.AppStore|x86.Build.0 = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Debug|ARM.ActiveCfg = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Debug|ARM.Build.0 = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Debug|iPhone.Build.0 = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Debug|x64.ActiveCfg = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Debug|x64.Build.0 = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Debug|x86.ActiveCfg = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Debug|x86.Build.0 = Debug|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Release|Any CPU.Build.0 = Release|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Release|ARM.ActiveCfg = Release|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Release|ARM.Build.0 = Release|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Release|iPhone.ActiveCfg = Release|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Release|iPhone.Build.0 = Release|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Release|x64.ActiveCfg = Release|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Release|x64.Build.0 = Release|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Release|x86.ActiveCfg = Release|Any CPU + {E0C5162E-DF26-4341-9E51-14AE800D7505}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1357,6 +1409,8 @@ Global {969E793C-C413-490E-9C9D-B2B46DA5AF32} = {EF0337F2-ED00-4643-89FD-EE10863F1870} {1815B651-941C-466B-AE33-D1D7EEB8F77F} = {DB0EFB20-B024-4E5E-A75C-52143C131D25} {15F4B3AA-89B6-4A0D-9051-414305974781} = {1815B651-941C-466B-AE33-D1D7EEB8F77F} + {7A58AA20-67F3-48F3-88C8-24EBFE621792} = {932D8224-11F6-4D07-B109-DA28AD288A63} + {E0C5162E-DF26-4341-9E51-14AE800D7505} = {7A58AA20-67F3-48F3-88C8-24EBFE621792} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {25728519-5F0F-4973-8A64-0A81EB4EA8D9} diff --git a/src/Apigw/OcelotApiGw/Dockerfile b/src/Apigw/OcelotApiGw/Dockerfile new file mode 100644 index 000000000..06b842479 --- /dev/null +++ b/src/Apigw/OcelotApiGw/Dockerfile @@ -0,0 +1,20 @@ +FROM microsoft/aspnetcore:2.0 AS base +WORKDIR /app +EXPOSE 80 + +FROM microsoft/aspnetcore-build:2.0 AS build +WORKDIR /src +COPY *.sln ./ +COPY src/Apigw/OcelotApiGw/OcelotApiGw.csproj src/Apigw/OcelotApiGw/ +RUN dotnet restore +COPY . . +WORKDIR /src/src/Apigw/OcelotApiGw +RUN dotnet build -c Release -o /app + +FROM build AS publish +RUN dotnet publish -c Release -o /app + +FROM base AS final +WORKDIR /app +COPY --from=publish /app . +ENTRYPOINT ["dotnet", "OcelotApiGw.dll"] diff --git a/src/Apigw/OcelotApiGw/OcelotApiGw.csproj b/src/Apigw/OcelotApiGw/OcelotApiGw.csproj new file mode 100644 index 000000000..2d176adde --- /dev/null +++ b/src/Apigw/OcelotApiGw/OcelotApiGw.csproj @@ -0,0 +1,15 @@ + + + + netcoreapp2.0 + + + + + + + + + + + diff --git a/src/Apigw/OcelotApiGw/Program.cs b/src/Apigw/OcelotApiGw/Program.cs new file mode 100644 index 000000000..43be3c57c --- /dev/null +++ b/src/Apigw/OcelotApiGw/Program.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; + +namespace OcelotApiGw +{ + public class Program + { + public static void Main(string[] args) + { + BuildWebHost(args).Run(); + } + + public static IWebHost BuildWebHost(string[] args) => + WebHost.CreateDefaultBuilder(args) + .UseStartup() + .Build(); + } +} diff --git a/src/Apigw/OcelotApiGw/Properties/launchSettings.json b/src/Apigw/OcelotApiGw/Properties/launchSettings.json new file mode 100644 index 000000000..796011a33 --- /dev/null +++ b/src/Apigw/OcelotApiGw/Properties/launchSettings.json @@ -0,0 +1,27 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:64020/", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "OcelotApiGw": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "http://localhost:64021/" + } + } +} diff --git a/src/Apigw/OcelotApiGw/Startup.cs b/src/Apigw/OcelotApiGw/Startup.cs new file mode 100644 index 000000000..671bb72aa --- /dev/null +++ b/src/Apigw/OcelotApiGw/Startup.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; + +namespace OcelotApiGw +{ + public class Startup + { + // This method gets called by the runtime. Use this method to add services to the container. + // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 + public void ConfigureServices(IServiceCollection services) + { + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IHostingEnvironment env) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + + app.Run(async (context) => + { + await context.Response.WriteAsync("Hello World!"); + }); + } + } +} From ea4e0ed6e8d9f0254790db2c21a5f8d19deb7303 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduard=20Tom=C3=A0s?= Date: Thu, 11 Jan 2018 18:18:16 +0100 Subject: [PATCH 02/45] Deploying ocelot to k8s configuration to ocelot passed through a k8s volume --- docker-compose.override.yml | 4 +- docker-compose.yml | 5 +- k8s/deploy.ps1 | 10 +++- k8s/ingress.yaml | 10 ++-- k8s/ocelot/configuration.json | 58 +++++++++++++++++++ k8s/ocelot/deployment.yaml | 31 ++++++++++ k8s/ocelot/service.yaml | 13 +++++ src/Apigw/OcelotApiGw/Dockerfile | 3 +- src/Apigw/OcelotApiGw/OcelotApiGw.csproj | 1 + src/Apigw/OcelotApiGw/Program.cs | 1 + src/Apigw/OcelotApiGw/Startup.cs | 22 ++++--- .../configuration/configuration.json | 58 +++++++++++++++++++ xglobal.json | 5 ++ 13 files changed, 201 insertions(+), 20 deletions(-) create mode 100644 k8s/ocelot/configuration.json create mode 100644 k8s/ocelot/deployment.yaml create mode 100644 k8s/ocelot/service.yaml create mode 100644 src/Apigw/OcelotApiGw/configuration/configuration.json create mode 100644 xglobal.json diff --git a/docker-compose.override.yml b/docker-compose.override.yml index a4f1eff0c..c8b952af5 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -221,9 +221,9 @@ services: - "15672:15672" - "5672:5672" - ocelotapigw: + apigw: environment: - ASPNETCORE_ENVIRONMENT=Development ports: - - "80" + - "5200:80" diff --git a/docker-compose.yml b/docker-compose.yml index 82b9b1670..bda0acded 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -108,9 +108,8 @@ services: rabbitmq: image: rabbitmq:3-management-alpine - ocelotapigw: - image: ocelotapigw + apigw: + image: eshop/ocelotapigw build: context: . dockerfile: src/Apigw/OcelotApiGw/Dockerfile - diff --git a/k8s/deploy.ps1 b/k8s/deploy.ps1 index 42202f637..3372a5937 100644 --- a/k8s/deploy.ps1 +++ b/k8s/deploy.ps1 @@ -105,6 +105,7 @@ ExecKube -cmd 'delete deployments --all' ExecKube -cmd 'delete services --all' ExecKube -cmd 'delete configmap urls' ExecKube -cmd 'delete configmap externalcfg' +ExecKube -cmd 'delete configmap ocelot' # start sql, rabbitmq, frontend deployments if ($deployInfrastructure) { @@ -113,6 +114,12 @@ if ($deployInfrastructure) { } +Write-Host 'Deploying ocelot APIGW' -ForegroundColor Yellow + +ExecKube "create configmap ocelot --from-file=ocelot/configuration.json" +ExecKube -cmd "apply -f ocelot/deployment.yaml" +ExecKube -cmd "apply -f ocelot/service.yaml" + Write-Host 'Deploying code deployments (Web APIs, Web apps, ...)' -ForegroundColor Yellow ExecKube -cmd 'create -f services.yaml' @@ -154,7 +161,6 @@ ExecKube -cmd 'create configmap urls ` ExecKube -cmd 'label configmap urls app=eshop' Write-Host "Deploying configuration from $configFile" -ForegroundColor Yellow - ExecKube -cmd "create -f $configFile" Write-Host "Creating deployments..." -ForegroundColor Yellow @@ -178,6 +184,7 @@ ExecKube -cmd 'set image deployments/payment payment=${registryPath}${dockerOrg} ExecKube -cmd 'set image deployments/webmvc webmvc=${registryPath}${dockerOrg}/webmvc:$imageTag' ExecKube -cmd 'set image deployments/webstatus webstatus=${registryPath}${dockerOrg}/webstatus:$imageTag' ExecKube -cmd 'set image deployments/webspa webspa=${registryPath}${dockerOrg}/webspa:$imageTag' +ExecKube -cmd 'set image deployments/ocelot ocelot=${registryPath}${dockerOrg}/ocelotapigw:$imageTag' Write-Host "Execute rollout..." -ForegroundColor Yellow ExecKube -cmd 'rollout resume deployments/basket' @@ -190,6 +197,7 @@ ExecKube -cmd 'rollout resume deployments/payment' ExecKube -cmd 'rollout resume deployments/webmvc' ExecKube -cmd 'rollout resume deployments/webstatus' ExecKube -cmd 'rollout resume deployments/webspa' +ExecKube -cmd 'rollout resume deployments/ocelot' Write-Host "WebSPA is exposed at http://$externalDns, WebMVC at http://$externalDns/webmvc, WebStatus at http://$externalDns/webstatus" -ForegroundColor Yellow diff --git a/k8s/ingress.yaml b/k8s/ingress.yaml index 3c2fe8bad..813a88a36 100644 --- a/k8s/ingress.yaml +++ b/k8s/ingress.yaml @@ -13,11 +13,11 @@ spec: paths: - path: /basket-api backend: - serviceName: basket + serviceName: ocelot servicePort: 80 - path: /catalog-api backend: - serviceName: catalog + serviceName: ocelot servicePort: 80 - path: /identity backend: @@ -25,7 +25,7 @@ spec: servicePort: 80 - path: /ordering-api backend: - serviceName: ordering + serviceName: ocelot servicePort: 80 - path: /webmvc backend: @@ -41,11 +41,11 @@ spec: servicePort: 80 - path: /payment-api backend: - serviceName: payment + serviceName: ocelot servicePort: 80 - path: /locations-api backend: - serviceName: locations + serviceName: ocelot servicePort: 80 - path: / backend: diff --git a/k8s/ocelot/configuration.json b/k8s/ocelot/configuration.json new file mode 100644 index 000000000..7a94504c3 --- /dev/null +++ b/k8s/ocelot/configuration.json @@ -0,0 +1,58 @@ +{ + "ReRoutes": [ + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHost": "ordering", + "DownstreamPort": 80, + "UpstreamPathTemplate": "/ordering-api/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHost": "basket", + "DownstreamPort": 80, + "UpstreamPathTemplate": "/basket-api/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHost": "catalog", + "DownstreamPort": 80, + "UpstreamPathTemplate": "/catalog-api/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHost": "marketing", + "DownstreamPort": 80, + "UpstreamPathTemplate": "/marketing-api/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHost": "payment", + "DownstreamPort": 80, + "UpstreamPathTemplate": "/payment-api/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHost": "locations", + "DownstreamPort": 80, + "UpstreamPathTemplate": "/location-api/{everything}", + "UpstreamHttpMethod": [] + } + + ], + "GlobalConfiguration": { + "RequestIdKey": "OcRequestId", + "AdministrationPath": "/administration" + } + } + \ No newline at end of file diff --git a/k8s/ocelot/deployment.yaml b/k8s/ocelot/deployment.yaml new file mode 100644 index 000000000..4800172e6 --- /dev/null +++ b/k8s/ocelot/deployment.yaml @@ -0,0 +1,31 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: ocelot +spec: + paused: true + template: + metadata: + labels: + app: eshop + component: ocelot + spec: + containers: + - name: ocelot + image: eshop/ocelotapigw + imagePullPolicy: Always + ports: + - containerPort: 80 + volumeMounts: + - name: config + mountPath: /app/configuration + volumes: + - name: config + configMap: + name: ocelot + items: + - key: configuration.json + path: configuration.json + imagePullSecrets: + - name: registry-key + diff --git a/k8s/ocelot/service.yaml b/k8s/ocelot/service.yaml new file mode 100644 index 000000000..6b376ca78 --- /dev/null +++ b/k8s/ocelot/service.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + app: eshop + component: ocelot + name: ocelot +spec: + ports: + - port: 80 + selector: + app: eshop + component: ocelot diff --git a/src/Apigw/OcelotApiGw/Dockerfile b/src/Apigw/OcelotApiGw/Dockerfile index 06b842479..aec2dc4e3 100644 --- a/src/Apigw/OcelotApiGw/Dockerfile +++ b/src/Apigw/OcelotApiGw/Dockerfile @@ -4,9 +4,8 @@ EXPOSE 80 FROM microsoft/aspnetcore-build:2.0 AS build WORKDIR /src -COPY *.sln ./ COPY src/Apigw/OcelotApiGw/OcelotApiGw.csproj src/Apigw/OcelotApiGw/ -RUN dotnet restore +RUN dotnet restore src/Apigw/OcelotApiGw/ COPY . . WORKDIR /src/src/Apigw/OcelotApiGw RUN dotnet build -c Release -o /app diff --git a/src/Apigw/OcelotApiGw/OcelotApiGw.csproj b/src/Apigw/OcelotApiGw/OcelotApiGw.csproj index 2d176adde..4f6ce6e77 100644 --- a/src/Apigw/OcelotApiGw/OcelotApiGw.csproj +++ b/src/Apigw/OcelotApiGw/OcelotApiGw.csproj @@ -10,6 +10,7 @@ + diff --git a/src/Apigw/OcelotApiGw/Program.cs b/src/Apigw/OcelotApiGw/Program.cs index 43be3c57c..bd5230b96 100644 --- a/src/Apigw/OcelotApiGw/Program.cs +++ b/src/Apigw/OcelotApiGw/Program.cs @@ -19,6 +19,7 @@ namespace OcelotApiGw public static IWebHost BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args) + .ConfigureAppConfiguration(ic => ic.AddJsonFile(Path.Combine("configuration", "configuration.json"))) .UseStartup() .Build(); } diff --git a/src/Apigw/OcelotApiGw/Startup.cs b/src/Apigw/OcelotApiGw/Startup.cs index 671bb72aa..8e99afaf2 100644 --- a/src/Apigw/OcelotApiGw/Startup.cs +++ b/src/Apigw/OcelotApiGw/Startup.cs @@ -2,22 +2,33 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using CacheManager.Core; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Ocelot.DependencyInjection; +using Ocelot.Middleware; namespace OcelotApiGw { public class Startup { - // This method gets called by the runtime. Use this method to add services to the container. - // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 + + private readonly IConfiguration _cfg; + + public Startup(IConfiguration configuration) + { + _cfg = configuration; + } + public void ConfigureServices(IServiceCollection services) { + services.AddOcelot(_cfg); } - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) @@ -25,10 +36,7 @@ namespace OcelotApiGw app.UseDeveloperExceptionPage(); } - app.Run(async (context) => - { - await context.Response.WriteAsync("Hello World!"); - }); + app.UseOcelot(); } } } diff --git a/src/Apigw/OcelotApiGw/configuration/configuration.json b/src/Apigw/OcelotApiGw/configuration/configuration.json new file mode 100644 index 000000000..6e9513993 --- /dev/null +++ b/src/Apigw/OcelotApiGw/configuration/configuration.json @@ -0,0 +1,58 @@ +{ + "ReRoutes": [ + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHost": "ordering.api", + "DownstreamPort": 80, + "UpstreamPathTemplate": "/orders-api/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHost": "basket.api", + "DownstreamPort": 80, + "UpstreamPathTemplate": "/basket-api/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHost": "catalog.api", + "DownstreamPort": 80, + "UpstreamPathTemplate": "/catalog-api/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHost": "marketing.api", + "DownstreamPort": 80, + "UpstreamPathTemplate": "/marketing-api/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHost": "payment.api", + "DownstreamPort": 80, + "UpstreamPathTemplate": "/payment-api/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHost": "locations.api", + "DownstreamPort": 80, + "UpstreamPathTemplate": "/location-api/{everything}", + "UpstreamHttpMethod": [] + } + + ], + "GlobalConfiguration": { + "RequestIdKey": "OcRequestId", + "AdministrationPath": "/administration" + } + } + \ No newline at end of file diff --git a/xglobal.json b/xglobal.json new file mode 100644 index 000000000..2ab18dceb --- /dev/null +++ b/xglobal.json @@ -0,0 +1,5 @@ +{ + "sdk": { + "version":"2.1.2" + } +} \ No newline at end of file From 266ec51e54493c7b42a8619c5ebf89fdbfa2ae2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduard=20Tom=C3=A0s?= Date: Thu, 18 Jan 2018 14:45:46 +0100 Subject: [PATCH 03/45] updates to ocelot --- k8s/gen-k8s-env-aks.ps1 | 5 ++--- k8s/ingress.yaml | 8 ++++++-- src/Apigw/OcelotApiGw/Startup.cs | 6 ++++-- src/Apigw/OcelotApiGw/appsettings.json | 10 ++++++++++ 4 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 src/Apigw/OcelotApiGw/appsettings.json diff --git a/k8s/gen-k8s-env-aks.ps1 b/k8s/gen-k8s-env-aks.ps1 index 6b8449565..1be5cd2c3 100644 --- a/k8s/gen-k8s-env-aks.ps1 +++ b/k8s/gen-k8s-env-aks.ps1 @@ -3,9 +3,8 @@ [parameter(Mandatory=$true)][string]$location, [parameter(Mandatory=$false)][string]$registryName, [parameter(Mandatory=$true)][string]$serviceName, - [parameter(Mandatory=$true)][string]$dnsName, [parameter(Mandatory=$true)][string]$createAcr=$true, - [parameter(Mandatory=$false)][int]$nodeCount=2, + [parameter(Mandatory=$false)][int]$nodeCount=3, [parameter(Mandatory=$false)][string]$nodeVMSize="Standard_D2_v2" ) @@ -21,7 +20,7 @@ if ($createAcr -eq $true) { # Create kubernetes orchestrator Write-Host "Creating kubernetes orchestrator..." -ForegroundColor Yellow -az aks create --resource-group=$resourceGroupName --name=$serviceName --dns-name-prefix=$dnsName --generate-ssh-keys --node-count=$nodeCount --node-vm-size=$nodeVMSize +az aks create --resource-group=$resourceGroupName --name=$serviceName --generate-ssh-keys --node-count=$nodeCount --node-vm-size=$nodeVMSize # Retrieve kubernetes cluster configuration and save it under ~/.kube/config az aks get-credentials --resource-group=$resourceGroupName --name=$serviceName diff --git a/k8s/ingress.yaml b/k8s/ingress.yaml index 813a88a36..59012bf26 100644 --- a/k8s/ingress.yaml +++ b/k8s/ingress.yaml @@ -37,7 +37,7 @@ spec: servicePort: 80 - path: /marketing-api backend: - serviceName: marketing + serviceName: ocelot servicePort: 80 - path: /payment-api backend: @@ -51,5 +51,9 @@ spec: backend: serviceName: webspa servicePort: 80 - + - path: /ocelot + backend: + serviceName: ocelot + servicePort: 80 + diff --git a/src/Apigw/OcelotApiGw/Startup.cs b/src/Apigw/OcelotApiGw/Startup.cs index 8e99afaf2..487793eda 100644 --- a/src/Apigw/OcelotApiGw/Startup.cs +++ b/src/Apigw/OcelotApiGw/Startup.cs @@ -29,14 +29,16 @@ namespace OcelotApiGw services.AddOcelot(_cfg); } - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - app.UseOcelot(); + loggerFactory.AddConsole(_cfg.GetSection("Logging")); + + app.UseOcelot().Wait(); } } } diff --git a/src/Apigw/OcelotApiGw/appsettings.json b/src/Apigw/OcelotApiGw/appsettings.json new file mode 100644 index 000000000..426750e6a --- /dev/null +++ b/src/Apigw/OcelotApiGw/appsettings.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "IncludeScopes": true, + "LogLevel": { + "Default": "Trace", + "System": "Information", + "Microsoft": "Information" + } + } +} \ No newline at end of file From b0e17c86a6675b8130f2054dd53e1ef215ee88a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduard=20Tom=C3=A0s?= Date: Wed, 24 Jan 2018 17:23:23 +0100 Subject: [PATCH 04/45] Updated deploy.ps1 --- k8s/deploy.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k8s/deploy.ps1 b/k8s/deploy.ps1 index 3372a5937..3d9c54b5c 100644 --- a/k8s/deploy.ps1 +++ b/k8s/deploy.ps1 @@ -65,7 +65,7 @@ if ($buildImages) { docker-compose -p .. -f ../docker-compose.yml build Write-Host "Pushing images to $registry/$dockerOrg..." -ForegroundColor Yellow - $services = ("basket.api", "catalog.api", "identity.api", "ordering.api", "marketing.api","payment.api","locations.api", "webmvc", "webspa", "webstatus") + $services = ("basket.api", "catalog.api", "identity.api", "ordering.api", "marketing.api","payment.api","locations.api", "webmvc", "webspa", "webstatus", "ocelotapigw") foreach ($service in $services) { $imageFqdn = if ($useDockerHub) {"$dockerOrg/${service}"} else {"$registry/$dockerOrg/${service}"} From c42a096ebbecb72b59d8e29bc8a263a1c34caa96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduard=20Tom=C3=A0s?= Date: Wed, 24 Jan 2018 17:24:03 +0100 Subject: [PATCH 05/45] Deleted frontend.yaml file as is no longer needed --- k8s/frontend.yaml | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 k8s/frontend.yaml diff --git a/k8s/frontend.yaml b/k8s/frontend.yaml deleted file mode 100644 index 291542404..000000000 --- a/k8s/frontend.yaml +++ /dev/null @@ -1,47 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - labels: - app: eshop - component: frontend - name: frontend -spec: - ports: - - port: 80 - targetPort: 8080 - selector: - app: eshop - component: frontend - type: LoadBalancer ---- -apiVersion: extensions/v1beta1 -kind: Deployment -metadata: - name: frontend -spec: - template: - metadata: - labels: - app: eshop - component: frontend - spec: - containers: - - name: nginx - image: nginx:1.11.10-alpine - imagePullPolicy: IfNotPresent - ports: - - containerPort: 8080 - lifecycle: - preStop: - exec: - command: ["/usr/sbin/nginx","-s","quit"] - volumeMounts: - - name: config - mountPath: /etc/nginx - volumes: - - name: config - configMap: - name: config-files - items: - - key: nginx-conf - path: nginx.conf From 02f5e1158ad4eac44d481cab947d0ca5386106d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduard=20Tom=C3=A0s?= Date: Fri, 26 Jan 2018 16:09:36 +0000 Subject: [PATCH 06/45] Purchase BFF skeleton created --- docker-compose.dcproj | 1 + docker-compose.override.yml | 9 +- docker-compose.prod.yml | 1 + docker-compose.yml | 7 ++ eShopOnContainers-ServicesAndWebApps.sln | 56 ++++++++++- .../configuration/configuration.json | 8 ++ .../Controllers/BasketController.cs | 23 +++++ src/BFFs/PurchaseBff/Dockerfile | 18 ++++ .../Filters/AuthorizeCheckOperationFilter.cs | 33 +++++++ src/BFFs/PurchaseBff/Program.cs | 25 +++++ .../Properties/launchSettings.json | 29 ++++++ src/BFFs/PurchaseBff/PurchaseBff.csproj | 23 +++++ src/BFFs/PurchaseBff/Startup.cs | 96 +++++++++++++++++++ .../PurchaseBff/appsettings.Development.json | 10 ++ src/BFFs/PurchaseBff/appsettings.json | 15 +++ .../Basket.API/Properties/launchSettings.json | 2 +- .../Identity.API/Configuration/Config.cs | 31 +++++- .../Data/ConfigurationDbContextSeed.cs | 1 + .../Properties/launchSettings.json | 6 +- 19 files changed, 383 insertions(+), 11 deletions(-) create mode 100644 src/BFFs/PurchaseBff/Controllers/BasketController.cs create mode 100644 src/BFFs/PurchaseBff/Dockerfile create mode 100644 src/BFFs/PurchaseBff/Filters/AuthorizeCheckOperationFilter.cs create mode 100644 src/BFFs/PurchaseBff/Program.cs create mode 100644 src/BFFs/PurchaseBff/Properties/launchSettings.json create mode 100644 src/BFFs/PurchaseBff/PurchaseBff.csproj create mode 100644 src/BFFs/PurchaseBff/Startup.cs create mode 100644 src/BFFs/PurchaseBff/appsettings.Development.json create mode 100644 src/BFFs/PurchaseBff/appsettings.json diff --git a/docker-compose.dcproj b/docker-compose.dcproj index 5f12f7d62..d1f485b05 100644 --- a/docker-compose.dcproj +++ b/docker-compose.dcproj @@ -7,6 +7,7 @@ webmvc Linux 2.1 + LaunchBrowser diff --git a/docker-compose.override.yml b/docker-compose.override.yml index c8b952af5..93c9cde4b 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -57,6 +57,7 @@ services: - MarketingApiClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5110 - BasketApiClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5103 - OrderingApiClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5102 + - PurchaseBFFClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5120 - UseCustomizationData=True - ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY} - OrchestratorType=${ORCHESTRATOR_TYPE} @@ -203,7 +204,7 @@ services: sql.data: environment: - - sa_password=Pass@word + - SA_PASSWORD=Pass@word - ACCEPT_EULA=Y ports: - "5433:1433" @@ -227,3 +228,9 @@ services: ports: - "5200:80" + purchasebff: + environment: + - ASPNETCORE_ENVIRONMENT=Development + ports: + - "5120:80" + diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 443f987f8..8c8d67b5d 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -64,6 +64,7 @@ services: - MarketingApiClient=http://${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}:5110 - BasketApiClient=http://${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}:5103 - OrderingApiClient=http://${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}:5102 + - PurchaseBFFClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5120 - UseCustomizationData=True - ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY} - OrchestratorType=${ORCHESTRATOR_TYPE} diff --git a/docker-compose.yml b/docker-compose.yml index bda0acded..18a3273f8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -113,3 +113,10 @@ services: build: context: . dockerfile: src/Apigw/OcelotApiGw/Dockerfile + + purchasebff: + image: eshop/purchasebff + build: + context: . + dockerfile: src/BFFs/PurchaseBff/Dockerfile + diff --git a/eShopOnContainers-ServicesAndWebApps.sln b/eShopOnContainers-ServicesAndWebApps.sln index 4a07ad380..7d25f9b3a 100644 --- a/eShopOnContainers-ServicesAndWebApps.sln +++ b/eShopOnContainers-ServicesAndWebApps.sln @@ -99,7 +99,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebHost.Customization", "sr EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ApiGw", "ApiGw", "{7A58AA20-67F3-48F3-88C8-24EBFE621792}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OcelotApiGw", "src\Apigw\OcelotApiGw\OcelotApiGw.csproj", "{E0C5162E-DF26-4341-9E51-14AE800D7505}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OcelotApiGw", "src\Apigw\OcelotApiGw\OcelotApiGw.csproj", "{E0C5162E-DF26-4341-9E51-14AE800D7505}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BFFs", "BFFs", "{EA378316-9D49-4A6B-858E-D4A25F948A74}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PurchaseBff", "src\BFFs\PurchaseBff\PurchaseBff.csproj", "{F77054A6-5808-45D7-88EB-CD92B3FDB889}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -1363,6 +1367,54 @@ Global {E0C5162E-DF26-4341-9E51-14AE800D7505}.Release|x64.Build.0 = Release|Any CPU {E0C5162E-DF26-4341-9E51-14AE800D7505}.Release|x86.ActiveCfg = Release|Any CPU {E0C5162E-DF26-4341-9E51-14AE800D7505}.Release|x86.Build.0 = Release|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Ad-Hoc|x64.Build.0 = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Ad-Hoc|x86.Build.0 = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.AppStore|Any CPU.Build.0 = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.AppStore|ARM.ActiveCfg = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.AppStore|ARM.Build.0 = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.AppStore|iPhone.ActiveCfg = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.AppStore|iPhone.Build.0 = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.AppStore|x64.ActiveCfg = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.AppStore|x64.Build.0 = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.AppStore|x86.ActiveCfg = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.AppStore|x86.Build.0 = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Debug|ARM.ActiveCfg = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Debug|ARM.Build.0 = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Debug|iPhone.Build.0 = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Debug|x64.ActiveCfg = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Debug|x64.Build.0 = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Debug|x86.ActiveCfg = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Debug|x86.Build.0 = Debug|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Release|Any CPU.Build.0 = Release|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Release|ARM.ActiveCfg = Release|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Release|ARM.Build.0 = Release|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Release|iPhone.ActiveCfg = Release|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Release|iPhone.Build.0 = Release|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Release|x64.ActiveCfg = Release|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Release|x64.Build.0 = Release|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Release|x86.ActiveCfg = Release|Any CPU + {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1411,6 +1463,8 @@ Global {15F4B3AA-89B6-4A0D-9051-414305974781} = {1815B651-941C-466B-AE33-D1D7EEB8F77F} {7A58AA20-67F3-48F3-88C8-24EBFE621792} = {932D8224-11F6-4D07-B109-DA28AD288A63} {E0C5162E-DF26-4341-9E51-14AE800D7505} = {7A58AA20-67F3-48F3-88C8-24EBFE621792} + {EA378316-9D49-4A6B-858E-D4A25F948A74} = {932D8224-11F6-4D07-B109-DA28AD288A63} + {F77054A6-5808-45D7-88EB-CD92B3FDB889} = {EA378316-9D49-4A6B-858E-D4A25F948A74} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {25728519-5F0F-4973-8A64-0A81EB4EA8D9} diff --git a/src/Apigw/OcelotApiGw/configuration/configuration.json b/src/Apigw/OcelotApiGw/configuration/configuration.json index 6e9513993..973f6874c 100644 --- a/src/Apigw/OcelotApiGw/configuration/configuration.json +++ b/src/Apigw/OcelotApiGw/configuration/configuration.json @@ -1,5 +1,13 @@ { "ReRoutes": [ + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHost": "catalog.api", + "DownstreamPort": 80, + "UpstreamPathTemplate": "/purchase-bff/catalog/{everything}", + "UpstreamHttpMethod": [ "GET" ] + }, { "DownstreamPathTemplate": "/{everything}", "DownstreamScheme": "http", diff --git a/src/BFFs/PurchaseBff/Controllers/BasketController.cs b/src/BFFs/PurchaseBff/Controllers/BasketController.cs new file mode 100644 index 000000000..7c875c9c4 --- /dev/null +++ b/src/BFFs/PurchaseBff/Controllers/BasketController.cs @@ -0,0 +1,23 @@ +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace PurchaseBff.Controllers +{ + [Route("api/v1/[controller]")] + public class BasketController : Controller + { + [HttpPost("items/{catalogItemId}")] + public async Task AddBasketItem(int catalogItemId) + { + // Step 1: Get the item from catalog + // Step 2: Get current basket status + // Step 3: Merge current status with new product + // Step 4: Update basket + + return Ok(); + } + } +} diff --git a/src/BFFs/PurchaseBff/Dockerfile b/src/BFFs/PurchaseBff/Dockerfile new file mode 100644 index 000000000..500f8406f --- /dev/null +++ b/src/BFFs/PurchaseBff/Dockerfile @@ -0,0 +1,18 @@ +FROM microsoft/aspnetcore:2.0.5 AS base +WORKDIR /app +EXPOSE 80 + +FROM microsoft/aspnetcore-build:2.0 AS build +WORKDIR /src +COPY . . +RUN dotnet restore -nowarn:msb3202,nu1503 +WORKDIR /src/src/BFFs/PurchaseBff +RUN dotnet build --no-restore -c Release -o /app + +FROM build AS publish +RUN dotnet publish --no-restore -c Release -o /app + +FROM base AS final +WORKDIR /app +COPY --from=publish /app . +ENTRYPOINT ["dotnet", "PurchaseBff.dll"] diff --git a/src/BFFs/PurchaseBff/Filters/AuthorizeCheckOperationFilter.cs b/src/BFFs/PurchaseBff/Filters/AuthorizeCheckOperationFilter.cs new file mode 100644 index 000000000..31b5bf99e --- /dev/null +++ b/src/BFFs/PurchaseBff/Filters/AuthorizeCheckOperationFilter.cs @@ -0,0 +1,33 @@ +namespace PurchaseBff.Filters +{ + using Microsoft.AspNetCore.Authorization; + using Swashbuckle.AspNetCore.Swagger; + using Swashbuckle.AspNetCore.SwaggerGen; + using System.Collections.Generic; + using System.Linq; + + namespace Basket.API.Infrastructure.Filters + { + public class AuthorizeCheckOperationFilter : IOperationFilter + { + public void Apply(Operation operation, OperationFilterContext context) + { + // Check for authorize attribute + var hasAuthorize = context.ApiDescription.ControllerAttributes().OfType().Any() || + context.ApiDescription.ActionAttributes().OfType().Any(); + + if (hasAuthorize) + { + operation.Responses.Add("401", new Response { Description = "Unauthorized" }); + operation.Responses.Add("403", new Response { Description = "Forbidden" }); + + operation.Security = new List>>(); + operation.Security.Add(new Dictionary> + { + { "oauth2", new [] { "purchasebff" } } + }); + } + } + } + } +} diff --git a/src/BFFs/PurchaseBff/Program.cs b/src/BFFs/PurchaseBff/Program.cs new file mode 100644 index 000000000..fe7210968 --- /dev/null +++ b/src/BFFs/PurchaseBff/Program.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; + +namespace PurchaseBff +{ + public class Program + { + public static void Main(string[] args) + { + BuildWebHost(args).Run(); + } + + public static IWebHost BuildWebHost(string[] args) => + WebHost.CreateDefaultBuilder(args) + .UseStartup() + .Build(); + } +} diff --git a/src/BFFs/PurchaseBff/Properties/launchSettings.json b/src/BFFs/PurchaseBff/Properties/launchSettings.json new file mode 100644 index 000000000..709d1b89a --- /dev/null +++ b/src/BFFs/PurchaseBff/Properties/launchSettings.json @@ -0,0 +1,29 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:61631/", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "api/values", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "PurchaseForMvc": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "api/values", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "http://localhost:61632/" + } + } +} diff --git a/src/BFFs/PurchaseBff/PurchaseBff.csproj b/src/BFFs/PurchaseBff/PurchaseBff.csproj new file mode 100644 index 000000000..b986e743f --- /dev/null +++ b/src/BFFs/PurchaseBff/PurchaseBff.csproj @@ -0,0 +1,23 @@ + + + + netcoreapp2.0 + PurchaseBff + PurchaseBff + ..\..\..\docker-compose.dcproj + + + + + + + + + + + + + + + + diff --git a/src/BFFs/PurchaseBff/Startup.cs b/src/BFFs/PurchaseBff/Startup.cs new file mode 100644 index 000000000..e82ee91fd --- /dev/null +++ b/src/BFFs/PurchaseBff/Startup.cs @@ -0,0 +1,96 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using PurchaseBff.Filters.Basket.API.Infrastructure.Filters; +using Swashbuckle.AspNetCore.Swagger; + +namespace PurchaseBff +{ + public class Startup + { + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + public IConfiguration Configuration { get; } + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + services.AddMvc(); + + services.AddSwaggerGen(options => + { + options.DescribeAllEnumsAsStrings(); + options.SwaggerDoc("v1", new Swashbuckle.AspNetCore.Swagger.Info + { + Title = "Purchase BFF API Gateway", + Version = "v1", + Description = "BFF API Gateway for Purchase features", + TermsOfService = "Terms Of Service" + }); + + options.AddSecurityDefinition("oauth2", new OAuth2Scheme + { + Type = "oauth2", + Flow = "implicit", + AuthorizationUrl = $"{Configuration.GetValue("IdentityUrlExternal")}/connect/authorize", + TokenUrl = $"{Configuration.GetValue("IdentityUrlExternal")}/connect/token", + Scopes = new Dictionary() + { + { "purchasebff", "Purchase BFF API Gateway" } + } + }); + + options.OperationFilter(); + }); + + services.AddCors(options => + { + options.AddPolicy("CorsPolicy", + builder => builder.AllowAnyOrigin() + .AllowAnyMethod() + .AllowAnyHeader() + .AllowCredentials()); + }); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + { + + var pathBase = Configuration["PATH_BASE"]; + if (!string.IsNullOrEmpty(pathBase)) + { + loggerFactory.CreateLogger("init").LogDebug($"Using PATH BASE '{pathBase}'"); + app.UsePathBase(pathBase); + } + + app.UseCors("CorsPolicy"); + + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + + app.UseMvc(); + + app.UseSwagger().UseSwaggerUI(c => + { + c.SwaggerEndpoint($"{ (!string.IsNullOrEmpty(pathBase) ? pathBase : string.Empty) }/swagger/v1/swagger.json", "Purchase BFF V1"); + c.ConfigureOAuth2("purchasebffwaggerui", "", "", "Purchase BFF Swagger UI"); + }); + + + } + } +} diff --git a/src/BFFs/PurchaseBff/appsettings.Development.json b/src/BFFs/PurchaseBff/appsettings.Development.json new file mode 100644 index 000000000..fa8ce71a9 --- /dev/null +++ b/src/BFFs/PurchaseBff/appsettings.Development.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "IncludeScopes": false, + "LogLevel": { + "Default": "Debug", + "System": "Information", + "Microsoft": "Information" + } + } +} diff --git a/src/BFFs/PurchaseBff/appsettings.json b/src/BFFs/PurchaseBff/appsettings.json new file mode 100644 index 000000000..26bb0ac7a --- /dev/null +++ b/src/BFFs/PurchaseBff/appsettings.json @@ -0,0 +1,15 @@ +{ + "Logging": { + "IncludeScopes": false, + "Debug": { + "LogLevel": { + "Default": "Warning" + } + }, + "Console": { + "LogLevel": { + "Default": "Warning" + } + } + } +} diff --git a/src/Services/Basket/Basket.API/Properties/launchSettings.json b/src/Services/Basket/Basket.API/Properties/launchSettings.json index 36effc287..a397c4eb3 100644 --- a/src/Services/Basket/Basket.API/Properties/launchSettings.json +++ b/src/Services/Basket/Basket.API/Properties/launchSettings.json @@ -3,7 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:5103/", + "applicationUrl": "http://localhost:63335/", "sslPort": 0 } }, diff --git a/src/Services/Identity/Identity.API/Configuration/Config.cs b/src/Services/Identity/Identity.API/Configuration/Config.cs index 969b86aa1..9905a04d3 100644 --- a/src/Services/Identity/Identity.API/Configuration/Config.cs +++ b/src/Services/Identity/Identity.API/Configuration/Config.cs @@ -14,7 +14,8 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration new ApiResource("orders", "Orders Service"), new ApiResource("basket", "Basket Service"), new ApiResource("marketing", "Marketing Service"), - new ApiResource("locations", "Locations Service") + new ApiResource("locations", "Locations Service"), + new ApiResource("purchasebff", "Purchase BFF") }; } @@ -52,7 +53,8 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration "orders", "basket", "locations", - "marketing" + "marketing", + "purchasebff" } }, new Client @@ -78,7 +80,8 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration "orders", "basket", "locations", - "marketing" + "marketing", + "purchasebff" }, //Allow requesting refresh tokens for long lived API access AllowOfflineAccess = true, @@ -114,7 +117,8 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration "orders", "basket", "locations", - "marketing" + "marketing", + "purchasebff" }, }, new Client @@ -146,7 +150,8 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration "orders", "basket", "locations", - "marketing" + "marketing", + "purchasebff" }, }, new Client @@ -208,7 +213,23 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration { "orders" } + }, + new Client + { + ClientId = "purchasebffwaggerui", + ClientName = "Purchase BFF Swagger UI", + AllowedGrantTypes = GrantTypes.Implicit, + AllowAccessTokensViaBrowser = true, + + RedirectUris = { $"{clientsUrl["PurchaseBFF"]}/swagger/o2c.html" }, + PostLogoutRedirectUris = { $"{clientsUrl["PurchaseBFF"]}/swagger/" }, + + AllowedScopes = + { + "purchasebff" + } } + }; } } diff --git a/src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs b/src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs index bb41f0d0a..0875361be 100644 --- a/src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs +++ b/src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs @@ -23,6 +23,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Data clientUrls.Add("MarketingApi", configuration.GetValue("MarketingApiClient")); clientUrls.Add("BasketApi", configuration.GetValue("BasketApiClient")); clientUrls.Add("OrderingApi", configuration.GetValue("OrderingApiClient")); + clientUrls.Add("PurchaseBFF", configuration.GetValue("PurchaseBFFClient")); if (!context.Clients.Any()) { diff --git a/src/Services/Payment/Payment.API/Properties/launchSettings.json b/src/Services/Payment/Payment.API/Properties/launchSettings.json index faf310f83..5eac4c092 100644 --- a/src/Services/Payment/Payment.API/Properties/launchSettings.json +++ b/src/Services/Payment/Payment.API/Properties/launchSettings.json @@ -1,9 +1,9 @@ -{ +{ "iisSettings": { "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:3330/", + "applicationUrl": "http://localhost:63336/", "sslPort": 0 } }, @@ -26,4 +26,4 @@ "applicationUrl": "http://localhost:3331" } } -} +} \ No newline at end of file From 47a33ddd05a4c5e00f311059a4a115899c7ce710 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduard=20Tom=C3=A0s?= Date: Mon, 29 Jan 2018 15:58:08 +0000 Subject: [PATCH 07/45] BFF Purchase - WIP --- .dockerignore | 3 +- docker-compose.override.yml | 2 ++ src/BFFs/PurchaseBff/Config/UrlsConfig.cs | 23 ++++++++++++ .../Controllers/BasketController.cs | 32 +++++++++++++++-- .../PurchaseBff/Controllers/HomeController.cs | 18 ++++++++++ .../Models/AddBasketItemRequest.cs | 20 +++++++++++ src/BFFs/PurchaseBff/Models/BasketData.cs | 31 ++++++++++++++++ src/BFFs/PurchaseBff/Models/CatalogItem.cs | 20 +++++++++++ src/BFFs/PurchaseBff/Program.cs | 4 +++ src/BFFs/PurchaseBff/PurchaseBff.csproj | 4 +++ .../PurchaseBff/Services/BasketService.cs | 34 ++++++++++++++++++ .../PurchaseBff/Services/CatalogService.cs | 35 +++++++++++++++++++ .../PurchaseBff/Services/IBasketService.cs | 13 +++++++ .../PurchaseBff/Services/ICatalogService.cs | 13 +++++++ src/BFFs/PurchaseBff/Startup.cs | 11 ++++++ .../PurchaseBff/appsettings.Development.json | 10 ------ .../PurchaseBff/appsettings.localhost.json | 6 ++++ .../Basket.API/Properties/launchSettings.json | 4 +-- .../Properties/launchSettings.json | 3 +- .../Properties/launchSettings.json | 2 +- 20 files changed, 271 insertions(+), 17 deletions(-) create mode 100644 src/BFFs/PurchaseBff/Config/UrlsConfig.cs create mode 100644 src/BFFs/PurchaseBff/Controllers/HomeController.cs create mode 100644 src/BFFs/PurchaseBff/Models/AddBasketItemRequest.cs create mode 100644 src/BFFs/PurchaseBff/Models/BasketData.cs create mode 100644 src/BFFs/PurchaseBff/Models/CatalogItem.cs create mode 100644 src/BFFs/PurchaseBff/Services/BasketService.cs create mode 100644 src/BFFs/PurchaseBff/Services/CatalogService.cs create mode 100644 src/BFFs/PurchaseBff/Services/IBasketService.cs create mode 100644 src/BFFs/PurchaseBff/Services/ICatalogService.cs delete mode 100644 src/BFFs/PurchaseBff/appsettings.Development.json create mode 100644 src/BFFs/PurchaseBff/appsettings.localhost.json diff --git a/.dockerignore b/.dockerignore index b5e7cb4f3..4c8d57b9a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -29,4 +29,5 @@ cli-linux **/node_modules/ **/bower_components/ **/wwwroot/lib/ -global.json \ No newline at end of file +global.json +**/appsettings.localhost.json \ No newline at end of file diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 93c9cde4b..c16d3d109 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -231,6 +231,8 @@ services: purchasebff: environment: - ASPNETCORE_ENVIRONMENT=Development + - urls__basket=http://basket.api + - urls__catalog=http://catalog.api ports: - "5120:80" diff --git a/src/BFFs/PurchaseBff/Config/UrlsConfig.cs b/src/BFFs/PurchaseBff/Config/UrlsConfig.cs new file mode 100644 index 000000000..5c43bdfa7 --- /dev/null +++ b/src/BFFs/PurchaseBff/Config/UrlsConfig.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace PurchaseBff.Config +{ + public class UrlsConfig + { + public class CatalogOperations + { + public static string GetItemById(int id) => $"/api/v1/catalog/items/{id}"; + } + + public class BasketOperations + { + public static string GetItemById(string id) => $"/api/v1/basket/{id}"; + } + + public string Basket { get; set; } + public string Catalog { get; set; } + } +} diff --git a/src/BFFs/PurchaseBff/Controllers/BasketController.cs b/src/BFFs/PurchaseBff/Controllers/BasketController.cs index 7c875c9c4..74d5bec66 100644 --- a/src/BFFs/PurchaseBff/Controllers/BasketController.cs +++ b/src/BFFs/PurchaseBff/Controllers/BasketController.cs @@ -1,4 +1,6 @@ using Microsoft.AspNetCore.Mvc; +using PurchaseBff.Models; +using PurchaseBff.Services; using System; using System.Collections.Generic; using System.Linq; @@ -9,12 +11,38 @@ namespace PurchaseBff.Controllers [Route("api/v1/[controller]")] public class BasketController : Controller { - [HttpPost("items/{catalogItemId}")] - public async Task AddBasketItem(int catalogItemId) + private readonly ICatalogService _catalog; + private readonly IBasketService _basket; + public BasketController(ICatalogService catalogService, IBasketService basketService) { + _catalog = catalogService; + _basket = basketService; + } + + [HttpPost("items")] + public async Task AddBasketItem([FromBody] AddBasketItemRequest data) + { + if (data == null || data.Quantity == 0) + { + return BadRequest("Invalid payload"); + } + // Step 1: Get the item from catalog + var item = await _catalog.GetCatalogItem(data.CatalogItemId); // Step 2: Get current basket status + var currentBasket = await _basket.GetById(data.BasketId); // Step 3: Merge current status with new product + currentBasket.Items.Add(new BasketDataItem() + { + OldUnitPrice = item.Price, + UnitPrice = item.Price, + PictureUrl = item.PictureUri, + ProductId = item.Id.ToString(), + ProductName = item.Name, + Quantity = data.Quantity, + Id = item.Id.ToString() + }); + // Step 4: Update basket return Ok(); diff --git a/src/BFFs/PurchaseBff/Controllers/HomeController.cs b/src/BFFs/PurchaseBff/Controllers/HomeController.cs new file mode 100644 index 000000000..f54ec94ad --- /dev/null +++ b/src/BFFs/PurchaseBff/Controllers/HomeController.cs @@ -0,0 +1,18 @@ +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace PurchaseBff.Controllers +{ + [Route("")] + public class HomeController : Controller + { + [HttpGet()] + public IActionResult Index() + { + return new RedirectResult("~/swagger"); + } + } +} diff --git a/src/BFFs/PurchaseBff/Models/AddBasketItemRequest.cs b/src/BFFs/PurchaseBff/Models/AddBasketItemRequest.cs new file mode 100644 index 000000000..7c589a233 --- /dev/null +++ b/src/BFFs/PurchaseBff/Models/AddBasketItemRequest.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace PurchaseBff.Models +{ + public class AddBasketItemRequest + { + public int CatalogItemId { get; set; } + public string BasketId { get; set; } + + public int Quantity { get; set; } + + public AddBasketItemRequest() + { + Quantity = 1; + } + } +} diff --git a/src/BFFs/PurchaseBff/Models/BasketData.cs b/src/BFFs/PurchaseBff/Models/BasketData.cs new file mode 100644 index 000000000..3f14660a7 --- /dev/null +++ b/src/BFFs/PurchaseBff/Models/BasketData.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace PurchaseBff.Models +{ + public class BasketData + { + public string BuyerId { get; set; } + public List Items { get; set; } + + public BasketData(string buyerId) + { + BuyerId = buyerId; + Items = new List(); + } + } + + public class BasketDataItem + { + public string Id { get; set; } + public string ProductId { get; set; } + public string ProductName { get; set; } + public decimal UnitPrice { get; set; } + public decimal OldUnitPrice { get; set; } + public int Quantity { get; set; } + public string PictureUrl { get; set; } + + } +} diff --git a/src/BFFs/PurchaseBff/Models/CatalogItem.cs b/src/BFFs/PurchaseBff/Models/CatalogItem.cs new file mode 100644 index 000000000..13b0a65c0 --- /dev/null +++ b/src/BFFs/PurchaseBff/Models/CatalogItem.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace PurchaseBff.Models +{ + public class CatalogItem + { + public int Id { get; set; } + + public string Name { get; set; } + + public decimal Price { get; set; } + + + public string PictureUri { get; set; } + + } +} diff --git a/src/BFFs/PurchaseBff/Program.cs b/src/BFFs/PurchaseBff/Program.cs index fe7210968..1c5b19865 100644 --- a/src/BFFs/PurchaseBff/Program.cs +++ b/src/BFFs/PurchaseBff/Program.cs @@ -20,6 +20,10 @@ namespace PurchaseBff public static IWebHost BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup() + .ConfigureAppConfiguration(cb => + { + cb.AddJsonFile("appsettings.localhost.json", optional: true); + }) .Build(); } } diff --git a/src/BFFs/PurchaseBff/PurchaseBff.csproj b/src/BFFs/PurchaseBff/PurchaseBff.csproj index b986e743f..dd7a5909e 100644 --- a/src/BFFs/PurchaseBff/PurchaseBff.csproj +++ b/src/BFFs/PurchaseBff/PurchaseBff.csproj @@ -20,4 +20,8 @@ + + + + diff --git a/src/BFFs/PurchaseBff/Services/BasketService.cs b/src/BFFs/PurchaseBff/Services/BasketService.cs new file mode 100644 index 000000000..023f587aa --- /dev/null +++ b/src/BFFs/PurchaseBff/Services/BasketService.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.eShopOnContainers.BuildingBlocks.Resilience.Http; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using Newtonsoft.Json; +using PurchaseBff.Config; +using PurchaseBff.Models; + +namespace PurchaseBff.Services +{ + public class BasketService : IBasketService + { + + private readonly IHttpClient _apiClient; + private readonly ILogger _logger; + private readonly UrlsConfig _urls; + public BasketService(IHttpClient httpClient, ILogger logger, IOptionsSnapshot config) + { + _apiClient = httpClient; + _logger = logger; + _urls = config.Value; + } + + public async Task GetById(string id) + { + var data = await _apiClient.GetStringAsync(_urls.Basket + UrlsConfig.BasketOperations.GetItemById(id)); + var basket = JsonConvert.DeserializeObject(data); + return basket; + } + } +} diff --git a/src/BFFs/PurchaseBff/Services/CatalogService.cs b/src/BFFs/PurchaseBff/Services/CatalogService.cs new file mode 100644 index 000000000..071c162b4 --- /dev/null +++ b/src/BFFs/PurchaseBff/Services/CatalogService.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.eShopOnContainers.BuildingBlocks.Resilience.Http; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using Newtonsoft.Json; +using PurchaseBff.Config; +using PurchaseBff.Models; + +namespace PurchaseBff.Services +{ + public class CatalogService : ICatalogService + { + + private readonly IHttpClient _apiClient; + private readonly ILogger _logger; + private readonly UrlsConfig _urls; + + public CatalogService(IHttpClient httpClient, ILogger logger, IOptionsSnapshot config) + { + _apiClient = httpClient; + _logger = logger; + _urls = config.Value; + } + + public async Task GetCatalogItem(int id) + { + var data = await _apiClient.GetStringAsync(_urls.Catalog + UrlsConfig.CatalogOperations.GetItemById(id)); + var item = JsonConvert.DeserializeObject(data); + return item; + } + } +} diff --git a/src/BFFs/PurchaseBff/Services/IBasketService.cs b/src/BFFs/PurchaseBff/Services/IBasketService.cs new file mode 100644 index 000000000..b4bafc461 --- /dev/null +++ b/src/BFFs/PurchaseBff/Services/IBasketService.cs @@ -0,0 +1,13 @@ +using PurchaseBff.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace PurchaseBff.Services +{ + public interface IBasketService + { + Task GetById(string id); + } +} diff --git a/src/BFFs/PurchaseBff/Services/ICatalogService.cs b/src/BFFs/PurchaseBff/Services/ICatalogService.cs new file mode 100644 index 000000000..f7caaf6e3 --- /dev/null +++ b/src/BFFs/PurchaseBff/Services/ICatalogService.cs @@ -0,0 +1,13 @@ +using PurchaseBff.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace PurchaseBff.Services +{ + public interface ICatalogService + { + Task GetCatalogItem(int id); + } +} diff --git a/src/BFFs/PurchaseBff/Startup.cs b/src/BFFs/PurchaseBff/Startup.cs index e82ee91fd..689e2925e 100644 --- a/src/BFFs/PurchaseBff/Startup.cs +++ b/src/BFFs/PurchaseBff/Startup.cs @@ -5,11 +5,14 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; +using Microsoft.eShopOnContainers.BuildingBlocks.Resilience.Http; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; +using PurchaseBff.Config; using PurchaseBff.Filters.Basket.API.Infrastructure.Filters; +using PurchaseBff.Services; using Swashbuckle.AspNetCore.Swagger; namespace PurchaseBff @@ -26,6 +29,14 @@ namespace PurchaseBff // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { + services.AddSingleton(); + services.AddSingleton(); + services.AddTransient(); + services.AddTransient(); + + services.AddOptions(); + services.Configure(Configuration.GetSection("urls")); + services.AddMvc(); services.AddSwaggerGen(options => diff --git a/src/BFFs/PurchaseBff/appsettings.Development.json b/src/BFFs/PurchaseBff/appsettings.Development.json deleted file mode 100644 index fa8ce71a9..000000000 --- a/src/BFFs/PurchaseBff/appsettings.Development.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "Logging": { - "IncludeScopes": false, - "LogLevel": { - "Default": "Debug", - "System": "Information", - "Microsoft": "Information" - } - } -} diff --git a/src/BFFs/PurchaseBff/appsettings.localhost.json b/src/BFFs/PurchaseBff/appsettings.localhost.json new file mode 100644 index 000000000..8267075d7 --- /dev/null +++ b/src/BFFs/PurchaseBff/appsettings.localhost.json @@ -0,0 +1,6 @@ +{ + "urls": { + "basket": "http://localhost:55105", + "catalog": "http://localhost:55101" + } +} diff --git a/src/Services/Basket/Basket.API/Properties/launchSettings.json b/src/Services/Basket/Basket.API/Properties/launchSettings.json index a397c4eb3..13aaf431f 100644 --- a/src/Services/Basket/Basket.API/Properties/launchSettings.json +++ b/src/Services/Basket/Basket.API/Properties/launchSettings.json @@ -3,7 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:63335/", + "applicationUrl": "http://localhost:55105/", "sslPort": 0 } }, @@ -19,7 +19,7 @@ "Microsoft.eShopOnContainers.Services.Basket.API": { "commandName": "Project", "launchBrowser": true, - "launchUrl": "http://localhost:5000/swagger", + "launchUrl": "http://localhost:55105/", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/src/Services/Catalog/Catalog.API/Properties/launchSettings.json b/src/Services/Catalog/Catalog.API/Properties/launchSettings.json index 1bf8eb1f3..0357943bb 100644 --- a/src/Services/Catalog/Catalog.API/Properties/launchSettings.json +++ b/src/Services/Catalog/Catalog.API/Properties/launchSettings.json @@ -3,7 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:5101", + "applicationUrl": "http://localhost:55101", "sslPort": 0 } }, @@ -19,6 +19,7 @@ "Microsoft.eShopOnContainers.Services.Catalog.API": { "commandName": "Project", "launchBrowser": true, + "launchUrl": "http://localhost:55101/", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/src/Services/Marketing/Marketing.API/Properties/launchSettings.json b/src/Services/Marketing/Marketing.API/Properties/launchSettings.json index e222e065d..dea046099 100644 --- a/src/Services/Marketing/Marketing.API/Properties/launchSettings.json +++ b/src/Services/Marketing/Marketing.API/Properties/launchSettings.json @@ -3,7 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:5110", + "applicationUrl": "http://localhost:63455/", "sslPort": 0 } }, From dcb9b87361d062804bb67b535be2b46061d0187e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduard=20Tom=C3=A0s?= Date: Tue, 30 Jan 2018 08:50:44 +0000 Subject: [PATCH 08/45] --- docker-compose.override.yml | 2 + src/Apigw/OcelotApiGw/Startup.cs | 11 ++++ .../configuration/configuration.json | 12 ++++ src/BFFs/PurchaseBff/Startup.cs | 24 ++++++++ .../PurchaseBff/appsettings.localhost.json | 3 +- .../Basket.API/Properties/launchSettings.json | 4 +- .../Properties/launchSettings.json | 6 +- src/Web/WebMVC/Controllers/TestController.cs | 56 +++++++++++++++++++ 8 files changed, 112 insertions(+), 6 deletions(-) create mode 100644 src/Web/WebMVC/Controllers/TestController.cs diff --git a/docker-compose.override.yml b/docker-compose.override.yml index c16d3d109..7a27451e2 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -225,6 +225,7 @@ services: apigw: environment: - ASPNETCORE_ENVIRONMENT=Development + - identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. ports: - "5200:80" @@ -233,6 +234,7 @@ services: - ASPNETCORE_ENVIRONMENT=Development - urls__basket=http://basket.api - urls__catalog=http://catalog.api + - urls__identity=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. ports: - "5120:80" diff --git a/src/Apigw/OcelotApiGw/Startup.cs b/src/Apigw/OcelotApiGw/Startup.cs index 487793eda..a7290c1bf 100644 --- a/src/Apigw/OcelotApiGw/Startup.cs +++ b/src/Apigw/OcelotApiGw/Startup.cs @@ -26,6 +26,17 @@ namespace OcelotApiGw public void ConfigureServices(IServiceCollection services) { + var identityUrl = _cfg.GetValue("IdentityUrl"); + var authenticationProviderKey = "IdentityApiKey"; + + services.AddAuthentication() + .AddJwtBearer(authenticationProviderKey, x => + { + x.Authority = identityUrl; + x.RequireHttpsMetadata = false; + x.Audience = "ocelot"; + }); + services.AddOcelot(_cfg); } diff --git a/src/Apigw/OcelotApiGw/configuration/configuration.json b/src/Apigw/OcelotApiGw/configuration/configuration.json index 973f6874c..5d17e6ee3 100644 --- a/src/Apigw/OcelotApiGw/configuration/configuration.json +++ b/src/Apigw/OcelotApiGw/configuration/configuration.json @@ -8,6 +8,18 @@ "UpstreamPathTemplate": "/purchase-bff/catalog/{everything}", "UpstreamHttpMethod": [ "GET" ] }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHost": "purchase-bff", + "DownstreamPort": 80, + "UpstreamPathTemplate": "/purchase-bff/{everything}", + "UpstreamHttpMethod": [], + "AuthenticationOptions": { + "AuthenticationProviderKey": "IdentityApiKey", + "AllowedScopes": [] + } + }, { "DownstreamPathTemplate": "/{everything}", "DownstreamScheme": "http", diff --git a/src/BFFs/PurchaseBff/Startup.cs b/src/BFFs/PurchaseBff/Startup.cs index 689e2925e..491fc7d87 100644 --- a/src/BFFs/PurchaseBff/Startup.cs +++ b/src/BFFs/PurchaseBff/Startup.cs @@ -1,7 +1,9 @@ using System; using System.Collections.Generic; +using System.IdentityModel.Tokens.Jwt; using System.Linq; using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; @@ -73,6 +75,28 @@ namespace PurchaseBff .AllowAnyHeader() .AllowCredentials()); }); + + + JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); + var identityUrl = Configuration.GetValue("urls:identity"); + services.AddAuthentication(options => + { + options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; + options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; + + }).AddJwtBearer(options => + { + options.Authority = identityUrl; + options.RequireHttpsMetadata = false; + options.Audience = "ocelot"; + options.Events = new JwtBearerEvents() + { + OnAuthenticationFailed = async ctx => + { + int i = 0; + } + }; + }); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. diff --git a/src/BFFs/PurchaseBff/appsettings.localhost.json b/src/BFFs/PurchaseBff/appsettings.localhost.json index 8267075d7..a8c119c93 100644 --- a/src/BFFs/PurchaseBff/appsettings.localhost.json +++ b/src/BFFs/PurchaseBff/appsettings.localhost.json @@ -1,6 +1,7 @@ { "urls": { "basket": "http://localhost:55105", - "catalog": "http://localhost:55101" + "catalog": "http://localhost:55101", + "identity": "http://localhost:55105" } } diff --git a/src/Services/Basket/Basket.API/Properties/launchSettings.json b/src/Services/Basket/Basket.API/Properties/launchSettings.json index 13aaf431f..a63a615ad 100644 --- a/src/Services/Basket/Basket.API/Properties/launchSettings.json +++ b/src/Services/Basket/Basket.API/Properties/launchSettings.json @@ -3,7 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:55105/", + "applicationUrl": "http://localhost:55103/", "sslPort": 0 } }, @@ -19,7 +19,7 @@ "Microsoft.eShopOnContainers.Services.Basket.API": { "commandName": "Project", "launchBrowser": true, - "launchUrl": "http://localhost:55105/", + "launchUrl": "http://localhost:55103/", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/src/Services/Identity/Identity.API/Properties/launchSettings.json b/src/Services/Identity/Identity.API/Properties/launchSettings.json index 91f06fd57..c20d94307 100644 --- a/src/Services/Identity/Identity.API/Properties/launchSettings.json +++ b/src/Services/Identity/Identity.API/Properties/launchSettings.json @@ -3,7 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:5105", + "applicationUrl": "http://localhost:55105", "sslPort": 0 } }, @@ -11,7 +11,7 @@ "IIS Express": { "commandName": "IISExpress", "launchBrowser": true, - "launchUrl": "http://localhost:5105", + "launchUrl": "http://localhost:55105", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } @@ -19,7 +19,7 @@ "eShopOnContainers.Identity": { "commandName": "Project", "launchBrowser": true, - "launchUrl": "http://localhost:5000", + "launchUrl": "http://localhost:55105", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/src/Web/WebMVC/Controllers/TestController.cs b/src/Web/WebMVC/Controllers/TestController.cs new file mode 100644 index 000000000..7a2140ea8 --- /dev/null +++ b/src/Web/WebMVC/Controllers/TestController.cs @@ -0,0 +1,56 @@ +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.eShopOnContainers.BuildingBlocks.Resilience.Http; +using Microsoft.eShopOnContainers.WebMVC.Services; +using Microsoft.eShopOnContainers.WebMVC.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace WebMVC.Controllers +{ + class TestPayload + { + public int CatalogItemId { get; set; } + public string BasketId { get; set; } + + public int Quantity { get; set; } + } + + [Authorize] + public class TestController : Controller + { + private readonly IHttpClient _client; + private readonly IIdentityParser _appUserParser; + public TestController(IHttpClient client, IIdentityParser identityParser) + { + _client = client; + _appUserParser = identityParser; + } + + public async Task Ocelot() + { + var url = "http://apigw/purchase-bff/api/v1/basket/items"; + var payload = new TestPayload() + { + CatalogItemId = 1, + Quantity = 1, + BasketId = _appUserParser.Parse(User).Id + }; + var token = await HttpContext.GetTokenAsync("access_token"); + var response = await _client.PostAsync(url, payload, token); + + if (response.IsSuccessStatusCode) + { + var str = await response.Content.ReadAsStringAsync(); + return Ok(str); + } + else + { + return Ok(new { response.StatusCode, response.ReasonPhrase }); + } + } + } +} From e59829e96b90cd45ac3fa1148506f371f65e6f35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduard=20Tom=C3=A0s?= Date: Tue, 30 Jan 2018 17:42:00 +0000 Subject: [PATCH 09/45] WIP on Ocelot: Change routing and config errors. --- src/Apigw/OcelotApiGw/Startup.cs | 12 +++++++++++- .../OcelotApiGw/configuration/configuration.json | 2 +- .../PurchaseBff/Controllers/BasketController.cs | 4 +++- src/BFFs/PurchaseBff/Program.cs | 13 ++++++++++--- src/BFFs/PurchaseBff/Startup.cs | 2 +- .../Basket.API/Properties/launchSettings.json | 2 +- 6 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/Apigw/OcelotApiGw/Startup.cs b/src/Apigw/OcelotApiGw/Startup.cs index a7290c1bf..fa20572b2 100644 --- a/src/Apigw/OcelotApiGw/Startup.cs +++ b/src/Apigw/OcelotApiGw/Startup.cs @@ -34,7 +34,17 @@ namespace OcelotApiGw { x.Authority = identityUrl; x.RequireHttpsMetadata = false; - x.Audience = "ocelot"; + x.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters() + { + ValidAudiences = new[] { "orders", "basket", "locations", "marketing", "purchasebff" } + }; + x.Events = new Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerEvents() + { + OnAuthenticationFailed = async ctx => + { + int i = 0; + } + }; }); services.AddOcelot(_cfg); diff --git a/src/Apigw/OcelotApiGw/configuration/configuration.json b/src/Apigw/OcelotApiGw/configuration/configuration.json index 5d17e6ee3..4aa756512 100644 --- a/src/Apigw/OcelotApiGw/configuration/configuration.json +++ b/src/Apigw/OcelotApiGw/configuration/configuration.json @@ -11,7 +11,7 @@ { "DownstreamPathTemplate": "/{everything}", "DownstreamScheme": "http", - "DownstreamHost": "purchase-bff", + "DownstreamHost": "purchasebff", "DownstreamPort": 80, "UpstreamPathTemplate": "/purchase-bff/{everything}", "UpstreamHttpMethod": [], diff --git a/src/BFFs/PurchaseBff/Controllers/BasketController.cs b/src/BFFs/PurchaseBff/Controllers/BasketController.cs index 74d5bec66..6886ec806 100644 --- a/src/BFFs/PurchaseBff/Controllers/BasketController.cs +++ b/src/BFFs/PurchaseBff/Controllers/BasketController.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; using PurchaseBff.Models; using PurchaseBff.Services; using System; @@ -9,6 +10,7 @@ using System.Threading.Tasks; namespace PurchaseBff.Controllers { [Route("api/v1/[controller]")] + [Authorize] public class BasketController : Controller { private readonly ICatalogService _catalog; diff --git a/src/BFFs/PurchaseBff/Program.cs b/src/BFFs/PurchaseBff/Program.cs index 1c5b19865..7c6110260 100644 --- a/src/BFFs/PurchaseBff/Program.cs +++ b/src/BFFs/PurchaseBff/Program.cs @@ -18,12 +18,19 @@ namespace PurchaseBff } public static IWebHost BuildWebHost(string[] args) => - WebHost.CreateDefaultBuilder(args) - .UseStartup() + WebHost + .CreateDefaultBuilder(args) .ConfigureAppConfiguration(cb => { - cb.AddJsonFile("appsettings.localhost.json", optional: true); + var sources = cb.Sources; + sources.Insert(3, new Microsoft.Extensions.Configuration.Json.JsonConfigurationSource() + { + Optional = true, + Path = "appsettings.localhost.json", + ReloadOnChange = false + }); }) + .UseStartup() .Build(); } } diff --git a/src/BFFs/PurchaseBff/Startup.cs b/src/BFFs/PurchaseBff/Startup.cs index 491fc7d87..07a3f4f71 100644 --- a/src/BFFs/PurchaseBff/Startup.cs +++ b/src/BFFs/PurchaseBff/Startup.cs @@ -88,7 +88,7 @@ namespace PurchaseBff { options.Authority = identityUrl; options.RequireHttpsMetadata = false; - options.Audience = "ocelot"; + options.Audience = "purchasebff"; options.Events = new JwtBearerEvents() { OnAuthenticationFailed = async ctx => diff --git a/src/Services/Basket/Basket.API/Properties/launchSettings.json b/src/Services/Basket/Basket.API/Properties/launchSettings.json index a63a615ad..e42e4f7d1 100644 --- a/src/Services/Basket/Basket.API/Properties/launchSettings.json +++ b/src/Services/Basket/Basket.API/Properties/launchSettings.json @@ -3,7 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:55103/", + "applicationUrl": "http://localhost:51078/", "sslPort": 0 } }, From 1c6431d5032e798701dc90190b8ae1d259bed397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduard=20Tom=C3=A0s?= Date: Wed, 31 Jan 2018 15:35:40 +0000 Subject: [PATCH 10/45] Moved "AddItemToBasket" from MVC Client to a single call in PurchaseBFF --- docker-compose.override.yml | 1 + .../Properties/launchSettings.json | 4 +-- src/Apigw/OcelotApiGw/Startup.cs | 9 +++++ .../configuration/configuration.json | 14 +++++++- src/BFFs/PurchaseBff/Config/UrlsConfig.cs | 1 + .../Controllers/BasketController.cs | 7 ++-- .../PurchaseBff/Services/BasketService.cs | 23 +++++++++++-- .../PurchaseBff/Services/IBasketService.cs | 1 + src/BFFs/PurchaseBff/Startup.cs | 6 ++++ .../Basket.API/Properties/launchSettings.json | 2 +- .../Properties/launchSettings.json | 2 +- .../Properties/launchSettings.json | 6 ++-- src/Web/WebMVC/AppSettings.cs | 2 ++ src/Web/WebMVC/Controllers/CartController.cs | 14 ++------ src/Web/WebMVC/Infrastructure/API.cs | 31 ++++++----------- src/Web/WebMVC/Services/BasketService.cs | 34 ++++++++++--------- src/Web/WebMVC/Services/IBasketService.cs | 2 +- src/Web/WebMVC/Startup.cs | 1 + src/Web/WebMVC/ViewModels/CatalogItem.cs | 2 +- src/Web/WebMVC/Views/Catalog/_product.cshtml | 8 ----- src/Web/WebSPA/Properties/launchSettings.json | 2 +- .../Basket/Application/CartControllerTest.cs | 4 +-- .../Application/CatalogControllerTest.cs | 6 ++-- 23 files changed, 106 insertions(+), 76 deletions(-) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 7a27451e2..4b4e3469b 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -137,6 +137,7 @@ services: - CatalogUrl=http://catalog.api - OrderingUrl=http://ordering.api - BasketUrl=http://basket.api + - PurchaseUrl=http://apigw/purchase-bff - LocationsUrl=http://locations.api - IdentityUrl=http://10.0.75.1:5105 # Local Mac: Use http://docker.for.mac.localhost:5105 || Local Windows: Use 10.0.75.1 in a "Docker for Windows" environment, if using "localhost" from browser. || #Remote access: Use ${ESHOP_EXTERNAL_DNS_NAME_OR_IP} if using external IP or DNS name from browser. - MarketingUrl=http://marketing.api diff --git a/src/Apigw/OcelotApiGw/Properties/launchSettings.json b/src/Apigw/OcelotApiGw/Properties/launchSettings.json index 796011a33..2308ca466 100644 --- a/src/Apigw/OcelotApiGw/Properties/launchSettings.json +++ b/src/Apigw/OcelotApiGw/Properties/launchSettings.json @@ -3,7 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:64020/", + "applicationUrl": "http://localhost:56755/", "sslPort": 0 } }, @@ -24,4 +24,4 @@ "applicationUrl": "http://localhost:64021/" } } -} +} \ No newline at end of file diff --git a/src/Apigw/OcelotApiGw/Startup.cs b/src/Apigw/OcelotApiGw/Startup.cs index fa20572b2..9c7eb18ef 100644 --- a/src/Apigw/OcelotApiGw/Startup.cs +++ b/src/Apigw/OcelotApiGw/Startup.cs @@ -41,6 +41,15 @@ namespace OcelotApiGw x.Events = new Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerEvents() { OnAuthenticationFailed = async ctx => + { + int i = 0; + }, + OnTokenValidated = async ctx => + { + int i = 0; + }, + + OnMessageReceived = async ctx => { int i = 0; } diff --git a/src/Apigw/OcelotApiGw/configuration/configuration.json b/src/Apigw/OcelotApiGw/configuration/configuration.json index 4aa756512..2e95c8843 100644 --- a/src/Apigw/OcelotApiGw/configuration/configuration.json +++ b/src/Apigw/OcelotApiGw/configuration/configuration.json @@ -8,13 +8,25 @@ "UpstreamPathTemplate": "/purchase-bff/catalog/{everything}", "UpstreamHttpMethod": [ "GET" ] }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHost": "basket.api", + "DownstreamPort": 80, + "UpstreamPathTemplate": "/purchase-bff/basket/{everything}", + "UpstreamHttpMethod": [ "GET" ], + "AuthenticationOptions": { + "AuthenticationProviderKey": "IdentityApiKey", + "AllowedScopes": [] + } + }, { "DownstreamPathTemplate": "/{everything}", "DownstreamScheme": "http", "DownstreamHost": "purchasebff", "DownstreamPort": 80, "UpstreamPathTemplate": "/purchase-bff/{everything}", - "UpstreamHttpMethod": [], + "UpstreamHttpMethod": ["POST"], "AuthenticationOptions": { "AuthenticationProviderKey": "IdentityApiKey", "AllowedScopes": [] diff --git a/src/BFFs/PurchaseBff/Config/UrlsConfig.cs b/src/BFFs/PurchaseBff/Config/UrlsConfig.cs index 5c43bdfa7..2079a4615 100644 --- a/src/BFFs/PurchaseBff/Config/UrlsConfig.cs +++ b/src/BFFs/PurchaseBff/Config/UrlsConfig.cs @@ -15,6 +15,7 @@ namespace PurchaseBff.Config public class BasketOperations { public static string GetItemById(string id) => $"/api/v1/basket/{id}"; + public static string UpdateBasket() => $"/api/v1/basket"; } public string Basket { get; set; } diff --git a/src/BFFs/PurchaseBff/Controllers/BasketController.cs b/src/BFFs/PurchaseBff/Controllers/BasketController.cs index 6886ec806..6030dfadb 100644 --- a/src/BFFs/PurchaseBff/Controllers/BasketController.cs +++ b/src/BFFs/PurchaseBff/Controllers/BasketController.cs @@ -32,20 +32,21 @@ namespace PurchaseBff.Controllers // Step 1: Get the item from catalog var item = await _catalog.GetCatalogItem(data.CatalogItemId); // Step 2: Get current basket status - var currentBasket = await _basket.GetById(data.BasketId); + var currentBasket = (await _basket.GetById(data.BasketId)) ?? new BasketData(data.BasketId); // Step 3: Merge current status with new product currentBasket.Items.Add(new BasketDataItem() { - OldUnitPrice = item.Price, UnitPrice = item.Price, PictureUrl = item.PictureUri, ProductId = item.Id.ToString(), ProductName = item.Name, Quantity = data.Quantity, - Id = item.Id.ToString() + Id = Guid.NewGuid().ToString() }); // Step 4: Update basket + await _basket.Update(currentBasket); + return Ok(); } diff --git a/src/BFFs/PurchaseBff/Services/BasketService.cs b/src/BFFs/PurchaseBff/Services/BasketService.cs index 023f587aa..881718baf 100644 --- a/src/BFFs/PurchaseBff/Services/BasketService.cs +++ b/src/BFFs/PurchaseBff/Services/BasketService.cs @@ -2,6 +2,8 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Http; using Microsoft.eShopOnContainers.BuildingBlocks.Resilience.Http; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -17,18 +19,35 @@ namespace PurchaseBff.Services private readonly IHttpClient _apiClient; private readonly ILogger _logger; private readonly UrlsConfig _urls; - public BasketService(IHttpClient httpClient, ILogger logger, IOptionsSnapshot config) + private readonly IHttpContextAccessor _httpContextAccessor; + + public BasketService(IHttpClient httpClient, IHttpContextAccessor httpContextAccessor, ILogger logger, IOptionsSnapshot config) { _apiClient = httpClient; _logger = logger; _urls = config.Value; + _httpContextAccessor = httpContextAccessor; } public async Task GetById(string id) { - var data = await _apiClient.GetStringAsync(_urls.Basket + UrlsConfig.BasketOperations.GetItemById(id)); + var token = await GetUserTokenAsync(); + var data = await _apiClient.GetStringAsync(_urls.Basket + UrlsConfig.BasketOperations.GetItemById(id), token); var basket = JsonConvert.DeserializeObject(data); return basket; } + + public async Task Update(BasketData currentBasket) + { + var token = await GetUserTokenAsync(); + var data = await _apiClient.PostAsync(_urls.Basket + UrlsConfig.BasketOperations.UpdateBasket(), currentBasket, token); + int i = 0; + } + + async Task GetUserTokenAsync() + { + var context = _httpContextAccessor.HttpContext; + return await context.GetTokenAsync("access_token"); + } } } diff --git a/src/BFFs/PurchaseBff/Services/IBasketService.cs b/src/BFFs/PurchaseBff/Services/IBasketService.cs index b4bafc461..0c33c5c41 100644 --- a/src/BFFs/PurchaseBff/Services/IBasketService.cs +++ b/src/BFFs/PurchaseBff/Services/IBasketService.cs @@ -9,5 +9,6 @@ namespace PurchaseBff.Services public interface IBasketService { Task GetById(string id); + Task Update(BasketData currentBasket); } } diff --git a/src/BFFs/PurchaseBff/Startup.cs b/src/BFFs/PurchaseBff/Startup.cs index 07a3f4f71..13fdcc269 100644 --- a/src/BFFs/PurchaseBff/Startup.cs +++ b/src/BFFs/PurchaseBff/Startup.cs @@ -92,6 +92,10 @@ namespace PurchaseBff options.Events = new JwtBearerEvents() { OnAuthenticationFailed = async ctx => + { + int i = 0; + }, + OnTokenValidated = async ctx => { int i = 0; } @@ -117,6 +121,8 @@ namespace PurchaseBff app.UseDeveloperExceptionPage(); } + app.UseAuthentication(); + app.UseMvc(); app.UseSwagger().UseSwaggerUI(c => diff --git a/src/Services/Basket/Basket.API/Properties/launchSettings.json b/src/Services/Basket/Basket.API/Properties/launchSettings.json index e42e4f7d1..0045edd47 100644 --- a/src/Services/Basket/Basket.API/Properties/launchSettings.json +++ b/src/Services/Basket/Basket.API/Properties/launchSettings.json @@ -3,7 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:51078/", + "applicationUrl": "http://localhost:56695/", "sslPort": 0 } }, diff --git a/src/Services/Catalog/Catalog.API/Properties/launchSettings.json b/src/Services/Catalog/Catalog.API/Properties/launchSettings.json index 0357943bb..28f08bad2 100644 --- a/src/Services/Catalog/Catalog.API/Properties/launchSettings.json +++ b/src/Services/Catalog/Catalog.API/Properties/launchSettings.json @@ -3,7 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:55101", + "applicationUrl": "http://localhost:56698/", "sslPort": 0 } }, diff --git a/src/Services/Location/Locations.API/Properties/launchSettings.json b/src/Services/Location/Locations.API/Properties/launchSettings.json index 45b637914..6401e4bbe 100644 --- a/src/Services/Location/Locations.API/Properties/launchSettings.json +++ b/src/Services/Location/Locations.API/Properties/launchSettings.json @@ -1,9 +1,9 @@ -{ +{ "iisSettings": { "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:3278/", + "applicationUrl": "http://localhost:53933/", "sslPort": 0 } }, @@ -26,4 +26,4 @@ "applicationUrl": "http://localhost:3279" } } -} +} \ No newline at end of file diff --git a/src/Web/WebMVC/AppSettings.cs b/src/Web/WebMVC/AppSettings.cs index 42100ab62..18db7d4bf 100644 --- a/src/Web/WebMVC/AppSettings.cs +++ b/src/Web/WebMVC/AppSettings.cs @@ -13,6 +13,8 @@ namespace Microsoft.eShopOnContainers.WebMVC public string BasketUrl { get; set; } public string MarketingUrl { get; set; } public string LocationsUrl { get; set; } + + public string PurchaseUrl { get; set; } public bool ActivateCampaignDetailFunction { get; set; } public Logging Logging { get; set; } public bool UseCustomizationData { get; set; } diff --git a/src/Web/WebMVC/Controllers/CartController.cs b/src/Web/WebMVC/Controllers/CartController.cs index 8b41c5320..94f50a2de 100644 --- a/src/Web/WebMVC/Controllers/CartController.cs +++ b/src/Web/WebMVC/Controllers/CartController.cs @@ -70,19 +70,11 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers { try { - if (productDetails.Id != null) + if (productDetails?.Id != null) { var user = _appUserParser.Parse(HttpContext.User); - var product = new BasketItem() - { - Id = Guid.NewGuid().ToString(), - Quantity = 1, - ProductName = productDetails.Name, - PictureUrl = productDetails.PictureUri, - UnitPrice = productDetails.Price, - ProductId = productDetails.Id - }; - await _basketSvc.AddItemToBasket(user, product); + await _basketSvc.AddItemToBasket(user, productDetails.Id); + //await _basketSvc.AddItemToBasket(user, product); } return RedirectToAction("Index", "Catalog"); } diff --git a/src/Web/WebMVC/Infrastructure/API.cs b/src/Web/WebMVC/Infrastructure/API.cs index edb2c5ed5..b59183512 100644 --- a/src/Web/WebMVC/Infrastructure/API.cs +++ b/src/Web/WebMVC/Infrastructure/API.cs @@ -4,27 +4,18 @@ namespace WebMVC.Infrastructure { public static class API { - public static class Basket - { - public static string GetBasket(string baseUri, string basketId) - { - return $"{baseUri}/{basketId}"; - } - public static string UpdateBasket(string baseUri) - { - return baseUri; - } - - public static string CheckoutBasket(string baseUri) - { - return $"{baseUri}/checkout"; - } + public static class Purchase + { + public static string AddItemToBasket(string baseUri) => $"{baseUri}/basket/items"; + } - public static string CleanBasket(string baseUri, string basketId) - { - return $"{baseUri}/{basketId}"; - } + public static class Basket + { + public static string GetBasket(string baseUri, string basketId) => $"{baseUri}/{basketId}"; + public static string UpdateBasket(string baseUri) => baseUri; + public static string CheckoutBasket(string baseUri) => $"{baseUri}/checkout"; + public static string CleanBasket(string baseUri, string basketId) => $"{baseUri}/{basketId}"; } public static class Order @@ -100,7 +91,7 @@ namespace WebMVC.Infrastructure public static string CreateOrUpdateUserLocation(string baseUri) { return baseUri; - } + } } } } \ No newline at end of file diff --git a/src/Web/WebMVC/Services/BasketService.cs b/src/Web/WebMVC/Services/BasketService.cs index 6c8524800..e167f73cc 100644 --- a/src/Web/WebMVC/Services/BasketService.cs +++ b/src/Web/WebMVC/Services/BasketService.cs @@ -14,14 +14,19 @@ namespace Microsoft.eShopOnContainers.WebMVC.Services public class BasketService : IBasketService { private readonly IOptionsSnapshot _settings; - private IHttpClient _apiClient; + private readonly IHttpClient _apiClient; private readonly string _remoteServiceBaseUrl; - private IHttpContextAccessor _httpContextAccesor; + private readonly string _purchaseUrl; + private readonly IHttpContextAccessor _httpContextAccesor; - public BasketService(IOptionsSnapshot settings, IHttpContextAccessor httpContextAccesor, IHttpClient httpClient) + private readonly string _bffUrl; + + public BasketService(IOptionsSnapshot settings, + IHttpContextAccessor httpContextAccesor, IHttpClient httpClient) { _settings = settings; _remoteServiceBaseUrl = $"{_settings.Value.BasketUrl}/api/v1/basket"; + _purchaseUrl = $"{_settings.Value.PurchaseUrl}/api/v1"; _httpContextAccesor = httpContextAccesor; _apiClient = httpClient; } @@ -104,23 +109,20 @@ namespace Microsoft.eShopOnContainers.WebMVC.Services return order; } - public async Task AddItemToBasket(ApplicationUser user, BasketItem product) + public async Task AddItemToBasket(ApplicationUser user, int productId) { - var basket = await GetBasket(user); + var token = await GetUserTokenAsync(); + var updateBasketUri = API.Purchase.AddItemToBasket(_purchaseUrl); + var userId = user.Id; - if (basket == null) + var response = await _apiClient.PostAsync(updateBasketUri, new { - basket = new Basket() - { - BuyerId = user.Id, - Items = new List() - }; - } - - basket.Items.Add(product); + CatalogItemId = productId, + BasketId = userId, + Quantity = 1 + }, token); - await UpdateBasket(basket); - } + } async Task GetUserTokenAsync() { diff --git a/src/Web/WebMVC/Services/IBasketService.cs b/src/Web/WebMVC/Services/IBasketService.cs index 13921909a..78898de7d 100644 --- a/src/Web/WebMVC/Services/IBasketService.cs +++ b/src/Web/WebMVC/Services/IBasketService.cs @@ -10,7 +10,7 @@ namespace Microsoft.eShopOnContainers.WebMVC.Services public interface IBasketService { Task GetBasket(ApplicationUser user); - Task AddItemToBasket(ApplicationUser user, BasketItem product); + Task AddItemToBasket(ApplicationUser user, int productId); Task UpdateBasket(Basket basket); Task Checkout(BasketDTO basket); Task SetQuantities(ApplicationUser user, Dictionary quantities); diff --git a/src/Web/WebMVC/Startup.cs b/src/Web/WebMVC/Startup.cs index ced47ea67..e9e86d1cd 100644 --- a/src/Web/WebMVC/Startup.cs +++ b/src/Web/WebMVC/Startup.cs @@ -130,6 +130,7 @@ namespace Microsoft.eShopOnContainers.WebMVC options.Scope.Add("basket"); options.Scope.Add("marketing"); options.Scope.Add("locations"); + options.Scope.Add("purchasebff"); }); } diff --git a/src/Web/WebMVC/ViewModels/CatalogItem.cs b/src/Web/WebMVC/ViewModels/CatalogItem.cs index 6dd216d1d..c869b7382 100644 --- a/src/Web/WebMVC/ViewModels/CatalogItem.cs +++ b/src/Web/WebMVC/ViewModels/CatalogItem.cs @@ -4,7 +4,7 @@ namespace Microsoft.eShopOnContainers.WebMVC.ViewModels { public class CatalogItem { - public string Id { get; set; } + public int Id { get; set; } public string Name { get; set; } public string Description { get; set; } public decimal Price { get; set; } diff --git a/src/Web/WebMVC/Views/Catalog/_product.cshtml b/src/Web/WebMVC/Views/Catalog/_product.cshtml index 11138b55d..0fb1c39c4 100644 --- a/src/Web/WebMVC/Views/Catalog/_product.cshtml +++ b/src/Web/WebMVC/Views/Catalog/_product.cshtml @@ -12,13 +12,5 @@
@Model.Price.ToString("N2")
- - - - - - - - diff --git a/src/Web/WebSPA/Properties/launchSettings.json b/src/Web/WebSPA/Properties/launchSettings.json index fd33f59ec..9be3bf34a 100644 --- a/src/Web/WebSPA/Properties/launchSettings.json +++ b/src/Web/WebSPA/Properties/launchSettings.json @@ -3,7 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:5104/", + "applicationUrl": "http://localhost:56727/", "sslPort": 0 } }, diff --git a/test/Services/UnitTest/Basket/Application/CartControllerTest.cs b/test/Services/UnitTest/Basket/Application/CartControllerTest.cs index 6bdd2c43c..63f74cf35 100644 --- a/test/Services/UnitTest/Basket/Application/CartControllerTest.cs +++ b/test/Services/UnitTest/Basket/Application/CartControllerTest.cs @@ -92,7 +92,7 @@ namespace UnitTest.Basket.Application //Arrange var fakeCatalogItem = GetFakeCatalogItem(); - _basketServiceMock.Setup(x => x.AddItemToBasket(It.IsAny(), It.IsAny())) + _basketServiceMock.Setup(x => x.AddItemToBasket(It.IsAny(), It.IsAny())) .Returns(Task.FromResult(1)); //Act @@ -118,7 +118,7 @@ namespace UnitTest.Basket.Application { return new CatalogItem() { - Id = "1", + Id = 1, Name = "fakeName", CatalogBrand = "fakeBrand", CatalogType = "fakeType", diff --git a/test/Services/UnitTest/Catalog/Application/CatalogControllerTest.cs b/test/Services/UnitTest/Catalog/Application/CatalogControllerTest.cs index 58d32c212..7410551e4 100644 --- a/test/Services/UnitTest/Catalog/Application/CatalogControllerTest.cs +++ b/test/Services/UnitTest/Catalog/Application/CatalogControllerTest.cs @@ -67,19 +67,19 @@ namespace UnitTest.Catalog.Application { new CatalogItem() { - Id = "1", + Id = 1, Name = "fakeItemA", CatalogTypeId = 1 }, new CatalogItem() { - Id = "2", + Id = 2, Name = "fakeItemB", CatalogTypeId = 1 }, new CatalogItem() { - Id = "3", + Id = 3, Name = "fakeItemC", CatalogTypeId = 1 } From d8382f8d523807d822fa93429e1523af73478d8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduard=20Tom=C3=A0s?= Date: Wed, 31 Jan 2018 15:46:10 +0000 Subject: [PATCH 11/45] Changed catalog.api url from catalog.api to pass through API gateway --- docker-compose.override.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 4b4e3469b..0a0b547b4 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -134,7 +134,7 @@ services: environment: - ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_URLS=http://0.0.0.0:80 - - CatalogUrl=http://catalog.api + - CatalogUrl=http://apigw/purchase-bff/catalog - OrderingUrl=http://ordering.api - BasketUrl=http://basket.api - PurchaseUrl=http://apigw/purchase-bff From 0256c6a7ad75403c8a5d4cf1587e41550aaf58a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduard=20Tom=C3=A0s?= Date: Wed, 31 Jan 2018 16:29:06 +0000 Subject: [PATCH 12/45] Moved Change Basket Quantities to PurchaseBFF. MVC client updated --- .../configuration/configuration.json | 2 +- .../Controllers/BasketController.cs | 35 ++++++++++++++++++- src/Web/WebMVC/Controllers/CartController.cs | 1 - src/Web/WebMVC/Infrastructure/API.cs | 1 + src/Web/WebMVC/Services/BasketService.cs | 24 ++++++++----- 5 files changed, 51 insertions(+), 12 deletions(-) diff --git a/src/Apigw/OcelotApiGw/configuration/configuration.json b/src/Apigw/OcelotApiGw/configuration/configuration.json index 2e95c8843..5216c9540 100644 --- a/src/Apigw/OcelotApiGw/configuration/configuration.json +++ b/src/Apigw/OcelotApiGw/configuration/configuration.json @@ -26,7 +26,7 @@ "DownstreamHost": "purchasebff", "DownstreamPort": 80, "UpstreamPathTemplate": "/purchase-bff/{everything}", - "UpstreamHttpMethod": ["POST"], + "UpstreamHttpMethod": [ "POST", "PUT" ], "AuthenticationOptions": { "AuthenticationProviderKey": "IdentityApiKey", "AllowedScopes": [] diff --git a/src/BFFs/PurchaseBff/Controllers/BasketController.cs b/src/BFFs/PurchaseBff/Controllers/BasketController.cs index 6030dfadb..12290a127 100644 --- a/src/BFFs/PurchaseBff/Controllers/BasketController.cs +++ b/src/BFFs/PurchaseBff/Controllers/BasketController.cs @@ -21,7 +21,40 @@ namespace PurchaseBff.Controllers _basket = basketService; } - [HttpPost("items")] + [HttpPut] + [Route("items")] + public async Task UpdateQuantities([FromBody] UpdateBasketItemsRequest data) + { + if (!data.Updates.Any()) + { + return BadRequest("No updates sent"); + } + + // Retrieve the current basket + var currentBasket = await _basket.GetById(data.BasketId); + if (currentBasket == null) + { + return BadRequest($"Basket with id {data.BasketId} not found."); + } + + // Update with new quantities + foreach (var update in data.Updates) + { + var basketItem = currentBasket.Items.SingleOrDefault(bitem => bitem.Id == update.BasketItemId); + if (basketItem == null) + { + return BadRequest($"Basket item with id {update.BasketItemId} not found"); + } + basketItem.Quantity = update.NewQty; + } + + // Save the updated basket + await _basket.Update(currentBasket); + return Ok(currentBasket); + } + + [HttpPost] + [Route("items")] public async Task AddBasketItem([FromBody] AddBasketItemRequest data) { if (data == null || data.Quantity == 0) diff --git a/src/Web/WebMVC/Controllers/CartController.cs b/src/Web/WebMVC/Controllers/CartController.cs index 94f50a2de..41484d79c 100644 --- a/src/Web/WebMVC/Controllers/CartController.cs +++ b/src/Web/WebMVC/Controllers/CartController.cs @@ -49,7 +49,6 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers { var user = _appUserParser.Parse(HttpContext.User); var basket = await _basketSvc.SetQuantities(user, quantities); - var vm = await _basketSvc.UpdateBasket(basket); if (action == "[ Checkout ]") { diff --git a/src/Web/WebMVC/Infrastructure/API.cs b/src/Web/WebMVC/Infrastructure/API.cs index b59183512..765ee3e9b 100644 --- a/src/Web/WebMVC/Infrastructure/API.cs +++ b/src/Web/WebMVC/Infrastructure/API.cs @@ -8,6 +8,7 @@ namespace WebMVC.Infrastructure public static class Purchase { public static string AddItemToBasket(string baseUri) => $"{baseUri}/basket/items"; + public static string UpdateBasketItem(string baseUri) => $"{baseUri}/basket/items"; } public static class Basket diff --git a/src/Web/WebMVC/Services/BasketService.cs b/src/Web/WebMVC/Services/BasketService.cs index e167f73cc..1c4b2aa87 100644 --- a/src/Web/WebMVC/Services/BasketService.cs +++ b/src/Web/WebMVC/Services/BasketService.cs @@ -5,6 +5,7 @@ using Microsoft.eShopOnContainers.WebMVC.ViewModels; using Microsoft.Extensions.Options; using Newtonsoft.Json; using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using WebMVC.Infrastructure; using WebMVC.Models; @@ -72,19 +73,24 @@ namespace Microsoft.eShopOnContainers.WebMVC.Services public async Task SetQuantities(ApplicationUser user, Dictionary quantities) { - var basket = await GetBasket(user); - basket.Items.ForEach(x => + var token = await GetUserTokenAsync(); + var updateBasketUri = API.Purchase.UpdateBasketItem(_purchaseUrl); + var userId = user.Id; + + var response = await _apiClient.PutAsync(updateBasketUri, new { - // Simplify this logic by using the - // new out variable initializer. - if (quantities.TryGetValue(x.Id, out var quantity)) + BasketId = userId, + Updates = quantities.Select(kvp => new { - x.Quantity = quantity; - } - }); + BasketItemId = kvp.Key, + NewQty = kvp.Value + }).ToArray() + }, token); - return basket; + response.EnsureSuccessStatusCode(); + var jsonResponse = await response.Content.ReadAsStringAsync(); + return JsonConvert.DeserializeObject(jsonResponse); } public Order MapBasketToOrder(Basket basket) From 2a2f3a4da195539f43d99e116b0d5fba5cd5007d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduard=20Tom=C3=A0s?= Date: Wed, 31 Jan 2018 16:29:19 +0000 Subject: [PATCH 13/45] Added missing file --- .../Models/UpdateBasketItemsRequest.cs | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/BFFs/PurchaseBff/Models/UpdateBasketItemsRequest.cs diff --git a/src/BFFs/PurchaseBff/Models/UpdateBasketItemsRequest.cs b/src/BFFs/PurchaseBff/Models/UpdateBasketItemsRequest.cs new file mode 100644 index 000000000..eb63efa23 --- /dev/null +++ b/src/BFFs/PurchaseBff/Models/UpdateBasketItemsRequest.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace PurchaseBff.Models +{ + public class UpdateBasketItemsRequest + { + + public string BasketId { get; set; } + + public ICollection Updates { get; set; } + + public UpdateBasketItemsRequest() + { + Updates = new List(); + } + } + + public class UpdateBasketItemData + { + public string BasketItemId { get; set; } + public int NewQty { get; set; } + + public UpdateBasketItemData() + { + NewQty = 0; + } + } +} From 2a81a080bacb978172c88097acb3c064b483d2bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduard=20Tom=C3=A0s?= Date: Thu, 1 Feb 2018 14:04:20 +0000 Subject: [PATCH 14/45] Moved Create Order from MVC logic client to Purchase logic. --- .../configuration/configuration.json | 2 +- .../Controllers/OrderController.cs | 40 +++++++++++++++++++ src/BFFs/PurchaseBff/Models/OrderData.cs | 33 +++++++++++++++ src/BFFs/PurchaseBff/Models/OrderItemData.cs | 17 ++++++++ .../Properties/launchSettings.json | 4 +- .../PurchaseBff/Services/BasketService.cs | 25 ++++++++++++ .../PurchaseBff/Services/IBasketService.cs | 2 + .../Basket.API/Properties/launchSettings.json | 2 +- .../Properties/launchSettings.json | 2 +- src/Web/WebMVC/Controllers/CartController.cs | 2 - src/Web/WebMVC/Controllers/OrderController.cs | 4 +- src/Web/WebMVC/Infrastructure/API.cs | 2 + src/Web/WebMVC/Services/BasketService.cs | 24 +++-------- src/Web/WebMVC/Services/IBasketService.cs | 2 +- src/Web/WebSPA/Properties/launchSettings.json | 2 +- .../Application/OrderControllerTest.cs | 35 +--------------- 16 files changed, 135 insertions(+), 63 deletions(-) create mode 100644 src/BFFs/PurchaseBff/Controllers/OrderController.cs create mode 100644 src/BFFs/PurchaseBff/Models/OrderData.cs create mode 100644 src/BFFs/PurchaseBff/Models/OrderItemData.cs diff --git a/src/Apigw/OcelotApiGw/configuration/configuration.json b/src/Apigw/OcelotApiGw/configuration/configuration.json index 5216c9540..cc2defca6 100644 --- a/src/Apigw/OcelotApiGw/configuration/configuration.json +++ b/src/Apigw/OcelotApiGw/configuration/configuration.json @@ -26,7 +26,7 @@ "DownstreamHost": "purchasebff", "DownstreamPort": 80, "UpstreamPathTemplate": "/purchase-bff/{everything}", - "UpstreamHttpMethod": [ "POST", "PUT" ], + "UpstreamHttpMethod": [ "POST", "PUT", "GET" ], "AuthenticationOptions": { "AuthenticationProviderKey": "IdentityApiKey", "AllowedScopes": [] diff --git a/src/BFFs/PurchaseBff/Controllers/OrderController.cs b/src/BFFs/PurchaseBff/Controllers/OrderController.cs new file mode 100644 index 000000000..7e7b00c1b --- /dev/null +++ b/src/BFFs/PurchaseBff/Controllers/OrderController.cs @@ -0,0 +1,40 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using PurchaseBff.Services; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace PurchaseBff.Controllers +{ + [Route("api/v1/[controller]")] + [Authorize] + public class OrderController : Controller + { + private readonly IBasketService _basketService; + public OrderController(IBasketService basketService) + { + _basketService = basketService; + } + + [Route("draft/{basketId}")] + [HttpGet] + public async Task GetOrderDraft(string basketId) + { + if (string.IsNullOrEmpty(basketId)) + { + return BadRequest("Need a valid basketid"); + } + // Get the basket data and build a order draft based on it + var basket = await _basketService.GetById(basketId); + if (basket == null) + { + return BadRequest($"No basket found for id {basketId}"); + } + + var order = _basketService.MapBasketToOrder(basket, isDraft: true); + return Ok(order); + } + } +} diff --git a/src/BFFs/PurchaseBff/Models/OrderData.cs b/src/BFFs/PurchaseBff/Models/OrderData.cs new file mode 100644 index 000000000..c561a53ad --- /dev/null +++ b/src/BFFs/PurchaseBff/Models/OrderData.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace PurchaseBff.Models +{ + public class OrderData + { + public string OrderNumber { get; set; } + public DateTime Date { get; set; } + public string Status { get; set; } + public decimal Total { get; set; } + public string Description { get; set; } + public string City { get; set; } + public string Street { get; set; } + public string State { get; set; } + public string Country { get; set; } + public string ZipCode { get; set; } + public string CardNumber { get; set; } + public string CardHolderName { get; set; } + public bool IsDraft { get; set; } + public DateTime CardExpiration { get; set; } + public string CardExpirationShort { get; set; } + public string CardSecurityNumber { get; set; } + + public int CardTypeId { get; set; } + + public string Buyer { get; set; } + + public List OrderItems { get; } = new List(); + } +} diff --git a/src/BFFs/PurchaseBff/Models/OrderItemData.cs b/src/BFFs/PurchaseBff/Models/OrderItemData.cs new file mode 100644 index 000000000..bdc7b361e --- /dev/null +++ b/src/BFFs/PurchaseBff/Models/OrderItemData.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace PurchaseBff.Models +{ + public class OrderItemData + { + public int ProductId { get; set; } + public string ProductName { get; set; } + public decimal UnitPrice { get; set; } + public decimal Discount { get; set; } + public int Units { get; set; } + public string PictureUrl { get; set; } + } +} diff --git a/src/BFFs/PurchaseBff/Properties/launchSettings.json b/src/BFFs/PurchaseBff/Properties/launchSettings.json index 709d1b89a..d6c88d211 100644 --- a/src/BFFs/PurchaseBff/Properties/launchSettings.json +++ b/src/BFFs/PurchaseBff/Properties/launchSettings.json @@ -3,7 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:61631/", + "applicationUrl": "http://localhost:58243/", "sslPort": 0 } }, @@ -26,4 +26,4 @@ "applicationUrl": "http://localhost:61632/" } } -} +} \ No newline at end of file diff --git a/src/BFFs/PurchaseBff/Services/BasketService.cs b/src/BFFs/PurchaseBff/Services/BasketService.cs index 881718baf..fd16843a1 100644 --- a/src/BFFs/PurchaseBff/Services/BasketService.cs +++ b/src/BFFs/PurchaseBff/Services/BasketService.cs @@ -44,6 +44,31 @@ namespace PurchaseBff.Services int i = 0; } + public OrderData MapBasketToOrder(BasketData basket, bool isDraft) + { + var order = new OrderData + { + Total = 0, + IsDraft = isDraft + }; + + basket.Items.ForEach(x => + { + order.OrderItems.Add(new OrderItemData() + { + ProductId = int.Parse(x.ProductId), + + PictureUrl = x.PictureUrl, + ProductName = x.ProductName, + Units = x.Quantity, + UnitPrice = x.UnitPrice + }); + order.Total += (x.Quantity * x.UnitPrice); + }); + + return order; + } + async Task GetUserTokenAsync() { var context = _httpContextAccessor.HttpContext; diff --git a/src/BFFs/PurchaseBff/Services/IBasketService.cs b/src/BFFs/PurchaseBff/Services/IBasketService.cs index 0c33c5c41..79319536f 100644 --- a/src/BFFs/PurchaseBff/Services/IBasketService.cs +++ b/src/BFFs/PurchaseBff/Services/IBasketService.cs @@ -10,5 +10,7 @@ namespace PurchaseBff.Services { Task GetById(string id); Task Update(BasketData currentBasket); + + OrderData MapBasketToOrder(BasketData basket, bool isDraft); } } diff --git a/src/Services/Basket/Basket.API/Properties/launchSettings.json b/src/Services/Basket/Basket.API/Properties/launchSettings.json index 0045edd47..013205c33 100644 --- a/src/Services/Basket/Basket.API/Properties/launchSettings.json +++ b/src/Services/Basket/Basket.API/Properties/launchSettings.json @@ -3,7 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:56695/", + "applicationUrl": "http://localhost:57622/", "sslPort": 0 } }, diff --git a/src/Services/Catalog/Catalog.API/Properties/launchSettings.json b/src/Services/Catalog/Catalog.API/Properties/launchSettings.json index 28f08bad2..a0b19b3bf 100644 --- a/src/Services/Catalog/Catalog.API/Properties/launchSettings.json +++ b/src/Services/Catalog/Catalog.API/Properties/launchSettings.json @@ -3,7 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:56698/", + "applicationUrl": "http://localhost:57623/", "sslPort": 0 } }, diff --git a/src/Web/WebMVC/Controllers/CartController.cs b/src/Web/WebMVC/Controllers/CartController.cs index 41484d79c..660da1d56 100644 --- a/src/Web/WebMVC/Controllers/CartController.cs +++ b/src/Web/WebMVC/Controllers/CartController.cs @@ -49,10 +49,8 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers { var user = _appUserParser.Parse(HttpContext.User); var basket = await _basketSvc.SetQuantities(user, quantities); - if (action == "[ Checkout ]") { - var order = _basketSvc.MapBasketToOrder(basket); return RedirectToAction("Create", "Order"); } } diff --git a/src/Web/WebMVC/Controllers/OrderController.cs b/src/Web/WebMVC/Controllers/OrderController.cs index 11e688728..a5bf4785e 100644 --- a/src/Web/WebMVC/Controllers/OrderController.cs +++ b/src/Web/WebMVC/Controllers/OrderController.cs @@ -27,9 +27,9 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers public async Task Create() { + var user = _appUserParser.Parse(HttpContext.User); - var basket = await _basketSvc.GetBasket(user); - var order = _basketSvc.MapBasketToOrder(basket); + var order = await _basketSvc.GetOrderDraft(user.Id); var vm = _orderSvc.MapUserInfoIntoOrder(user, order); vm.CardExpirationShortFormat(); diff --git a/src/Web/WebMVC/Infrastructure/API.cs b/src/Web/WebMVC/Infrastructure/API.cs index 765ee3e9b..d6f485e21 100644 --- a/src/Web/WebMVC/Infrastructure/API.cs +++ b/src/Web/WebMVC/Infrastructure/API.cs @@ -9,6 +9,8 @@ namespace WebMVC.Infrastructure { public static string AddItemToBasket(string baseUri) => $"{baseUri}/basket/items"; public static string UpdateBasketItem(string baseUri) => $"{baseUri}/basket/items"; + + public static string GetOrderDraft(string baseUri, string basketId) => $"{baseUri}/order/draft/{basketId}"; } public static class Basket diff --git a/src/Web/WebMVC/Services/BasketService.cs b/src/Web/WebMVC/Services/BasketService.cs index 1c4b2aa87..208ea71ad 100644 --- a/src/Web/WebMVC/Services/BasketService.cs +++ b/src/Web/WebMVC/Services/BasketService.cs @@ -93,27 +93,15 @@ namespace Microsoft.eShopOnContainers.WebMVC.Services return JsonConvert.DeserializeObject(jsonResponse); } - public Order MapBasketToOrder(Basket basket) + public async Task GetOrderDraft(string basketId) { - var order = new Order(); - order.Total = 0; - - basket.Items.ForEach(x => - { - order.OrderItems.Add(new OrderItem() - { - ProductId = int.Parse(x.ProductId), + var token = await GetUserTokenAsync(); + var draftOrderUri = API.Purchase.GetOrderDraft(_purchaseUrl, basketId); + var json = await _apiClient.GetStringAsync(draftOrderUri, token); + return JsonConvert.DeserializeObject(json); + } - PictureUrl = x.PictureUrl, - ProductName = x.ProductName, - Units = x.Quantity, - UnitPrice = x.UnitPrice - }); - order.Total += (x.Quantity * x.UnitPrice); - }); - return order; - } public async Task AddItemToBasket(ApplicationUser user, int productId) { diff --git a/src/Web/WebMVC/Services/IBasketService.cs b/src/Web/WebMVC/Services/IBasketService.cs index 78898de7d..cfbea5ff0 100644 --- a/src/Web/WebMVC/Services/IBasketService.cs +++ b/src/Web/WebMVC/Services/IBasketService.cs @@ -14,6 +14,6 @@ namespace Microsoft.eShopOnContainers.WebMVC.Services Task UpdateBasket(Basket basket); Task Checkout(BasketDTO basket); Task SetQuantities(ApplicationUser user, Dictionary quantities); - Order MapBasketToOrder(Basket basket); + Task GetOrderDraft(string basketId); } } diff --git a/src/Web/WebSPA/Properties/launchSettings.json b/src/Web/WebSPA/Properties/launchSettings.json index 9be3bf34a..8a55ca730 100644 --- a/src/Web/WebSPA/Properties/launchSettings.json +++ b/src/Web/WebSPA/Properties/launchSettings.json @@ -3,7 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:56727/", + "applicationUrl": "http://localhost:57625/", "sslPort": 0 } }, diff --git a/test/Services/UnitTest/Ordering/Application/OrderControllerTest.cs b/test/Services/UnitTest/Ordering/Application/OrderControllerTest.cs index 12f2be395..a60ce3bb3 100644 --- a/test/Services/UnitTest/Ordering/Application/OrderControllerTest.cs +++ b/test/Services/UnitTest/Ordering/Application/OrderControllerTest.cs @@ -68,40 +68,7 @@ namespace UnitTest.Ordering.Application Assert.IsAssignableFrom(viewResult.ViewData.Model); } - [Fact] - public async Task Get_create_order_success() - { - //Arrange - var fakeBuyerId = "1"; - var fakeBasket = GetFakeBasket(fakeBuyerId); - var fakeOrder = GetFakeOrder(); - - _basketServiceMock.Setup(x => x.GetBasket(It.IsAny())) - .Returns(Task.FromResult(fakeBasket)); - - _basketServiceMock.Setup(x => x.MapBasketToOrder(It.IsAny())) - .Returns(fakeOrder); - - _orderServiceMock.Setup(x => x.MapUserInfoIntoOrder(It.IsAny(), It.IsAny())) - .Returns(fakeOrder); - - //Act - var orderController = new OrderController(_orderServiceMock.Object, _basketServiceMock.Object, _identityParserMock.Object); - orderController.ControllerContext.HttpContext = _contextMock.Object; - var actionResult = await orderController.Create(); - - //Assert - var viewResult = Assert.IsType(actionResult); - Assert.IsAssignableFrom(viewResult.ViewData.Model); - } - - private BasketModel GetFakeBasket(string buyerId) - { - return new BasketModel() - { - BuyerId = buyerId - }; - } + private Order GetFakeOrder() { From b0d4ae5a72c36158716653a40b1c24308d53d76d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduard=20Tom=C3=A0s?= Date: Fri, 2 Feb 2018 11:26:47 +0000 Subject: [PATCH 15/45] All order flow goes through Purchase BFF API. Also some refactorings. --- docker-compose.override.yml | 1 + src/BFFs/PurchaseBff/Config/UrlsConfig.cs | 8 ++- .../Controllers/BasketController.cs | 3 + .../Controllers/OrderController.cs | 8 ++- .../PurchaseBff/Services/BasketService.cs | 25 ------- .../PurchaseBff/Services/IBasketService.cs | 1 - .../PurchaseBff/Services/IOrderApiClient.cs | 13 ++++ .../PurchaseBff/Services/OrderApiClient.cs | 37 ++++++++++ src/BFFs/PurchaseBff/Startup.cs | 1 + .../PurchaseBff/appsettings.localhost.json | 3 +- .../Basket.API/Properties/launchSettings.json | 2 +- .../Controllers/CatalogController.cs | 14 ++-- .../Extensions/CatalogItemExtensions.cs | 17 +++++ .../Commands/CreateOrderCommand.cs | 17 +---- .../Commands/CreateOrderDraftCommand.cs | 27 +++++++ .../CreateOrderDraftCommandHandler.cs | 72 +++++++++++++++++++ .../Controllers/OrdersController.cs | 9 +++ .../Extensions/BasketItemExtensions.cs | 32 +++++++++ .../Properties/launchSettings.json | 4 +- .../AggregatesModel/OrderAggregate/Order.cs | 31 +++++--- .../OrderAggregate/OrderItem.cs | 8 +-- src/Web/WebSPA/Properties/launchSettings.json | 2 +- 22 files changed, 264 insertions(+), 71 deletions(-) create mode 100644 src/BFFs/PurchaseBff/Services/IOrderApiClient.cs create mode 100644 src/BFFs/PurchaseBff/Services/OrderApiClient.cs create mode 100644 src/Services/Catalog/Catalog.API/Extensions/CatalogItemExtensions.cs create mode 100644 src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderDraftCommand.cs create mode 100644 src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderDraftCommandHandler.cs create mode 100644 src/Services/Ordering/Ordering.API/Extensions/BasketItemExtensions.cs diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 0a0b547b4..bf6a80691 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -235,6 +235,7 @@ services: - ASPNETCORE_ENVIRONMENT=Development - urls__basket=http://basket.api - urls__catalog=http://catalog.api + - urls__orders=http://ordering.api - urls__identity=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. ports: - "5120:80" diff --git a/src/BFFs/PurchaseBff/Config/UrlsConfig.cs b/src/BFFs/PurchaseBff/Config/UrlsConfig.cs index 2079a4615..bca4db9ff 100644 --- a/src/BFFs/PurchaseBff/Config/UrlsConfig.cs +++ b/src/BFFs/PurchaseBff/Config/UrlsConfig.cs @@ -15,10 +15,16 @@ namespace PurchaseBff.Config public class BasketOperations { public static string GetItemById(string id) => $"/api/v1/basket/{id}"; - public static string UpdateBasket() => $"/api/v1/basket"; + public static string UpdateBasket() => "/api/v1/basket"; + } + + public class OrdersOperations + { + public static string GetOrderDraft() => "/api/v1/orders/draft"; } public string Basket { get; set; } public string Catalog { get; set; } + public string Orders { get; set; } } } diff --git a/src/BFFs/PurchaseBff/Controllers/BasketController.cs b/src/BFFs/PurchaseBff/Controllers/BasketController.cs index 12290a127..17dbf6ff5 100644 --- a/src/BFFs/PurchaseBff/Controllers/BasketController.cs +++ b/src/BFFs/PurchaseBff/Controllers/BasketController.cs @@ -64,6 +64,9 @@ namespace PurchaseBff.Controllers // Step 1: Get the item from catalog var item = await _catalog.GetCatalogItem(data.CatalogItemId); + + //item.PictureUri = + // Step 2: Get current basket status var currentBasket = (await _basket.GetById(data.BasketId)) ?? new BasketData(data.BasketId); // Step 3: Merge current status with new product diff --git a/src/BFFs/PurchaseBff/Controllers/OrderController.cs b/src/BFFs/PurchaseBff/Controllers/OrderController.cs index 7e7b00c1b..91d0062ac 100644 --- a/src/BFFs/PurchaseBff/Controllers/OrderController.cs +++ b/src/BFFs/PurchaseBff/Controllers/OrderController.cs @@ -13,9 +13,11 @@ namespace PurchaseBff.Controllers public class OrderController : Controller { private readonly IBasketService _basketService; - public OrderController(IBasketService basketService) + private readonly IOrderApiClient _orderClient; + public OrderController(IBasketService basketService, IOrderApiClient orderClient) { _basketService = basketService; + _orderClient = orderClient; } [Route("draft/{basketId}")] @@ -33,8 +35,8 @@ namespace PurchaseBff.Controllers return BadRequest($"No basket found for id {basketId}"); } - var order = _basketService.MapBasketToOrder(basket, isDraft: true); - return Ok(order); + var orderDraft = await _orderClient.GetOrderDraftFromBasket(basket); + return Ok(orderDraft); } } } diff --git a/src/BFFs/PurchaseBff/Services/BasketService.cs b/src/BFFs/PurchaseBff/Services/BasketService.cs index fd16843a1..881718baf 100644 --- a/src/BFFs/PurchaseBff/Services/BasketService.cs +++ b/src/BFFs/PurchaseBff/Services/BasketService.cs @@ -44,31 +44,6 @@ namespace PurchaseBff.Services int i = 0; } - public OrderData MapBasketToOrder(BasketData basket, bool isDraft) - { - var order = new OrderData - { - Total = 0, - IsDraft = isDraft - }; - - basket.Items.ForEach(x => - { - order.OrderItems.Add(new OrderItemData() - { - ProductId = int.Parse(x.ProductId), - - PictureUrl = x.PictureUrl, - ProductName = x.ProductName, - Units = x.Quantity, - UnitPrice = x.UnitPrice - }); - order.Total += (x.Quantity * x.UnitPrice); - }); - - return order; - } - async Task GetUserTokenAsync() { var context = _httpContextAccessor.HttpContext; diff --git a/src/BFFs/PurchaseBff/Services/IBasketService.cs b/src/BFFs/PurchaseBff/Services/IBasketService.cs index 79319536f..74f6c21ba 100644 --- a/src/BFFs/PurchaseBff/Services/IBasketService.cs +++ b/src/BFFs/PurchaseBff/Services/IBasketService.cs @@ -11,6 +11,5 @@ namespace PurchaseBff.Services Task GetById(string id); Task Update(BasketData currentBasket); - OrderData MapBasketToOrder(BasketData basket, bool isDraft); } } diff --git a/src/BFFs/PurchaseBff/Services/IOrderApiClient.cs b/src/BFFs/PurchaseBff/Services/IOrderApiClient.cs new file mode 100644 index 000000000..2d23e71f6 --- /dev/null +++ b/src/BFFs/PurchaseBff/Services/IOrderApiClient.cs @@ -0,0 +1,13 @@ +using PurchaseBff.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace PurchaseBff.Services +{ + public interface IOrderApiClient + { + Task GetOrderDraftFromBasket(BasketData basket); + } +} diff --git a/src/BFFs/PurchaseBff/Services/OrderApiClient.cs b/src/BFFs/PurchaseBff/Services/OrderApiClient.cs new file mode 100644 index 000000000..44f33cf71 --- /dev/null +++ b/src/BFFs/PurchaseBff/Services/OrderApiClient.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.eShopOnContainers.BuildingBlocks.Resilience.Http; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using Newtonsoft.Json; +using PurchaseBff.Config; +using PurchaseBff.Models; + +namespace PurchaseBff.Services +{ + public class OrderApiClient : IOrderApiClient + { + + private readonly IHttpClient _apiClient; + private readonly ILogger _logger; + private readonly UrlsConfig _urls; + + public OrderApiClient(IHttpClient httpClient, ILogger logger, IOptionsSnapshot config) + { + _apiClient = httpClient; + _logger = logger; + _urls = config.Value; + } + + public async Task GetOrderDraftFromBasket(BasketData basket) + { + var url = _urls.Orders + UrlsConfig.OrdersOperations.GetOrderDraft(); + var response = await _apiClient.PostAsync(url, basket); + response.EnsureSuccessStatusCode(); + var jsonResponse = await response.Content.ReadAsStringAsync(); + return JsonConvert.DeserializeObject(jsonResponse); + } + } +} diff --git a/src/BFFs/PurchaseBff/Startup.cs b/src/BFFs/PurchaseBff/Startup.cs index 13fdcc269..d7e9b4e28 100644 --- a/src/BFFs/PurchaseBff/Startup.cs +++ b/src/BFFs/PurchaseBff/Startup.cs @@ -35,6 +35,7 @@ namespace PurchaseBff services.AddSingleton(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddOptions(); services.Configure(Configuration.GetSection("urls")); diff --git a/src/BFFs/PurchaseBff/appsettings.localhost.json b/src/BFFs/PurchaseBff/appsettings.localhost.json index a8c119c93..57b5e894d 100644 --- a/src/BFFs/PurchaseBff/appsettings.localhost.json +++ b/src/BFFs/PurchaseBff/appsettings.localhost.json @@ -2,6 +2,7 @@ "urls": { "basket": "http://localhost:55105", "catalog": "http://localhost:55101", - "identity": "http://localhost:55105" + "orders": "http://localhost:55102", + "identity": "http://localhost:55105" } } diff --git a/src/Services/Basket/Basket.API/Properties/launchSettings.json b/src/Services/Basket/Basket.API/Properties/launchSettings.json index 013205c33..bce29a595 100644 --- a/src/Services/Basket/Basket.API/Properties/launchSettings.json +++ b/src/Services/Basket/Basket.API/Properties/launchSettings.json @@ -3,7 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:57622/", + "applicationUrl": "http://localhost:50920/", "sslPort": 0 } }, diff --git a/src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs b/src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs index 1b53171d0..0d224fc68 100644 --- a/src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs +++ b/src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs @@ -66,6 +66,11 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers } var item = await _catalogContext.CatalogItems.SingleOrDefaultAsync(ci => ci.Id == id); + + var baseUri = _settings.PicBaseUrl; + var azureStorageEnabled = _settings.AzureStorageEnabled; + item.FillProductUrl(baseUri, azureStorageEnabled: azureStorageEnabled); + if (item != null) { return Ok(item); @@ -244,13 +249,12 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers private List ChangeUriPlaceholder(List items) { var baseUri = _settings.PicBaseUrl; + var azureStorageEnabled = _settings.AzureStorageEnabled; - items.ForEach(catalogItem => + foreach (var item in items) { - catalogItem.PictureUri = _settings.AzureStorageEnabled - ? baseUri + catalogItem.PictureFileName - : baseUri.Replace("[0]", catalogItem.Id.ToString()); - }); + item.FillProductUrl(baseUri, azureStorageEnabled: azureStorageEnabled); + } return items; } diff --git a/src/Services/Catalog/Catalog.API/Extensions/CatalogItemExtensions.cs b/src/Services/Catalog/Catalog.API/Extensions/CatalogItemExtensions.cs new file mode 100644 index 000000000..71b9d88a3 --- /dev/null +++ b/src/Services/Catalog/Catalog.API/Extensions/CatalogItemExtensions.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Microsoft.eShopOnContainers.Services.Catalog.API.Model +{ + public static class CatalogItemExtensions + { + public static void FillProductUrl(this CatalogItem item, string picBaseUrl, bool azureStorageEnabled) + { + item.PictureUri = azureStorageEnabled + ? picBaseUrl + item.PictureFileName + : picBaseUrl.Replace("[0]", item.Id.ToString()); + } + } +} diff --git a/src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderCommand.cs b/src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderCommand.cs index 980f9d0b6..437212b8d 100644 --- a/src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderCommand.cs +++ b/src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderCommand.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Runtime.Serialization; using System.Collections; using Ordering.API.Application.Models; +using System.Linq; namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.Commands { @@ -68,7 +69,7 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.Commands string cardNumber, string cardHolderName, DateTime cardExpiration, string cardSecurityNumber, int cardTypeId) : this() { - _orderItems = MapToOrderItems(basketItems); + _orderItems = basketItems.ToOrderItemsDTO().ToList(); UserId = userId; City = city; Street = street; @@ -83,20 +84,6 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.Commands CardExpiration = cardExpiration; } - private List MapToOrderItems(List basketItems) - { - var result = new List(); - basketItems.ForEach((item) => { - result.Add(new OrderItemDTO() { - ProductId = int.TryParse(item.ProductId, out int id) ? id : -1, - ProductName = item.ProductName, - PictureUrl = item.PictureUrl, - UnitPrice = item.UnitPrice, - Units = item.Quantity - }); - }); - return result; - } public class OrderItemDTO { diff --git a/src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderDraftCommand.cs b/src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderDraftCommand.cs new file mode 100644 index 000000000..1d3d52c63 --- /dev/null +++ b/src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderDraftCommand.cs @@ -0,0 +1,27 @@ +using MediatR; +using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate; +using Ordering.API.Application.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Threading.Tasks; +using static Microsoft.eShopOnContainers.Services.Ordering.API.Application.Commands.CreateOrderCommand; + +namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.Commands +{ + public class CreateOrderDraftCommand : IRequest + { + + public string BuyerId { get; private set; } + + public IEnumerable Items { get; private set; } + + public CreateOrderDraftCommand(string buyerId, IEnumerable items) + { + BuyerId = buyerId; + Items = items; + } + } + +} diff --git a/src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderDraftCommandHandler.cs b/src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderDraftCommandHandler.cs new file mode 100644 index 000000000..2c315248b --- /dev/null +++ b/src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderDraftCommandHandler.cs @@ -0,0 +1,72 @@ +namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.Commands +{ + using Domain.AggregatesModel.OrderAggregate; + using global::Ordering.API.Application.Models; + using MediatR; + using Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.Services; + using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Idempotency; + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading; + using System.Threading.Tasks; + using static Microsoft.eShopOnContainers.Services.Ordering.API.Application.Commands.CreateOrderCommand; + + // Regular CommandHandler + public class CreateOrderDraftCommandHandler + : IRequestHandler + { + private readonly IOrderRepository _orderRepository; + private readonly IIdentityService _identityService; + private readonly IMediator _mediator; + + // Using DI to inject infrastructure persistence Repositories + public CreateOrderDraftCommandHandler(IMediator mediator, IIdentityService identityService) + { + _identityService = identityService ?? throw new ArgumentNullException(nameof(identityService)); + _mediator = mediator ?? throw new ArgumentNullException(nameof(mediator)); + } + + public Task Handle(CreateOrderDraftCommand message, CancellationToken cancellationToken) + { + + var order = Order.NewDraft(); + var orderItems = message.Items.Select(i => i.ToOrderItemDTO()); + foreach (var item in orderItems) + { + order.AddOrderItem(item.ProductId, item.ProductName, item.UnitPrice, item.Discount, item.PictureUrl, item.Units); + } + + return Task.FromResult(OrderDraftDTO.FromOrder(order)); + } + } + + + public class OrderDraftDTO + { + public IEnumerable OrderItems { get; set; } + public decimal Total { get; set; } + + public static OrderDraftDTO FromOrder(Order order) + { + return new OrderDraftDTO() + { + OrderItems = order.OrderItems.Select(oi => new OrderItemDTO + { + Discount = oi.GetCurrentDiscount(), + ProductId = oi.ProductId, + UnitPrice = oi.GetUnitPrice(), + PictureUrl = oi.GetPictureUri(), + Units = oi.GetUnits(), + ProductName = oi.GetOrderItemProductName() + }), + Total = order.GetTotal() + }; + } + + } + + + + +} diff --git a/src/Services/Ordering/Ordering.API/Controllers/OrdersController.cs b/src/Services/Ordering/Ordering.API/Controllers/OrdersController.cs index 993986543..ac179c97f 100644 --- a/src/Services/Ordering/Ordering.API/Controllers/OrdersController.cs +++ b/src/Services/Ordering/Ordering.API/Controllers/OrdersController.cs @@ -5,6 +5,7 @@ using Microsoft.eShopOnContainers.Services.Ordering.API.Application.Commands; using Microsoft.eShopOnContainers.Services.Ordering.API.Application.Queries; using Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.Services; using Ordering.API.Application.Commands; +using Ordering.API.Application.Models; using System; using System.Collections.Generic; using System.Net; @@ -101,6 +102,14 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.API.Controllers return Ok(cardTypes); } + + [Route("draft")] + [HttpPost] + public async Task GetOrderDraftFromBasketData([FromBody] CreateOrderDraftCommand createOrderDraftCommand) + { + var draft = await _mediator.Send(createOrderDraftCommand); + return Ok(draft); + } } } diff --git a/src/Services/Ordering/Ordering.API/Extensions/BasketItemExtensions.cs b/src/Services/Ordering/Ordering.API/Extensions/BasketItemExtensions.cs new file mode 100644 index 000000000..56f280978 --- /dev/null +++ b/src/Services/Ordering/Ordering.API/Extensions/BasketItemExtensions.cs @@ -0,0 +1,32 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using static Microsoft.eShopOnContainers.Services.Ordering.API.Application.Commands.CreateOrderCommand; + +namespace Ordering.API.Application.Models +{ + public static class BasketItemExtensions + { + public static IEnumerable ToOrderItemsDTO(this IEnumerable basketItems) + { + foreach (var item in basketItems) + { + yield return item.ToOrderItemDTO(); + } + } + + public static OrderItemDTO ToOrderItemDTO(this BasketItem item) + { + return new OrderItemDTO() + { + ProductId = int.TryParse(item.ProductId, out int id) ? id : -1, + ProductName = item.ProductName, + PictureUrl = item.PictureUrl, + UnitPrice = item.UnitPrice, + Units = item.Quantity + }; + } + } +} diff --git a/src/Services/Ordering/Ordering.API/Properties/launchSettings.json b/src/Services/Ordering/Ordering.API/Properties/launchSettings.json index a6e47ca2d..9d9a76490 100644 --- a/src/Services/Ordering/Ordering.API/Properties/launchSettings.json +++ b/src/Services/Ordering/Ordering.API/Properties/launchSettings.json @@ -3,7 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:5102/", + "applicationUrl": "http://localhost:55102/", "sslPort": 0 } }, @@ -19,7 +19,7 @@ "Microsoft.eShopOnContainers.Services.Ordering.API": { "commandName": "Project", "launchBrowser": true, - "launchUrl": "http://localhost:5000/api/environmentInfo/machinename", + "launchUrl": "http://localhost:55102/", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/Order.cs b/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/Order.cs index d2e742b33..82e5744dd 100644 --- a/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/Order.cs +++ b/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/Order.cs @@ -25,6 +25,10 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.O private string _description; + + // Draft orders have this set to true. Currently we don't check anywhere the draft status of an Order, but we could do it if needed + private bool _isDraft; + // DDD Patterns comment // Using a private collection field, better for DDD Aggregate's encapsulation // so OrderItems cannot be added from "outside the AggregateRoot" directly to the collection, @@ -34,12 +38,21 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.O private int? _paymentMethodId; - protected Order() { _orderItems = new List(); } + public static Order NewDraft() + { + var order = new Order(); + order._isDraft = true; + return order; + } + + protected Order() { + _orderItems = new List(); + _isDraft = false; + } public Order(string userId, Address address, int cardTypeId, string cardNumber, string cardSecurityNumber, - string cardHolderName, DateTime cardExpiration, int? buyerId = null, int? paymentMethodId = null) + string cardHolderName, DateTime cardExpiration, int? buyerId = null, int? paymentMethodId = null) : this() { - _orderItems = new List(); _buyerId = buyerId; _paymentMethodId = paymentMethodId; _orderStatusId = OrderStatus.Submitted.Id; @@ -92,12 +105,12 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.O } public void SetAwaitingValidationStatus() - { + { if (_orderStatusId == OrderStatus.Submitted.Id) { AddDomainEvent(new OrderStatusChangedToAwaitingValidationDomainEvent(Id, _orderItems)); _orderStatusId = OrderStatus.AwaitingValidation.Id; - } + } } public void SetStockConfirmedStatus() @@ -108,7 +121,7 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.O _orderStatusId = OrderStatus.StockConfirmed.Id; _description = "All the items were confirmed with available stock."; - } + } } public void SetPaidStatus() @@ -119,7 +132,7 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.O _orderStatusId = OrderStatus.Paid.Id; _description = "The payment was performed at a simulated \"American Bank checking bank account endinf on XX35071\""; - } + } } public void SetShippedStatus() @@ -157,13 +170,13 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.O var itemsStockRejectedDescription = string.Join(", ", itemsStockRejectedProductNames); _description = $"The product items don't have stock: ({itemsStockRejectedDescription})."; - } + } } private void AddOrderStartedDomainEvent(string userId, int cardTypeId, string cardNumber, string cardSecurityNumber, string cardHolderName, DateTime cardExpiration) { - var orderStartedDomainEvent = new OrderStartedDomainEvent(this, userId, cardTypeId, + var orderStartedDomainEvent = new OrderStartedDomainEvent(this, userId, cardTypeId, cardNumber, cardSecurityNumber, cardHolderName, cardExpiration); diff --git a/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/OrderItem.cs b/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/OrderItem.cs index 1b7896dcc..b3b7435e3 100644 --- a/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/OrderItem.cs +++ b/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/OrderItem.cs @@ -41,13 +41,7 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.O _pictureUrl = PictureUrl; } - public void SetPictureUri(string pictureUri) - { - if (!String.IsNullOrWhiteSpace(pictureUri)) - { - _pictureUrl = pictureUri; - } - } + public string GetPictureUri() => _pictureUrl; public decimal GetCurrentDiscount() { diff --git a/src/Web/WebSPA/Properties/launchSettings.json b/src/Web/WebSPA/Properties/launchSettings.json index 8a55ca730..9ae65426a 100644 --- a/src/Web/WebSPA/Properties/launchSettings.json +++ b/src/Web/WebSPA/Properties/launchSettings.json @@ -3,7 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:57625/", + "applicationUrl": "http://localhost:50921/", "sslPort": 0 } }, From 5dfaf07059bbd25201d2d801b8d5fa342a889610 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduard=20Tom=C3=A0s?= Date: Fri, 2 Feb 2018 12:03:48 +0000 Subject: [PATCH 16/45] Ocelot updated to 3.0.0 --- src/Apigw/OcelotApiGw/OcelotApiGw.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Apigw/OcelotApiGw/OcelotApiGw.csproj b/src/Apigw/OcelotApiGw/OcelotApiGw.csproj index 4f6ce6e77..d72d014b4 100644 --- a/src/Apigw/OcelotApiGw/OcelotApiGw.csproj +++ b/src/Apigw/OcelotApiGw/OcelotApiGw.csproj @@ -10,7 +10,7 @@ - + From 704e6ae69333551e3d7b91b361e60211e035430e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduard=20Tom=C3=A0s?= Date: Fri, 2 Feb 2018 15:55:33 +0000 Subject: [PATCH 17/45] Finished purchase-bff implementation and ocelot rerouting --- docker-compose.override.yml | 3 - src/Apigw/OcelotApiGw/Program.cs | 13 ++- .../configuration/configuration.json | 98 ++++++++++++++----- .../Resilience.Http/ResilientHttpClient.cs | 5 + .../Resilience.Http/StandardHttpClient.cs | 5 + .../Controllers/BasketController.cs | 4 + src/Web/WebMVC/AppSettings.cs | 3 - src/Web/WebMVC/Services/BasketService.cs | 21 ++-- src/Web/WebMVC/Services/CatalogService.cs | 2 +- src/Web/WebMVC/Services/OrderingService.cs | 2 +- 10 files changed, 108 insertions(+), 48 deletions(-) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index bf6a80691..1a8d9c284 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -134,9 +134,6 @@ services: environment: - ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_URLS=http://0.0.0.0:80 - - CatalogUrl=http://apigw/purchase-bff/catalog - - OrderingUrl=http://ordering.api - - BasketUrl=http://basket.api - PurchaseUrl=http://apigw/purchase-bff - LocationsUrl=http://locations.api - IdentityUrl=http://10.0.75.1:5105 # Local Mac: Use http://docker.for.mac.localhost:5105 || Local Windows: Use 10.0.75.1 in a "Docker for Windows" environment, if using "localhost" from browser. || #Remote access: Use ${ESHOP_EXTERNAL_DNS_NAME_OR_IP} if using external IP or DNS name from browser. diff --git a/src/Apigw/OcelotApiGw/Program.cs b/src/Apigw/OcelotApiGw/Program.cs index bd5230b96..782681901 100644 --- a/src/Apigw/OcelotApiGw/Program.cs +++ b/src/Apigw/OcelotApiGw/Program.cs @@ -7,6 +7,7 @@ using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.DependencyInjection; namespace OcelotApiGw { @@ -17,10 +18,14 @@ namespace OcelotApiGw BuildWebHost(args).Run(); } - public static IWebHost BuildWebHost(string[] args) => - WebHost.CreateDefaultBuilder(args) + public static IWebHost BuildWebHost(string[] args) + { + var builder = WebHost.CreateDefaultBuilder(args); + builder.ConfigureServices(s => s.AddSingleton(builder)) .ConfigureAppConfiguration(ic => ic.AddJsonFile(Path.Combine("configuration", "configuration.json"))) - .UseStartup() - .Build(); + .UseStartup(); + var host = builder.Build(); + return host; + } } } diff --git a/src/Apigw/OcelotApiGw/configuration/configuration.json b/src/Apigw/OcelotApiGw/configuration/configuration.json index cc2defca6..2d5e6c8f7 100644 --- a/src/Apigw/OcelotApiGw/configuration/configuration.json +++ b/src/Apigw/OcelotApiGw/configuration/configuration.json @@ -1,20 +1,44 @@ { "ReRoutes": [ { - "DownstreamPathTemplate": "/{everything}", + "DownstreamPathTemplate": "/api/{version}/{everything}", "DownstreamScheme": "http", - "DownstreamHost": "catalog.api", - "DownstreamPort": 80, - "UpstreamPathTemplate": "/purchase-bff/catalog/{everything}", + "DownstreamHostAndPorts": [ + { + "Host": "catalog.api", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/purchase-bff/api/{version}/c/{everything}", "UpstreamHttpMethod": [ "GET" ] }, { - "DownstreamPathTemplate": "/{everything}", + "DownstreamPathTemplate": "/api/{version}/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "basket.api", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/purchase-bff/api/{version}/b/{everything}", + "UpstreamHttpMethod": [], + "AuthenticationOptions": { + "AuthenticationProviderKey": "IdentityApiKey", + "AllowedScopes": [] + } + }, + { + "DownstreamPathTemplate": "/api/{version}/{everything}", "DownstreamScheme": "http", - "DownstreamHost": "basket.api", - "DownstreamPort": 80, - "UpstreamPathTemplate": "/purchase-bff/basket/{everything}", - "UpstreamHttpMethod": [ "GET" ], + "DownstreamHostAndPorts": [ + { + "Host": "ordering.api", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/purchase-bff/api/{version}/o/{everything}", + "UpstreamHttpMethod": [], "AuthenticationOptions": { "AuthenticationProviderKey": "IdentityApiKey", "AllowedScopes": [] @@ -23,8 +47,12 @@ { "DownstreamPathTemplate": "/{everything}", "DownstreamScheme": "http", - "DownstreamHost": "purchasebff", - "DownstreamPort": 80, + "DownstreamHostAndPorts": [ + { + "Host": "purchasebff", + "Port": 80 + } + ], "UpstreamPathTemplate": "/purchase-bff/{everything}", "UpstreamHttpMethod": [ "POST", "PUT", "GET" ], "AuthenticationOptions": { @@ -35,48 +63,72 @@ { "DownstreamPathTemplate": "/{everything}", "DownstreamScheme": "http", - "DownstreamHost": "ordering.api", - "DownstreamPort": 80, + "DownstreamHostAndPorts": [ + { + "Host": "ordering.api", + "Port": 80 + } + ], "UpstreamPathTemplate": "/orders-api/{everything}", "UpstreamHttpMethod": [] }, { "DownstreamPathTemplate": "/{everything}", "DownstreamScheme": "http", - "DownstreamHost": "basket.api", - "DownstreamPort": 80, + "DownstreamHostAndPorts": [ + { + "Host": "basket.api", + "Port": 80 + } + ], "UpstreamPathTemplate": "/basket-api/{everything}", "UpstreamHttpMethod": [] }, { "DownstreamPathTemplate": "/{everything}", "DownstreamScheme": "http", - "DownstreamHost": "catalog.api", - "DownstreamPort": 80, + "DownstreamHostAndPorts": [ + { + "Host": "catalog.api", + "Port": 80 + } + ], "UpstreamPathTemplate": "/catalog-api/{everything}", "UpstreamHttpMethod": [] }, { "DownstreamPathTemplate": "/{everything}", "DownstreamScheme": "http", - "DownstreamHost": "marketing.api", - "DownstreamPort": 80, + "DownstreamHostAndPorts": [ + { + "Host": "marketing.api", + "Port": 80 + } + ], "UpstreamPathTemplate": "/marketing-api/{everything}", "UpstreamHttpMethod": [] }, { "DownstreamPathTemplate": "/{everything}", "DownstreamScheme": "http", - "DownstreamHost": "payment.api", - "DownstreamPort": 80, + "DownstreamHostAndPorts": [ + { + "Host": "payment.api", + "Port": 80 + } + ], "UpstreamPathTemplate": "/payment-api/{everything}", "UpstreamHttpMethod": [] }, { "DownstreamPathTemplate": "/{everything}", "DownstreamScheme": "http", - "DownstreamHost": "locations.api", - "DownstreamPort": 80, + "DownstreamHostAndPorts": [ + { + "Host": "locations.api", + "Port": 80 + } + ], "UpstreamPathTemplate": "/location-api/{everything}", "UpstreamHttpMethod": [] } diff --git a/src/BuildingBlocks/Resilience/Resilience.Http/ResilientHttpClient.cs b/src/BuildingBlocks/Resilience/Resilience.Http/ResilientHttpClient.cs index 18051a501..9fa38ee8d 100644 --- a/src/BuildingBlocks/Resilience/Resilience.Http/ResilientHttpClient.cs +++ b/src/BuildingBlocks/Resilience/Resilience.Http/ResilientHttpClient.cs @@ -97,6 +97,11 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.Resilience.Http throw new HttpRequestException(); } + if (!response.IsSuccessStatusCode) + { + return null; + } + return await response.Content.ReadAsStringAsync(); }); } diff --git a/src/BuildingBlocks/Resilience/Resilience.Http/StandardHttpClient.cs b/src/BuildingBlocks/Resilience/Resilience.Http/StandardHttpClient.cs index a5f6a63c4..578168bff 100644 --- a/src/BuildingBlocks/Resilience/Resilience.Http/StandardHttpClient.cs +++ b/src/BuildingBlocks/Resilience/Resilience.Http/StandardHttpClient.cs @@ -36,6 +36,11 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.Resilience.Http var response = await _client.SendAsync(requestMessage); + if (!response.IsSuccessStatusCode) + { + return null; + } + return await response.Content.ReadAsStringAsync(); } diff --git a/src/Services/Basket/Basket.API/Controllers/BasketController.cs b/src/Services/Basket/Basket.API/Controllers/BasketController.cs index 11ecac7c2..48ad68903 100644 --- a/src/Services/Basket/Basket.API/Controllers/BasketController.cs +++ b/src/Services/Basket/Basket.API/Controllers/BasketController.cs @@ -34,6 +34,10 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API.Controllers public async Task Get(string id) { var basket = await _repository.GetBasketAsync(id); + if (basket == null) + { + return NotFound(); + } return Ok(basket); } diff --git a/src/Web/WebMVC/AppSettings.cs b/src/Web/WebMVC/AppSettings.cs index 18db7d4bf..d235910b0 100644 --- a/src/Web/WebMVC/AppSettings.cs +++ b/src/Web/WebMVC/AppSettings.cs @@ -8,9 +8,6 @@ namespace Microsoft.eShopOnContainers.WebMVC public class AppSettings { public Connectionstrings ConnectionStrings { get; set; } - public string CatalogUrl { get; set; } - public string OrderingUrl { get; set; } - public string BasketUrl { get; set; } public string MarketingUrl { get; set; } public string LocationsUrl { get; set; } diff --git a/src/Web/WebMVC/Services/BasketService.cs b/src/Web/WebMVC/Services/BasketService.cs index 208ea71ad..54287a796 100644 --- a/src/Web/WebMVC/Services/BasketService.cs +++ b/src/Web/WebMVC/Services/BasketService.cs @@ -16,7 +16,7 @@ namespace Microsoft.eShopOnContainers.WebMVC.Services { private readonly IOptionsSnapshot _settings; private readonly IHttpClient _apiClient; - private readonly string _remoteServiceBaseUrl; + private readonly string _basketByPassUrl; private readonly string _purchaseUrl; private readonly IHttpContextAccessor _httpContextAccesor; @@ -26,7 +26,7 @@ namespace Microsoft.eShopOnContainers.WebMVC.Services IHttpContextAccessor httpContextAccesor, IHttpClient httpClient) { _settings = settings; - _remoteServiceBaseUrl = $"{_settings.Value.BasketUrl}/api/v1/basket"; + _basketByPassUrl = $"{_settings.Value.PurchaseUrl}/api/v1/b/basket"; _purchaseUrl = $"{_settings.Value.PurchaseUrl}/api/v1"; _httpContextAccesor = httpContextAccesor; _apiClient = httpClient; @@ -35,24 +35,19 @@ namespace Microsoft.eShopOnContainers.WebMVC.Services public async Task GetBasket(ApplicationUser user) { var token = await GetUserTokenAsync(); - var getBasketUri = API.Basket.GetBasket(_remoteServiceBaseUrl, user.Id); + var getBasketUri = API.Basket.GetBasket(_basketByPassUrl, user.Id); var dataString = await _apiClient.GetStringAsync(getBasketUri, token); - // Use the ?? Null conditional operator to simplify the initialization of response - var response = JsonConvert.DeserializeObject(dataString) ?? - new Basket() - { - BuyerId = user.Id - }; - - return response; + return string.IsNullOrEmpty(dataString) ? + new Basket() { BuyerId = user.Id} : + JsonConvert.DeserializeObject(dataString); } public async Task UpdateBasket(Basket basket) { var token = await GetUserTokenAsync(); - var updateBasketUri = API.Basket.UpdateBasket(_remoteServiceBaseUrl); + var updateBasketUri = API.Basket.UpdateBasket(_basketByPassUrl); var response = await _apiClient.PostAsync(updateBasketUri, basket, token); @@ -64,7 +59,7 @@ namespace Microsoft.eShopOnContainers.WebMVC.Services public async Task Checkout(BasketDTO basket) { var token = await GetUserTokenAsync(); - var updateBasketUri = API.Basket.CheckoutBasket(_remoteServiceBaseUrl); + var updateBasketUri = API.Basket.CheckoutBasket(_basketByPassUrl); var response = await _apiClient.PostAsync(updateBasketUri, basket, token); diff --git a/src/Web/WebMVC/Services/CatalogService.cs b/src/Web/WebMVC/Services/CatalogService.cs index 2af428e2e..5b6fbe26b 100644 --- a/src/Web/WebMVC/Services/CatalogService.cs +++ b/src/Web/WebMVC/Services/CatalogService.cs @@ -25,7 +25,7 @@ namespace Microsoft.eShopOnContainers.WebMVC.Services _apiClient = httpClient; _logger = logger; - _remoteServiceBaseUrl = $"{_settings.Value.CatalogUrl}/api/v1/catalog/"; + _remoteServiceBaseUrl = $"{_settings.Value.PurchaseUrl}/api/v1/c/catalog/"; } public async Task GetCatalogItems(int page, int take, int? brand, int? type) diff --git a/src/Web/WebMVC/Services/OrderingService.cs b/src/Web/WebMVC/Services/OrderingService.cs index f36f1410d..ec9d2e8fd 100644 --- a/src/Web/WebMVC/Services/OrderingService.cs +++ b/src/Web/WebMVC/Services/OrderingService.cs @@ -21,7 +21,7 @@ namespace Microsoft.eShopOnContainers.WebMVC.Services public OrderingService(IOptionsSnapshot settings, IHttpContextAccessor httpContextAccesor, IHttpClient httpClient) { - _remoteServiceBaseUrl = $"{settings.Value.OrderingUrl}/api/v1/orders"; + _remoteServiceBaseUrl = $"{settings.Value.PurchaseUrl}/api/v1/o/orders"; _settings = settings; _httpContextAccesor = httpContextAccesor; _apiClient = httpClient; From 735e9bd94ea85e821f3e6e54bb562cf28498ea17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduard=20Tom=C3=A0s?= Date: Fri, 2 Feb 2018 15:55:51 +0000 Subject: [PATCH 18/45] Fixed crash on BasketService --- src/BFFs/PurchaseBff/Services/BasketService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BFFs/PurchaseBff/Services/BasketService.cs b/src/BFFs/PurchaseBff/Services/BasketService.cs index 881718baf..c1c3a6f9d 100644 --- a/src/BFFs/PurchaseBff/Services/BasketService.cs +++ b/src/BFFs/PurchaseBff/Services/BasketService.cs @@ -33,7 +33,7 @@ namespace PurchaseBff.Services { var token = await GetUserTokenAsync(); var data = await _apiClient.GetStringAsync(_urls.Basket + UrlsConfig.BasketOperations.GetItemById(id), token); - var basket = JsonConvert.DeserializeObject(data); + var basket = !string.IsNullOrEmpty(data) ? JsonConvert.DeserializeObject(data) : null; return basket; } From 8edd7361967c25a7e93763389447f1d71e87bd26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduard=20Tom=C3=A0s?= Date: Tue, 6 Feb 2018 17:35:01 +0000 Subject: [PATCH 19/45] Updating SPA for working with PurchaseBFF. --- docker-compose.override.yml | 4 +- src/Apigw/OcelotApiGw/Startup.cs | 11 +++++ src/BFFs/PurchaseBff/Config/UrlsConfig.cs | 1 + .../Controllers/BasketController.cs | 43 +++++++++++++++++++ .../PurchaseBff/Models/UpdateBasketRequest.cs | 21 +++++++++ .../Properties/launchSettings.json | 2 +- .../PurchaseBff/Services/CatalogService.cs | 8 ++++ .../PurchaseBff/Services/ICatalogService.cs | 1 + .../Basket.API/Properties/launchSettings.json | 2 +- .../Controllers/CatalogController.cs | 28 ++++++++++-- .../Properties/launchSettings.json | 2 +- src/Web/WebSPA/AppSettings.cs | 8 ++-- .../Client/modules/basket/basket.service.ts | 13 +++--- .../Client/modules/catalog/catalog.service.ts | 6 +-- .../Client/modules/orders/orders.service.ts | 8 ++-- .../shared/models/configuration.model.ts | 4 +- .../shared/services/configuration.service.ts | 4 +- .../shared/services/security.service.ts | 2 +- src/Web/WebSPA/Properties/launchSettings.json | 2 +- src/Web/WebSPA/appsettings.json | 4 +- 20 files changed, 138 insertions(+), 36 deletions(-) create mode 100644 src/BFFs/PurchaseBff/Models/UpdateBasketRequest.cs diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 1a8d9c284..cfff01732 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -112,12 +112,10 @@ services: environment: - ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_URLS=http://0.0.0.0:80 - - CatalogUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5101 - - OrderingUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5102 - IdentityUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105 #Local: You need to open your local dev-machine firewall at range 5100-5105. at range 5100-5105. - - BasketUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5103 - MarketingUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5110 - LocationsUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5109 + - PurchaseUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5200 - CatalogUrlHC=http://catalog.api/hc - OrderingUrlHC=http://ordering.api/hc - IdentityUrlHC=http://identity.api/hc #Local: Use ${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}, if using external IP or DNS name from browser. diff --git a/src/Apigw/OcelotApiGw/Startup.cs b/src/Apigw/OcelotApiGw/Startup.cs index 9c7eb18ef..01ffe5139 100644 --- a/src/Apigw/OcelotApiGw/Startup.cs +++ b/src/Apigw/OcelotApiGw/Startup.cs @@ -29,6 +29,15 @@ namespace OcelotApiGw var identityUrl = _cfg.GetValue("IdentityUrl"); var authenticationProviderKey = "IdentityApiKey"; + services.AddCors(options => + { + options.AddPolicy("CorsPolicy", + builder => builder.AllowAnyOrigin() + .AllowAnyMethod() + .AllowAnyHeader() + .AllowCredentials()); + }); + services.AddAuthentication() .AddJwtBearer(authenticationProviderKey, x => { @@ -68,6 +77,8 @@ namespace OcelotApiGw loggerFactory.AddConsole(_cfg.GetSection("Logging")); + app.UseCors("CorsPolicy"); + app.UseOcelot().Wait(); } } diff --git a/src/BFFs/PurchaseBff/Config/UrlsConfig.cs b/src/BFFs/PurchaseBff/Config/UrlsConfig.cs index bca4db9ff..58f344aac 100644 --- a/src/BFFs/PurchaseBff/Config/UrlsConfig.cs +++ b/src/BFFs/PurchaseBff/Config/UrlsConfig.cs @@ -10,6 +10,7 @@ namespace PurchaseBff.Config public class CatalogOperations { public static string GetItemById(int id) => $"/api/v1/catalog/items/{id}"; + public static string GetItemsById(IEnumerable ids) => $"/api/v1/catalog/items?ids={string.Join(',', ids)}"; } public class BasketOperations diff --git a/src/BFFs/PurchaseBff/Controllers/BasketController.cs b/src/BFFs/PurchaseBff/Controllers/BasketController.cs index 17dbf6ff5..ac8620623 100644 --- a/src/BFFs/PurchaseBff/Controllers/BasketController.cs +++ b/src/BFFs/PurchaseBff/Controllers/BasketController.cs @@ -21,6 +21,49 @@ namespace PurchaseBff.Controllers _basket = basketService; } + [HttpPost] + [HttpPut] + public async Task UpdateAllBasket([FromBody] UpdateBasketRequest data) + { + + if (data.Items == null || !data.Items.Any()) + { + return BadRequest("Need to pass at least one basket line"); + } + + // Retrieve the current basket + var currentBasket = await _basket.GetById(data.BuyerId); + if (currentBasket == null) + { + currentBasket = new BasketData(data.BuyerId); + } + + var catalogItems = await _catalog.GetCatalogItems(data.Items.Select(x => x.ProductId)); + var newBasket = new BasketData(data.BuyerId); + + foreach (var bitem in data.Items) + { + var catalogItem = catalogItems.SingleOrDefault(ci => ci.Id == bitem.ProductId); + if (catalogItem == null) + { + return BadRequest($"Basket refers to a non-existing catalog item ({bitem.ProductId})"); + } + + newBasket.Items.Add(new BasketDataItem() + { + Id = bitem.Id, + ProductId = catalogItem.Id.ToString(), + ProductName = catalogItem.Name, + PictureUrl = catalogItem.PictureUri, + UnitPrice = catalogItem.Price, + Quantity = bitem.Quantity + }); + } + + await _basket.Update(newBasket); + return Ok(newBasket); + } + [HttpPut] [Route("items")] public async Task UpdateQuantities([FromBody] UpdateBasketItemsRequest data) diff --git a/src/BFFs/PurchaseBff/Models/UpdateBasketRequest.cs b/src/BFFs/PurchaseBff/Models/UpdateBasketRequest.cs new file mode 100644 index 000000000..a6813c788 --- /dev/null +++ b/src/BFFs/PurchaseBff/Models/UpdateBasketRequest.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace PurchaseBff.Models +{ + public class UpdateBasketRequest + { + public string BuyerId { get; set; } + + public IEnumerable Items { get; set; } + } + + public class UpdateBasketRequestItemData + { + public string Id { get; set; } // Basket id + public int ProductId { get; set; } // Catalog item id + public int Quantity { get; set; } // Quantity + } +} diff --git a/src/BFFs/PurchaseBff/Properties/launchSettings.json b/src/BFFs/PurchaseBff/Properties/launchSettings.json index d6c88d211..925e70b0d 100644 --- a/src/BFFs/PurchaseBff/Properties/launchSettings.json +++ b/src/BFFs/PurchaseBff/Properties/launchSettings.json @@ -3,7 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:58243/", + "applicationUrl": "http://localhost:57425/", "sslPort": 0 } }, diff --git a/src/BFFs/PurchaseBff/Services/CatalogService.cs b/src/BFFs/PurchaseBff/Services/CatalogService.cs index 071c162b4..7030da747 100644 --- a/src/BFFs/PurchaseBff/Services/CatalogService.cs +++ b/src/BFFs/PurchaseBff/Services/CatalogService.cs @@ -31,5 +31,13 @@ namespace PurchaseBff.Services var item = JsonConvert.DeserializeObject(data); return item; } + + public async Task> GetCatalogItems(IEnumerable ids) + { + var data = await _apiClient.GetStringAsync(_urls.Catalog + UrlsConfig.CatalogOperations.GetItemsById(ids)); + var item = JsonConvert.DeserializeObject(data); + return item; + + } } } diff --git a/src/BFFs/PurchaseBff/Services/ICatalogService.cs b/src/BFFs/PurchaseBff/Services/ICatalogService.cs index f7caaf6e3..b51c0f0cd 100644 --- a/src/BFFs/PurchaseBff/Services/ICatalogService.cs +++ b/src/BFFs/PurchaseBff/Services/ICatalogService.cs @@ -9,5 +9,6 @@ namespace PurchaseBff.Services public interface ICatalogService { Task GetCatalogItem(int id); + Task> GetCatalogItems(IEnumerable ids); } } diff --git a/src/Services/Basket/Basket.API/Properties/launchSettings.json b/src/Services/Basket/Basket.API/Properties/launchSettings.json index bce29a595..7d1c959e3 100644 --- a/src/Services/Basket/Basket.API/Properties/launchSettings.json +++ b/src/Services/Basket/Basket.API/Properties/launchSettings.json @@ -3,7 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:50920/", + "applicationUrl": "http://localhost:57423/", "sslPort": 0 } }, diff --git a/src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs b/src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs index 0d224fc68..71f700762 100644 --- a/src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs +++ b/src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs @@ -32,11 +32,16 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers // GET api/v1/[controller]/items[?pageSize=3&pageIndex=10] [HttpGet] - [Route("[action]")] + [Route("items")] [ProducesResponseType(typeof(PaginatedItemsViewModel), (int)HttpStatusCode.OK)] - public async Task Items([FromQuery]int pageSize = 10, [FromQuery]int pageIndex = 0) - + [ProducesResponseType(typeof(IEnumerable), (int)HttpStatusCode.OK)] + public async Task Items([FromQuery]int pageSize = 10, [FromQuery]int pageIndex = 0, [FromQuery] string ids = null) { + if (!string.IsNullOrEmpty(ids)) + { + return GetItemsByIds(ids); + } + var totalItems = await _catalogContext.CatalogItems .LongCountAsync(); @@ -54,6 +59,23 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers return Ok(model); } + private IActionResult GetItemsByIds(string ids) + { + var numIds = ids.Split(',') + .Select(id => (Ok: int.TryParse(id, out int x), Value: x)); + if (!numIds.All(nid => nid.Ok)) + { + return BadRequest("ids value invalid. Must be comma-separated list of numbers"); + } + + var idsToSelect = numIds.Select(id => id.Value); + var items = _catalogContext.CatalogItems.Where(ci => idsToSelect.Contains(ci.Id)).ToList(); + + items = ChangeUriPlaceholder(items); + return Ok(items); + + } + [HttpGet] [Route("items/{id:int}")] [ProducesResponseType((int)HttpStatusCode.NotFound)] diff --git a/src/Services/Catalog/Catalog.API/Properties/launchSettings.json b/src/Services/Catalog/Catalog.API/Properties/launchSettings.json index a0b19b3bf..2b21ca280 100644 --- a/src/Services/Catalog/Catalog.API/Properties/launchSettings.json +++ b/src/Services/Catalog/Catalog.API/Properties/launchSettings.json @@ -3,7 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:57623/", + "applicationUrl": "http://localhost:57424/", "sslPort": 0 } }, diff --git a/src/Web/WebSPA/AppSettings.cs b/src/Web/WebSPA/AppSettings.cs index fd254c3ae..c3fbd3b80 100644 --- a/src/Web/WebSPA/AppSettings.cs +++ b/src/Web/WebSPA/AppSettings.cs @@ -7,13 +7,13 @@ namespace eShopOnContainers.WebSPA { public class AppSettings { - public string BaseUrl { get; set; } - public string CatalogUrl { get; set; } - public string OrderingUrl { get; set; } public string IdentityUrl { get; set; } public string BasketUrl { get; set; } public string MarketingUrl { get; set; } + + public string PurchaseUrl { get; set; } + public string ActivateCampaignDetailFunction { get; set; } - public bool UseCustomizationData { get; set; } + public bool UseCustomizationData { get; set; } } } diff --git a/src/Web/WebSPA/Client/modules/basket/basket.service.ts b/src/Web/WebSPA/Client/modules/basket/basket.service.ts index 864915541..da422d5ad 100644 --- a/src/Web/WebSPA/Client/modules/basket/basket.service.ts +++ b/src/Web/WebSPA/Client/modules/basket/basket.service.ts @@ -23,6 +23,7 @@ import { Subject } from 'rxjs/Subject'; @Injectable() export class BasketService { private basketUrl: string = ''; + private purchaseUrl: string = ''; basket: IBasket = { buyerId: '', items: [] @@ -40,12 +41,14 @@ export class BasketService { if (this.authService.UserData) { this.basket.buyerId = this.authService.UserData.sub; if (this.configurationService.isReady) { - this.basketUrl = this.configurationService.serverSettings.basketUrl; + this.basketUrl = this.configurationService.serverSettings.purchaseUrl; + this.purchaseUrl = this.configurationService.serverSettings.purchaseUrl; this.loadData(); } else { this.configurationService.settingsLoaded$.subscribe(x => { - this.basketUrl = this.configurationService.serverSettings.basketUrl; + this.basketUrl = this.configurationService.serverSettings.purchaseUrl; + this.purchaseUrl = this.configurationService.serverSettings.purchaseUrl; this.loadData(); }); } @@ -63,7 +66,7 @@ export class BasketService { } setBasket(basket): Observable { - let url = this.basketUrl + '/api/v1/basket/'; + let url = this.purchaseUrl + '/purchase-bff/api/v1/basket/'; this.basket = basket; return this.service.post(url, basket).map((response: Response) => { return true; @@ -71,7 +74,7 @@ export class BasketService { } setBasketCheckout(basketCheckout): Observable { - let url = this.basketUrl + '/api/v1/basket/checkout'; + let url = this.basketUrl + '/purchase-bff/api/v1/b/basket/checkout'; return this.service.postWithId(url, basketCheckout).map((response: Response) => { this.basketEvents.orderCreated(); return true; @@ -79,7 +82,7 @@ export class BasketService { } getBasket(): Observable { - let url = this.basketUrl + '/api/v1/basket/' + this.basket.buyerId; + let url = this.basketUrl + '/api/v1/b/basket/' + this.basket.buyerId; return this.service.get(url).map((response: Response) => { if (response.status === 204) { return null; diff --git a/src/Web/WebSPA/Client/modules/catalog/catalog.service.ts b/src/Web/WebSPA/Client/modules/catalog/catalog.service.ts index bdcb9d664..672146c9e 100644 --- a/src/Web/WebSPA/Client/modules/catalog/catalog.service.ts +++ b/src/Web/WebSPA/Client/modules/catalog/catalog.service.ts @@ -21,9 +21,9 @@ export class CatalogService { constructor(private service: DataService, private configurationService: ConfigurationService) { this.configurationService.settingsLoaded$.subscribe(x => { - this.catalogUrl = this.configurationService.serverSettings.catalogUrl + '/api/v1/catalog/items'; - this.brandUrl = this.configurationService.serverSettings.catalogUrl + '/api/v1/catalog/catalogbrands'; - this.typesUrl = this.configurationService.serverSettings.catalogUrl + '/api/v1/catalog/catalogtypes'; + this.catalogUrl = this.configurationService.serverSettings.purchaseUrl + '/purchase-bff/api/v1/c/catalog/items'; + this.brandUrl = this.configurationService.serverSettings.purchaseUrl + '/purchase-bff/api/v1/c/catalog/catalogbrands'; + this.typesUrl = this.configurationService.serverSettings.purchaseUrl + '/purchase-bff/api/v1/c/catalog/catalogtypes'; }); } diff --git a/src/Web/WebSPA/Client/modules/orders/orders.service.ts b/src/Web/WebSPA/Client/modules/orders/orders.service.ts index 5eda7c8ce..8d96602a1 100644 --- a/src/Web/WebSPA/Client/modules/orders/orders.service.ts +++ b/src/Web/WebSPA/Client/modules/orders/orders.service.ts @@ -22,14 +22,14 @@ export class OrdersService { constructor(private service: DataService, private basketService: BasketWrapperService, private identityService: SecurityService, private configurationService: ConfigurationService) { if (this.configurationService.isReady) - this.ordersUrl = this.configurationService.serverSettings.orderingUrl; + this.ordersUrl = this.configurationService.serverSettings.purchaseUrl; else - this.configurationService.settingsLoaded$.subscribe(x => this.ordersUrl = this.configurationService.serverSettings.orderingUrl); + this.configurationService.settingsLoaded$.subscribe(x => this.ordersUrl = this.configurationService.serverSettings.purchaseUrl); } getOrders(): Observable { - let url = this.ordersUrl + '/api/v1/orders'; + let url = this.ordersUrl + '/purchase-bff/api/v1/o/orders'; return this.service.get(url).map((response: Response) => { return response.json(); @@ -37,7 +37,7 @@ export class OrdersService { } getOrder(id: number): Observable { - let url = this.ordersUrl + '/api/v1/orders/' + id; + let url = this.ordersUrl + '/purchase-bff/api/v1/o/orders/' + id; return this.service.get(url).map((response: Response) => { return response.json(); diff --git a/src/Web/WebSPA/Client/modules/shared/models/configuration.model.ts b/src/Web/WebSPA/Client/modules/shared/models/configuration.model.ts index f22b28a3e..49950e9d6 100644 --- a/src/Web/WebSPA/Client/modules/shared/models/configuration.model.ts +++ b/src/Web/WebSPA/Client/modules/shared/models/configuration.model.ts @@ -1,8 +1,6 @@ export interface IConfiguration { - catalogUrl: string, - orderingUrl: string, identityUrl: string, - basketUrl: string, marketingUrl: string, + purchaseUrl: string, activateCampaignDetailFunction: boolean } \ No newline at end of file diff --git a/src/Web/WebSPA/Client/modules/shared/services/configuration.service.ts b/src/Web/WebSPA/Client/modules/shared/services/configuration.service.ts index d41786859..ea95275e0 100644 --- a/src/Web/WebSPA/Client/modules/shared/services/configuration.service.ts +++ b/src/Web/WebSPA/Client/modules/shared/services/configuration.service.ts @@ -28,11 +28,9 @@ export class ConfigurationService { console.log('server settings loaded'); this.serverSettings = response.json(); console.log(this.serverSettings); - this.storageService.store('basketUrl', this.serverSettings.basketUrl); - this.storageService.store('catalogUrl', this.serverSettings.catalogUrl); this.storageService.store('identityUrl', this.serverSettings.identityUrl); - this.storageService.store('orderingUrl', this.serverSettings.orderingUrl); this.storageService.store('marketingUrl', this.serverSettings.marketingUrl); + this.storageService.store('purchaseUrl', this.serverSettings.purchaseUrl); this.storageService.store('activateCampaignDetailFunction', this.serverSettings.activateCampaignDetailFunction); this.isReady = true; this.settingsLoadedSource.next(); diff --git a/src/Web/WebSPA/Client/modules/shared/services/security.service.ts b/src/Web/WebSPA/Client/modules/shared/services/security.service.ts index 483ea4ae4..2b580b5cd 100644 --- a/src/Web/WebSPA/Client/modules/shared/services/security.service.ts +++ b/src/Web/WebSPA/Client/modules/shared/services/security.service.ts @@ -82,7 +82,7 @@ export class SecurityService { let client_id = 'js'; let redirect_uri = location.origin + '/'; let response_type = 'id_token token'; - let scope = 'openid profile orders basket marketing locations'; + let scope = 'openid profile orders basket marketing locations purchasebff'; let nonce = 'N' + Math.random() + '' + Date.now(); let state = Date.now() + '' + Math.random(); diff --git a/src/Web/WebSPA/Properties/launchSettings.json b/src/Web/WebSPA/Properties/launchSettings.json index 9ae65426a..bf0fc44d4 100644 --- a/src/Web/WebSPA/Properties/launchSettings.json +++ b/src/Web/WebSPA/Properties/launchSettings.json @@ -3,7 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:50921/", + "applicationUrl": "http://localhost:64923/", "sslPort": 0 } }, diff --git a/src/Web/WebSPA/appsettings.json b/src/Web/WebSPA/appsettings.json index 7b1930f84..75f17ac35 100644 --- a/src/Web/WebSPA/appsettings.json +++ b/src/Web/WebSPA/appsettings.json @@ -1,10 +1,8 @@ { - "CatalogUrl": "http://localhost:5101", - "OrderingUrl": "http://localhost:5102", - "BasketUrl": "http://localhost:5103", "IdentityUrl": "http://localhost:5105", "MarketingUrl": "http://localhost:5110", "CallBackUrl": "http://localhost:5104/", + "PurchaseUrl": "http://localhost:5200", "UseCustomizationData": true, "IsClusterEnv": "False", "ActivateCampaignDetailFunction": true, From 0be655d2e0f72f8ca4aaa800b05478b607f10753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduard=20Tom=C3=A0s?= Date: Wed, 7 Feb 2018 13:15:17 +0000 Subject: [PATCH 20/45] Fixing errors in SPA when calling basket api through apigw --- src/Services/Basket/Basket.API/Properties/launchSettings.json | 2 +- .../Identity/Identity.API/Properties/launchSettings.json | 2 +- .../Location/Locations.API/Properties/launchSettings.json | 2 +- src/Web/WebSPA/Client/modules/basket/basket.service.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Services/Basket/Basket.API/Properties/launchSettings.json b/src/Services/Basket/Basket.API/Properties/launchSettings.json index 7d1c959e3..382f0584a 100644 --- a/src/Services/Basket/Basket.API/Properties/launchSettings.json +++ b/src/Services/Basket/Basket.API/Properties/launchSettings.json @@ -3,7 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:57423/", + "applicationUrl": "http://localhost:53998/", "sslPort": 0 } }, diff --git a/src/Services/Identity/Identity.API/Properties/launchSettings.json b/src/Services/Identity/Identity.API/Properties/launchSettings.json index c20d94307..e52e9f99c 100644 --- a/src/Services/Identity/Identity.API/Properties/launchSettings.json +++ b/src/Services/Identity/Identity.API/Properties/launchSettings.json @@ -3,7 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:55105", + "applicationUrl": "http://localhost:54010/", "sslPort": 0 } }, diff --git a/src/Services/Location/Locations.API/Properties/launchSettings.json b/src/Services/Location/Locations.API/Properties/launchSettings.json index 6401e4bbe..1c86a33b1 100644 --- a/src/Services/Location/Locations.API/Properties/launchSettings.json +++ b/src/Services/Location/Locations.API/Properties/launchSettings.json @@ -3,7 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:53933/", + "applicationUrl": "http://localhost:54020/", "sslPort": 0 } }, diff --git a/src/Web/WebSPA/Client/modules/basket/basket.service.ts b/src/Web/WebSPA/Client/modules/basket/basket.service.ts index da422d5ad..f59357020 100644 --- a/src/Web/WebSPA/Client/modules/basket/basket.service.ts +++ b/src/Web/WebSPA/Client/modules/basket/basket.service.ts @@ -82,7 +82,7 @@ export class BasketService { } getBasket(): Observable { - let url = this.basketUrl + '/api/v1/b/basket/' + this.basket.buyerId; + let url = this.basketUrl + '/purchase-bff/api/v1/b/basket/' + this.basket.buyerId; return this.service.get(url).map((response: Response) => { if (response.status === 204) { return null; From 6cc87fc80ab52f203c6817945574baeba02a9796 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduard=20Tom=C3=A0s?= Date: Thu, 15 Feb 2018 17:30:39 +0100 Subject: [PATCH 21/45] renaming of PurchaseBff to Aggregator --- docker-compose.override.yml | 6 +- docker-compose.prod.yml | 2 +- docker-compose.yml | 6 +- eShopOnContainers-ServicesAndWebApps.sln | 104 +++++++++--------- .../Config/UrlsConfig.cs | 2 +- .../Controllers/BasketController.cs | 6 +- .../Controllers/HomeController.cs | 2 +- .../Controllers/OrderController.cs | 4 +- .../Dockerfile | 4 +- .../Filters/AuthorizeCheckOperationFilter.cs | 4 +- .../Mobile.Shopping.HttpAggregator.csproj} | 4 +- .../Models/AddBasketItemRequest.cs | 2 +- .../Models/BasketData.cs | 2 +- .../Models/CatalogItem.cs | 2 +- .../Models/OrderData.cs | 2 +- .../Models/OrderItemData.cs | 2 +- .../Models/UpdateBasketItemsRequest.cs | 2 +- .../Models/UpdateBasketRequest.cs | 2 +- .../Program.cs | 2 +- .../Properties/launchSettings.json | 0 .../Services/BasketService.cs | 6 +- .../Services/CatalogService.cs | 6 +- .../Services/IBasketService.cs | 4 +- .../Services/ICatalogService.cs | 4 +- .../Services/IOrderApiClient.cs | 4 +- .../Services/OrderApiClient.cs | 6 +- .../Startup.cs | 14 +-- .../appsettings.json | 0 .../appsettings.localhost.json | 0 src/Apigw/OcelotApiGw/Startup.cs | 2 +- .../configuration/configuration.json | 10 +- .../Basket.API/Properties/launchSettings.json | 2 +- .../Identity.API/Configuration/Config.cs | 20 ++-- .../Data/ConfigurationDbContextSeed.cs | 2 +- src/Web/WebMVC/Controllers/TestController.cs | 2 +- src/Web/WebMVC/Startup.cs | 2 +- .../Client/modules/basket/basket.service.ts | 6 +- .../Client/modules/catalog/catalog.service.ts | 6 +- .../Client/modules/orders/orders.service.ts | 4 +- .../shared/services/security.service.ts | 2 +- src/Web/WebSPA/Properties/launchSettings.json | 2 +- 41 files changed, 132 insertions(+), 132 deletions(-) rename src/{BFFs/PurchaseBff => Aggregators/Mobile.Shopping.HttpAggregator}/Config/UrlsConfig.cs (92%) rename src/{BFFs/PurchaseBff => Aggregators/Mobile.Shopping.HttpAggregator}/Controllers/BasketController.cs (95%) rename src/{BFFs/PurchaseBff => Aggregators/Mobile.Shopping.HttpAggregator}/Controllers/HomeController.cs (80%) rename src/{BFFs/PurchaseBff => Aggregators/Mobile.Shopping.HttpAggregator}/Controllers/OrderController.cs (88%) rename src/{BFFs/PurchaseBff => Aggregators/Mobile.Shopping.HttpAggregator}/Dockerfile (74%) rename src/{BFFs/PurchaseBff => Aggregators/Mobile.Shopping.HttpAggregator}/Filters/AuthorizeCheckOperationFilter.cs (86%) rename src/{BFFs/PurchaseBff/PurchaseBff.csproj => Aggregators/Mobile.Shopping.HttpAggregator/Mobile.Shopping.HttpAggregator.csproj} (82%) rename src/{BFFs/PurchaseBff => Aggregators/Mobile.Shopping.HttpAggregator}/Models/AddBasketItemRequest.cs (83%) rename src/{BFFs/PurchaseBff => Aggregators/Mobile.Shopping.HttpAggregator}/Models/BasketData.cs (90%) rename src/{BFFs/PurchaseBff => Aggregators/Mobile.Shopping.HttpAggregator}/Models/CatalogItem.cs (80%) rename src/{BFFs/PurchaseBff => Aggregators/Mobile.Shopping.HttpAggregator}/Models/OrderData.cs (93%) rename src/{BFFs/PurchaseBff => Aggregators/Mobile.Shopping.HttpAggregator}/Models/OrderItemData.cs (84%) rename src/{BFFs/PurchaseBff => Aggregators/Mobile.Shopping.HttpAggregator}/Models/UpdateBasketItemsRequest.cs (89%) rename src/{BFFs/PurchaseBff => Aggregators/Mobile.Shopping.HttpAggregator}/Models/UpdateBasketRequest.cs (87%) rename src/{BFFs/PurchaseBff => Aggregators/Mobile.Shopping.HttpAggregator}/Program.cs (93%) rename src/{BFFs/PurchaseBff => Aggregators/Mobile.Shopping.HttpAggregator}/Properties/launchSettings.json (100%) rename src/{BFFs/PurchaseBff => Aggregators/Mobile.Shopping.HttpAggregator}/Services/BasketService.cs (89%) rename src/{BFFs/PurchaseBff => Aggregators/Mobile.Shopping.HttpAggregator}/Services/CatalogService.cs (85%) rename src/{BFFs/PurchaseBff => Aggregators/Mobile.Shopping.HttpAggregator}/Services/IBasketService.cs (61%) rename src/{BFFs/PurchaseBff => Aggregators/Mobile.Shopping.HttpAggregator}/Services/ICatalogService.cs (64%) rename src/{BFFs/PurchaseBff => Aggregators/Mobile.Shopping.HttpAggregator}/Services/IOrderApiClient.cs (58%) rename src/{BFFs/PurchaseBff => Aggregators/Mobile.Shopping.HttpAggregator}/Services/OrderApiClient.cs (84%) rename src/{BFFs/PurchaseBff => Aggregators/Mobile.Shopping.HttpAggregator}/Startup.cs (88%) rename src/{BFFs/PurchaseBff => Aggregators/Mobile.Shopping.HttpAggregator}/appsettings.json (100%) rename src/{BFFs/PurchaseBff => Aggregators/Mobile.Shopping.HttpAggregator}/appsettings.localhost.json (100%) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index cfff01732..b6347824f 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -57,7 +57,7 @@ services: - MarketingApiClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5110 - BasketApiClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5103 - OrderingApiClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5102 - - PurchaseBFFClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5120 + - MobileShoppingAggClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5120 - UseCustomizationData=True - ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY} - OrchestratorType=${ORCHESTRATOR_TYPE} @@ -132,7 +132,7 @@ services: environment: - ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_URLS=http://0.0.0.0:80 - - PurchaseUrl=http://apigw/purchase-bff + - PurchaseUrl=http://apigw/shopping - LocationsUrl=http://locations.api - IdentityUrl=http://10.0.75.1:5105 # Local Mac: Use http://docker.for.mac.localhost:5105 || Local Windows: Use 10.0.75.1 in a "Docker for Windows" environment, if using "localhost" from browser. || #Remote access: Use ${ESHOP_EXTERNAL_DNS_NAME_OR_IP} if using external IP or DNS name from browser. - MarketingUrl=http://marketing.api @@ -225,7 +225,7 @@ services: ports: - "5200:80" - purchasebff: + mobileshoppingagg: environment: - ASPNETCORE_ENVIRONMENT=Development - urls__basket=http://basket.api diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 8c8d67b5d..68e02e4da 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -64,7 +64,7 @@ services: - MarketingApiClient=http://${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}:5110 - BasketApiClient=http://${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}:5103 - OrderingApiClient=http://${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}:5102 - - PurchaseBFFClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5120 + - MobileShoppingAggClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5120 - UseCustomizationData=True - ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY} - OrchestratorType=${ORCHESTRATOR_TYPE} diff --git a/docker-compose.yml b/docker-compose.yml index 18a3273f8..672790166 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -114,9 +114,9 @@ services: context: . dockerfile: src/Apigw/OcelotApiGw/Dockerfile - purchasebff: - image: eshop/purchasebff + mobileshoppingagg: + image: eshop/mobileshoppingagg build: context: . - dockerfile: src/BFFs/PurchaseBff/Dockerfile + dockerfile: src/Aggregators/Mobile.Shopping.HttpAggregator/Dockerfile diff --git a/eShopOnContainers-ServicesAndWebApps.sln b/eShopOnContainers-ServicesAndWebApps.sln index 7d25f9b3a..fc72b85f6 100644 --- a/eShopOnContainers-ServicesAndWebApps.sln +++ b/eShopOnContainers-ServicesAndWebApps.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.27004.2009 +VisualStudioVersion = 15.0.27130.2027 MinimumVisualStudioVersion = 10.0.40219.1 Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{FEA0C318-FFED-4D39-8781-265718CA43DD}" EndProject @@ -101,9 +101,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ApiGw", "ApiGw", "{7A58AA20 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OcelotApiGw", "src\Apigw\OcelotApiGw\OcelotApiGw.csproj", "{E0C5162E-DF26-4341-9E51-14AE800D7505}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BFFs", "BFFs", "{EA378316-9D49-4A6B-858E-D4A25F948A74}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Aggregators", "Aggregators", "{EA378316-9D49-4A6B-858E-D4A25F948A74}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PurchaseBff", "src\BFFs\PurchaseBff\PurchaseBff.csproj", "{F77054A6-5808-45D7-88EB-CD92B3FDB889}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mobile.Shopping.HttpAggregator", "src\Aggregators\Mobile.Shopping.HttpAggregator\Mobile.Shopping.HttpAggregator.csproj", "{6E99F232-1536-424F-A28C-91692C8FD325}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -1367,54 +1367,54 @@ Global {E0C5162E-DF26-4341-9E51-14AE800D7505}.Release|x64.Build.0 = Release|Any CPU {E0C5162E-DF26-4341-9E51-14AE800D7505}.Release|x86.ActiveCfg = Release|Any CPU {E0C5162E-DF26-4341-9E51-14AE800D7505}.Release|x86.Build.0 = Release|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Ad-Hoc|x64.Build.0 = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Ad-Hoc|x86.Build.0 = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.AppStore|Any CPU.Build.0 = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.AppStore|ARM.ActiveCfg = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.AppStore|ARM.Build.0 = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.AppStore|iPhone.ActiveCfg = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.AppStore|iPhone.Build.0 = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.AppStore|x64.ActiveCfg = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.AppStore|x64.Build.0 = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.AppStore|x86.ActiveCfg = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.AppStore|x86.Build.0 = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Debug|ARM.ActiveCfg = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Debug|ARM.Build.0 = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Debug|iPhone.ActiveCfg = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Debug|iPhone.Build.0 = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Debug|x64.ActiveCfg = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Debug|x64.Build.0 = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Debug|x86.ActiveCfg = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Debug|x86.Build.0 = Debug|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Release|Any CPU.Build.0 = Release|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Release|ARM.ActiveCfg = Release|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Release|ARM.Build.0 = Release|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Release|iPhone.ActiveCfg = Release|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Release|iPhone.Build.0 = Release|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Release|iPhoneSimulator.Build.0 = Release|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Release|x64.ActiveCfg = Release|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Release|x64.Build.0 = Release|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Release|x86.ActiveCfg = Release|Any CPU - {F77054A6-5808-45D7-88EB-CD92B3FDB889}.Release|x86.Build.0 = Release|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Ad-Hoc|x64.Build.0 = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Ad-Hoc|x86.Build.0 = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.AppStore|Any CPU.Build.0 = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.AppStore|ARM.ActiveCfg = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.AppStore|ARM.Build.0 = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.AppStore|iPhone.ActiveCfg = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.AppStore|iPhone.Build.0 = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.AppStore|x64.ActiveCfg = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.AppStore|x64.Build.0 = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.AppStore|x86.ActiveCfg = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.AppStore|x86.Build.0 = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Debug|ARM.ActiveCfg = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Debug|ARM.Build.0 = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Debug|iPhone.Build.0 = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Debug|x64.ActiveCfg = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Debug|x64.Build.0 = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Debug|x86.ActiveCfg = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Debug|x86.Build.0 = Debug|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Release|Any CPU.Build.0 = Release|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Release|ARM.ActiveCfg = Release|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Release|ARM.Build.0 = Release|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Release|iPhone.ActiveCfg = Release|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Release|iPhone.Build.0 = Release|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Release|x64.ActiveCfg = Release|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Release|x64.Build.0 = Release|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Release|x86.ActiveCfg = Release|Any CPU + {6E99F232-1536-424F-A28C-91692C8FD325}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1464,7 +1464,7 @@ Global {7A58AA20-67F3-48F3-88C8-24EBFE621792} = {932D8224-11F6-4D07-B109-DA28AD288A63} {E0C5162E-DF26-4341-9E51-14AE800D7505} = {7A58AA20-67F3-48F3-88C8-24EBFE621792} {EA378316-9D49-4A6B-858E-D4A25F948A74} = {932D8224-11F6-4D07-B109-DA28AD288A63} - {F77054A6-5808-45D7-88EB-CD92B3FDB889} = {EA378316-9D49-4A6B-858E-D4A25F948A74} + {6E99F232-1536-424F-A28C-91692C8FD325} = {EA378316-9D49-4A6B-858E-D4A25F948A74} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {25728519-5F0F-4973-8A64-0A81EB4EA8D9} diff --git a/src/BFFs/PurchaseBff/Config/UrlsConfig.cs b/src/Aggregators/Mobile.Shopping.HttpAggregator/Config/UrlsConfig.cs similarity index 92% rename from src/BFFs/PurchaseBff/Config/UrlsConfig.cs rename to src/Aggregators/Mobile.Shopping.HttpAggregator/Config/UrlsConfig.cs index 58f344aac..e920fbbb2 100644 --- a/src/BFFs/PurchaseBff/Config/UrlsConfig.cs +++ b/src/Aggregators/Mobile.Shopping.HttpAggregator/Config/UrlsConfig.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace PurchaseBff.Config +namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Config { public class UrlsConfig { diff --git a/src/BFFs/PurchaseBff/Controllers/BasketController.cs b/src/Aggregators/Mobile.Shopping.HttpAggregator/Controllers/BasketController.cs similarity index 95% rename from src/BFFs/PurchaseBff/Controllers/BasketController.cs rename to src/Aggregators/Mobile.Shopping.HttpAggregator/Controllers/BasketController.cs index ac8620623..702c805fb 100644 --- a/src/BFFs/PurchaseBff/Controllers/BasketController.cs +++ b/src/Aggregators/Mobile.Shopping.HttpAggregator/Controllers/BasketController.cs @@ -1,13 +1,13 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using PurchaseBff.Models; -using PurchaseBff.Services; +using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models; +using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Services; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace PurchaseBff.Controllers +namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Controllers { [Route("api/v1/[controller]")] [Authorize] diff --git a/src/BFFs/PurchaseBff/Controllers/HomeController.cs b/src/Aggregators/Mobile.Shopping.HttpAggregator/Controllers/HomeController.cs similarity index 80% rename from src/BFFs/PurchaseBff/Controllers/HomeController.cs rename to src/Aggregators/Mobile.Shopping.HttpAggregator/Controllers/HomeController.cs index f54ec94ad..48a71480a 100644 --- a/src/BFFs/PurchaseBff/Controllers/HomeController.cs +++ b/src/Aggregators/Mobile.Shopping.HttpAggregator/Controllers/HomeController.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace PurchaseBff.Controllers +namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Controllers { [Route("")] public class HomeController : Controller diff --git a/src/BFFs/PurchaseBff/Controllers/OrderController.cs b/src/Aggregators/Mobile.Shopping.HttpAggregator/Controllers/OrderController.cs similarity index 88% rename from src/BFFs/PurchaseBff/Controllers/OrderController.cs rename to src/Aggregators/Mobile.Shopping.HttpAggregator/Controllers/OrderController.cs index 91d0062ac..4c18d25ae 100644 --- a/src/BFFs/PurchaseBff/Controllers/OrderController.cs +++ b/src/Aggregators/Mobile.Shopping.HttpAggregator/Controllers/OrderController.cs @@ -1,12 +1,12 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using PurchaseBff.Services; +using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Services; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace PurchaseBff.Controllers +namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Controllers { [Route("api/v1/[controller]")] [Authorize] diff --git a/src/BFFs/PurchaseBff/Dockerfile b/src/Aggregators/Mobile.Shopping.HttpAggregator/Dockerfile similarity index 74% rename from src/BFFs/PurchaseBff/Dockerfile rename to src/Aggregators/Mobile.Shopping.HttpAggregator/Dockerfile index 500f8406f..24df53c80 100644 --- a/src/BFFs/PurchaseBff/Dockerfile +++ b/src/Aggregators/Mobile.Shopping.HttpAggregator/Dockerfile @@ -6,7 +6,7 @@ FROM microsoft/aspnetcore-build:2.0 AS build WORKDIR /src COPY . . RUN dotnet restore -nowarn:msb3202,nu1503 -WORKDIR /src/src/BFFs/PurchaseBff +WORKDIR /src/src/Aggregators/Mobile.Shopping.HttpAggregator RUN dotnet build --no-restore -c Release -o /app FROM build AS publish @@ -15,4 +15,4 @@ RUN dotnet publish --no-restore -c Release -o /app FROM base AS final WORKDIR /app COPY --from=publish /app . -ENTRYPOINT ["dotnet", "PurchaseBff.dll"] +ENTRYPOINT ["dotnet", "Mobile.Shopping.HttpAggregator.dll"] diff --git a/src/BFFs/PurchaseBff/Filters/AuthorizeCheckOperationFilter.cs b/src/Aggregators/Mobile.Shopping.HttpAggregator/Filters/AuthorizeCheckOperationFilter.cs similarity index 86% rename from src/BFFs/PurchaseBff/Filters/AuthorizeCheckOperationFilter.cs rename to src/Aggregators/Mobile.Shopping.HttpAggregator/Filters/AuthorizeCheckOperationFilter.cs index 31b5bf99e..b3a7246aa 100644 --- a/src/BFFs/PurchaseBff/Filters/AuthorizeCheckOperationFilter.cs +++ b/src/Aggregators/Mobile.Shopping.HttpAggregator/Filters/AuthorizeCheckOperationFilter.cs @@ -1,4 +1,4 @@ -namespace PurchaseBff.Filters +namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Filters { using Microsoft.AspNetCore.Authorization; using Swashbuckle.AspNetCore.Swagger; @@ -24,7 +24,7 @@ operation.Security = new List>>(); operation.Security.Add(new Dictionary> { - { "oauth2", new [] { "purchasebff" } } + { "oauth2", new [] { "Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator" } } }); } } diff --git a/src/BFFs/PurchaseBff/PurchaseBff.csproj b/src/Aggregators/Mobile.Shopping.HttpAggregator/Mobile.Shopping.HttpAggregator.csproj similarity index 82% rename from src/BFFs/PurchaseBff/PurchaseBff.csproj rename to src/Aggregators/Mobile.Shopping.HttpAggregator/Mobile.Shopping.HttpAggregator.csproj index dd7a5909e..093e7a370 100644 --- a/src/BFFs/PurchaseBff/PurchaseBff.csproj +++ b/src/Aggregators/Mobile.Shopping.HttpAggregator/Mobile.Shopping.HttpAggregator.csproj @@ -2,8 +2,8 @@ netcoreapp2.0 - PurchaseBff - PurchaseBff + Mobile.Shopping.HttpAggregator + Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator ..\..\..\docker-compose.dcproj diff --git a/src/BFFs/PurchaseBff/Models/AddBasketItemRequest.cs b/src/Aggregators/Mobile.Shopping.HttpAggregator/Models/AddBasketItemRequest.cs similarity index 83% rename from src/BFFs/PurchaseBff/Models/AddBasketItemRequest.cs rename to src/Aggregators/Mobile.Shopping.HttpAggregator/Models/AddBasketItemRequest.cs index 7c589a233..f81842c09 100644 --- a/src/BFFs/PurchaseBff/Models/AddBasketItemRequest.cs +++ b/src/Aggregators/Mobile.Shopping.HttpAggregator/Models/AddBasketItemRequest.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace PurchaseBff.Models +namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models { public class AddBasketItemRequest { diff --git a/src/BFFs/PurchaseBff/Models/BasketData.cs b/src/Aggregators/Mobile.Shopping.HttpAggregator/Models/BasketData.cs similarity index 90% rename from src/BFFs/PurchaseBff/Models/BasketData.cs rename to src/Aggregators/Mobile.Shopping.HttpAggregator/Models/BasketData.cs index 3f14660a7..1b9348c44 100644 --- a/src/BFFs/PurchaseBff/Models/BasketData.cs +++ b/src/Aggregators/Mobile.Shopping.HttpAggregator/Models/BasketData.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace PurchaseBff.Models +namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models { public class BasketData { diff --git a/src/BFFs/PurchaseBff/Models/CatalogItem.cs b/src/Aggregators/Mobile.Shopping.HttpAggregator/Models/CatalogItem.cs similarity index 80% rename from src/BFFs/PurchaseBff/Models/CatalogItem.cs rename to src/Aggregators/Mobile.Shopping.HttpAggregator/Models/CatalogItem.cs index 13b0a65c0..25f766719 100644 --- a/src/BFFs/PurchaseBff/Models/CatalogItem.cs +++ b/src/Aggregators/Mobile.Shopping.HttpAggregator/Models/CatalogItem.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace PurchaseBff.Models +namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models { public class CatalogItem { diff --git a/src/BFFs/PurchaseBff/Models/OrderData.cs b/src/Aggregators/Mobile.Shopping.HttpAggregator/Models/OrderData.cs similarity index 93% rename from src/BFFs/PurchaseBff/Models/OrderData.cs rename to src/Aggregators/Mobile.Shopping.HttpAggregator/Models/OrderData.cs index c561a53ad..e87cc18f0 100644 --- a/src/BFFs/PurchaseBff/Models/OrderData.cs +++ b/src/Aggregators/Mobile.Shopping.HttpAggregator/Models/OrderData.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace PurchaseBff.Models +namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models { public class OrderData { diff --git a/src/BFFs/PurchaseBff/Models/OrderItemData.cs b/src/Aggregators/Mobile.Shopping.HttpAggregator/Models/OrderItemData.cs similarity index 84% rename from src/BFFs/PurchaseBff/Models/OrderItemData.cs rename to src/Aggregators/Mobile.Shopping.HttpAggregator/Models/OrderItemData.cs index bdc7b361e..b0179e470 100644 --- a/src/BFFs/PurchaseBff/Models/OrderItemData.cs +++ b/src/Aggregators/Mobile.Shopping.HttpAggregator/Models/OrderItemData.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace PurchaseBff.Models +namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models { public class OrderItemData { diff --git a/src/BFFs/PurchaseBff/Models/UpdateBasketItemsRequest.cs b/src/Aggregators/Mobile.Shopping.HttpAggregator/Models/UpdateBasketItemsRequest.cs similarity index 89% rename from src/BFFs/PurchaseBff/Models/UpdateBasketItemsRequest.cs rename to src/Aggregators/Mobile.Shopping.HttpAggregator/Models/UpdateBasketItemsRequest.cs index eb63efa23..43cc81b89 100644 --- a/src/BFFs/PurchaseBff/Models/UpdateBasketItemsRequest.cs +++ b/src/Aggregators/Mobile.Shopping.HttpAggregator/Models/UpdateBasketItemsRequest.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace PurchaseBff.Models +namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models { public class UpdateBasketItemsRequest { diff --git a/src/BFFs/PurchaseBff/Models/UpdateBasketRequest.cs b/src/Aggregators/Mobile.Shopping.HttpAggregator/Models/UpdateBasketRequest.cs similarity index 87% rename from src/BFFs/PurchaseBff/Models/UpdateBasketRequest.cs rename to src/Aggregators/Mobile.Shopping.HttpAggregator/Models/UpdateBasketRequest.cs index a6813c788..cb22bf55f 100644 --- a/src/BFFs/PurchaseBff/Models/UpdateBasketRequest.cs +++ b/src/Aggregators/Mobile.Shopping.HttpAggregator/Models/UpdateBasketRequest.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace PurchaseBff.Models +namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models { public class UpdateBasketRequest { diff --git a/src/BFFs/PurchaseBff/Program.cs b/src/Aggregators/Mobile.Shopping.HttpAggregator/Program.cs similarity index 93% rename from src/BFFs/PurchaseBff/Program.cs rename to src/Aggregators/Mobile.Shopping.HttpAggregator/Program.cs index 7c6110260..0c88fcd7d 100644 --- a/src/BFFs/PurchaseBff/Program.cs +++ b/src/Aggregators/Mobile.Shopping.HttpAggregator/Program.cs @@ -8,7 +8,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; -namespace PurchaseBff +namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator { public class Program { diff --git a/src/BFFs/PurchaseBff/Properties/launchSettings.json b/src/Aggregators/Mobile.Shopping.HttpAggregator/Properties/launchSettings.json similarity index 100% rename from src/BFFs/PurchaseBff/Properties/launchSettings.json rename to src/Aggregators/Mobile.Shopping.HttpAggregator/Properties/launchSettings.json diff --git a/src/BFFs/PurchaseBff/Services/BasketService.cs b/src/Aggregators/Mobile.Shopping.HttpAggregator/Services/BasketService.cs similarity index 89% rename from src/BFFs/PurchaseBff/Services/BasketService.cs rename to src/Aggregators/Mobile.Shopping.HttpAggregator/Services/BasketService.cs index c1c3a6f9d..b00fbb52c 100644 --- a/src/BFFs/PurchaseBff/Services/BasketService.cs +++ b/src/Aggregators/Mobile.Shopping.HttpAggregator/Services/BasketService.cs @@ -8,10 +8,10 @@ using Microsoft.eShopOnContainers.BuildingBlocks.Resilience.Http; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Newtonsoft.Json; -using PurchaseBff.Config; -using PurchaseBff.Models; +using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Config; +using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models; -namespace PurchaseBff.Services +namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Services { public class BasketService : IBasketService { diff --git a/src/BFFs/PurchaseBff/Services/CatalogService.cs b/src/Aggregators/Mobile.Shopping.HttpAggregator/Services/CatalogService.cs similarity index 85% rename from src/BFFs/PurchaseBff/Services/CatalogService.cs rename to src/Aggregators/Mobile.Shopping.HttpAggregator/Services/CatalogService.cs index 7030da747..d37b67679 100644 --- a/src/BFFs/PurchaseBff/Services/CatalogService.cs +++ b/src/Aggregators/Mobile.Shopping.HttpAggregator/Services/CatalogService.cs @@ -6,10 +6,10 @@ using Microsoft.eShopOnContainers.BuildingBlocks.Resilience.Http; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Newtonsoft.Json; -using PurchaseBff.Config; -using PurchaseBff.Models; +using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Config; +using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models; -namespace PurchaseBff.Services +namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Services { public class CatalogService : ICatalogService { diff --git a/src/BFFs/PurchaseBff/Services/IBasketService.cs b/src/Aggregators/Mobile.Shopping.HttpAggregator/Services/IBasketService.cs similarity index 61% rename from src/BFFs/PurchaseBff/Services/IBasketService.cs rename to src/Aggregators/Mobile.Shopping.HttpAggregator/Services/IBasketService.cs index 74f6c21ba..6fd6871c1 100644 --- a/src/BFFs/PurchaseBff/Services/IBasketService.cs +++ b/src/Aggregators/Mobile.Shopping.HttpAggregator/Services/IBasketService.cs @@ -1,10 +1,10 @@ -using PurchaseBff.Models; +using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace PurchaseBff.Services +namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Services { public interface IBasketService { diff --git a/src/BFFs/PurchaseBff/Services/ICatalogService.cs b/src/Aggregators/Mobile.Shopping.HttpAggregator/Services/ICatalogService.cs similarity index 64% rename from src/BFFs/PurchaseBff/Services/ICatalogService.cs rename to src/Aggregators/Mobile.Shopping.HttpAggregator/Services/ICatalogService.cs index b51c0f0cd..d7e605bfa 100644 --- a/src/BFFs/PurchaseBff/Services/ICatalogService.cs +++ b/src/Aggregators/Mobile.Shopping.HttpAggregator/Services/ICatalogService.cs @@ -1,10 +1,10 @@ -using PurchaseBff.Models; +using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace PurchaseBff.Services +namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Services { public interface ICatalogService { diff --git a/src/BFFs/PurchaseBff/Services/IOrderApiClient.cs b/src/Aggregators/Mobile.Shopping.HttpAggregator/Services/IOrderApiClient.cs similarity index 58% rename from src/BFFs/PurchaseBff/Services/IOrderApiClient.cs rename to src/Aggregators/Mobile.Shopping.HttpAggregator/Services/IOrderApiClient.cs index 2d23e71f6..30ac013b9 100644 --- a/src/BFFs/PurchaseBff/Services/IOrderApiClient.cs +++ b/src/Aggregators/Mobile.Shopping.HttpAggregator/Services/IOrderApiClient.cs @@ -1,10 +1,10 @@ -using PurchaseBff.Models; +using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace PurchaseBff.Services +namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Services { public interface IOrderApiClient { diff --git a/src/BFFs/PurchaseBff/Services/OrderApiClient.cs b/src/Aggregators/Mobile.Shopping.HttpAggregator/Services/OrderApiClient.cs similarity index 84% rename from src/BFFs/PurchaseBff/Services/OrderApiClient.cs rename to src/Aggregators/Mobile.Shopping.HttpAggregator/Services/OrderApiClient.cs index 44f33cf71..2659e11cc 100644 --- a/src/BFFs/PurchaseBff/Services/OrderApiClient.cs +++ b/src/Aggregators/Mobile.Shopping.HttpAggregator/Services/OrderApiClient.cs @@ -6,10 +6,10 @@ using Microsoft.eShopOnContainers.BuildingBlocks.Resilience.Http; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Newtonsoft.Json; -using PurchaseBff.Config; -using PurchaseBff.Models; +using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Config; +using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models; -namespace PurchaseBff.Services +namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Services { public class OrderApiClient : IOrderApiClient { diff --git a/src/BFFs/PurchaseBff/Startup.cs b/src/Aggregators/Mobile.Shopping.HttpAggregator/Startup.cs similarity index 88% rename from src/BFFs/PurchaseBff/Startup.cs rename to src/Aggregators/Mobile.Shopping.HttpAggregator/Startup.cs index d7e9b4e28..083839bd5 100644 --- a/src/BFFs/PurchaseBff/Startup.cs +++ b/src/Aggregators/Mobile.Shopping.HttpAggregator/Startup.cs @@ -12,12 +12,12 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -using PurchaseBff.Config; -using PurchaseBff.Filters.Basket.API.Infrastructure.Filters; -using PurchaseBff.Services; +using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Config; +using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Filters.Basket.API.Infrastructure.Filters; +using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Services; using Swashbuckle.AspNetCore.Swagger; -namespace PurchaseBff +namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator { public class Startup { @@ -61,7 +61,7 @@ namespace PurchaseBff TokenUrl = $"{Configuration.GetValue("IdentityUrlExternal")}/connect/token", Scopes = new Dictionary() { - { "purchasebff", "Purchase BFF API Gateway" } + { "mobileshoppingagg", "Purchase BFF API Gateway" } } }); @@ -89,7 +89,7 @@ namespace PurchaseBff { options.Authority = identityUrl; options.RequireHttpsMetadata = false; - options.Audience = "purchasebff"; + options.Audience = "mobileshoppingagg"; options.Events = new JwtBearerEvents() { OnAuthenticationFailed = async ctx => @@ -129,7 +129,7 @@ namespace PurchaseBff app.UseSwagger().UseSwaggerUI(c => { c.SwaggerEndpoint($"{ (!string.IsNullOrEmpty(pathBase) ? pathBase : string.Empty) }/swagger/v1/swagger.json", "Purchase BFF V1"); - c.ConfigureOAuth2("purchasebffwaggerui", "", "", "Purchase BFF Swagger UI"); + c.ConfigureOAuth2("Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregatorwaggerui", "", "", "Purchase BFF Swagger UI"); }); diff --git a/src/BFFs/PurchaseBff/appsettings.json b/src/Aggregators/Mobile.Shopping.HttpAggregator/appsettings.json similarity index 100% rename from src/BFFs/PurchaseBff/appsettings.json rename to src/Aggregators/Mobile.Shopping.HttpAggregator/appsettings.json diff --git a/src/BFFs/PurchaseBff/appsettings.localhost.json b/src/Aggregators/Mobile.Shopping.HttpAggregator/appsettings.localhost.json similarity index 100% rename from src/BFFs/PurchaseBff/appsettings.localhost.json rename to src/Aggregators/Mobile.Shopping.HttpAggregator/appsettings.localhost.json diff --git a/src/Apigw/OcelotApiGw/Startup.cs b/src/Apigw/OcelotApiGw/Startup.cs index 01ffe5139..f0a41c172 100644 --- a/src/Apigw/OcelotApiGw/Startup.cs +++ b/src/Apigw/OcelotApiGw/Startup.cs @@ -45,7 +45,7 @@ namespace OcelotApiGw x.RequireHttpsMetadata = false; x.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters() { - ValidAudiences = new[] { "orders", "basket", "locations", "marketing", "purchasebff" } + ValidAudiences = new[] { "orders", "basket", "locations", "marketing", "mobileshoppingagg" } }; x.Events = new Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerEvents() { diff --git a/src/Apigw/OcelotApiGw/configuration/configuration.json b/src/Apigw/OcelotApiGw/configuration/configuration.json index 2d5e6c8f7..80d3f1116 100644 --- a/src/Apigw/OcelotApiGw/configuration/configuration.json +++ b/src/Apigw/OcelotApiGw/configuration/configuration.json @@ -9,7 +9,7 @@ "Port": 80 } ], - "UpstreamPathTemplate": "/purchase-bff/api/{version}/c/{everything}", + "UpstreamPathTemplate": "/shopping/api/{version}/c/{everything}", "UpstreamHttpMethod": [ "GET" ] }, { @@ -21,7 +21,7 @@ "Port": 80 } ], - "UpstreamPathTemplate": "/purchase-bff/api/{version}/b/{everything}", + "UpstreamPathTemplate": "/shopping/api/{version}/b/{everything}", "UpstreamHttpMethod": [], "AuthenticationOptions": { "AuthenticationProviderKey": "IdentityApiKey", @@ -37,7 +37,7 @@ "Port": 80 } ], - "UpstreamPathTemplate": "/purchase-bff/api/{version}/o/{everything}", + "UpstreamPathTemplate": "/shopping/api/{version}/o/{everything}", "UpstreamHttpMethod": [], "AuthenticationOptions": { "AuthenticationProviderKey": "IdentityApiKey", @@ -49,11 +49,11 @@ "DownstreamScheme": "http", "DownstreamHostAndPorts": [ { - "Host": "purchasebff", + "Host": "mobileshoppingagg", "Port": 80 } ], - "UpstreamPathTemplate": "/purchase-bff/{everything}", + "UpstreamPathTemplate": "/shopping/{everything}", "UpstreamHttpMethod": [ "POST", "PUT", "GET" ], "AuthenticationOptions": { "AuthenticationProviderKey": "IdentityApiKey", diff --git a/src/Services/Basket/Basket.API/Properties/launchSettings.json b/src/Services/Basket/Basket.API/Properties/launchSettings.json index 382f0584a..60a56b153 100644 --- a/src/Services/Basket/Basket.API/Properties/launchSettings.json +++ b/src/Services/Basket/Basket.API/Properties/launchSettings.json @@ -3,7 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:53998/", + "applicationUrl": "http://localhost:58017/", "sslPort": 0 } }, diff --git a/src/Services/Identity/Identity.API/Configuration/Config.cs b/src/Services/Identity/Identity.API/Configuration/Config.cs index 9905a04d3..18e313bf8 100644 --- a/src/Services/Identity/Identity.API/Configuration/Config.cs +++ b/src/Services/Identity/Identity.API/Configuration/Config.cs @@ -15,7 +15,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration new ApiResource("basket", "Basket Service"), new ApiResource("marketing", "Marketing Service"), new ApiResource("locations", "Locations Service"), - new ApiResource("purchasebff", "Purchase BFF") + new ApiResource("mobileshoppingagg", "Mobile Shopping Aggregator") }; } @@ -54,7 +54,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration "basket", "locations", "marketing", - "purchasebff" + "mobileshoppingagg" } }, new Client @@ -81,7 +81,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration "basket", "locations", "marketing", - "purchasebff" + "mobileshoppingagg" }, //Allow requesting refresh tokens for long lived API access AllowOfflineAccess = true, @@ -118,7 +118,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration "basket", "locations", "marketing", - "purchasebff" + "mobileshoppingagg" }, }, new Client @@ -151,7 +151,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration "basket", "locations", "marketing", - "purchasebff" + "mobileshoppingagg" }, }, new Client @@ -216,17 +216,17 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration }, new Client { - ClientId = "purchasebffwaggerui", - ClientName = "Purchase BFF Swagger UI", + ClientId = "mobileshoppingaggswaggerui", + ClientName = "Mobile Shopping Aggregattor Swagger UI", AllowedGrantTypes = GrantTypes.Implicit, AllowAccessTokensViaBrowser = true, - RedirectUris = { $"{clientsUrl["PurchaseBFF"]}/swagger/o2c.html" }, - PostLogoutRedirectUris = { $"{clientsUrl["PurchaseBFF"]}/swagger/" }, + RedirectUris = { $"{clientsUrl["MobileShoppingAgg"]}/swagger/o2c.html" }, + PostLogoutRedirectUris = { $"{clientsUrl["MobileShoppingAgg"]}/swagger/" }, AllowedScopes = { - "purchasebff" + "mobileshoppingagg" } } diff --git a/src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs b/src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs index 0875361be..4757d4743 100644 --- a/src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs +++ b/src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs @@ -23,7 +23,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Data clientUrls.Add("MarketingApi", configuration.GetValue("MarketingApiClient")); clientUrls.Add("BasketApi", configuration.GetValue("BasketApiClient")); clientUrls.Add("OrderingApi", configuration.GetValue("OrderingApiClient")); - clientUrls.Add("PurchaseBFF", configuration.GetValue("PurchaseBFFClient")); + clientUrls.Add("MobileShoppingAgg", configuration.GetValue("MobileShoppingAggClient")); if (!context.Clients.Any()) { diff --git a/src/Web/WebMVC/Controllers/TestController.cs b/src/Web/WebMVC/Controllers/TestController.cs index 7a2140ea8..1b35d5d2b 100644 --- a/src/Web/WebMVC/Controllers/TestController.cs +++ b/src/Web/WebMVC/Controllers/TestController.cs @@ -32,7 +32,7 @@ namespace WebMVC.Controllers public async Task Ocelot() { - var url = "http://apigw/purchase-bff/api/v1/basket/items"; + var url = "http://apigw/shopping/api/v1/basket/items"; var payload = new TestPayload() { CatalogItemId = 1, diff --git a/src/Web/WebMVC/Startup.cs b/src/Web/WebMVC/Startup.cs index e9e86d1cd..21986b5df 100644 --- a/src/Web/WebMVC/Startup.cs +++ b/src/Web/WebMVC/Startup.cs @@ -130,7 +130,7 @@ namespace Microsoft.eShopOnContainers.WebMVC options.Scope.Add("basket"); options.Scope.Add("marketing"); options.Scope.Add("locations"); - options.Scope.Add("purchasebff"); + options.Scope.Add("mobileshoppingagg"); }); } diff --git a/src/Web/WebSPA/Client/modules/basket/basket.service.ts b/src/Web/WebSPA/Client/modules/basket/basket.service.ts index f59357020..f26cbc2cb 100644 --- a/src/Web/WebSPA/Client/modules/basket/basket.service.ts +++ b/src/Web/WebSPA/Client/modules/basket/basket.service.ts @@ -66,7 +66,7 @@ export class BasketService { } setBasket(basket): Observable { - let url = this.purchaseUrl + '/purchase-bff/api/v1/basket/'; + let url = this.purchaseUrl + '/shopping/api/v1/basket/'; this.basket = basket; return this.service.post(url, basket).map((response: Response) => { return true; @@ -74,7 +74,7 @@ export class BasketService { } setBasketCheckout(basketCheckout): Observable { - let url = this.basketUrl + '/purchase-bff/api/v1/b/basket/checkout'; + let url = this.basketUrl + '/shopping/api/v1/b/basket/checkout'; return this.service.postWithId(url, basketCheckout).map((response: Response) => { this.basketEvents.orderCreated(); return true; @@ -82,7 +82,7 @@ export class BasketService { } getBasket(): Observable { - let url = this.basketUrl + '/purchase-bff/api/v1/b/basket/' + this.basket.buyerId; + let url = this.basketUrl + '/shopping/api/v1/b/basket/' + this.basket.buyerId; return this.service.get(url).map((response: Response) => { if (response.status === 204) { return null; diff --git a/src/Web/WebSPA/Client/modules/catalog/catalog.service.ts b/src/Web/WebSPA/Client/modules/catalog/catalog.service.ts index 672146c9e..8e91ef541 100644 --- a/src/Web/WebSPA/Client/modules/catalog/catalog.service.ts +++ b/src/Web/WebSPA/Client/modules/catalog/catalog.service.ts @@ -21,9 +21,9 @@ export class CatalogService { constructor(private service: DataService, private configurationService: ConfigurationService) { this.configurationService.settingsLoaded$.subscribe(x => { - this.catalogUrl = this.configurationService.serverSettings.purchaseUrl + '/purchase-bff/api/v1/c/catalog/items'; - this.brandUrl = this.configurationService.serverSettings.purchaseUrl + '/purchase-bff/api/v1/c/catalog/catalogbrands'; - this.typesUrl = this.configurationService.serverSettings.purchaseUrl + '/purchase-bff/api/v1/c/catalog/catalogtypes'; + this.catalogUrl = this.configurationService.serverSettings.purchaseUrl + '/shopping/api/v1/c/catalog/items'; + this.brandUrl = this.configurationService.serverSettings.purchaseUrl + '/shopping/api/v1/c/catalog/catalogbrands'; + this.typesUrl = this.configurationService.serverSettings.purchaseUrl + '/shopping/api/v1/c/catalog/catalogtypes'; }); } diff --git a/src/Web/WebSPA/Client/modules/orders/orders.service.ts b/src/Web/WebSPA/Client/modules/orders/orders.service.ts index 8d96602a1..9eabeb1cf 100644 --- a/src/Web/WebSPA/Client/modules/orders/orders.service.ts +++ b/src/Web/WebSPA/Client/modules/orders/orders.service.ts @@ -29,7 +29,7 @@ export class OrdersService { } getOrders(): Observable { - let url = this.ordersUrl + '/purchase-bff/api/v1/o/orders'; + let url = this.ordersUrl + '/shopping/api/v1/o/orders'; return this.service.get(url).map((response: Response) => { return response.json(); @@ -37,7 +37,7 @@ export class OrdersService { } getOrder(id: number): Observable { - let url = this.ordersUrl + '/purchase-bff/api/v1/o/orders/' + id; + let url = this.ordersUrl + '/shopping/api/v1/o/orders/' + id; return this.service.get(url).map((response: Response) => { return response.json(); diff --git a/src/Web/WebSPA/Client/modules/shared/services/security.service.ts b/src/Web/WebSPA/Client/modules/shared/services/security.service.ts index 2b580b5cd..c2ac8e5e2 100644 --- a/src/Web/WebSPA/Client/modules/shared/services/security.service.ts +++ b/src/Web/WebSPA/Client/modules/shared/services/security.service.ts @@ -82,7 +82,7 @@ export class SecurityService { let client_id = 'js'; let redirect_uri = location.origin + '/'; let response_type = 'id_token token'; - let scope = 'openid profile orders basket marketing locations purchasebff'; + let scope = 'openid profile orders basket marketing locations mobileshoppingagg'; let nonce = 'N' + Math.random() + '' + Date.now(); let state = Date.now() + '' + Math.random(); diff --git a/src/Web/WebSPA/Properties/launchSettings.json b/src/Web/WebSPA/Properties/launchSettings.json index bf0fc44d4..eff752f63 100644 --- a/src/Web/WebSPA/Properties/launchSettings.json +++ b/src/Web/WebSPA/Properties/launchSettings.json @@ -3,7 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:64923/", + "applicationUrl": "http://localhost:58018/", "sslPort": 0 } }, From 3b2c80e6d34d1969af480d99764c70e400f91015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduard=20Tom=C3=A0s?= Date: Thu, 15 Feb 2018 18:13:14 +0100 Subject: [PATCH 22/45] Ocelot config via volumes --- .gitattributes | 12 ++ docker-compose.override.yml | 32 +++- docker-compose.yml | 20 ++- eShopOnContainers-ServicesAndWebApps.sln | 15 ++ .../mobilemarketingapigw/configuration.json | 1 + .../mobileshoppingapigw/configuration.json | 1 + .../webmarketingapigw/configuration.json | 1 + .../webshoppingapigw}/configuration.json | 0 .../mobilemarketingapigw/configuration.json | 1 + .../mobileshoppingapigw/configuration.json | 1 + .../webmarketingapigw/configuration.json | 1 + .../webshoppingapigw/configuration.json | 142 ++++++++++++++++++ 12 files changed, 225 insertions(+), 2 deletions(-) create mode 100644 src/Apigw/configs/linux/mobilemarketingapigw/configuration.json create mode 100644 src/Apigw/configs/linux/mobileshoppingapigw/configuration.json create mode 100644 src/Apigw/configs/linux/webmarketingapigw/configuration.json rename src/Apigw/{OcelotApiGw/configuration => configs/linux/webshoppingapigw}/configuration.json (100%) create mode 100644 src/Apigw/configs/windows/mobilemarketingapigw/configuration.json create mode 100644 src/Apigw/configs/windows/mobileshoppingapigw/configuration.json create mode 100644 src/Apigw/configs/windows/webmarketingapigw/configuration.json create mode 100644 src/Apigw/configs/windows/webshoppingapigw/configuration.json diff --git a/.gitattributes b/.gitattributes index f2943e52e..1afa507c8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -69,3 +69,15 @@ ############################################################################### *.pfx binary +################################################################################ +# Ocelot config files are shared via volumes, so its EOL are important +################################################################################ +/src/Apigw/configs/linux/mobilemarketingapigw/configuration.json text eol=lf +/src/Apigw/configs/linux/mobileshoppingapigw/configuration.json text eol=lf +/src/Apigw/configs/linux/webmarketingapigw/configuration.json text eol=lf +/src/Apigw/configs/linux/webshoppingapigw/configuration.json text eol=lf + +/src/Apigw/configs/windows/mobilemarketingapigw/configuration.json text eol=crlf +/src/Apigw/configs/windows/mobileshoppingapigw/configuration.json text eol=crlf +/src/Apigw/configs/windows/webmarketingapigw/configuration.json text eol=crlf +/src/Apigw/configs/windows/webshoppingapigw/configuration.json text eol=crlf \ No newline at end of file diff --git a/docker-compose.override.yml b/docker-compose.override.yml index b6347824f..152d2ec0e 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -218,12 +218,42 @@ services: - "15672:15672" - "5672:5672" - apigw: + mobileshoppingapigw: environment: - ASPNETCORE_ENVIRONMENT=Development - identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. ports: - "5200:80" + volumes: + - ./src/Apigw/configs/mobileshoppingapigw:/app/configuration + + mobilemarketingapigw: + environment: + - ASPNETCORE_ENVIRONMENT=Development + - identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. + ports: + - "5201:80" + volumes: + - ./src/Apigw/configs/mobilemarketingapigw:/app/configuration + + webshoppingapigw: + environment: + - ASPNETCORE_ENVIRONMENT=Development + - identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. + ports: + - "5202:80" + volumes: + - ./src/Apigw/configs/webshoppingapigw:/app/configuration + + + webmarketingapigw: + environment: + - ASPNETCORE_ENVIRONMENT=Development + - identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. + ports: + - "5203:80" + volumes: + - ./src/Apigw/configs/webmarketingapigw:/app/configuration mobileshoppingagg: environment: diff --git a/docker-compose.yml b/docker-compose.yml index 672790166..4b2fb7a1d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -108,7 +108,25 @@ services: rabbitmq: image: rabbitmq:3-management-alpine - apigw: + mobileshoppingapigw: + image: eshop/ocelotapigw + build: + context: . + dockerfile: src/Apigw/OcelotApiGw/Dockerfile + + mobilemarketingapigw: + image: eshop/ocelotapigw + build: + context: . + dockerfile: src/Apigw/OcelotApiGw/Dockerfile + + webshoppingapigw: + image: eshop/ocelotapigw + build: + context: . + dockerfile: src/Apigw/OcelotApiGw/Dockerfile + + webmarketingapigw: image: eshop/ocelotapigw build: context: . diff --git a/eShopOnContainers-ServicesAndWebApps.sln b/eShopOnContainers-ServicesAndWebApps.sln index fc72b85f6..d274f804e 100644 --- a/eShopOnContainers-ServicesAndWebApps.sln +++ b/eShopOnContainers-ServicesAndWebApps.sln @@ -105,6 +105,18 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Aggregators", "Aggregators" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mobile.Shopping.HttpAggregator", "src\Aggregators\Mobile.Shopping.HttpAggregator\Mobile.Shopping.HttpAggregator.csproj", "{6E99F232-1536-424F-A28C-91692C8FD325}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "configs", "configs", "{D8D24753-8421-40EE-8FE5-B8BE06A07AC5}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MobileBff.Shopping.ApiGw", "MobileBff.Shopping.ApiGw", "{DAEA3807-1578-4B43-9033-E400FAF1DC49}" + ProjectSection(SolutionItems) = preProject + src\Apigw\configs\mobileshoppingapigw\configuration.json = src\Apigw\configs\mobileshoppingapigw\configuration.json + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MobileBff.Marketing.ApiGw", "MobileBff.Marketing.ApiGw", "{AC3EDABD-8EB0-4045-BC12-39865490A79D}" + ProjectSection(SolutionItems) = preProject + src\Apigw\configs\mobilemarketingapigw\configuration.json = src\Apigw\configs\mobilemarketingapigw\configuration.json + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Ad-Hoc|Any CPU = Ad-Hoc|Any CPU @@ -1465,6 +1477,9 @@ Global {E0C5162E-DF26-4341-9E51-14AE800D7505} = {7A58AA20-67F3-48F3-88C8-24EBFE621792} {EA378316-9D49-4A6B-858E-D4A25F948A74} = {932D8224-11F6-4D07-B109-DA28AD288A63} {6E99F232-1536-424F-A28C-91692C8FD325} = {EA378316-9D49-4A6B-858E-D4A25F948A74} + {D8D24753-8421-40EE-8FE5-B8BE06A07AC5} = {7A58AA20-67F3-48F3-88C8-24EBFE621792} + {DAEA3807-1578-4B43-9033-E400FAF1DC49} = {D8D24753-8421-40EE-8FE5-B8BE06A07AC5} + {AC3EDABD-8EB0-4045-BC12-39865490A79D} = {D8D24753-8421-40EE-8FE5-B8BE06A07AC5} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {25728519-5F0F-4973-8A64-0A81EB4EA8D9} diff --git a/src/Apigw/configs/linux/mobilemarketingapigw/configuration.json b/src/Apigw/configs/linux/mobilemarketingapigw/configuration.json new file mode 100644 index 000000000..22fdca1b2 --- /dev/null +++ b/src/Apigw/configs/linux/mobilemarketingapigw/configuration.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/src/Apigw/configs/linux/mobileshoppingapigw/configuration.json b/src/Apigw/configs/linux/mobileshoppingapigw/configuration.json new file mode 100644 index 000000000..22fdca1b2 --- /dev/null +++ b/src/Apigw/configs/linux/mobileshoppingapigw/configuration.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/src/Apigw/configs/linux/webmarketingapigw/configuration.json b/src/Apigw/configs/linux/webmarketingapigw/configuration.json new file mode 100644 index 000000000..22fdca1b2 --- /dev/null +++ b/src/Apigw/configs/linux/webmarketingapigw/configuration.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/src/Apigw/OcelotApiGw/configuration/configuration.json b/src/Apigw/configs/linux/webshoppingapigw/configuration.json similarity index 100% rename from src/Apigw/OcelotApiGw/configuration/configuration.json rename to src/Apigw/configs/linux/webshoppingapigw/configuration.json diff --git a/src/Apigw/configs/windows/mobilemarketingapigw/configuration.json b/src/Apigw/configs/windows/mobilemarketingapigw/configuration.json new file mode 100644 index 000000000..22fdca1b2 --- /dev/null +++ b/src/Apigw/configs/windows/mobilemarketingapigw/configuration.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/src/Apigw/configs/windows/mobileshoppingapigw/configuration.json b/src/Apigw/configs/windows/mobileshoppingapigw/configuration.json new file mode 100644 index 000000000..22fdca1b2 --- /dev/null +++ b/src/Apigw/configs/windows/mobileshoppingapigw/configuration.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/src/Apigw/configs/windows/webmarketingapigw/configuration.json b/src/Apigw/configs/windows/webmarketingapigw/configuration.json new file mode 100644 index 000000000..22fdca1b2 --- /dev/null +++ b/src/Apigw/configs/windows/webmarketingapigw/configuration.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/src/Apigw/configs/windows/webshoppingapigw/configuration.json b/src/Apigw/configs/windows/webshoppingapigw/configuration.json new file mode 100644 index 000000000..80d3f1116 --- /dev/null +++ b/src/Apigw/configs/windows/webshoppingapigw/configuration.json @@ -0,0 +1,142 @@ +{ + "ReRoutes": [ + { + "DownstreamPathTemplate": "/api/{version}/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "catalog.api", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/shopping/api/{version}/c/{everything}", + "UpstreamHttpMethod": [ "GET" ] + }, + { + "DownstreamPathTemplate": "/api/{version}/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "basket.api", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/shopping/api/{version}/b/{everything}", + "UpstreamHttpMethod": [], + "AuthenticationOptions": { + "AuthenticationProviderKey": "IdentityApiKey", + "AllowedScopes": [] + } + }, + { + "DownstreamPathTemplate": "/api/{version}/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "ordering.api", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/shopping/api/{version}/o/{everything}", + "UpstreamHttpMethod": [], + "AuthenticationOptions": { + "AuthenticationProviderKey": "IdentityApiKey", + "AllowedScopes": [] + } + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "mobileshoppingagg", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/shopping/{everything}", + "UpstreamHttpMethod": [ "POST", "PUT", "GET" ], + "AuthenticationOptions": { + "AuthenticationProviderKey": "IdentityApiKey", + "AllowedScopes": [] + } + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "ordering.api", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/orders-api/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "basket.api", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/basket-api/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "catalog.api", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/catalog-api/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "marketing.api", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/marketing-api/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "payment.api", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/payment-api/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "locations.api", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/location-api/{everything}", + "UpstreamHttpMethod": [] + } + + ], + "GlobalConfiguration": { + "RequestIdKey": "OcRequestId", + "AdministrationPath": "/administration" + } + } + \ No newline at end of file From 1b87e2a18f15cae958818349a7e9b7b698461e38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduard=20Tom=C3=A0s?= Date: Thu, 15 Feb 2018 18:45:18 +0100 Subject: [PATCH 23/45] Reverted duality of config files for ocelot because were not really needed --- .gitattributes | 12 -- docker-compose.override.yml | 9 +- eShopOnContainers-ServicesAndWebApps.sln | 15 -- .../mobilemarketingapigw/configuration.json | 0 .../mobileshoppingapigw/configuration.json | 0 .../webmarketingapigw/configuration.json | 0 .../webshoppingapigw/configuration.json | 0 .../mobilemarketingapigw/configuration.json | 1 - .../mobileshoppingapigw/configuration.json | 1 - .../webmarketingapigw/configuration.json | 1 - .../webshoppingapigw/configuration.json | 142 ------------------ 11 files changed, 4 insertions(+), 177 deletions(-) rename src/Apigw/configs/{linux => }/mobilemarketingapigw/configuration.json (100%) rename src/Apigw/configs/{linux => }/mobileshoppingapigw/configuration.json (100%) rename src/Apigw/configs/{linux => }/webmarketingapigw/configuration.json (100%) rename src/Apigw/configs/{linux => }/webshoppingapigw/configuration.json (100%) delete mode 100644 src/Apigw/configs/windows/mobilemarketingapigw/configuration.json delete mode 100644 src/Apigw/configs/windows/mobileshoppingapigw/configuration.json delete mode 100644 src/Apigw/configs/windows/webmarketingapigw/configuration.json delete mode 100644 src/Apigw/configs/windows/webshoppingapigw/configuration.json diff --git a/.gitattributes b/.gitattributes index 1afa507c8..f2943e52e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -69,15 +69,3 @@ ############################################################################### *.pfx binary -################################################################################ -# Ocelot config files are shared via volumes, so its EOL are important -################################################################################ -/src/Apigw/configs/linux/mobilemarketingapigw/configuration.json text eol=lf -/src/Apigw/configs/linux/mobileshoppingapigw/configuration.json text eol=lf -/src/Apigw/configs/linux/webmarketingapigw/configuration.json text eol=lf -/src/Apigw/configs/linux/webshoppingapigw/configuration.json text eol=lf - -/src/Apigw/configs/windows/mobilemarketingapigw/configuration.json text eol=crlf -/src/Apigw/configs/windows/mobileshoppingapigw/configuration.json text eol=crlf -/src/Apigw/configs/windows/webmarketingapigw/configuration.json text eol=crlf -/src/Apigw/configs/windows/webshoppingapigw/configuration.json text eol=crlf \ No newline at end of file diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 152d2ec0e..43e2fbcb8 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -221,7 +221,7 @@ services: mobileshoppingapigw: environment: - ASPNETCORE_ENVIRONMENT=Development - - identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. + - IdentityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. ports: - "5200:80" volumes: @@ -230,7 +230,7 @@ services: mobilemarketingapigw: environment: - ASPNETCORE_ENVIRONMENT=Development - - identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. + - IdentityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. ports: - "5201:80" volumes: @@ -239,17 +239,16 @@ services: webshoppingapigw: environment: - ASPNETCORE_ENVIRONMENT=Development - - identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. + - IdentityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. ports: - "5202:80" volumes: - ./src/Apigw/configs/webshoppingapigw:/app/configuration - webmarketingapigw: environment: - ASPNETCORE_ENVIRONMENT=Development - - identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. + - IdentityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. ports: - "5203:80" volumes: diff --git a/eShopOnContainers-ServicesAndWebApps.sln b/eShopOnContainers-ServicesAndWebApps.sln index d274f804e..fc72b85f6 100644 --- a/eShopOnContainers-ServicesAndWebApps.sln +++ b/eShopOnContainers-ServicesAndWebApps.sln @@ -105,18 +105,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Aggregators", "Aggregators" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mobile.Shopping.HttpAggregator", "src\Aggregators\Mobile.Shopping.HttpAggregator\Mobile.Shopping.HttpAggregator.csproj", "{6E99F232-1536-424F-A28C-91692C8FD325}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "configs", "configs", "{D8D24753-8421-40EE-8FE5-B8BE06A07AC5}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MobileBff.Shopping.ApiGw", "MobileBff.Shopping.ApiGw", "{DAEA3807-1578-4B43-9033-E400FAF1DC49}" - ProjectSection(SolutionItems) = preProject - src\Apigw\configs\mobileshoppingapigw\configuration.json = src\Apigw\configs\mobileshoppingapigw\configuration.json - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MobileBff.Marketing.ApiGw", "MobileBff.Marketing.ApiGw", "{AC3EDABD-8EB0-4045-BC12-39865490A79D}" - ProjectSection(SolutionItems) = preProject - src\Apigw\configs\mobilemarketingapigw\configuration.json = src\Apigw\configs\mobilemarketingapigw\configuration.json - EndProjectSection -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Ad-Hoc|Any CPU = Ad-Hoc|Any CPU @@ -1477,9 +1465,6 @@ Global {E0C5162E-DF26-4341-9E51-14AE800D7505} = {7A58AA20-67F3-48F3-88C8-24EBFE621792} {EA378316-9D49-4A6B-858E-D4A25F948A74} = {932D8224-11F6-4D07-B109-DA28AD288A63} {6E99F232-1536-424F-A28C-91692C8FD325} = {EA378316-9D49-4A6B-858E-D4A25F948A74} - {D8D24753-8421-40EE-8FE5-B8BE06A07AC5} = {7A58AA20-67F3-48F3-88C8-24EBFE621792} - {DAEA3807-1578-4B43-9033-E400FAF1DC49} = {D8D24753-8421-40EE-8FE5-B8BE06A07AC5} - {AC3EDABD-8EB0-4045-BC12-39865490A79D} = {D8D24753-8421-40EE-8FE5-B8BE06A07AC5} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {25728519-5F0F-4973-8A64-0A81EB4EA8D9} diff --git a/src/Apigw/configs/linux/mobilemarketingapigw/configuration.json b/src/Apigw/configs/mobilemarketingapigw/configuration.json similarity index 100% rename from src/Apigw/configs/linux/mobilemarketingapigw/configuration.json rename to src/Apigw/configs/mobilemarketingapigw/configuration.json diff --git a/src/Apigw/configs/linux/mobileshoppingapigw/configuration.json b/src/Apigw/configs/mobileshoppingapigw/configuration.json similarity index 100% rename from src/Apigw/configs/linux/mobileshoppingapigw/configuration.json rename to src/Apigw/configs/mobileshoppingapigw/configuration.json diff --git a/src/Apigw/configs/linux/webmarketingapigw/configuration.json b/src/Apigw/configs/webmarketingapigw/configuration.json similarity index 100% rename from src/Apigw/configs/linux/webmarketingapigw/configuration.json rename to src/Apigw/configs/webmarketingapigw/configuration.json diff --git a/src/Apigw/configs/linux/webshoppingapigw/configuration.json b/src/Apigw/configs/webshoppingapigw/configuration.json similarity index 100% rename from src/Apigw/configs/linux/webshoppingapigw/configuration.json rename to src/Apigw/configs/webshoppingapigw/configuration.json diff --git a/src/Apigw/configs/windows/mobilemarketingapigw/configuration.json b/src/Apigw/configs/windows/mobilemarketingapigw/configuration.json deleted file mode 100644 index 22fdca1b2..000000000 --- a/src/Apigw/configs/windows/mobilemarketingapigw/configuration.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/src/Apigw/configs/windows/mobileshoppingapigw/configuration.json b/src/Apigw/configs/windows/mobileshoppingapigw/configuration.json deleted file mode 100644 index 22fdca1b2..000000000 --- a/src/Apigw/configs/windows/mobileshoppingapigw/configuration.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/src/Apigw/configs/windows/webmarketingapigw/configuration.json b/src/Apigw/configs/windows/webmarketingapigw/configuration.json deleted file mode 100644 index 22fdca1b2..000000000 --- a/src/Apigw/configs/windows/webmarketingapigw/configuration.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/src/Apigw/configs/windows/webshoppingapigw/configuration.json b/src/Apigw/configs/windows/webshoppingapigw/configuration.json deleted file mode 100644 index 80d3f1116..000000000 --- a/src/Apigw/configs/windows/webshoppingapigw/configuration.json +++ /dev/null @@ -1,142 +0,0 @@ -{ - "ReRoutes": [ - { - "DownstreamPathTemplate": "/api/{version}/{everything}", - "DownstreamScheme": "http", - "DownstreamHostAndPorts": [ - { - "Host": "catalog.api", - "Port": 80 - } - ], - "UpstreamPathTemplate": "/shopping/api/{version}/c/{everything}", - "UpstreamHttpMethod": [ "GET" ] - }, - { - "DownstreamPathTemplate": "/api/{version}/{everything}", - "DownstreamScheme": "http", - "DownstreamHostAndPorts": [ - { - "Host": "basket.api", - "Port": 80 - } - ], - "UpstreamPathTemplate": "/shopping/api/{version}/b/{everything}", - "UpstreamHttpMethod": [], - "AuthenticationOptions": { - "AuthenticationProviderKey": "IdentityApiKey", - "AllowedScopes": [] - } - }, - { - "DownstreamPathTemplate": "/api/{version}/{everything}", - "DownstreamScheme": "http", - "DownstreamHostAndPorts": [ - { - "Host": "ordering.api", - "Port": 80 - } - ], - "UpstreamPathTemplate": "/shopping/api/{version}/o/{everything}", - "UpstreamHttpMethod": [], - "AuthenticationOptions": { - "AuthenticationProviderKey": "IdentityApiKey", - "AllowedScopes": [] - } - }, - { - "DownstreamPathTemplate": "/{everything}", - "DownstreamScheme": "http", - "DownstreamHostAndPorts": [ - { - "Host": "mobileshoppingagg", - "Port": 80 - } - ], - "UpstreamPathTemplate": "/shopping/{everything}", - "UpstreamHttpMethod": [ "POST", "PUT", "GET" ], - "AuthenticationOptions": { - "AuthenticationProviderKey": "IdentityApiKey", - "AllowedScopes": [] - } - }, - { - "DownstreamPathTemplate": "/{everything}", - "DownstreamScheme": "http", - "DownstreamHostAndPorts": [ - { - "Host": "ordering.api", - "Port": 80 - } - ], - "UpstreamPathTemplate": "/orders-api/{everything}", - "UpstreamHttpMethod": [] - }, - { - "DownstreamPathTemplate": "/{everything}", - "DownstreamScheme": "http", - "DownstreamHostAndPorts": [ - { - "Host": "basket.api", - "Port": 80 - } - ], - "UpstreamPathTemplate": "/basket-api/{everything}", - "UpstreamHttpMethod": [] - }, - { - "DownstreamPathTemplate": "/{everything}", - "DownstreamScheme": "http", - "DownstreamHostAndPorts": [ - { - "Host": "catalog.api", - "Port": 80 - } - ], - "UpstreamPathTemplate": "/catalog-api/{everything}", - "UpstreamHttpMethod": [] - }, - { - "DownstreamPathTemplate": "/{everything}", - "DownstreamScheme": "http", - "DownstreamHostAndPorts": [ - { - "Host": "marketing.api", - "Port": 80 - } - ], - "UpstreamPathTemplate": "/marketing-api/{everything}", - "UpstreamHttpMethod": [] - }, - { - "DownstreamPathTemplate": "/{everything}", - "DownstreamScheme": "http", - "DownstreamHostAndPorts": [ - { - "Host": "payment.api", - "Port": 80 - } - ], - "UpstreamPathTemplate": "/payment-api/{everything}", - "UpstreamHttpMethod": [] - }, - { - "DownstreamPathTemplate": "/{everything}", - "DownstreamScheme": "http", - "DownstreamHostAndPorts": [ - { - "Host": "locations.api", - "Port": 80 - } - ], - "UpstreamPathTemplate": "/location-api/{everything}", - "UpstreamHttpMethod": [] - } - - ], - "GlobalConfiguration": { - "RequestIdKey": "OcRequestId", - "AdministrationPath": "/administration" - } - } - \ No newline at end of file From 8cfb74fe9335591a8ba08bf7afe184b79a985751 Mon Sep 17 00:00:00 2001 From: eiximenis Date: Tue, 27 Feb 2018 13:10:39 +0100 Subject: [PATCH 24/45] Fixing SPA for using aggregators --- docker-compose.override.yml | 57 +- docker-compose.prod.yml | 11 +- docker-compose.yml | 38 +- src/Apigw/OcelotApiGw/Dockerfile2 | 19 + src/Apigw/OcelotApiGw/Dockerfile3 | 19 + src/Apigw/OcelotApiGw/Dockerfile4 | 19 + .../webshoppingapigw/configuration.json | 8 +- .../Client/modules/basket/basket.service.ts | 6 +- .../Client/modules/catalog/catalog.service.ts | 6 +- .../Client/modules/orders/orders.service.ts | 4 +- src/Web/WebSPA/package-lock.json | 905 ++++++++++++++++++ 11 files changed, 1026 insertions(+), 66 deletions(-) create mode 100644 src/Apigw/OcelotApiGw/Dockerfile2 create mode 100644 src/Apigw/OcelotApiGw/Dockerfile3 create mode 100644 src/Apigw/OcelotApiGw/Dockerfile4 diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 43e2fbcb8..c3dbd0027 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -115,7 +115,7 @@ services: - IdentityUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105 #Local: You need to open your local dev-machine firewall at range 5100-5105. at range 5100-5105. - MarketingUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5110 - LocationsUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5109 - - PurchaseUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5200 + - PurchaseUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5202 - CatalogUrlHC=http://catalog.api/hc - OrderingUrlHC=http://ordering.api/hc - IdentityUrlHC=http://identity.api/hc #Local: Use ${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}, if using external IP or DNS name from browser. @@ -132,7 +132,7 @@ services: environment: - ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_URLS=http://0.0.0.0:80 - - PurchaseUrl=http://apigw/shopping + - PurchaseUrl=http://webshoppingapigw - LocationsUrl=http://locations.api - IdentityUrl=http://10.0.75.1:5105 # Local Mac: Use http://docker.for.mac.localhost:5105 || Local Windows: Use 10.0.75.1 in a "Docker for Windows" environment, if using "localhost" from browser. || #Remote access: Use ${ESHOP_EXTERNAL_DNS_NAME_OR_IP} if using external IP or DNS name from browser. - MarketingUrl=http://marketing.api @@ -218,23 +218,23 @@ services: - "15672:15672" - "5672:5672" - mobileshoppingapigw: - environment: - - ASPNETCORE_ENVIRONMENT=Development - - IdentityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. - ports: - - "5200:80" - volumes: - - ./src/Apigw/configs/mobileshoppingapigw:/app/configuration - - mobilemarketingapigw: - environment: - - ASPNETCORE_ENVIRONMENT=Development - - IdentityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. - ports: - - "5201:80" - volumes: - - ./src/Apigw/configs/mobilemarketingapigw:/app/configuration +# mobileshoppingapigw: +# environment: +# - ASPNETCORE_ENVIRONMENT=Development +# - IdentityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. +# ports: +# - "5200:80" +# volumes: +# - ./src/Apigw/configs/mobileshoppingapigw:/app/configuration +# +# mobilemarketingapigw: +# environment: +# - ASPNETCORE_ENVIRONMENT=Development +# - IdentityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. +# ports: +# - "5201:80" +# volumes: +# - ./src/Apigw/configs/mobilemarketingapigw:/app/configuration webshoppingapigw: environment: @@ -245,14 +245,14 @@ services: volumes: - ./src/Apigw/configs/webshoppingapigw:/app/configuration - webmarketingapigw: - environment: - - ASPNETCORE_ENVIRONMENT=Development - - IdentityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. - ports: - - "5203:80" - volumes: - - ./src/Apigw/configs/webmarketingapigw:/app/configuration +# webmarketingapigw: +# environment: +# - ASPNETCORE_ENVIRONMENT=Development +# - IdentityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. +# ports: +# - "5203:80" +# volumes: +# - ./src/Apigw/configs/webmarketingapigw:/app/configuration mobileshoppingagg: environment: @@ -262,5 +262,4 @@ services: - urls__orders=http://ordering.api - urls__identity=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. ports: - - "5120:80" - + - "5120:80" \ No newline at end of file diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 68e02e4da..81deef911 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -139,17 +139,16 @@ services: webmvc: environment: + - ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_URLS=http://0.0.0.0:80 - - CatalogUrl=http://catalog.api - - OrderingUrl=http://ordering.api - - BasketUrl=http://basket.api + - PurchaseUrl=http://webshoppingapigw/shopping - LocationsUrl=http://locations.api - - IdentityUrl=http://${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}:5105 #Local: Use 10.0.75.1 in a "Docker for Windows" environment, if using "localhost" from browser. #Remote: Use ${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP} if using external IP or DNS name from browser. - - MarketingUrl=http://marketing.api + - IdentityUrl=http://${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}:5105 # Local Mac: Use http://docker.for.mac.localhost:5105 || Local Windows: Use 10.0.75.1 in a "Docker for Windows" environment, if using "localhost" from browser. || #Remote access: Use ${ESHOP_EXTERNAL_DNS_NAME_OR_IP} if using external IP or DNS name from browser. + - MarketingUrl=http://marketing.api - CatalogUrlHC=http://catalog.api/hc - OrderingUrlHC=http://ordering.api/hc - - IdentityUrlHC=http://identity.api/hc + - IdentityUrlHC=http://identity.api/hc #Local: Use ${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}, if using external IP or DNS name from browser. - BasketUrlHC=http://basket.api/hc - MarketingUrlHC=http://marketing.api/hc - PaymentUrlHC=http://payment.api/hc diff --git a/docker-compose.yml b/docker-compose.yml index 4b2fb7a1d..703dbfee9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -108,29 +108,29 @@ services: rabbitmq: image: rabbitmq:3-management-alpine - mobileshoppingapigw: - image: eshop/ocelotapigw - build: - context: . - dockerfile: src/Apigw/OcelotApiGw/Dockerfile - - mobilemarketingapigw: - image: eshop/ocelotapigw - build: - context: . - dockerfile: src/Apigw/OcelotApiGw/Dockerfile - +# mobileshoppingapigw: +# image: eshop/ocelotapigw-ms +# build: +# context: . +# dockerfile: src/Apigw/OcelotApiGw/Dockerfile +# +# mobilemarketingapigw: +# image: eshop/ocelotapigw-mm +# build: +# context: . +# dockerfile: src/Apigw/OcelotApiGw/Dockerfile2 +# webshoppingapigw: - image: eshop/ocelotapigw + image: eshop/ocelotapigw-ws build: context: . - dockerfile: src/Apigw/OcelotApiGw/Dockerfile + dockerfile: src/Apigw/OcelotApiGw/Dockerfile3 - webmarketingapigw: - image: eshop/ocelotapigw - build: - context: . - dockerfile: src/Apigw/OcelotApiGw/Dockerfile +# webmarketingapigw: +# image: eshop/ocelotapigw-wm +# build: +# context: . +# dockerfile: src/Apigw/OcelotApiGw/Dockerfile4 mobileshoppingagg: image: eshop/mobileshoppingagg diff --git a/src/Apigw/OcelotApiGw/Dockerfile2 b/src/Apigw/OcelotApiGw/Dockerfile2 new file mode 100644 index 000000000..aec2dc4e3 --- /dev/null +++ b/src/Apigw/OcelotApiGw/Dockerfile2 @@ -0,0 +1,19 @@ +FROM microsoft/aspnetcore:2.0 AS base +WORKDIR /app +EXPOSE 80 + +FROM microsoft/aspnetcore-build:2.0 AS build +WORKDIR /src +COPY src/Apigw/OcelotApiGw/OcelotApiGw.csproj src/Apigw/OcelotApiGw/ +RUN dotnet restore src/Apigw/OcelotApiGw/ +COPY . . +WORKDIR /src/src/Apigw/OcelotApiGw +RUN dotnet build -c Release -o /app + +FROM build AS publish +RUN dotnet publish -c Release -o /app + +FROM base AS final +WORKDIR /app +COPY --from=publish /app . +ENTRYPOINT ["dotnet", "OcelotApiGw.dll"] diff --git a/src/Apigw/OcelotApiGw/Dockerfile3 b/src/Apigw/OcelotApiGw/Dockerfile3 new file mode 100644 index 000000000..aec2dc4e3 --- /dev/null +++ b/src/Apigw/OcelotApiGw/Dockerfile3 @@ -0,0 +1,19 @@ +FROM microsoft/aspnetcore:2.0 AS base +WORKDIR /app +EXPOSE 80 + +FROM microsoft/aspnetcore-build:2.0 AS build +WORKDIR /src +COPY src/Apigw/OcelotApiGw/OcelotApiGw.csproj src/Apigw/OcelotApiGw/ +RUN dotnet restore src/Apigw/OcelotApiGw/ +COPY . . +WORKDIR /src/src/Apigw/OcelotApiGw +RUN dotnet build -c Release -o /app + +FROM build AS publish +RUN dotnet publish -c Release -o /app + +FROM base AS final +WORKDIR /app +COPY --from=publish /app . +ENTRYPOINT ["dotnet", "OcelotApiGw.dll"] diff --git a/src/Apigw/OcelotApiGw/Dockerfile4 b/src/Apigw/OcelotApiGw/Dockerfile4 new file mode 100644 index 000000000..aec2dc4e3 --- /dev/null +++ b/src/Apigw/OcelotApiGw/Dockerfile4 @@ -0,0 +1,19 @@ +FROM microsoft/aspnetcore:2.0 AS base +WORKDIR /app +EXPOSE 80 + +FROM microsoft/aspnetcore-build:2.0 AS build +WORKDIR /src +COPY src/Apigw/OcelotApiGw/OcelotApiGw.csproj src/Apigw/OcelotApiGw/ +RUN dotnet restore src/Apigw/OcelotApiGw/ +COPY . . +WORKDIR /src/src/Apigw/OcelotApiGw +RUN dotnet build -c Release -o /app + +FROM build AS publish +RUN dotnet publish -c Release -o /app + +FROM base AS final +WORKDIR /app +COPY --from=publish /app . +ENTRYPOINT ["dotnet", "OcelotApiGw.dll"] diff --git a/src/Apigw/configs/webshoppingapigw/configuration.json b/src/Apigw/configs/webshoppingapigw/configuration.json index 80d3f1116..801eac5d9 100644 --- a/src/Apigw/configs/webshoppingapigw/configuration.json +++ b/src/Apigw/configs/webshoppingapigw/configuration.json @@ -9,7 +9,7 @@ "Port": 80 } ], - "UpstreamPathTemplate": "/shopping/api/{version}/c/{everything}", + "UpstreamPathTemplate": "/api/{version}/c/{everything}", "UpstreamHttpMethod": [ "GET" ] }, { @@ -21,7 +21,7 @@ "Port": 80 } ], - "UpstreamPathTemplate": "/shopping/api/{version}/b/{everything}", + "UpstreamPathTemplate": "/api/{version}/b/{everything}", "UpstreamHttpMethod": [], "AuthenticationOptions": { "AuthenticationProviderKey": "IdentityApiKey", @@ -37,7 +37,7 @@ "Port": 80 } ], - "UpstreamPathTemplate": "/shopping/api/{version}/o/{everything}", + "UpstreamPathTemplate": "/api/{version}/o/{everything}", "UpstreamHttpMethod": [], "AuthenticationOptions": { "AuthenticationProviderKey": "IdentityApiKey", @@ -53,7 +53,7 @@ "Port": 80 } ], - "UpstreamPathTemplate": "/shopping/{everything}", + "UpstreamPathTemplate": "/{everything}", "UpstreamHttpMethod": [ "POST", "PUT", "GET" ], "AuthenticationOptions": { "AuthenticationProviderKey": "IdentityApiKey", diff --git a/src/Web/WebSPA/Client/modules/basket/basket.service.ts b/src/Web/WebSPA/Client/modules/basket/basket.service.ts index f26cbc2cb..fef74974e 100644 --- a/src/Web/WebSPA/Client/modules/basket/basket.service.ts +++ b/src/Web/WebSPA/Client/modules/basket/basket.service.ts @@ -66,7 +66,7 @@ export class BasketService { } setBasket(basket): Observable { - let url = this.purchaseUrl + '/shopping/api/v1/basket/'; + let url = this.purchaseUrl + '/api/v1/basket/'; this.basket = basket; return this.service.post(url, basket).map((response: Response) => { return true; @@ -74,7 +74,7 @@ export class BasketService { } setBasketCheckout(basketCheckout): Observable { - let url = this.basketUrl + '/shopping/api/v1/b/basket/checkout'; + let url = this.basketUrl + '/api/v1/b/basket/checkout'; return this.service.postWithId(url, basketCheckout).map((response: Response) => { this.basketEvents.orderCreated(); return true; @@ -82,7 +82,7 @@ export class BasketService { } getBasket(): Observable { - let url = this.basketUrl + '/shopping/api/v1/b/basket/' + this.basket.buyerId; + let url = this.basketUrl + '/api/v1/b/basket/' + this.basket.buyerId; return this.service.get(url).map((response: Response) => { if (response.status === 204) { return null; diff --git a/src/Web/WebSPA/Client/modules/catalog/catalog.service.ts b/src/Web/WebSPA/Client/modules/catalog/catalog.service.ts index 8e91ef541..fc5bc4c5e 100644 --- a/src/Web/WebSPA/Client/modules/catalog/catalog.service.ts +++ b/src/Web/WebSPA/Client/modules/catalog/catalog.service.ts @@ -21,9 +21,9 @@ export class CatalogService { constructor(private service: DataService, private configurationService: ConfigurationService) { this.configurationService.settingsLoaded$.subscribe(x => { - this.catalogUrl = this.configurationService.serverSettings.purchaseUrl + '/shopping/api/v1/c/catalog/items'; - this.brandUrl = this.configurationService.serverSettings.purchaseUrl + '/shopping/api/v1/c/catalog/catalogbrands'; - this.typesUrl = this.configurationService.serverSettings.purchaseUrl + '/shopping/api/v1/c/catalog/catalogtypes'; + this.catalogUrl = this.configurationService.serverSettings.purchaseUrl + '/api/v1/c/catalog/items'; + this.brandUrl = this.configurationService.serverSettings.purchaseUrl + '/api/v1/c/catalog/catalogbrands'; + this.typesUrl = this.configurationService.serverSettings.purchaseUrl + '/api/v1/c/catalog/catalogtypes'; }); } diff --git a/src/Web/WebSPA/Client/modules/orders/orders.service.ts b/src/Web/WebSPA/Client/modules/orders/orders.service.ts index 9eabeb1cf..5c563f836 100644 --- a/src/Web/WebSPA/Client/modules/orders/orders.service.ts +++ b/src/Web/WebSPA/Client/modules/orders/orders.service.ts @@ -29,7 +29,7 @@ export class OrdersService { } getOrders(): Observable { - let url = this.ordersUrl + '/shopping/api/v1/o/orders'; + let url = this.ordersUrl + '/api/v1/o/orders'; return this.service.get(url).map((response: Response) => { return response.json(); @@ -37,7 +37,7 @@ export class OrdersService { } getOrder(id: number): Observable { - let url = this.ordersUrl + '/shopping/api/v1/o/orders/' + id; + let url = this.ordersUrl + '/api/v1/o/orders/' + id; return this.service.get(url).map((response: Response) => { return response.json(); diff --git a/src/Web/WebSPA/package-lock.json b/src/Web/WebSPA/package-lock.json index 313a88257..550b77da7 100644 --- a/src/Web/WebSPA/package-lock.json +++ b/src/Web/WebSPA/package-lock.json @@ -1176,6 +1176,7 @@ "requires": { "anymatch": "1.3.2", "async-each": "1.0.1", + "fsevents": "1.1.3", "glob-parent": "2.0.0", "inherits": "2.0.3", "is-binary-path": "1.0.1", @@ -2806,6 +2807,910 @@ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, + "fsevents": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.1.3.tgz", + "integrity": "sha512-WIr7iDkdmdbxu/Gh6eKEZJL6KPE74/5MEsf2whTOFNxbIoIixogroLdKYqB6FDav4Wavh/lZdzzd3b2KxIXC5Q==", + "dev": true, + "optional": true, + "requires": { + "nan": "2.6.2", + "node-pre-gyp": "0.6.39" + }, + "dependencies": { + "abbrev": { + "version": "1.1.0", + "bundled": true, + "dev": true, + "optional": true + }, + "ajv": { + "version": "4.11.8", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "co": "4.6.0", + "json-stable-stringify": "1.0.1" + } + }, + "ansi-regex": { + "version": "2.1.1", + "bundled": true, + "dev": true + }, + "aproba": { + "version": "1.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "are-we-there-yet": { + "version": "1.1.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "delegates": "1.0.0", + "readable-stream": "2.2.9" + } + }, + "asn1": { + "version": "0.2.3", + "bundled": true, + "dev": true, + "optional": true + }, + "assert-plus": { + "version": "0.2.0", + "bundled": true, + "dev": true, + "optional": true + }, + "asynckit": { + "version": "0.4.0", + "bundled": true, + "dev": true, + "optional": true + }, + "aws-sign2": { + "version": "0.6.0", + "bundled": true, + "dev": true, + "optional": true + }, + "aws4": { + "version": "1.6.0", + "bundled": true, + "dev": true, + "optional": true + }, + "balanced-match": { + "version": "0.4.2", + "bundled": true, + "dev": true + }, + "bcrypt-pbkdf": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "tweetnacl": "0.14.5" + } + }, + "block-stream": { + "version": "0.0.9", + "bundled": true, + "dev": true, + "requires": { + "inherits": "2.0.3" + } + }, + "boom": { + "version": "2.10.1", + "bundled": true, + "dev": true, + "requires": { + "hoek": "2.16.3" + } + }, + "brace-expansion": { + "version": "1.1.7", + "bundled": true, + "dev": true, + "requires": { + "balanced-match": "0.4.2", + "concat-map": "0.0.1" + } + }, + "buffer-shims": { + "version": "1.0.0", + "bundled": true, + "dev": true + }, + "caseless": { + "version": "0.12.0", + "bundled": true, + "dev": true, + "optional": true + }, + "co": { + "version": "4.6.0", + "bundled": true, + "dev": true, + "optional": true + }, + "code-point-at": { + "version": "1.1.0", + "bundled": true, + "dev": true + }, + "combined-stream": { + "version": "1.0.5", + "bundled": true, + "dev": true, + "requires": { + "delayed-stream": "1.0.0" + } + }, + "concat-map": { + "version": "0.0.1", + "bundled": true, + "dev": true + }, + "console-control-strings": { + "version": "1.1.0", + "bundled": true, + "dev": true + }, + "core-util-is": { + "version": "1.0.2", + "bundled": true, + "dev": true + }, + "cryptiles": { + "version": "2.0.5", + "bundled": true, + "dev": true, + "requires": { + "boom": "2.10.1" + } + }, + "dashdash": { + "version": "1.14.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "assert-plus": "1.0.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "debug": { + "version": "2.6.8", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "ms": "2.0.0" + } + }, + "deep-extend": { + "version": "0.4.2", + "bundled": true, + "dev": true, + "optional": true + }, + "delayed-stream": { + "version": "1.0.0", + "bundled": true, + "dev": true + }, + "delegates": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "detect-libc": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "ecc-jsbn": { + "version": "0.1.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "jsbn": "0.1.1" + } + }, + "extend": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "extsprintf": { + "version": "1.0.2", + "bundled": true, + "dev": true + }, + "forever-agent": { + "version": "0.6.1", + "bundled": true, + "dev": true, + "optional": true + }, + "form-data": { + "version": "2.1.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "asynckit": "0.4.0", + "combined-stream": "1.0.5", + "mime-types": "2.1.15" + } + }, + "fs.realpath": { + "version": "1.0.0", + "bundled": true, + "dev": true + }, + "fstream": { + "version": "1.0.11", + "bundled": true, + "dev": true, + "requires": { + "graceful-fs": "4.1.11", + "inherits": "2.0.3", + "mkdirp": "0.5.1", + "rimraf": "2.6.1" + } + }, + "fstream-ignore": { + "version": "1.0.5", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "fstream": "1.0.11", + "inherits": "2.0.3", + "minimatch": "3.0.4" + } + }, + "gauge": { + "version": "2.7.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "aproba": "1.1.1", + "console-control-strings": "1.1.0", + "has-unicode": "2.0.1", + "object-assign": "4.1.1", + "signal-exit": "3.0.2", + "string-width": "1.0.2", + "strip-ansi": "3.0.1", + "wide-align": "1.1.2" + } + }, + "getpass": { + "version": "0.1.7", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "assert-plus": "1.0.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "glob": { + "version": "7.1.2", + "bundled": true, + "dev": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + }, + "graceful-fs": { + "version": "4.1.11", + "bundled": true, + "dev": true + }, + "har-schema": { + "version": "1.0.5", + "bundled": true, + "dev": true, + "optional": true + }, + "har-validator": { + "version": "4.2.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "ajv": "4.11.8", + "har-schema": "1.0.5" + } + }, + "has-unicode": { + "version": "2.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "hawk": { + "version": "3.1.3", + "bundled": true, + "dev": true, + "requires": { + "boom": "2.10.1", + "cryptiles": "2.0.5", + "hoek": "2.16.3", + "sntp": "1.0.9" + } + }, + "hoek": { + "version": "2.16.3", + "bundled": true, + "dev": true + }, + "http-signature": { + "version": "1.1.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "assert-plus": "0.2.0", + "jsprim": "1.4.0", + "sshpk": "1.13.0" + } + }, + "inflight": { + "version": "1.0.6", + "bundled": true, + "dev": true, + "requires": { + "once": "1.4.0", + "wrappy": "1.0.2" + } + }, + "inherits": { + "version": "2.0.3", + "bundled": true, + "dev": true + }, + "ini": { + "version": "1.3.4", + "bundled": true, + "dev": true, + "optional": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "requires": { + "number-is-nan": "1.0.1" + } + }, + "is-typedarray": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "isarray": { + "version": "1.0.0", + "bundled": true, + "dev": true + }, + "isstream": { + "version": "0.1.2", + "bundled": true, + "dev": true, + "optional": true + }, + "jodid25519": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "jsbn": "0.1.1" + } + }, + "jsbn": { + "version": "0.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "json-schema": { + "version": "0.2.3", + "bundled": true, + "dev": true, + "optional": true + }, + "json-stable-stringify": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "jsonify": "0.0.0" + } + }, + "json-stringify-safe": { + "version": "5.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "jsonify": { + "version": "0.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "jsprim": { + "version": "1.4.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.0.2", + "json-schema": "0.2.3", + "verror": "1.3.6" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "mime-db": { + "version": "1.27.0", + "bundled": true, + "dev": true + }, + "mime-types": { + "version": "2.1.15", + "bundled": true, + "dev": true, + "requires": { + "mime-db": "1.27.0" + } + }, + "minimatch": { + "version": "3.0.4", + "bundled": true, + "dev": true, + "requires": { + "brace-expansion": "1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "bundled": true, + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "bundled": true, + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, + "ms": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "node-pre-gyp": { + "version": "0.6.39", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "detect-libc": "1.0.2", + "hawk": "3.1.3", + "mkdirp": "0.5.1", + "nopt": "4.0.1", + "npmlog": "4.1.0", + "rc": "1.2.1", + "request": "2.81.0", + "rimraf": "2.6.1", + "semver": "5.3.0", + "tar": "2.2.1", + "tar-pack": "3.4.0" + } + }, + "nopt": { + "version": "4.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "abbrev": "1.1.0", + "osenv": "0.1.4" + } + }, + "npmlog": { + "version": "4.1.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "are-we-there-yet": "1.1.4", + "console-control-strings": "1.1.0", + "gauge": "2.7.4", + "set-blocking": "2.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "bundled": true, + "dev": true + }, + "oauth-sign": { + "version": "0.8.2", + "bundled": true, + "dev": true, + "optional": true + }, + "object-assign": { + "version": "4.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "once": { + "version": "1.4.0", + "bundled": true, + "dev": true, + "requires": { + "wrappy": "1.0.2" + } + }, + "os-homedir": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "os-tmpdir": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "osenv": { + "version": "0.1.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "os-homedir": "1.0.2", + "os-tmpdir": "1.0.2" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "bundled": true, + "dev": true + }, + "performance-now": { + "version": "0.2.0", + "bundled": true, + "dev": true, + "optional": true + }, + "process-nextick-args": { + "version": "1.0.7", + "bundled": true, + "dev": true + }, + "punycode": { + "version": "1.4.1", + "bundled": true, + "dev": true, + "optional": true + }, + "qs": { + "version": "6.4.0", + "bundled": true, + "dev": true, + "optional": true + }, + "rc": { + "version": "1.2.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "deep-extend": "0.4.2", + "ini": "1.3.4", + "minimist": "1.2.0", + "strip-json-comments": "2.0.1" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "readable-stream": { + "version": "2.2.9", + "bundled": true, + "dev": true, + "requires": { + "buffer-shims": "1.0.0", + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "string_decoder": "1.0.1", + "util-deprecate": "1.0.2" + } + }, + "request": { + "version": "2.81.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "aws-sign2": "0.6.0", + "aws4": "1.6.0", + "caseless": "0.12.0", + "combined-stream": "1.0.5", + "extend": "3.0.1", + "forever-agent": "0.6.1", + "form-data": "2.1.4", + "har-validator": "4.2.1", + "hawk": "3.1.3", + "http-signature": "1.1.1", + "is-typedarray": "1.0.0", + "isstream": "0.1.2", + "json-stringify-safe": "5.0.1", + "mime-types": "2.1.15", + "oauth-sign": "0.8.2", + "performance-now": "0.2.0", + "qs": "6.4.0", + "safe-buffer": "5.0.1", + "stringstream": "0.0.5", + "tough-cookie": "2.3.2", + "tunnel-agent": "0.6.0", + "uuid": "3.0.1" + } + }, + "rimraf": { + "version": "2.6.1", + "bundled": true, + "dev": true, + "requires": { + "glob": "7.1.2" + } + }, + "safe-buffer": { + "version": "5.0.1", + "bundled": true, + "dev": true + }, + "semver": { + "version": "5.3.0", + "bundled": true, + "dev": true, + "optional": true + }, + "set-blocking": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "signal-exit": { + "version": "3.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "sntp": { + "version": "1.0.9", + "bundled": true, + "dev": true, + "requires": { + "hoek": "2.16.3" + } + }, + "sshpk": { + "version": "1.13.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "asn1": "0.2.3", + "assert-plus": "1.0.0", + "bcrypt-pbkdf": "1.0.1", + "dashdash": "1.14.1", + "ecc-jsbn": "0.1.1", + "getpass": "0.1.7", + "jodid25519": "1.0.2", + "jsbn": "0.1.1", + "tweetnacl": "0.14.5" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "string-width": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "requires": { + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" + } + }, + "string_decoder": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "requires": { + "safe-buffer": "5.0.1" + } + }, + "stringstream": { + "version": "0.0.5", + "bundled": true, + "dev": true, + "optional": true + }, + "strip-ansi": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "requires": { + "ansi-regex": "2.1.1" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "tar": { + "version": "2.2.1", + "bundled": true, + "dev": true, + "requires": { + "block-stream": "0.0.9", + "fstream": "1.0.11", + "inherits": "2.0.3" + } + }, + "tar-pack": { + "version": "3.4.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "debug": "2.6.8", + "fstream": "1.0.11", + "fstream-ignore": "1.0.5", + "once": "1.4.0", + "readable-stream": "2.2.9", + "rimraf": "2.6.1", + "tar": "2.2.1", + "uid-number": "0.0.6" + } + }, + "tough-cookie": { + "version": "2.3.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "punycode": "1.4.1" + } + }, + "tunnel-agent": { + "version": "0.6.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "safe-buffer": "5.0.1" + } + }, + "tweetnacl": { + "version": "0.14.5", + "bundled": true, + "dev": true, + "optional": true + }, + "uid-number": { + "version": "0.0.6", + "bundled": true, + "dev": true, + "optional": true + }, + "util-deprecate": { + "version": "1.0.2", + "bundled": true, + "dev": true + }, + "uuid": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "verror": { + "version": "1.3.6", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "extsprintf": "1.0.2" + } + }, + "wide-align": { + "version": "1.1.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "string-width": "1.0.2" + } + }, + "wrappy": { + "version": "1.0.2", + "bundled": true, + "dev": true + } + } + }, "fstream": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz", From a18cec21fea70d2ad0c9368a52d95f981689521b Mon Sep 17 00:00:00 2001 From: eiximenis Date: Tue, 27 Feb 2018 14:32:25 +0100 Subject: [PATCH 25/45] Missing aggregator project --- docker-compose.override.yml | 13 +- docker-compose.prod.yml | 1 + docker-compose.yml | 6 + eShopOnContainers-ServicesAndWebApps.sln | 51 +++++++ .../Config/UrlsConfig.cs | 31 ++++ .../Controllers/BasketController.cs | 133 +++++++++++++++++ .../Controllers/HomeController.cs | 18 +++ .../Controllers/OrderController.cs | 42 ++++++ .../Web.Shopping.HttpAggregator/Dockerfile | 18 +++ .../Filters/AuthorizeCheckOperationFilter.cs | 33 +++++ .../Models/AddBasketItemRequest.cs | 20 +++ .../Models/BasketData.cs | 31 ++++ .../Models/CatalogItem.cs | 20 +++ .../Models/OrderData.cs | 33 +++++ .../Models/OrderItemData.cs | 17 +++ .../Models/UpdateBasketItemsRequest.cs | 31 ++++ .../Models/UpdateBasketRequest.cs | 21 +++ .../Web.Shopping.HttpAggregator/Program.cs | 36 +++++ .../Properties/launchSettings.json | 29 ++++ .../Services/BasketService.cs | 53 +++++++ .../Services/CatalogService.cs | 43 ++++++ .../Services/IBasketService.cs | 15 ++ .../Services/ICatalogService.cs | 14 ++ .../Services/IOrderApiClient.cs | 13 ++ .../Services/OrderApiClient.cs | 37 +++++ .../Web.Shopping.HttpAggregator/Startup.cs | 138 ++++++++++++++++++ .../Web.Shopping.HttpAggregator.csproj | 27 ++++ .../appsettings.json | 15 ++ .../appsettings.localhost.json | 8 + src/Apigw/OcelotApiGw/Startup.cs | 2 +- .../webshoppingapigw/configuration.json | 2 +- .../Identity.API/Configuration/Config.cs | 24 ++- .../Data/ConfigurationDbContextSeed.cs | 1 + src/Web/WebMVC/Startup.cs | 1 + 34 files changed, 970 insertions(+), 7 deletions(-) create mode 100644 src/Aggregators/Web.Shopping.HttpAggregator/Config/UrlsConfig.cs create mode 100644 src/Aggregators/Web.Shopping.HttpAggregator/Controllers/BasketController.cs create mode 100644 src/Aggregators/Web.Shopping.HttpAggregator/Controllers/HomeController.cs create mode 100644 src/Aggregators/Web.Shopping.HttpAggregator/Controllers/OrderController.cs create mode 100644 src/Aggregators/Web.Shopping.HttpAggregator/Dockerfile create mode 100644 src/Aggregators/Web.Shopping.HttpAggregator/Filters/AuthorizeCheckOperationFilter.cs create mode 100644 src/Aggregators/Web.Shopping.HttpAggregator/Models/AddBasketItemRequest.cs create mode 100644 src/Aggregators/Web.Shopping.HttpAggregator/Models/BasketData.cs create mode 100644 src/Aggregators/Web.Shopping.HttpAggregator/Models/CatalogItem.cs create mode 100644 src/Aggregators/Web.Shopping.HttpAggregator/Models/OrderData.cs create mode 100644 src/Aggregators/Web.Shopping.HttpAggregator/Models/OrderItemData.cs create mode 100644 src/Aggregators/Web.Shopping.HttpAggregator/Models/UpdateBasketItemsRequest.cs create mode 100644 src/Aggregators/Web.Shopping.HttpAggregator/Models/UpdateBasketRequest.cs create mode 100644 src/Aggregators/Web.Shopping.HttpAggregator/Program.cs create mode 100644 src/Aggregators/Web.Shopping.HttpAggregator/Properties/launchSettings.json create mode 100644 src/Aggregators/Web.Shopping.HttpAggregator/Services/BasketService.cs create mode 100644 src/Aggregators/Web.Shopping.HttpAggregator/Services/CatalogService.cs create mode 100644 src/Aggregators/Web.Shopping.HttpAggregator/Services/IBasketService.cs create mode 100644 src/Aggregators/Web.Shopping.HttpAggregator/Services/ICatalogService.cs create mode 100644 src/Aggregators/Web.Shopping.HttpAggregator/Services/IOrderApiClient.cs create mode 100644 src/Aggregators/Web.Shopping.HttpAggregator/Services/OrderApiClient.cs create mode 100644 src/Aggregators/Web.Shopping.HttpAggregator/Startup.cs create mode 100644 src/Aggregators/Web.Shopping.HttpAggregator/Web.Shopping.HttpAggregator.csproj create mode 100644 src/Aggregators/Web.Shopping.HttpAggregator/appsettings.json create mode 100644 src/Aggregators/Web.Shopping.HttpAggregator/appsettings.localhost.json diff --git a/docker-compose.override.yml b/docker-compose.override.yml index c3dbd0027..51284360a 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -58,6 +58,7 @@ services: - BasketApiClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5103 - OrderingApiClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5102 - MobileShoppingAggClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5120 + - WebShoppingAggClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5121 - UseCustomizationData=True - ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY} - OrchestratorType=${ORCHESTRATOR_TYPE} @@ -262,4 +263,14 @@ services: - urls__orders=http://ordering.api - urls__identity=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. ports: - - "5120:80" \ No newline at end of file + - "5120:80" + + webshoppingagg: + environment: + - ASPNETCORE_ENVIRONMENT=Development + - urls__basket=http://basket.api + - urls__catalog=http://catalog.api + - urls__orders=http://ordering.api + - urls__identity=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. + ports: + - "5121:80" \ No newline at end of file diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 81deef911..1f8fc6dd9 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -65,6 +65,7 @@ services: - BasketApiClient=http://${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}:5103 - OrderingApiClient=http://${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}:5102 - MobileShoppingAggClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5120 + - WebShoppingAggClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5120 - UseCustomizationData=True - ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY} - OrchestratorType=${ORCHESTRATOR_TYPE} diff --git a/docker-compose.yml b/docker-compose.yml index 703dbfee9..ae7a7faa0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -138,3 +138,9 @@ services: context: . dockerfile: src/Aggregators/Mobile.Shopping.HttpAggregator/Dockerfile + webshoppingagg: + image: eshop/webshoppingagg + build: + context: . + dockerfile: src/Aggregators/Mobile.Shopping.HttpAggregator/Dockerfile + diff --git a/eShopOnContainers-ServicesAndWebApps.sln b/eShopOnContainers-ServicesAndWebApps.sln index fc72b85f6..2be8cf090 100644 --- a/eShopOnContainers-ServicesAndWebApps.sln +++ b/eShopOnContainers-ServicesAndWebApps.sln @@ -105,6 +105,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Aggregators", "Aggregators" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mobile.Shopping.HttpAggregator", "src\Aggregators\Mobile.Shopping.HttpAggregator\Mobile.Shopping.HttpAggregator.csproj", "{6E99F232-1536-424F-A28C-91692C8FD325}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Web.Shopping.HttpAggregator", "src\Aggregators\Web.Shopping.HttpAggregator\Web.Shopping.HttpAggregator.csproj", "{714CE0A1-E8BE-4CF1-8948-C1202E1526E2}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Ad-Hoc|Any CPU = Ad-Hoc|Any CPU @@ -1415,6 +1417,54 @@ Global {6E99F232-1536-424F-A28C-91692C8FD325}.Release|x64.Build.0 = Release|Any CPU {6E99F232-1536-424F-A28C-91692C8FD325}.Release|x86.ActiveCfg = Release|Any CPU {6E99F232-1536-424F-A28C-91692C8FD325}.Release|x86.Build.0 = Release|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Ad-Hoc|x64.Build.0 = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Ad-Hoc|x86.Build.0 = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.AppStore|Any CPU.Build.0 = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.AppStore|ARM.ActiveCfg = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.AppStore|ARM.Build.0 = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.AppStore|iPhone.ActiveCfg = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.AppStore|iPhone.Build.0 = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.AppStore|x64.ActiveCfg = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.AppStore|x64.Build.0 = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.AppStore|x86.ActiveCfg = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.AppStore|x86.Build.0 = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Debug|ARM.ActiveCfg = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Debug|ARM.Build.0 = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Debug|iPhone.Build.0 = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Debug|x64.ActiveCfg = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Debug|x64.Build.0 = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Debug|x86.ActiveCfg = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Debug|x86.Build.0 = Debug|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Release|Any CPU.Build.0 = Release|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Release|ARM.ActiveCfg = Release|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Release|ARM.Build.0 = Release|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Release|iPhone.ActiveCfg = Release|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Release|iPhone.Build.0 = Release|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Release|x64.ActiveCfg = Release|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Release|x64.Build.0 = Release|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Release|x86.ActiveCfg = Release|Any CPU + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1465,6 +1515,7 @@ Global {E0C5162E-DF26-4341-9E51-14AE800D7505} = {7A58AA20-67F3-48F3-88C8-24EBFE621792} {EA378316-9D49-4A6B-858E-D4A25F948A74} = {932D8224-11F6-4D07-B109-DA28AD288A63} {6E99F232-1536-424F-A28C-91692C8FD325} = {EA378316-9D49-4A6B-858E-D4A25F948A74} + {714CE0A1-E8BE-4CF1-8948-C1202E1526E2} = {EA378316-9D49-4A6B-858E-D4A25F948A74} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {25728519-5F0F-4973-8A64-0A81EB4EA8D9} diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Config/UrlsConfig.cs b/src/Aggregators/Web.Shopping.HttpAggregator/Config/UrlsConfig.cs new file mode 100644 index 000000000..19be27dce --- /dev/null +++ b/src/Aggregators/Web.Shopping.HttpAggregator/Config/UrlsConfig.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Config +{ + public class UrlsConfig + { + public class CatalogOperations + { + public static string GetItemById(int id) => $"/api/v1/catalog/items/{id}"; + public static string GetItemsById(IEnumerable ids) => $"/api/v1/catalog/items?ids={string.Join(',', ids)}"; + } + + public class BasketOperations + { + public static string GetItemById(string id) => $"/api/v1/basket/{id}"; + public static string UpdateBasket() => "/api/v1/basket"; + } + + public class OrdersOperations + { + public static string GetOrderDraft() => "/api/v1/orders/draft"; + } + + public string Basket { get; set; } + public string Catalog { get; set; } + public string Orders { get; set; } + } +} diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Controllers/BasketController.cs b/src/Aggregators/Web.Shopping.HttpAggregator/Controllers/BasketController.cs new file mode 100644 index 000000000..bfef55726 --- /dev/null +++ b/src/Aggregators/Web.Shopping.HttpAggregator/Controllers/BasketController.cs @@ -0,0 +1,133 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models; +using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Services; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Controllers +{ + [Route("api/v1/[controller]")] + [Authorize] + public class BasketController : Controller + { + private readonly ICatalogService _catalog; + private readonly IBasketService _basket; + public BasketController(ICatalogService catalogService, IBasketService basketService) + { + _catalog = catalogService; + _basket = basketService; + } + + [HttpPost] + [HttpPut] + public async Task UpdateAllBasket([FromBody] UpdateBasketRequest data) + { + + if (data.Items == null || !data.Items.Any()) + { + return BadRequest("Need to pass at least one basket line"); + } + + // Retrieve the current basket + var currentBasket = await _basket.GetById(data.BuyerId); + if (currentBasket == null) + { + currentBasket = new BasketData(data.BuyerId); + } + + var catalogItems = await _catalog.GetCatalogItems(data.Items.Select(x => x.ProductId)); + var newBasket = new BasketData(data.BuyerId); + + foreach (var bitem in data.Items) + { + var catalogItem = catalogItems.SingleOrDefault(ci => ci.Id == bitem.ProductId); + if (catalogItem == null) + { + return BadRequest($"Basket refers to a non-existing catalog item ({bitem.ProductId})"); + } + + newBasket.Items.Add(new BasketDataItem() + { + Id = bitem.Id, + ProductId = catalogItem.Id.ToString(), + ProductName = catalogItem.Name, + PictureUrl = catalogItem.PictureUri, + UnitPrice = catalogItem.Price, + Quantity = bitem.Quantity + }); + } + + await _basket.Update(newBasket); + return Ok(newBasket); + } + + [HttpPut] + [Route("items")] + public async Task UpdateQuantities([FromBody] UpdateBasketItemsRequest data) + { + if (!data.Updates.Any()) + { + return BadRequest("No updates sent"); + } + + // Retrieve the current basket + var currentBasket = await _basket.GetById(data.BasketId); + if (currentBasket == null) + { + return BadRequest($"Basket with id {data.BasketId} not found."); + } + + // Update with new quantities + foreach (var update in data.Updates) + { + var basketItem = currentBasket.Items.SingleOrDefault(bitem => bitem.Id == update.BasketItemId); + if (basketItem == null) + { + return BadRequest($"Basket item with id {update.BasketItemId} not found"); + } + basketItem.Quantity = update.NewQty; + } + + // Save the updated basket + await _basket.Update(currentBasket); + return Ok(currentBasket); + } + + [HttpPost] + [Route("items")] + public async Task AddBasketItem([FromBody] AddBasketItemRequest data) + { + if (data == null || data.Quantity == 0) + { + return BadRequest("Invalid payload"); + } + + // Step 1: Get the item from catalog + var item = await _catalog.GetCatalogItem(data.CatalogItemId); + + //item.PictureUri = + + // Step 2: Get current basket status + var currentBasket = (await _basket.GetById(data.BasketId)) ?? new BasketData(data.BasketId); + // Step 3: Merge current status with new product + currentBasket.Items.Add(new BasketDataItem() + { + UnitPrice = item.Price, + PictureUrl = item.PictureUri, + ProductId = item.Id.ToString(), + ProductName = item.Name, + Quantity = data.Quantity, + Id = Guid.NewGuid().ToString() + }); + + // Step 4: Update basket + await _basket.Update(currentBasket); + + + return Ok(); + } + } +} diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Controllers/HomeController.cs b/src/Aggregators/Web.Shopping.HttpAggregator/Controllers/HomeController.cs new file mode 100644 index 000000000..58ed48d1a --- /dev/null +++ b/src/Aggregators/Web.Shopping.HttpAggregator/Controllers/HomeController.cs @@ -0,0 +1,18 @@ +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Controllers +{ + [Route("")] + public class HomeController : Controller + { + [HttpGet()] + public IActionResult Index() + { + return new RedirectResult("~/swagger"); + } + } +} diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Controllers/OrderController.cs b/src/Aggregators/Web.Shopping.HttpAggregator/Controllers/OrderController.cs new file mode 100644 index 000000000..fd108ffb8 --- /dev/null +++ b/src/Aggregators/Web.Shopping.HttpAggregator/Controllers/OrderController.cs @@ -0,0 +1,42 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Services; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Controllers +{ + [Route("api/v1/[controller]")] + [Authorize] + public class OrderController : Controller + { + private readonly IBasketService _basketService; + private readonly IOrderApiClient _orderClient; + public OrderController(IBasketService basketService, IOrderApiClient orderClient) + { + _basketService = basketService; + _orderClient = orderClient; + } + + [Route("draft/{basketId}")] + [HttpGet] + public async Task GetOrderDraft(string basketId) + { + if (string.IsNullOrEmpty(basketId)) + { + return BadRequest("Need a valid basketid"); + } + // Get the basket data and build a order draft based on it + var basket = await _basketService.GetById(basketId); + if (basket == null) + { + return BadRequest($"No basket found for id {basketId}"); + } + + var orderDraft = await _orderClient.GetOrderDraftFromBasket(basket); + return Ok(orderDraft); + } + } +} diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Dockerfile b/src/Aggregators/Web.Shopping.HttpAggregator/Dockerfile new file mode 100644 index 000000000..267cb233c --- /dev/null +++ b/src/Aggregators/Web.Shopping.HttpAggregator/Dockerfile @@ -0,0 +1,18 @@ +FROM microsoft/aspnetcore:2.0.5 AS base +WORKDIR /app +EXPOSE 80 + +FROM microsoft/aspnetcore-build:2.0 AS build +WORKDIR /src +COPY . . +RUN dotnet restore -nowarn:msb3202,nu1503 +WORKDIR /src/src/Aggregators/Web.Shopping.HttpAggregator +RUN dotnet build --no-restore -c Release -o /app + +FROM build AS publish +RUN dotnet publish --no-restore -c Release -o /app + +FROM base AS final +WORKDIR /app +COPY --from=publish /app . +ENTRYPOINT ["dotnet", "Web.Shopping.HttpAggregator.dll"] diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Filters/AuthorizeCheckOperationFilter.cs b/src/Aggregators/Web.Shopping.HttpAggregator/Filters/AuthorizeCheckOperationFilter.cs new file mode 100644 index 000000000..3f382e5df --- /dev/null +++ b/src/Aggregators/Web.Shopping.HttpAggregator/Filters/AuthorizeCheckOperationFilter.cs @@ -0,0 +1,33 @@ +namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Filters +{ + using Microsoft.AspNetCore.Authorization; + using Swashbuckle.AspNetCore.Swagger; + using Swashbuckle.AspNetCore.SwaggerGen; + using System.Collections.Generic; + using System.Linq; + + namespace Basket.API.Infrastructure.Filters + { + public class AuthorizeCheckOperationFilter : IOperationFilter + { + public void Apply(Operation operation, OperationFilterContext context) + { + // Check for authorize attribute + var hasAuthorize = context.ApiDescription.ControllerAttributes().OfType().Any() || + context.ApiDescription.ActionAttributes().OfType().Any(); + + if (hasAuthorize) + { + operation.Responses.Add("401", new Response { Description = "Unauthorized" }); + operation.Responses.Add("403", new Response { Description = "Forbidden" }); + + operation.Security = new List>>(); + operation.Security.Add(new Dictionary> + { + { "oauth2", new [] { "Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator" } } + }); + } + } + } + } +} diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Models/AddBasketItemRequest.cs b/src/Aggregators/Web.Shopping.HttpAggregator/Models/AddBasketItemRequest.cs new file mode 100644 index 000000000..88aff245f --- /dev/null +++ b/src/Aggregators/Web.Shopping.HttpAggregator/Models/AddBasketItemRequest.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models +{ + public class AddBasketItemRequest + { + public int CatalogItemId { get; set; } + public string BasketId { get; set; } + + public int Quantity { get; set; } + + public AddBasketItemRequest() + { + Quantity = 1; + } + } +} diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Models/BasketData.cs b/src/Aggregators/Web.Shopping.HttpAggregator/Models/BasketData.cs new file mode 100644 index 000000000..01831a5c9 --- /dev/null +++ b/src/Aggregators/Web.Shopping.HttpAggregator/Models/BasketData.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models +{ + public class BasketData + { + public string BuyerId { get; set; } + public List Items { get; set; } + + public BasketData(string buyerId) + { + BuyerId = buyerId; + Items = new List(); + } + } + + public class BasketDataItem + { + public string Id { get; set; } + public string ProductId { get; set; } + public string ProductName { get; set; } + public decimal UnitPrice { get; set; } + public decimal OldUnitPrice { get; set; } + public int Quantity { get; set; } + public string PictureUrl { get; set; } + + } +} diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Models/CatalogItem.cs b/src/Aggregators/Web.Shopping.HttpAggregator/Models/CatalogItem.cs new file mode 100644 index 000000000..c6085f934 --- /dev/null +++ b/src/Aggregators/Web.Shopping.HttpAggregator/Models/CatalogItem.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models +{ + public class CatalogItem + { + public int Id { get; set; } + + public string Name { get; set; } + + public decimal Price { get; set; } + + + public string PictureUri { get; set; } + + } +} diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Models/OrderData.cs b/src/Aggregators/Web.Shopping.HttpAggregator/Models/OrderData.cs new file mode 100644 index 000000000..e9d5982b9 --- /dev/null +++ b/src/Aggregators/Web.Shopping.HttpAggregator/Models/OrderData.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models +{ + public class OrderData + { + public string OrderNumber { get; set; } + public DateTime Date { get; set; } + public string Status { get; set; } + public decimal Total { get; set; } + public string Description { get; set; } + public string City { get; set; } + public string Street { get; set; } + public string State { get; set; } + public string Country { get; set; } + public string ZipCode { get; set; } + public string CardNumber { get; set; } + public string CardHolderName { get; set; } + public bool IsDraft { get; set; } + public DateTime CardExpiration { get; set; } + public string CardExpirationShort { get; set; } + public string CardSecurityNumber { get; set; } + + public int CardTypeId { get; set; } + + public string Buyer { get; set; } + + public List OrderItems { get; } = new List(); + } +} diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Models/OrderItemData.cs b/src/Aggregators/Web.Shopping.HttpAggregator/Models/OrderItemData.cs new file mode 100644 index 000000000..1a40cb8cb --- /dev/null +++ b/src/Aggregators/Web.Shopping.HttpAggregator/Models/OrderItemData.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models +{ + public class OrderItemData + { + public int ProductId { get; set; } + public string ProductName { get; set; } + public decimal UnitPrice { get; set; } + public decimal Discount { get; set; } + public int Units { get; set; } + public string PictureUrl { get; set; } + } +} diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Models/UpdateBasketItemsRequest.cs b/src/Aggregators/Web.Shopping.HttpAggregator/Models/UpdateBasketItemsRequest.cs new file mode 100644 index 000000000..b41c069bc --- /dev/null +++ b/src/Aggregators/Web.Shopping.HttpAggregator/Models/UpdateBasketItemsRequest.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models +{ + public class UpdateBasketItemsRequest + { + + public string BasketId { get; set; } + + public ICollection Updates { get; set; } + + public UpdateBasketItemsRequest() + { + Updates = new List(); + } + } + + public class UpdateBasketItemData + { + public string BasketItemId { get; set; } + public int NewQty { get; set; } + + public UpdateBasketItemData() + { + NewQty = 0; + } + } +} diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Models/UpdateBasketRequest.cs b/src/Aggregators/Web.Shopping.HttpAggregator/Models/UpdateBasketRequest.cs new file mode 100644 index 000000000..9beeeade4 --- /dev/null +++ b/src/Aggregators/Web.Shopping.HttpAggregator/Models/UpdateBasketRequest.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models +{ + public class UpdateBasketRequest + { + public string BuyerId { get; set; } + + public IEnumerable Items { get; set; } + } + + public class UpdateBasketRequestItemData + { + public string Id { get; set; } // Basket id + public int ProductId { get; set; } // Catalog item id + public int Quantity { get; set; } // Quantity + } +} diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Program.cs b/src/Aggregators/Web.Shopping.HttpAggregator/Program.cs new file mode 100644 index 000000000..c865a8b3b --- /dev/null +++ b/src/Aggregators/Web.Shopping.HttpAggregator/Program.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; + +namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator +{ + public class Program + { + public static void Main(string[] args) + { + BuildWebHost(args).Run(); + } + + public static IWebHost BuildWebHost(string[] args) => + WebHost + .CreateDefaultBuilder(args) + .ConfigureAppConfiguration(cb => + { + var sources = cb.Sources; + sources.Insert(3, new Microsoft.Extensions.Configuration.Json.JsonConfigurationSource() + { + Optional = true, + Path = "appsettings.localhost.json", + ReloadOnChange = false + }); + }) + .UseStartup() + .Build(); + } +} diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Properties/launchSettings.json b/src/Aggregators/Web.Shopping.HttpAggregator/Properties/launchSettings.json new file mode 100644 index 000000000..925e70b0d --- /dev/null +++ b/src/Aggregators/Web.Shopping.HttpAggregator/Properties/launchSettings.json @@ -0,0 +1,29 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:57425/", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "api/values", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "PurchaseForMvc": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "api/values", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "http://localhost:61632/" + } + } +} \ No newline at end of file diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Services/BasketService.cs b/src/Aggregators/Web.Shopping.HttpAggregator/Services/BasketService.cs new file mode 100644 index 000000000..5ca89a408 --- /dev/null +++ b/src/Aggregators/Web.Shopping.HttpAggregator/Services/BasketService.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Http; +using Microsoft.eShopOnContainers.BuildingBlocks.Resilience.Http; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using Newtonsoft.Json; +using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Config; +using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models; + +namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Services +{ + public class BasketService : IBasketService + { + + private readonly IHttpClient _apiClient; + private readonly ILogger _logger; + private readonly UrlsConfig _urls; + private readonly IHttpContextAccessor _httpContextAccessor; + + public BasketService(IHttpClient httpClient, IHttpContextAccessor httpContextAccessor, ILogger logger, IOptionsSnapshot config) + { + _apiClient = httpClient; + _logger = logger; + _urls = config.Value; + _httpContextAccessor = httpContextAccessor; + } + + public async Task GetById(string id) + { + var token = await GetUserTokenAsync(); + var data = await _apiClient.GetStringAsync(_urls.Basket + UrlsConfig.BasketOperations.GetItemById(id), token); + var basket = !string.IsNullOrEmpty(data) ? JsonConvert.DeserializeObject(data) : null; + return basket; + } + + public async Task Update(BasketData currentBasket) + { + var token = await GetUserTokenAsync(); + var data = await _apiClient.PostAsync(_urls.Basket + UrlsConfig.BasketOperations.UpdateBasket(), currentBasket, token); + int i = 0; + } + + async Task GetUserTokenAsync() + { + var context = _httpContextAccessor.HttpContext; + return await context.GetTokenAsync("access_token"); + } + } +} diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Services/CatalogService.cs b/src/Aggregators/Web.Shopping.HttpAggregator/Services/CatalogService.cs new file mode 100644 index 000000000..46d895f68 --- /dev/null +++ b/src/Aggregators/Web.Shopping.HttpAggregator/Services/CatalogService.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.eShopOnContainers.BuildingBlocks.Resilience.Http; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using Newtonsoft.Json; +using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Config; +using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models; + +namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Services +{ + public class CatalogService : ICatalogService + { + + private readonly IHttpClient _apiClient; + private readonly ILogger _logger; + private readonly UrlsConfig _urls; + + public CatalogService(IHttpClient httpClient, ILogger logger, IOptionsSnapshot config) + { + _apiClient = httpClient; + _logger = logger; + _urls = config.Value; + } + + public async Task GetCatalogItem(int id) + { + var data = await _apiClient.GetStringAsync(_urls.Catalog + UrlsConfig.CatalogOperations.GetItemById(id)); + var item = JsonConvert.DeserializeObject(data); + return item; + } + + public async Task> GetCatalogItems(IEnumerable ids) + { + var data = await _apiClient.GetStringAsync(_urls.Catalog + UrlsConfig.CatalogOperations.GetItemsById(ids)); + var item = JsonConvert.DeserializeObject(data); + return item; + + } + } +} diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Services/IBasketService.cs b/src/Aggregators/Web.Shopping.HttpAggregator/Services/IBasketService.cs new file mode 100644 index 000000000..f59c31965 --- /dev/null +++ b/src/Aggregators/Web.Shopping.HttpAggregator/Services/IBasketService.cs @@ -0,0 +1,15 @@ +using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Services +{ + public interface IBasketService + { + Task GetById(string id); + Task Update(BasketData currentBasket); + + } +} diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Services/ICatalogService.cs b/src/Aggregators/Web.Shopping.HttpAggregator/Services/ICatalogService.cs new file mode 100644 index 000000000..7d192f3cc --- /dev/null +++ b/src/Aggregators/Web.Shopping.HttpAggregator/Services/ICatalogService.cs @@ -0,0 +1,14 @@ +using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Services +{ + public interface ICatalogService + { + Task GetCatalogItem(int id); + Task> GetCatalogItems(IEnumerable ids); + } +} diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Services/IOrderApiClient.cs b/src/Aggregators/Web.Shopping.HttpAggregator/Services/IOrderApiClient.cs new file mode 100644 index 000000000..c97eccbbd --- /dev/null +++ b/src/Aggregators/Web.Shopping.HttpAggregator/Services/IOrderApiClient.cs @@ -0,0 +1,13 @@ +using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Services +{ + public interface IOrderApiClient + { + Task GetOrderDraftFromBasket(BasketData basket); + } +} diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Services/OrderApiClient.cs b/src/Aggregators/Web.Shopping.HttpAggregator/Services/OrderApiClient.cs new file mode 100644 index 000000000..220e9afa9 --- /dev/null +++ b/src/Aggregators/Web.Shopping.HttpAggregator/Services/OrderApiClient.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.eShopOnContainers.BuildingBlocks.Resilience.Http; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using Newtonsoft.Json; +using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Config; +using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models; + +namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Services +{ + public class OrderApiClient : IOrderApiClient + { + + private readonly IHttpClient _apiClient; + private readonly ILogger _logger; + private readonly UrlsConfig _urls; + + public OrderApiClient(IHttpClient httpClient, ILogger logger, IOptionsSnapshot config) + { + _apiClient = httpClient; + _logger = logger; + _urls = config.Value; + } + + public async Task GetOrderDraftFromBasket(BasketData basket) + { + var url = _urls.Orders + UrlsConfig.OrdersOperations.GetOrderDraft(); + var response = await _apiClient.PostAsync(url, basket); + response.EnsureSuccessStatusCode(); + var jsonResponse = await response.Content.ReadAsStringAsync(); + return JsonConvert.DeserializeObject(jsonResponse); + } + } +} diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Startup.cs b/src/Aggregators/Web.Shopping.HttpAggregator/Startup.cs new file mode 100644 index 000000000..79b9bc77b --- /dev/null +++ b/src/Aggregators/Web.Shopping.HttpAggregator/Startup.cs @@ -0,0 +1,138 @@ +using System; +using System.Collections.Generic; +using System.IdentityModel.Tokens.Jwt; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication.JwtBearer; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.eShopOnContainers.BuildingBlocks.Resilience.Http; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Config; +using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Filters.Basket.API.Infrastructure.Filters; +using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Services; +using Swashbuckle.AspNetCore.Swagger; + +namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator +{ + public class Startup + { + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + public IConfiguration Configuration { get; } + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + services.AddSingleton(); + services.AddSingleton(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + + services.AddOptions(); + services.Configure(Configuration.GetSection("urls")); + + services.AddMvc(); + + services.AddSwaggerGen(options => + { + options.DescribeAllEnumsAsStrings(); + options.SwaggerDoc("v1", new Swashbuckle.AspNetCore.Swagger.Info + { + Title = "Purchase BFF API Gateway", + Version = "v1", + Description = "BFF API Gateway for Purchase features", + TermsOfService = "Terms Of Service" + }); + + options.AddSecurityDefinition("oauth2", new OAuth2Scheme + { + Type = "oauth2", + Flow = "implicit", + AuthorizationUrl = $"{Configuration.GetValue("IdentityUrlExternal")}/connect/authorize", + TokenUrl = $"{Configuration.GetValue("IdentityUrlExternal")}/connect/token", + Scopes = new Dictionary() + { + { "webshoppingagg", "Purchase BFF API Gateway" } + } + }); + + options.OperationFilter(); + }); + + services.AddCors(options => + { + options.AddPolicy("CorsPolicy", + builder => builder.AllowAnyOrigin() + .AllowAnyMethod() + .AllowAnyHeader() + .AllowCredentials()); + }); + + + JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); + var identityUrl = Configuration.GetValue("urls:identity"); + services.AddAuthentication(options => + { + options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; + options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; + + }).AddJwtBearer(options => + { + options.Authority = identityUrl; + options.RequireHttpsMetadata = false; + options.Audience = "webshoppingagg"; + options.Events = new JwtBearerEvents() + { + OnAuthenticationFailed = async ctx => + { + int i = 0; + }, + OnTokenValidated = async ctx => + { + int i = 0; + } + }; + }); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + { + + var pathBase = Configuration["PATH_BASE"]; + if (!string.IsNullOrEmpty(pathBase)) + { + loggerFactory.CreateLogger("init").LogDebug($"Using PATH BASE '{pathBase}'"); + app.UsePathBase(pathBase); + } + + app.UseCors("CorsPolicy"); + + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + + app.UseAuthentication(); + + app.UseMvc(); + + app.UseSwagger().UseSwaggerUI(c => + { + c.SwaggerEndpoint($"{ (!string.IsNullOrEmpty(pathBase) ? pathBase : string.Empty) }/swagger/v1/swagger.json", "Purchase BFF V1"); + c.ConfigureOAuth2("Microsoft.eShopOnContainers.Web.Shopping.HttpAggregatorwaggerui", "", "", "Purchase BFF Swagger UI"); + }); + + + } + } +} diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Web.Shopping.HttpAggregator.csproj b/src/Aggregators/Web.Shopping.HttpAggregator/Web.Shopping.HttpAggregator.csproj new file mode 100644 index 000000000..fd04c8bee --- /dev/null +++ b/src/Aggregators/Web.Shopping.HttpAggregator/Web.Shopping.HttpAggregator.csproj @@ -0,0 +1,27 @@ + + + + netcoreapp2.0 + Web.Shopping.HttpAggregator + Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator + ..\..\..\docker-compose.dcproj + + + + + + + + + + + + + + + + + + + + diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/appsettings.json b/src/Aggregators/Web.Shopping.HttpAggregator/appsettings.json new file mode 100644 index 000000000..26bb0ac7a --- /dev/null +++ b/src/Aggregators/Web.Shopping.HttpAggregator/appsettings.json @@ -0,0 +1,15 @@ +{ + "Logging": { + "IncludeScopes": false, + "Debug": { + "LogLevel": { + "Default": "Warning" + } + }, + "Console": { + "LogLevel": { + "Default": "Warning" + } + } + } +} diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/appsettings.localhost.json b/src/Aggregators/Web.Shopping.HttpAggregator/appsettings.localhost.json new file mode 100644 index 000000000..57b5e894d --- /dev/null +++ b/src/Aggregators/Web.Shopping.HttpAggregator/appsettings.localhost.json @@ -0,0 +1,8 @@ +{ + "urls": { + "basket": "http://localhost:55105", + "catalog": "http://localhost:55101", + "orders": "http://localhost:55102", + "identity": "http://localhost:55105" + } +} diff --git a/src/Apigw/OcelotApiGw/Startup.cs b/src/Apigw/OcelotApiGw/Startup.cs index f0a41c172..254849d89 100644 --- a/src/Apigw/OcelotApiGw/Startup.cs +++ b/src/Apigw/OcelotApiGw/Startup.cs @@ -45,7 +45,7 @@ namespace OcelotApiGw x.RequireHttpsMetadata = false; x.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters() { - ValidAudiences = new[] { "orders", "basket", "locations", "marketing", "mobileshoppingagg" } + ValidAudiences = new[] { "orders", "basket", "locations", "marketing", "mobileshoppingagg", "webshoppingagg" } }; x.Events = new Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerEvents() { diff --git a/src/Apigw/configs/webshoppingapigw/configuration.json b/src/Apigw/configs/webshoppingapigw/configuration.json index 801eac5d9..63aeb7752 100644 --- a/src/Apigw/configs/webshoppingapigw/configuration.json +++ b/src/Apigw/configs/webshoppingapigw/configuration.json @@ -49,7 +49,7 @@ "DownstreamScheme": "http", "DownstreamHostAndPorts": [ { - "Host": "mobileshoppingagg", + "Host": "webshoppingagg", "Port": 80 } ], diff --git a/src/Services/Identity/Identity.API/Configuration/Config.cs b/src/Services/Identity/Identity.API/Configuration/Config.cs index 18e313bf8..6aed6120d 100644 --- a/src/Services/Identity/Identity.API/Configuration/Config.cs +++ b/src/Services/Identity/Identity.API/Configuration/Config.cs @@ -15,7 +15,8 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration new ApiResource("basket", "Basket Service"), new ApiResource("marketing", "Marketing Service"), new ApiResource("locations", "Locations Service"), - new ApiResource("mobileshoppingagg", "Mobile Shopping Aggregator") + new ApiResource("mobileshoppingagg", "Mobile Shopping Aggregator"), + new ApiResource("Webshoppingagg", "Web Shopping Aggregator") }; } @@ -54,7 +55,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration "basket", "locations", "marketing", - "mobileshoppingagg" + "webshoppingagg" } }, new Client @@ -118,7 +119,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration "basket", "locations", "marketing", - "mobileshoppingagg" + "webshoppingagg" }, }, new Client @@ -151,7 +152,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration "basket", "locations", "marketing", - "mobileshoppingagg" + "webshoppingagg" }, }, new Client @@ -228,6 +229,21 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration { "mobileshoppingagg" } + }, + new Client + { + ClientId = "webshoppingaggswaggerui", + ClientName = "Web Shopping Aggregattor Swagger UI", + AllowedGrantTypes = GrantTypes.Implicit, + AllowAccessTokensViaBrowser = true, + + RedirectUris = { $"{clientsUrl["WebShoppingAgg"]}/swagger/o2c.html" }, + PostLogoutRedirectUris = { $"{clientsUrl["WebShoppingAgg"]}/swagger/" }, + + AllowedScopes = + { + "webshoppingagg" + } } }; diff --git a/src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs b/src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs index 4757d4743..a5a4383bd 100644 --- a/src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs +++ b/src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs @@ -24,6 +24,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Data clientUrls.Add("BasketApi", configuration.GetValue("BasketApiClient")); clientUrls.Add("OrderingApi", configuration.GetValue("OrderingApiClient")); clientUrls.Add("MobileShoppingAgg", configuration.GetValue("MobileShoppingAggClient")); + clientUrls.Add("WebShoppingAgg", configuration.GetValue("WebShoppingAggClient")); if (!context.Clients.Any()) { diff --git a/src/Web/WebMVC/Startup.cs b/src/Web/WebMVC/Startup.cs index 21986b5df..385a007c3 100644 --- a/src/Web/WebMVC/Startup.cs +++ b/src/Web/WebMVC/Startup.cs @@ -131,6 +131,7 @@ namespace Microsoft.eShopOnContainers.WebMVC options.Scope.Add("marketing"); options.Scope.Add("locations"); options.Scope.Add("mobileshoppingagg"); + options.Scope.Add("webshoppingagg"); }); } From 152fcc820576889b76e1a39be14bf4fe328cacc4 Mon Sep 17 00:00:00 2001 From: eiximenis Date: Tue, 27 Feb 2018 17:29:37 +0100 Subject: [PATCH 26/45] Fixed errors and updated config --- docker-compose.yml | 2 +- src/Aggregators/Mobile.Shopping.HttpAggregator/Startup.cs | 6 +++--- src/Aggregators/Web.Shopping.HttpAggregator/Startup.cs | 6 +++--- src/Services/Identity/Identity.API/Configuration/Config.cs | 2 +- src/Web/WebMVC/Startup.cs | 1 - .../Client/modules/shared/services/security.service.ts | 2 +- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index ae7a7faa0..18372f23e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -142,5 +142,5 @@ services: image: eshop/webshoppingagg build: context: . - dockerfile: src/Aggregators/Mobile.Shopping.HttpAggregator/Dockerfile + dockerfile: src/Aggregators/Web.Shopping.HttpAggregator/Dockerfile diff --git a/src/Aggregators/Mobile.Shopping.HttpAggregator/Startup.cs b/src/Aggregators/Mobile.Shopping.HttpAggregator/Startup.cs index 083839bd5..73b736519 100644 --- a/src/Aggregators/Mobile.Shopping.HttpAggregator/Startup.cs +++ b/src/Aggregators/Mobile.Shopping.HttpAggregator/Startup.cs @@ -47,9 +47,9 @@ namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator options.DescribeAllEnumsAsStrings(); options.SwaggerDoc("v1", new Swashbuckle.AspNetCore.Swagger.Info { - Title = "Purchase BFF API Gateway", + Title = "Shopping Aggregator for Mobile Clients", Version = "v1", - Description = "BFF API Gateway for Purchase features", + Description = "Shopping Aggregator for Mobile Clients", TermsOfService = "Terms Of Service" }); @@ -61,7 +61,7 @@ namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator TokenUrl = $"{Configuration.GetValue("IdentityUrlExternal")}/connect/token", Scopes = new Dictionary() { - { "mobileshoppingagg", "Purchase BFF API Gateway" } + { "mobileshoppingagg", "Shopping Aggregator for Mobile Clients" } } }); diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Startup.cs b/src/Aggregators/Web.Shopping.HttpAggregator/Startup.cs index 79b9bc77b..17f9f90e6 100644 --- a/src/Aggregators/Web.Shopping.HttpAggregator/Startup.cs +++ b/src/Aggregators/Web.Shopping.HttpAggregator/Startup.cs @@ -47,9 +47,9 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator options.DescribeAllEnumsAsStrings(); options.SwaggerDoc("v1", new Swashbuckle.AspNetCore.Swagger.Info { - Title = "Purchase BFF API Gateway", + Title = "Shopping Aggregator for Web Clients", Version = "v1", - Description = "BFF API Gateway for Purchase features", + Description = "Shopping Aggregator for Web Clients", TermsOfService = "Terms Of Service" }); @@ -61,7 +61,7 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator TokenUrl = $"{Configuration.GetValue("IdentityUrlExternal")}/connect/token", Scopes = new Dictionary() { - { "webshoppingagg", "Purchase BFF API Gateway" } + { "webshoppingagg", "Shopping Aggregator for Web Clients" } } }); diff --git a/src/Services/Identity/Identity.API/Configuration/Config.cs b/src/Services/Identity/Identity.API/Configuration/Config.cs index 6aed6120d..3bc705995 100644 --- a/src/Services/Identity/Identity.API/Configuration/Config.cs +++ b/src/Services/Identity/Identity.API/Configuration/Config.cs @@ -16,7 +16,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration new ApiResource("marketing", "Marketing Service"), new ApiResource("locations", "Locations Service"), new ApiResource("mobileshoppingagg", "Mobile Shopping Aggregator"), - new ApiResource("Webshoppingagg", "Web Shopping Aggregator") + new ApiResource("webshoppingagg", "Web Shopping Aggregator") }; } diff --git a/src/Web/WebMVC/Startup.cs b/src/Web/WebMVC/Startup.cs index 385a007c3..b1dd6580a 100644 --- a/src/Web/WebMVC/Startup.cs +++ b/src/Web/WebMVC/Startup.cs @@ -130,7 +130,6 @@ namespace Microsoft.eShopOnContainers.WebMVC options.Scope.Add("basket"); options.Scope.Add("marketing"); options.Scope.Add("locations"); - options.Scope.Add("mobileshoppingagg"); options.Scope.Add("webshoppingagg"); }); } diff --git a/src/Web/WebSPA/Client/modules/shared/services/security.service.ts b/src/Web/WebSPA/Client/modules/shared/services/security.service.ts index c2ac8e5e2..45007b5d1 100644 --- a/src/Web/WebSPA/Client/modules/shared/services/security.service.ts +++ b/src/Web/WebSPA/Client/modules/shared/services/security.service.ts @@ -82,7 +82,7 @@ export class SecurityService { let client_id = 'js'; let redirect_uri = location.origin + '/'; let response_type = 'id_token token'; - let scope = 'openid profile orders basket marketing locations mobileshoppingagg'; + let scope = 'openid profile orders basket marketing locations webshoppingagg'; let nonce = 'N' + Math.random() + '' + Date.now(); let state = Date.now() + '' + Math.random(); From de37559c4186a9fac590ca74b7626972f90b1c41 Mon Sep 17 00:00:00 2001 From: eiximenis Date: Wed, 28 Feb 2018 11:30:25 +0100 Subject: [PATCH 27/45] Files moved / names changes / csprojs updated / sln updated --- docker-compose.override.yml | 52 +-- docker-compose.yml | 40 +-- eShopOnContainers-ServicesAndWebApps.sln | 332 ++++++++++-------- .../ApiGw-Base}/Dockerfile | 7 +- .../ApiGw-Base}/Dockerfile2 | 7 +- .../ApiGw-Base}/Dockerfile3 | 7 +- .../ApiGw-Base}/Dockerfile4 | 7 +- .../ApiGw-Base}/OcelotApiGw.csproj | 0 .../ApiGw-Base}/Program.cs | 0 .../Properties/launchSettings.json | 0 .../ApiGw-Base}/Startup.cs | 0 .../ApiGw-Base}/appsettings.json | 0 .../apigw}/configuration.json | 0 .../aggregator}/Config/UrlsConfig.cs | 0 .../Controllers/BasketController.cs | 0 .../aggregator}/Controllers/HomeController.cs | 0 .../Controllers/OrderController.cs | 0 .../aggregator}/Dockerfile | 3 +- .../Filters/AuthorizeCheckOperationFilter.cs | 0 .../Mobile.Shopping.HttpAggregator.csproj | 2 +- .../Models/AddBasketItemRequest.cs | 0 .../aggregator}/Models/BasketData.cs | 0 .../aggregator}/Models/CatalogItem.cs | 0 .../aggregator}/Models/OrderData.cs | 0 .../aggregator}/Models/OrderItemData.cs | 0 .../Models/UpdateBasketItemsRequest.cs | 0 .../aggregator}/Models/UpdateBasketRequest.cs | 0 .../aggregator}/Program.cs | 0 .../Properties/launchSettings.json | 0 .../aggregator}/Services/BasketService.cs | 0 .../aggregator}/Services/CatalogService.cs | 0 .../aggregator}/Services/IBasketService.cs | 0 .../aggregator}/Services/ICatalogService.cs | 0 .../aggregator}/Services/IOrderApiClient.cs | 0 .../aggregator}/Services/OrderApiClient.cs | 0 .../aggregator}/Startup.cs | 0 .../aggregator}/appsettings.json | 0 .../aggregator}/appsettings.localhost.json | 0 .../apigw}/configuration.json | 0 .../apigw}/configuration.json | 0 .../aggregator}/Config/UrlsConfig.cs | 0 .../Controllers/BasketController.cs | 0 .../aggregator}/Controllers/HomeController.cs | 0 .../Controllers/OrderController.cs | 0 .../Web.Bff.Shopping/aggregator}/Dockerfile | 2 +- .../Filters/AuthorizeCheckOperationFilter.cs | 0 .../Models/AddBasketItemRequest.cs | 0 .../aggregator}/Models/BasketData.cs | 0 .../aggregator}/Models/CatalogItem.cs | 0 .../aggregator}/Models/OrderData.cs | 0 .../aggregator}/Models/OrderItemData.cs | 0 .../Models/UpdateBasketItemsRequest.cs | 0 .../aggregator}/Models/UpdateBasketRequest.cs | 0 .../Web.Bff.Shopping/aggregator}/Program.cs | 0 .../Properties/launchSettings.json | 0 .../aggregator}/Services/BasketService.cs | 0 .../aggregator}/Services/CatalogService.cs | 0 .../aggregator}/Services/IBasketService.cs | 0 .../aggregator}/Services/ICatalogService.cs | 0 .../aggregator}/Services/IOrderApiClient.cs | 0 .../aggregator}/Services/OrderApiClient.cs | 0 .../Web.Bff.Shopping/aggregator}/Startup.cs | 0 .../Web.Shopping.HttpAggregator.csproj | 2 +- .../aggregator}/appsettings.json | 0 .../aggregator}/appsettings.localhost.json | 0 .../apigw}/configuration.json | 0 66 files changed, 245 insertions(+), 216 deletions(-) rename src/{Apigw/OcelotApiGw => ApiGateways/ApiGw-Base}/Dockerfile (60%) rename src/{Apigw/OcelotApiGw => ApiGateways/ApiGw-Base}/Dockerfile2 (60%) rename src/{Apigw/OcelotApiGw => ApiGateways/ApiGw-Base}/Dockerfile3 (61%) rename src/{Apigw/OcelotApiGw => ApiGateways/ApiGw-Base}/Dockerfile4 (61%) rename src/{Apigw/OcelotApiGw => ApiGateways/ApiGw-Base}/OcelotApiGw.csproj (100%) rename src/{Apigw/OcelotApiGw => ApiGateways/ApiGw-Base}/Program.cs (100%) rename src/{Apigw/OcelotApiGw => ApiGateways/ApiGw-Base}/Properties/launchSettings.json (100%) rename src/{Apigw/OcelotApiGw => ApiGateways/ApiGw-Base}/Startup.cs (100%) rename src/{Apigw/OcelotApiGw => ApiGateways/ApiGw-Base}/appsettings.json (100%) rename src/{Apigw/configs/mobilemarketingapigw => ApiGateways/Mobile.Bff.Marketing/apigw}/configuration.json (100%) rename src/{Aggregators/Mobile.Shopping.HttpAggregator => ApiGateways/Mobile.Bff.Shopping/aggregator}/Config/UrlsConfig.cs (100%) rename src/{Aggregators/Mobile.Shopping.HttpAggregator => ApiGateways/Mobile.Bff.Shopping/aggregator}/Controllers/BasketController.cs (100%) rename src/{Aggregators/Mobile.Shopping.HttpAggregator => ApiGateways/Mobile.Bff.Shopping/aggregator}/Controllers/HomeController.cs (100%) rename src/{Aggregators/Mobile.Shopping.HttpAggregator => ApiGateways/Mobile.Bff.Shopping/aggregator}/Controllers/OrderController.cs (100%) rename src/{Aggregators/Mobile.Shopping.HttpAggregator => ApiGateways/Mobile.Bff.Shopping/aggregator}/Dockerfile (87%) rename src/{Aggregators/Mobile.Shopping.HttpAggregator => ApiGateways/Mobile.Bff.Shopping/aggregator}/Filters/AuthorizeCheckOperationFilter.cs (100%) rename src/{Aggregators/Mobile.Shopping.HttpAggregator => ApiGateways/Mobile.Bff.Shopping/aggregator}/Mobile.Shopping.HttpAggregator.csproj (87%) rename src/{Aggregators/Mobile.Shopping.HttpAggregator => ApiGateways/Mobile.Bff.Shopping/aggregator}/Models/AddBasketItemRequest.cs (100%) rename src/{Aggregators/Mobile.Shopping.HttpAggregator => ApiGateways/Mobile.Bff.Shopping/aggregator}/Models/BasketData.cs (100%) rename src/{Aggregators/Mobile.Shopping.HttpAggregator => ApiGateways/Mobile.Bff.Shopping/aggregator}/Models/CatalogItem.cs (100%) rename src/{Aggregators/Mobile.Shopping.HttpAggregator => ApiGateways/Mobile.Bff.Shopping/aggregator}/Models/OrderData.cs (100%) rename src/{Aggregators/Mobile.Shopping.HttpAggregator => ApiGateways/Mobile.Bff.Shopping/aggregator}/Models/OrderItemData.cs (100%) rename src/{Aggregators/Mobile.Shopping.HttpAggregator => ApiGateways/Mobile.Bff.Shopping/aggregator}/Models/UpdateBasketItemsRequest.cs (100%) rename src/{Aggregators/Mobile.Shopping.HttpAggregator => ApiGateways/Mobile.Bff.Shopping/aggregator}/Models/UpdateBasketRequest.cs (100%) rename src/{Aggregators/Mobile.Shopping.HttpAggregator => ApiGateways/Mobile.Bff.Shopping/aggregator}/Program.cs (100%) rename src/{Aggregators/Mobile.Shopping.HttpAggregator => ApiGateways/Mobile.Bff.Shopping/aggregator}/Properties/launchSettings.json (100%) rename src/{Aggregators/Mobile.Shopping.HttpAggregator => ApiGateways/Mobile.Bff.Shopping/aggregator}/Services/BasketService.cs (100%) rename src/{Aggregators/Mobile.Shopping.HttpAggregator => ApiGateways/Mobile.Bff.Shopping/aggregator}/Services/CatalogService.cs (100%) rename src/{Aggregators/Mobile.Shopping.HttpAggregator => ApiGateways/Mobile.Bff.Shopping/aggregator}/Services/IBasketService.cs (100%) rename src/{Aggregators/Mobile.Shopping.HttpAggregator => ApiGateways/Mobile.Bff.Shopping/aggregator}/Services/ICatalogService.cs (100%) rename src/{Aggregators/Mobile.Shopping.HttpAggregator => ApiGateways/Mobile.Bff.Shopping/aggregator}/Services/IOrderApiClient.cs (100%) rename src/{Aggregators/Mobile.Shopping.HttpAggregator => ApiGateways/Mobile.Bff.Shopping/aggregator}/Services/OrderApiClient.cs (100%) rename src/{Aggregators/Mobile.Shopping.HttpAggregator => ApiGateways/Mobile.Bff.Shopping/aggregator}/Startup.cs (100%) rename src/{Aggregators/Mobile.Shopping.HttpAggregator => ApiGateways/Mobile.Bff.Shopping/aggregator}/appsettings.json (100%) rename src/{Aggregators/Mobile.Shopping.HttpAggregator => ApiGateways/Mobile.Bff.Shopping/aggregator}/appsettings.localhost.json (100%) rename src/{Apigw/configs/mobileshoppingapigw => ApiGateways/Mobile.Bff.Shopping/apigw}/configuration.json (100%) rename src/{Apigw/configs/webmarketingapigw => ApiGateways/Web.Bff.Marketing/apigw}/configuration.json (100%) rename src/{Aggregators/Web.Shopping.HttpAggregator => ApiGateways/Web.Bff.Shopping/aggregator}/Config/UrlsConfig.cs (100%) rename src/{Aggregators/Web.Shopping.HttpAggregator => ApiGateways/Web.Bff.Shopping/aggregator}/Controllers/BasketController.cs (100%) rename src/{Aggregators/Web.Shopping.HttpAggregator => ApiGateways/Web.Bff.Shopping/aggregator}/Controllers/HomeController.cs (100%) rename src/{Aggregators/Web.Shopping.HttpAggregator => ApiGateways/Web.Bff.Shopping/aggregator}/Controllers/OrderController.cs (100%) rename src/{Aggregators/Web.Shopping.HttpAggregator => ApiGateways/Web.Bff.Shopping/aggregator}/Dockerfile (87%) rename src/{Aggregators/Web.Shopping.HttpAggregator => ApiGateways/Web.Bff.Shopping/aggregator}/Filters/AuthorizeCheckOperationFilter.cs (100%) rename src/{Aggregators/Web.Shopping.HttpAggregator => ApiGateways/Web.Bff.Shopping/aggregator}/Models/AddBasketItemRequest.cs (100%) rename src/{Aggregators/Web.Shopping.HttpAggregator => ApiGateways/Web.Bff.Shopping/aggregator}/Models/BasketData.cs (100%) rename src/{Aggregators/Web.Shopping.HttpAggregator => ApiGateways/Web.Bff.Shopping/aggregator}/Models/CatalogItem.cs (100%) rename src/{Aggregators/Web.Shopping.HttpAggregator => ApiGateways/Web.Bff.Shopping/aggregator}/Models/OrderData.cs (100%) rename src/{Aggregators/Web.Shopping.HttpAggregator => ApiGateways/Web.Bff.Shopping/aggregator}/Models/OrderItemData.cs (100%) rename src/{Aggregators/Web.Shopping.HttpAggregator => ApiGateways/Web.Bff.Shopping/aggregator}/Models/UpdateBasketItemsRequest.cs (100%) rename src/{Aggregators/Web.Shopping.HttpAggregator => ApiGateways/Web.Bff.Shopping/aggregator}/Models/UpdateBasketRequest.cs (100%) rename src/{Aggregators/Web.Shopping.HttpAggregator => ApiGateways/Web.Bff.Shopping/aggregator}/Program.cs (100%) rename src/{Aggregators/Web.Shopping.HttpAggregator => ApiGateways/Web.Bff.Shopping/aggregator}/Properties/launchSettings.json (100%) rename src/{Aggregators/Web.Shopping.HttpAggregator => ApiGateways/Web.Bff.Shopping/aggregator}/Services/BasketService.cs (100%) rename src/{Aggregators/Web.Shopping.HttpAggregator => ApiGateways/Web.Bff.Shopping/aggregator}/Services/CatalogService.cs (100%) rename src/{Aggregators/Web.Shopping.HttpAggregator => ApiGateways/Web.Bff.Shopping/aggregator}/Services/IBasketService.cs (100%) rename src/{Aggregators/Web.Shopping.HttpAggregator => ApiGateways/Web.Bff.Shopping/aggregator}/Services/ICatalogService.cs (100%) rename src/{Aggregators/Web.Shopping.HttpAggregator => ApiGateways/Web.Bff.Shopping/aggregator}/Services/IOrderApiClient.cs (100%) rename src/{Aggregators/Web.Shopping.HttpAggregator => ApiGateways/Web.Bff.Shopping/aggregator}/Services/OrderApiClient.cs (100%) rename src/{Aggregators/Web.Shopping.HttpAggregator => ApiGateways/Web.Bff.Shopping/aggregator}/Startup.cs (100%) rename src/{Aggregators/Web.Shopping.HttpAggregator => ApiGateways/Web.Bff.Shopping/aggregator}/Web.Shopping.HttpAggregator.csproj (87%) rename src/{Aggregators/Web.Shopping.HttpAggregator => ApiGateways/Web.Bff.Shopping/aggregator}/appsettings.json (100%) rename src/{Aggregators/Web.Shopping.HttpAggregator => ApiGateways/Web.Bff.Shopping/aggregator}/appsettings.localhost.json (100%) rename src/{Apigw/configs/webshoppingapigw => ApiGateways/Web.Bff.Shopping/apigw}/configuration.json (100%) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 51284360a..dc01317a8 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -219,23 +219,23 @@ services: - "15672:15672" - "5672:5672" -# mobileshoppingapigw: -# environment: -# - ASPNETCORE_ENVIRONMENT=Development -# - IdentityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. -# ports: -# - "5200:80" -# volumes: -# - ./src/Apigw/configs/mobileshoppingapigw:/app/configuration -# -# mobilemarketingapigw: -# environment: -# - ASPNETCORE_ENVIRONMENT=Development -# - IdentityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. -# ports: -# - "5201:80" -# volumes: -# - ./src/Apigw/configs/mobilemarketingapigw:/app/configuration + mobileshoppingapigw: + environment: + - ASPNETCORE_ENVIRONMENT=Development + - IdentityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. + ports: + - "5200:80" + volumes: + - ./src/ApiGateways/Mobile.Bff.Shopping/apigw:/app/configuration + + mobilemarketingapigw: + environment: + - ASPNETCORE_ENVIRONMENT=Development + - IdentityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. + ports: + - "5201:80" + volumes: + - ./src/ApiGateways/Mobile.Bff.Marketing/apigw:/app/configuration webshoppingapigw: environment: @@ -244,16 +244,16 @@ services: ports: - "5202:80" volumes: - - ./src/Apigw/configs/webshoppingapigw:/app/configuration + - ./src/ApiGateways/Web.Bff.Shopping/apigw:/app/configuration -# webmarketingapigw: -# environment: -# - ASPNETCORE_ENVIRONMENT=Development -# - IdentityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. -# ports: -# - "5203:80" -# volumes: -# - ./src/Apigw/configs/webmarketingapigw:/app/configuration + webmarketingapigw: + environment: + - ASPNETCORE_ENVIRONMENT=Development + - IdentityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. + ports: + - "5203:80" + volumes: + - ./src/ApiGateways/Web.Bff.Marketing/apigw:/app/configuration mobileshoppingagg: environment: diff --git a/docker-compose.yml b/docker-compose.yml index 18372f23e..f1bd68076 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -108,39 +108,39 @@ services: rabbitmq: image: rabbitmq:3-management-alpine -# mobileshoppingapigw: -# image: eshop/ocelotapigw-ms -# build: -# context: . -# dockerfile: src/Apigw/OcelotApiGw/Dockerfile -# -# mobilemarketingapigw: -# image: eshop/ocelotapigw-mm -# build: -# context: . -# dockerfile: src/Apigw/OcelotApiGw/Dockerfile2 -# + mobileshoppingapigw: + image: eshop/ocelotapigw-ms + build: + context: . + dockerfile: src/ApiGateways/ApiGw-Base/Dockerfile + + mobilemarketingapigw: + image: eshop/ocelotapigw-mm + build: + context: . + dockerfile: src/ApiGateways/ApiGw-Base/Dockerfile2 + webshoppingapigw: image: eshop/ocelotapigw-ws build: context: . - dockerfile: src/Apigw/OcelotApiGw/Dockerfile3 + dockerfile: src/ApiGateways/ApiGw-Base/Dockerfile3 -# webmarketingapigw: -# image: eshop/ocelotapigw-wm -# build: -# context: . -# dockerfile: src/Apigw/OcelotApiGw/Dockerfile4 + webmarketingapigw: + image: eshop/ocelotapigw-wm + build: + context: . + dockerfile: src/ApiGateways/ApiGw-Base/Dockerfile mobileshoppingagg: image: eshop/mobileshoppingagg build: context: . - dockerfile: src/Aggregators/Mobile.Shopping.HttpAggregator/Dockerfile + dockerfile: src/ApiGateways/Mobile.Bff.Shopping/aggregator/Dockerfile webshoppingagg: image: eshop/webshoppingagg build: context: . - dockerfile: src/Aggregators/Web.Shopping.HttpAggregator/Dockerfile + dockerfile: src/ApiGateways/Web.Bff.Shopping/aggregator/Dockerfile diff --git a/eShopOnContainers-ServicesAndWebApps.sln b/eShopOnContainers-ServicesAndWebApps.sln index 2be8cf090..c1fe125a5 100644 --- a/eShopOnContainers-ServicesAndWebApps.sln +++ b/eShopOnContainers-ServicesAndWebApps.sln @@ -97,15 +97,35 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WebHost", "WebHost", "{1815 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebHost.Customization", "src\BuildingBlocks\WebHostCustomization\WebHost.Customization\WebHost.Customization.csproj", "{15F4B3AA-89B6-4A0D-9051-414305974781}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ApiGw", "ApiGw", "{7A58AA20-67F3-48F3-88C8-24EBFE621792}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ApiGateways", "ApiGateways", "{77849D35-37D4-4802-81DC-9477B2775A40}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OcelotApiGw", "src\Apigw\OcelotApiGw\OcelotApiGw.csproj", "{E0C5162E-DF26-4341-9E51-14AE800D7505}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ApiGw-Base", "ApiGw-Base", "{EC91ADE9-3D66-4AB2-9FB4-2B585E1F3531}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Aggregators", "Aggregators", "{EA378316-9D49-4A6B-858E-D4A25F948A74}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Mobile.Bff.Marketing", "Mobile.Bff.Marketing", "{DB813A36-11BA-41FE-B258-CA9A7152247B}" + ProjectSection(SolutionItems) = preProject + src\ApiGateways\Mobile.Bff.Marketing\apigw\configuration.json = src\ApiGateways\Mobile.Bff.Marketing\apigw\configuration.json + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Mobile.Bff.Shopping", "Mobile.Bff.Shopping", "{0189E4FB-6E2B-4F2E-9B1D-5473D23FC6DB}" + ProjectSection(SolutionItems) = preProject + src\ApiGateways\Mobile.Bff.Shopping\apigw\configuration.json = src\ApiGateways\Mobile.Bff.Shopping\apigw\configuration.json + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Web.Bff.Marketing", "Web.Bff.Marketing", "{F8F0921C-EE5D-4AED-A4D6-5BF5FAE02CB5}" + ProjectSection(SolutionItems) = preProject + src\ApiGateways\Web.Bff.Marketing\apigw\configuration.json = src\ApiGateways\Web.Bff.Marketing\apigw\configuration.json + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Web.Bff.Shopping", "Web.Bff.Shopping", "{28C0F5C8-4849-4035-80AB-45639424E73F}" + ProjectSection(SolutionItems) = preProject + src\ApiGateways\Web.Bff.Shopping\apigw\configuration.json = src\ApiGateways\Web.Bff.Shopping\apigw\configuration.json + EndProjectSection +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OcelotApiGw", "src\ApiGateways\ApiGw-Base\OcelotApiGw.csproj", "{3F79558C-485D-49E1-BD3E-E12538D3D308}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mobile.Shopping.HttpAggregator", "src\Aggregators\Mobile.Shopping.HttpAggregator\Mobile.Shopping.HttpAggregator.csproj", "{6E99F232-1536-424F-A28C-91692C8FD325}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mobile.Shopping.HttpAggregator", "src\ApiGateways\Mobile.Bff.Shopping\aggregator\Mobile.Shopping.HttpAggregator.csproj", "{BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Web.Shopping.HttpAggregator", "src\Aggregators\Web.Shopping.HttpAggregator\Web.Shopping.HttpAggregator.csproj", "{714CE0A1-E8BE-4CF1-8948-C1202E1526E2}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Web.Shopping.HttpAggregator", "src\ApiGateways\Web.Bff.Shopping\aggregator\Web.Shopping.HttpAggregator.csproj", "{AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -1321,150 +1341,150 @@ Global {15F4B3AA-89B6-4A0D-9051-414305974781}.Release|x64.Build.0 = Release|Any CPU {15F4B3AA-89B6-4A0D-9051-414305974781}.Release|x86.ActiveCfg = Release|Any CPU {15F4B3AA-89B6-4A0D-9051-414305974781}.Release|x86.Build.0 = Release|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Ad-Hoc|x64.Build.0 = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Ad-Hoc|x86.Build.0 = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.AppStore|Any CPU.Build.0 = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.AppStore|ARM.ActiveCfg = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.AppStore|ARM.Build.0 = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.AppStore|iPhone.ActiveCfg = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.AppStore|iPhone.Build.0 = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.AppStore|x64.ActiveCfg = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.AppStore|x64.Build.0 = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.AppStore|x86.ActiveCfg = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.AppStore|x86.Build.0 = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Debug|ARM.ActiveCfg = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Debug|ARM.Build.0 = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Debug|iPhone.ActiveCfg = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Debug|iPhone.Build.0 = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Debug|x64.ActiveCfg = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Debug|x64.Build.0 = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Debug|x86.ActiveCfg = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Debug|x86.Build.0 = Debug|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Release|Any CPU.Build.0 = Release|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Release|ARM.ActiveCfg = Release|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Release|ARM.Build.0 = Release|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Release|iPhone.ActiveCfg = Release|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Release|iPhone.Build.0 = Release|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Release|iPhoneSimulator.Build.0 = Release|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Release|x64.ActiveCfg = Release|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Release|x64.Build.0 = Release|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Release|x86.ActiveCfg = Release|Any CPU - {E0C5162E-DF26-4341-9E51-14AE800D7505}.Release|x86.Build.0 = Release|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Ad-Hoc|x64.Build.0 = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Ad-Hoc|x86.Build.0 = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.AppStore|Any CPU.Build.0 = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.AppStore|ARM.ActiveCfg = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.AppStore|ARM.Build.0 = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.AppStore|iPhone.ActiveCfg = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.AppStore|iPhone.Build.0 = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.AppStore|x64.ActiveCfg = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.AppStore|x64.Build.0 = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.AppStore|x86.ActiveCfg = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.AppStore|x86.Build.0 = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Debug|ARM.ActiveCfg = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Debug|ARM.Build.0 = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Debug|iPhone.ActiveCfg = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Debug|iPhone.Build.0 = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Debug|x64.ActiveCfg = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Debug|x64.Build.0 = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Debug|x86.ActiveCfg = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Debug|x86.Build.0 = Debug|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Release|Any CPU.Build.0 = Release|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Release|ARM.ActiveCfg = Release|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Release|ARM.Build.0 = Release|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Release|iPhone.ActiveCfg = Release|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Release|iPhone.Build.0 = Release|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Release|iPhoneSimulator.Build.0 = Release|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Release|x64.ActiveCfg = Release|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Release|x64.Build.0 = Release|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Release|x86.ActiveCfg = Release|Any CPU - {6E99F232-1536-424F-A28C-91692C8FD325}.Release|x86.Build.0 = Release|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Ad-Hoc|x64.Build.0 = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Ad-Hoc|x86.Build.0 = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.AppStore|Any CPU.Build.0 = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.AppStore|ARM.ActiveCfg = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.AppStore|ARM.Build.0 = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.AppStore|iPhone.ActiveCfg = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.AppStore|iPhone.Build.0 = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.AppStore|x64.ActiveCfg = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.AppStore|x64.Build.0 = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.AppStore|x86.ActiveCfg = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.AppStore|x86.Build.0 = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Debug|ARM.ActiveCfg = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Debug|ARM.Build.0 = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Debug|iPhone.ActiveCfg = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Debug|iPhone.Build.0 = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Debug|x64.ActiveCfg = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Debug|x64.Build.0 = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Debug|x86.ActiveCfg = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Debug|x86.Build.0 = Debug|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Release|Any CPU.Build.0 = Release|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Release|ARM.ActiveCfg = Release|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Release|ARM.Build.0 = Release|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Release|iPhone.ActiveCfg = Release|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Release|iPhone.Build.0 = Release|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Release|iPhoneSimulator.Build.0 = Release|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Release|x64.ActiveCfg = Release|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Release|x64.Build.0 = Release|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Release|x86.ActiveCfg = Release|Any CPU - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2}.Release|x86.Build.0 = Release|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Ad-Hoc|x64.Build.0 = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Ad-Hoc|x86.Build.0 = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.AppStore|Any CPU.Build.0 = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.AppStore|ARM.ActiveCfg = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.AppStore|ARM.Build.0 = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.AppStore|iPhone.ActiveCfg = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.AppStore|iPhone.Build.0 = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.AppStore|x64.ActiveCfg = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.AppStore|x64.Build.0 = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.AppStore|x86.ActiveCfg = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.AppStore|x86.Build.0 = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Debug|ARM.ActiveCfg = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Debug|ARM.Build.0 = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Debug|iPhone.Build.0 = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Debug|x64.ActiveCfg = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Debug|x64.Build.0 = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Debug|x86.ActiveCfg = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Debug|x86.Build.0 = Debug|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Release|Any CPU.Build.0 = Release|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Release|ARM.ActiveCfg = Release|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Release|ARM.Build.0 = Release|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Release|iPhone.ActiveCfg = Release|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Release|iPhone.Build.0 = Release|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Release|x64.ActiveCfg = Release|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Release|x64.Build.0 = Release|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Release|x86.ActiveCfg = Release|Any CPU + {3F79558C-485D-49E1-BD3E-E12538D3D308}.Release|x86.Build.0 = Release|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Ad-Hoc|x64.Build.0 = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Ad-Hoc|x86.Build.0 = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.AppStore|Any CPU.Build.0 = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.AppStore|ARM.ActiveCfg = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.AppStore|ARM.Build.0 = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.AppStore|iPhone.ActiveCfg = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.AppStore|iPhone.Build.0 = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.AppStore|x64.ActiveCfg = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.AppStore|x64.Build.0 = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.AppStore|x86.ActiveCfg = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.AppStore|x86.Build.0 = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Debug|ARM.ActiveCfg = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Debug|ARM.Build.0 = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Debug|iPhone.Build.0 = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Debug|x64.ActiveCfg = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Debug|x64.Build.0 = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Debug|x86.ActiveCfg = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Debug|x86.Build.0 = Debug|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Release|Any CPU.Build.0 = Release|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Release|ARM.ActiveCfg = Release|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Release|ARM.Build.0 = Release|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Release|iPhone.ActiveCfg = Release|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Release|iPhone.Build.0 = Release|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Release|x64.ActiveCfg = Release|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Release|x64.Build.0 = Release|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Release|x86.ActiveCfg = Release|Any CPU + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0}.Release|x86.Build.0 = Release|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Ad-Hoc|x64.Build.0 = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Ad-Hoc|x86.Build.0 = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.AppStore|Any CPU.Build.0 = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.AppStore|ARM.ActiveCfg = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.AppStore|ARM.Build.0 = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.AppStore|iPhone.ActiveCfg = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.AppStore|iPhone.Build.0 = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.AppStore|x64.ActiveCfg = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.AppStore|x64.Build.0 = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.AppStore|x86.ActiveCfg = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.AppStore|x86.Build.0 = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Debug|ARM.ActiveCfg = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Debug|ARM.Build.0 = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Debug|iPhone.Build.0 = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Debug|x64.ActiveCfg = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Debug|x64.Build.0 = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Debug|x86.ActiveCfg = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Debug|x86.Build.0 = Debug|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Release|Any CPU.Build.0 = Release|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Release|ARM.ActiveCfg = Release|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Release|ARM.Build.0 = Release|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Release|iPhone.ActiveCfg = Release|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Release|iPhone.Build.0 = Release|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Release|x64.ActiveCfg = Release|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Release|x64.Build.0 = Release|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Release|x86.ActiveCfg = Release|Any CPU + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1511,11 +1531,15 @@ Global {969E793C-C413-490E-9C9D-B2B46DA5AF32} = {EF0337F2-ED00-4643-89FD-EE10863F1870} {1815B651-941C-466B-AE33-D1D7EEB8F77F} = {DB0EFB20-B024-4E5E-A75C-52143C131D25} {15F4B3AA-89B6-4A0D-9051-414305974781} = {1815B651-941C-466B-AE33-D1D7EEB8F77F} - {7A58AA20-67F3-48F3-88C8-24EBFE621792} = {932D8224-11F6-4D07-B109-DA28AD288A63} - {E0C5162E-DF26-4341-9E51-14AE800D7505} = {7A58AA20-67F3-48F3-88C8-24EBFE621792} - {EA378316-9D49-4A6B-858E-D4A25F948A74} = {932D8224-11F6-4D07-B109-DA28AD288A63} - {6E99F232-1536-424F-A28C-91692C8FD325} = {EA378316-9D49-4A6B-858E-D4A25F948A74} - {714CE0A1-E8BE-4CF1-8948-C1202E1526E2} = {EA378316-9D49-4A6B-858E-D4A25F948A74} + {77849D35-37D4-4802-81DC-9477B2775A40} = {932D8224-11F6-4D07-B109-DA28AD288A63} + {EC91ADE9-3D66-4AB2-9FB4-2B585E1F3531} = {77849D35-37D4-4802-81DC-9477B2775A40} + {DB813A36-11BA-41FE-B258-CA9A7152247B} = {77849D35-37D4-4802-81DC-9477B2775A40} + {0189E4FB-6E2B-4F2E-9B1D-5473D23FC6DB} = {77849D35-37D4-4802-81DC-9477B2775A40} + {F8F0921C-EE5D-4AED-A4D6-5BF5FAE02CB5} = {77849D35-37D4-4802-81DC-9477B2775A40} + {28C0F5C8-4849-4035-80AB-45639424E73F} = {77849D35-37D4-4802-81DC-9477B2775A40} + {3F79558C-485D-49E1-BD3E-E12538D3D308} = {EC91ADE9-3D66-4AB2-9FB4-2B585E1F3531} + {BEA37D6D-4CF2-4AE8-9575-72388E54FBD0} = {0189E4FB-6E2B-4F2E-9B1D-5473D23FC6DB} + {AF0828DB-8BDD-411A-AEEF-B780FBB8D8C1} = {28C0F5C8-4849-4035-80AB-45639424E73F} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {25728519-5F0F-4973-8A64-0A81EB4EA8D9} diff --git a/src/Apigw/OcelotApiGw/Dockerfile b/src/ApiGateways/ApiGw-Base/Dockerfile similarity index 60% rename from src/Apigw/OcelotApiGw/Dockerfile rename to src/ApiGateways/ApiGw-Base/Dockerfile index aec2dc4e3..f0ff49f43 100644 --- a/src/Apigw/OcelotApiGw/Dockerfile +++ b/src/ApiGateways/ApiGw-Base/Dockerfile @@ -1,13 +1,14 @@ FROM microsoft/aspnetcore:2.0 AS base WORKDIR /app +ENV ESHOP_API_GW Mobile_Bff_Shopping_ApiGw EXPOSE 80 FROM microsoft/aspnetcore-build:2.0 AS build WORKDIR /src -COPY src/Apigw/OcelotApiGw/OcelotApiGw.csproj src/Apigw/OcelotApiGw/ -RUN dotnet restore src/Apigw/OcelotApiGw/ +COPY src/ApiGateways/ApiGw-Base/OcelotApiGw.csproj src/ApiGateways/ApiGw-Base/ +RUN dotnet restore src/ApiGateways/ApiGw-Base/ COPY . . -WORKDIR /src/src/Apigw/OcelotApiGw +WORKDIR /src/src/ApiGateways/ApiGw-Base/ RUN dotnet build -c Release -o /app FROM build AS publish diff --git a/src/Apigw/OcelotApiGw/Dockerfile2 b/src/ApiGateways/ApiGw-Base/Dockerfile2 similarity index 60% rename from src/Apigw/OcelotApiGw/Dockerfile2 rename to src/ApiGateways/ApiGw-Base/Dockerfile2 index aec2dc4e3..f127b33d1 100644 --- a/src/Apigw/OcelotApiGw/Dockerfile2 +++ b/src/ApiGateways/ApiGw-Base/Dockerfile2 @@ -1,13 +1,14 @@ FROM microsoft/aspnetcore:2.0 AS base WORKDIR /app +ENV ESHOP_API_GW Mobile_Bff_Marketing_ApiGw EXPOSE 80 FROM microsoft/aspnetcore-build:2.0 AS build WORKDIR /src -COPY src/Apigw/OcelotApiGw/OcelotApiGw.csproj src/Apigw/OcelotApiGw/ -RUN dotnet restore src/Apigw/OcelotApiGw/ +COPY src/ApiGateways/ApiGw-Base/OcelotApiGw.csproj src/ApiGateways/ApiGw-Base/ +RUN dotnet restore src/ApiGateways/ApiGw-Base/ COPY . . -WORKDIR /src/src/Apigw/OcelotApiGw +WORKDIR /src/src/ApiGateways/ApiGw-Base/ RUN dotnet build -c Release -o /app FROM build AS publish diff --git a/src/Apigw/OcelotApiGw/Dockerfile3 b/src/ApiGateways/ApiGw-Base/Dockerfile3 similarity index 61% rename from src/Apigw/OcelotApiGw/Dockerfile3 rename to src/ApiGateways/ApiGw-Base/Dockerfile3 index aec2dc4e3..aff6cc920 100644 --- a/src/Apigw/OcelotApiGw/Dockerfile3 +++ b/src/ApiGateways/ApiGw-Base/Dockerfile3 @@ -1,13 +1,14 @@ FROM microsoft/aspnetcore:2.0 AS base WORKDIR /app +ENV ESHOP_API_GW Web_Bff_Shopping_ApiGw EXPOSE 80 FROM microsoft/aspnetcore-build:2.0 AS build WORKDIR /src -COPY src/Apigw/OcelotApiGw/OcelotApiGw.csproj src/Apigw/OcelotApiGw/ -RUN dotnet restore src/Apigw/OcelotApiGw/ +COPY src/ApiGateways/ApiGw-Base/OcelotApiGw.csproj src/ApiGateways/ApiGw-Base/ +RUN dotnet restore src/ApiGateways/ApiGw-Base/ COPY . . -WORKDIR /src/src/Apigw/OcelotApiGw +WORKDIR /src/src/ApiGateways/ApiGw-Base/ RUN dotnet build -c Release -o /app FROM build AS publish diff --git a/src/Apigw/OcelotApiGw/Dockerfile4 b/src/ApiGateways/ApiGw-Base/Dockerfile4 similarity index 61% rename from src/Apigw/OcelotApiGw/Dockerfile4 rename to src/ApiGateways/ApiGw-Base/Dockerfile4 index aec2dc4e3..4686420d1 100644 --- a/src/Apigw/OcelotApiGw/Dockerfile4 +++ b/src/ApiGateways/ApiGw-Base/Dockerfile4 @@ -1,13 +1,14 @@ FROM microsoft/aspnetcore:2.0 AS base WORKDIR /app +ENV ESHOP_API_GW Web_Bff_Marketing_ApiGw EXPOSE 80 FROM microsoft/aspnetcore-build:2.0 AS build WORKDIR /src -COPY src/Apigw/OcelotApiGw/OcelotApiGw.csproj src/Apigw/OcelotApiGw/ -RUN dotnet restore src/Apigw/OcelotApiGw/ +COPY src/ApiGateways/ApiGw-Base/OcelotApiGw.csproj src/ApiGateways/ApiGw-Base/ +RUN dotnet restore src/ApiGateways/ApiGw-Base/ COPY . . -WORKDIR /src/src/Apigw/OcelotApiGw +WORKDIR /src/src/ApiGateways/ApiGw-Base/ RUN dotnet build -c Release -o /app FROM build AS publish diff --git a/src/Apigw/OcelotApiGw/OcelotApiGw.csproj b/src/ApiGateways/ApiGw-Base/OcelotApiGw.csproj similarity index 100% rename from src/Apigw/OcelotApiGw/OcelotApiGw.csproj rename to src/ApiGateways/ApiGw-Base/OcelotApiGw.csproj diff --git a/src/Apigw/OcelotApiGw/Program.cs b/src/ApiGateways/ApiGw-Base/Program.cs similarity index 100% rename from src/Apigw/OcelotApiGw/Program.cs rename to src/ApiGateways/ApiGw-Base/Program.cs diff --git a/src/Apigw/OcelotApiGw/Properties/launchSettings.json b/src/ApiGateways/ApiGw-Base/Properties/launchSettings.json similarity index 100% rename from src/Apigw/OcelotApiGw/Properties/launchSettings.json rename to src/ApiGateways/ApiGw-Base/Properties/launchSettings.json diff --git a/src/Apigw/OcelotApiGw/Startup.cs b/src/ApiGateways/ApiGw-Base/Startup.cs similarity index 100% rename from src/Apigw/OcelotApiGw/Startup.cs rename to src/ApiGateways/ApiGw-Base/Startup.cs diff --git a/src/Apigw/OcelotApiGw/appsettings.json b/src/ApiGateways/ApiGw-Base/appsettings.json similarity index 100% rename from src/Apigw/OcelotApiGw/appsettings.json rename to src/ApiGateways/ApiGw-Base/appsettings.json diff --git a/src/Apigw/configs/mobilemarketingapigw/configuration.json b/src/ApiGateways/Mobile.Bff.Marketing/apigw/configuration.json similarity index 100% rename from src/Apigw/configs/mobilemarketingapigw/configuration.json rename to src/ApiGateways/Mobile.Bff.Marketing/apigw/configuration.json diff --git a/src/Aggregators/Mobile.Shopping.HttpAggregator/Config/UrlsConfig.cs b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Config/UrlsConfig.cs similarity index 100% rename from src/Aggregators/Mobile.Shopping.HttpAggregator/Config/UrlsConfig.cs rename to src/ApiGateways/Mobile.Bff.Shopping/aggregator/Config/UrlsConfig.cs diff --git a/src/Aggregators/Mobile.Shopping.HttpAggregator/Controllers/BasketController.cs b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Controllers/BasketController.cs similarity index 100% rename from src/Aggregators/Mobile.Shopping.HttpAggregator/Controllers/BasketController.cs rename to src/ApiGateways/Mobile.Bff.Shopping/aggregator/Controllers/BasketController.cs diff --git a/src/Aggregators/Mobile.Shopping.HttpAggregator/Controllers/HomeController.cs b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Controllers/HomeController.cs similarity index 100% rename from src/Aggregators/Mobile.Shopping.HttpAggregator/Controllers/HomeController.cs rename to src/ApiGateways/Mobile.Bff.Shopping/aggregator/Controllers/HomeController.cs diff --git a/src/Aggregators/Mobile.Shopping.HttpAggregator/Controllers/OrderController.cs b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Controllers/OrderController.cs similarity index 100% rename from src/Aggregators/Mobile.Shopping.HttpAggregator/Controllers/OrderController.cs rename to src/ApiGateways/Mobile.Bff.Shopping/aggregator/Controllers/OrderController.cs diff --git a/src/Aggregators/Mobile.Shopping.HttpAggregator/Dockerfile b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Dockerfile similarity index 87% rename from src/Aggregators/Mobile.Shopping.HttpAggregator/Dockerfile rename to src/ApiGateways/Mobile.Bff.Shopping/aggregator/Dockerfile index 24df53c80..273743cee 100644 --- a/src/Aggregators/Mobile.Shopping.HttpAggregator/Dockerfile +++ b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Dockerfile @@ -6,7 +6,7 @@ FROM microsoft/aspnetcore-build:2.0 AS build WORKDIR /src COPY . . RUN dotnet restore -nowarn:msb3202,nu1503 -WORKDIR /src/src/Aggregators/Mobile.Shopping.HttpAggregator +WORKDIR /src/src/ApiGateways/Mobile.Bff.Shopping/aggregator RUN dotnet build --no-restore -c Release -o /app FROM build AS publish @@ -16,3 +16,4 @@ FROM base AS final WORKDIR /app COPY --from=publish /app . ENTRYPOINT ["dotnet", "Mobile.Shopping.HttpAggregator.dll"] + diff --git a/src/Aggregators/Mobile.Shopping.HttpAggregator/Filters/AuthorizeCheckOperationFilter.cs b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Filters/AuthorizeCheckOperationFilter.cs similarity index 100% rename from src/Aggregators/Mobile.Shopping.HttpAggregator/Filters/AuthorizeCheckOperationFilter.cs rename to src/ApiGateways/Mobile.Bff.Shopping/aggregator/Filters/AuthorizeCheckOperationFilter.cs diff --git a/src/Aggregators/Mobile.Shopping.HttpAggregator/Mobile.Shopping.HttpAggregator.csproj b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Mobile.Shopping.HttpAggregator.csproj similarity index 87% rename from src/Aggregators/Mobile.Shopping.HttpAggregator/Mobile.Shopping.HttpAggregator.csproj rename to src/ApiGateways/Mobile.Bff.Shopping/aggregator/Mobile.Shopping.HttpAggregator.csproj index 093e7a370..bd6d73950 100644 --- a/src/Aggregators/Mobile.Shopping.HttpAggregator/Mobile.Shopping.HttpAggregator.csproj +++ b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Mobile.Shopping.HttpAggregator.csproj @@ -21,7 +21,7 @@ - + diff --git a/src/Aggregators/Mobile.Shopping.HttpAggregator/Models/AddBasketItemRequest.cs b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Models/AddBasketItemRequest.cs similarity index 100% rename from src/Aggregators/Mobile.Shopping.HttpAggregator/Models/AddBasketItemRequest.cs rename to src/ApiGateways/Mobile.Bff.Shopping/aggregator/Models/AddBasketItemRequest.cs diff --git a/src/Aggregators/Mobile.Shopping.HttpAggregator/Models/BasketData.cs b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Models/BasketData.cs similarity index 100% rename from src/Aggregators/Mobile.Shopping.HttpAggregator/Models/BasketData.cs rename to src/ApiGateways/Mobile.Bff.Shopping/aggregator/Models/BasketData.cs diff --git a/src/Aggregators/Mobile.Shopping.HttpAggregator/Models/CatalogItem.cs b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Models/CatalogItem.cs similarity index 100% rename from src/Aggregators/Mobile.Shopping.HttpAggregator/Models/CatalogItem.cs rename to src/ApiGateways/Mobile.Bff.Shopping/aggregator/Models/CatalogItem.cs diff --git a/src/Aggregators/Mobile.Shopping.HttpAggregator/Models/OrderData.cs b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Models/OrderData.cs similarity index 100% rename from src/Aggregators/Mobile.Shopping.HttpAggregator/Models/OrderData.cs rename to src/ApiGateways/Mobile.Bff.Shopping/aggregator/Models/OrderData.cs diff --git a/src/Aggregators/Mobile.Shopping.HttpAggregator/Models/OrderItemData.cs b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Models/OrderItemData.cs similarity index 100% rename from src/Aggregators/Mobile.Shopping.HttpAggregator/Models/OrderItemData.cs rename to src/ApiGateways/Mobile.Bff.Shopping/aggregator/Models/OrderItemData.cs diff --git a/src/Aggregators/Mobile.Shopping.HttpAggregator/Models/UpdateBasketItemsRequest.cs b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Models/UpdateBasketItemsRequest.cs similarity index 100% rename from src/Aggregators/Mobile.Shopping.HttpAggregator/Models/UpdateBasketItemsRequest.cs rename to src/ApiGateways/Mobile.Bff.Shopping/aggregator/Models/UpdateBasketItemsRequest.cs diff --git a/src/Aggregators/Mobile.Shopping.HttpAggregator/Models/UpdateBasketRequest.cs b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Models/UpdateBasketRequest.cs similarity index 100% rename from src/Aggregators/Mobile.Shopping.HttpAggregator/Models/UpdateBasketRequest.cs rename to src/ApiGateways/Mobile.Bff.Shopping/aggregator/Models/UpdateBasketRequest.cs diff --git a/src/Aggregators/Mobile.Shopping.HttpAggregator/Program.cs b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Program.cs similarity index 100% rename from src/Aggregators/Mobile.Shopping.HttpAggregator/Program.cs rename to src/ApiGateways/Mobile.Bff.Shopping/aggregator/Program.cs diff --git a/src/Aggregators/Mobile.Shopping.HttpAggregator/Properties/launchSettings.json b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Properties/launchSettings.json similarity index 100% rename from src/Aggregators/Mobile.Shopping.HttpAggregator/Properties/launchSettings.json rename to src/ApiGateways/Mobile.Bff.Shopping/aggregator/Properties/launchSettings.json diff --git a/src/Aggregators/Mobile.Shopping.HttpAggregator/Services/BasketService.cs b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/BasketService.cs similarity index 100% rename from src/Aggregators/Mobile.Shopping.HttpAggregator/Services/BasketService.cs rename to src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/BasketService.cs diff --git a/src/Aggregators/Mobile.Shopping.HttpAggregator/Services/CatalogService.cs b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/CatalogService.cs similarity index 100% rename from src/Aggregators/Mobile.Shopping.HttpAggregator/Services/CatalogService.cs rename to src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/CatalogService.cs diff --git a/src/Aggregators/Mobile.Shopping.HttpAggregator/Services/IBasketService.cs b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/IBasketService.cs similarity index 100% rename from src/Aggregators/Mobile.Shopping.HttpAggregator/Services/IBasketService.cs rename to src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/IBasketService.cs diff --git a/src/Aggregators/Mobile.Shopping.HttpAggregator/Services/ICatalogService.cs b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/ICatalogService.cs similarity index 100% rename from src/Aggregators/Mobile.Shopping.HttpAggregator/Services/ICatalogService.cs rename to src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/ICatalogService.cs diff --git a/src/Aggregators/Mobile.Shopping.HttpAggregator/Services/IOrderApiClient.cs b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/IOrderApiClient.cs similarity index 100% rename from src/Aggregators/Mobile.Shopping.HttpAggregator/Services/IOrderApiClient.cs rename to src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/IOrderApiClient.cs diff --git a/src/Aggregators/Mobile.Shopping.HttpAggregator/Services/OrderApiClient.cs b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/OrderApiClient.cs similarity index 100% rename from src/Aggregators/Mobile.Shopping.HttpAggregator/Services/OrderApiClient.cs rename to src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/OrderApiClient.cs diff --git a/src/Aggregators/Mobile.Shopping.HttpAggregator/Startup.cs b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Startup.cs similarity index 100% rename from src/Aggregators/Mobile.Shopping.HttpAggregator/Startup.cs rename to src/ApiGateways/Mobile.Bff.Shopping/aggregator/Startup.cs diff --git a/src/Aggregators/Mobile.Shopping.HttpAggregator/appsettings.json b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/appsettings.json similarity index 100% rename from src/Aggregators/Mobile.Shopping.HttpAggregator/appsettings.json rename to src/ApiGateways/Mobile.Bff.Shopping/aggregator/appsettings.json diff --git a/src/Aggregators/Mobile.Shopping.HttpAggregator/appsettings.localhost.json b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/appsettings.localhost.json similarity index 100% rename from src/Aggregators/Mobile.Shopping.HttpAggregator/appsettings.localhost.json rename to src/ApiGateways/Mobile.Bff.Shopping/aggregator/appsettings.localhost.json diff --git a/src/Apigw/configs/mobileshoppingapigw/configuration.json b/src/ApiGateways/Mobile.Bff.Shopping/apigw/configuration.json similarity index 100% rename from src/Apigw/configs/mobileshoppingapigw/configuration.json rename to src/ApiGateways/Mobile.Bff.Shopping/apigw/configuration.json diff --git a/src/Apigw/configs/webmarketingapigw/configuration.json b/src/ApiGateways/Web.Bff.Marketing/apigw/configuration.json similarity index 100% rename from src/Apigw/configs/webmarketingapigw/configuration.json rename to src/ApiGateways/Web.Bff.Marketing/apigw/configuration.json diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Config/UrlsConfig.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/Config/UrlsConfig.cs similarity index 100% rename from src/Aggregators/Web.Shopping.HttpAggregator/Config/UrlsConfig.cs rename to src/ApiGateways/Web.Bff.Shopping/aggregator/Config/UrlsConfig.cs diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Controllers/BasketController.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/Controllers/BasketController.cs similarity index 100% rename from src/Aggregators/Web.Shopping.HttpAggregator/Controllers/BasketController.cs rename to src/ApiGateways/Web.Bff.Shopping/aggregator/Controllers/BasketController.cs diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Controllers/HomeController.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/Controllers/HomeController.cs similarity index 100% rename from src/Aggregators/Web.Shopping.HttpAggregator/Controllers/HomeController.cs rename to src/ApiGateways/Web.Bff.Shopping/aggregator/Controllers/HomeController.cs diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Controllers/OrderController.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/Controllers/OrderController.cs similarity index 100% rename from src/Aggregators/Web.Shopping.HttpAggregator/Controllers/OrderController.cs rename to src/ApiGateways/Web.Bff.Shopping/aggregator/Controllers/OrderController.cs diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Dockerfile b/src/ApiGateways/Web.Bff.Shopping/aggregator/Dockerfile similarity index 87% rename from src/Aggregators/Web.Shopping.HttpAggregator/Dockerfile rename to src/ApiGateways/Web.Bff.Shopping/aggregator/Dockerfile index 267cb233c..ce6f1b155 100644 --- a/src/Aggregators/Web.Shopping.HttpAggregator/Dockerfile +++ b/src/ApiGateways/Web.Bff.Shopping/aggregator/Dockerfile @@ -6,7 +6,7 @@ FROM microsoft/aspnetcore-build:2.0 AS build WORKDIR /src COPY . . RUN dotnet restore -nowarn:msb3202,nu1503 -WORKDIR /src/src/Aggregators/Web.Shopping.HttpAggregator +WORKDIR /src/src/ApiGateways/Web.Bff.Shopping/aggregator RUN dotnet build --no-restore -c Release -o /app FROM build AS publish diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Filters/AuthorizeCheckOperationFilter.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/Filters/AuthorizeCheckOperationFilter.cs similarity index 100% rename from src/Aggregators/Web.Shopping.HttpAggregator/Filters/AuthorizeCheckOperationFilter.cs rename to src/ApiGateways/Web.Bff.Shopping/aggregator/Filters/AuthorizeCheckOperationFilter.cs diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Models/AddBasketItemRequest.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/Models/AddBasketItemRequest.cs similarity index 100% rename from src/Aggregators/Web.Shopping.HttpAggregator/Models/AddBasketItemRequest.cs rename to src/ApiGateways/Web.Bff.Shopping/aggregator/Models/AddBasketItemRequest.cs diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Models/BasketData.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/Models/BasketData.cs similarity index 100% rename from src/Aggregators/Web.Shopping.HttpAggregator/Models/BasketData.cs rename to src/ApiGateways/Web.Bff.Shopping/aggregator/Models/BasketData.cs diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Models/CatalogItem.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/Models/CatalogItem.cs similarity index 100% rename from src/Aggregators/Web.Shopping.HttpAggregator/Models/CatalogItem.cs rename to src/ApiGateways/Web.Bff.Shopping/aggregator/Models/CatalogItem.cs diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Models/OrderData.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/Models/OrderData.cs similarity index 100% rename from src/Aggregators/Web.Shopping.HttpAggregator/Models/OrderData.cs rename to src/ApiGateways/Web.Bff.Shopping/aggregator/Models/OrderData.cs diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Models/OrderItemData.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/Models/OrderItemData.cs similarity index 100% rename from src/Aggregators/Web.Shopping.HttpAggregator/Models/OrderItemData.cs rename to src/ApiGateways/Web.Bff.Shopping/aggregator/Models/OrderItemData.cs diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Models/UpdateBasketItemsRequest.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/Models/UpdateBasketItemsRequest.cs similarity index 100% rename from src/Aggregators/Web.Shopping.HttpAggregator/Models/UpdateBasketItemsRequest.cs rename to src/ApiGateways/Web.Bff.Shopping/aggregator/Models/UpdateBasketItemsRequest.cs diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Models/UpdateBasketRequest.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/Models/UpdateBasketRequest.cs similarity index 100% rename from src/Aggregators/Web.Shopping.HttpAggregator/Models/UpdateBasketRequest.cs rename to src/ApiGateways/Web.Bff.Shopping/aggregator/Models/UpdateBasketRequest.cs diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Program.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/Program.cs similarity index 100% rename from src/Aggregators/Web.Shopping.HttpAggregator/Program.cs rename to src/ApiGateways/Web.Bff.Shopping/aggregator/Program.cs diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Properties/launchSettings.json b/src/ApiGateways/Web.Bff.Shopping/aggregator/Properties/launchSettings.json similarity index 100% rename from src/Aggregators/Web.Shopping.HttpAggregator/Properties/launchSettings.json rename to src/ApiGateways/Web.Bff.Shopping/aggregator/Properties/launchSettings.json diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Services/BasketService.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/Services/BasketService.cs similarity index 100% rename from src/Aggregators/Web.Shopping.HttpAggregator/Services/BasketService.cs rename to src/ApiGateways/Web.Bff.Shopping/aggregator/Services/BasketService.cs diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Services/CatalogService.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/Services/CatalogService.cs similarity index 100% rename from src/Aggregators/Web.Shopping.HttpAggregator/Services/CatalogService.cs rename to src/ApiGateways/Web.Bff.Shopping/aggregator/Services/CatalogService.cs diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Services/IBasketService.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/Services/IBasketService.cs similarity index 100% rename from src/Aggregators/Web.Shopping.HttpAggregator/Services/IBasketService.cs rename to src/ApiGateways/Web.Bff.Shopping/aggregator/Services/IBasketService.cs diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Services/ICatalogService.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/Services/ICatalogService.cs similarity index 100% rename from src/Aggregators/Web.Shopping.HttpAggregator/Services/ICatalogService.cs rename to src/ApiGateways/Web.Bff.Shopping/aggregator/Services/ICatalogService.cs diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Services/IOrderApiClient.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/Services/IOrderApiClient.cs similarity index 100% rename from src/Aggregators/Web.Shopping.HttpAggregator/Services/IOrderApiClient.cs rename to src/ApiGateways/Web.Bff.Shopping/aggregator/Services/IOrderApiClient.cs diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Services/OrderApiClient.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/Services/OrderApiClient.cs similarity index 100% rename from src/Aggregators/Web.Shopping.HttpAggregator/Services/OrderApiClient.cs rename to src/ApiGateways/Web.Bff.Shopping/aggregator/Services/OrderApiClient.cs diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Startup.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/Startup.cs similarity index 100% rename from src/Aggregators/Web.Shopping.HttpAggregator/Startup.cs rename to src/ApiGateways/Web.Bff.Shopping/aggregator/Startup.cs diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/Web.Shopping.HttpAggregator.csproj b/src/ApiGateways/Web.Bff.Shopping/aggregator/Web.Shopping.HttpAggregator.csproj similarity index 87% rename from src/Aggregators/Web.Shopping.HttpAggregator/Web.Shopping.HttpAggregator.csproj rename to src/ApiGateways/Web.Bff.Shopping/aggregator/Web.Shopping.HttpAggregator.csproj index fd04c8bee..0b6dbf44b 100644 --- a/src/Aggregators/Web.Shopping.HttpAggregator/Web.Shopping.HttpAggregator.csproj +++ b/src/ApiGateways/Web.Bff.Shopping/aggregator/Web.Shopping.HttpAggregator.csproj @@ -21,7 +21,7 @@ - + diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/appsettings.json b/src/ApiGateways/Web.Bff.Shopping/aggregator/appsettings.json similarity index 100% rename from src/Aggregators/Web.Shopping.HttpAggregator/appsettings.json rename to src/ApiGateways/Web.Bff.Shopping/aggregator/appsettings.json diff --git a/src/Aggregators/Web.Shopping.HttpAggregator/appsettings.localhost.json b/src/ApiGateways/Web.Bff.Shopping/aggregator/appsettings.localhost.json similarity index 100% rename from src/Aggregators/Web.Shopping.HttpAggregator/appsettings.localhost.json rename to src/ApiGateways/Web.Bff.Shopping/aggregator/appsettings.localhost.json diff --git a/src/Apigw/configs/webshoppingapigw/configuration.json b/src/ApiGateways/Web.Bff.Shopping/apigw/configuration.json similarity index 100% rename from src/Apigw/configs/webshoppingapigw/configuration.json rename to src/ApiGateways/Web.Bff.Shopping/apigw/configuration.json From 181b475e3222a51f297f061f5e742dc736da663e Mon Sep 17 00:00:00 2001 From: eiximenis Date: Wed, 28 Feb 2018 13:13:18 +0100 Subject: [PATCH 28/45] MVC adapted to marketing bff apigw --- docker-compose.override.yml | 3 +- .../apigw/configuration.json | 35 ++++++++++++++++++- src/Web/WebMVC/AppSettings.cs | 1 - src/Web/WebMVC/Services/CampaignService.cs | 2 +- src/Web/WebMVC/Services/LocationService.cs | 2 +- 5 files changed, 37 insertions(+), 6 deletions(-) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index dc01317a8..488868511 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -134,9 +134,8 @@ services: - ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_URLS=http://0.0.0.0:80 - PurchaseUrl=http://webshoppingapigw - - LocationsUrl=http://locations.api - IdentityUrl=http://10.0.75.1:5105 # Local Mac: Use http://docker.for.mac.localhost:5105 || Local Windows: Use 10.0.75.1 in a "Docker for Windows" environment, if using "localhost" from browser. || #Remote access: Use ${ESHOP_EXTERNAL_DNS_NAME_OR_IP} if using external IP or DNS name from browser. - - MarketingUrl=http://marketing.api + - MarketingUrl=http://webmarketingapigw - CatalogUrlHC=http://catalog.api/hc - OrderingUrlHC=http://ordering.api/hc - IdentityUrlHC=http://identity.api/hc #Local: Use ${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}, if using external IP or DNS name from browser. diff --git a/src/ApiGateways/Web.Bff.Marketing/apigw/configuration.json b/src/ApiGateways/Web.Bff.Marketing/apigw/configuration.json index 22fdca1b2..8afe4a4d6 100644 --- a/src/ApiGateways/Web.Bff.Marketing/apigw/configuration.json +++ b/src/ApiGateways/Web.Bff.Marketing/apigw/configuration.json @@ -1 +1,34 @@ -{} \ No newline at end of file +{ + "ReRoutes": [ + { + "DownstreamPathTemplate": "/api/{version}/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "marketing.api", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/api/{version}/m/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/api/{version}/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "locations.api", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/api/{version}/l/{everything}", + "UpstreamHttpMethod": [] + } + + ], + "GlobalConfiguration": { + "RequestIdKey": "OcRequestId", + "AdministrationPath": "/administration" + } +} + \ No newline at end of file diff --git a/src/Web/WebMVC/AppSettings.cs b/src/Web/WebMVC/AppSettings.cs index d235910b0..1f11e750e 100644 --- a/src/Web/WebMVC/AppSettings.cs +++ b/src/Web/WebMVC/AppSettings.cs @@ -9,7 +9,6 @@ namespace Microsoft.eShopOnContainers.WebMVC { public Connectionstrings ConnectionStrings { get; set; } public string MarketingUrl { get; set; } - public string LocationsUrl { get; set; } public string PurchaseUrl { get; set; } public bool ActivateCampaignDetailFunction { get; set; } diff --git a/src/Web/WebMVC/Services/CampaignService.cs b/src/Web/WebMVC/Services/CampaignService.cs index 6190e74d6..7d61c9e7a 100644 --- a/src/Web/WebMVC/Services/CampaignService.cs +++ b/src/Web/WebMVC/Services/CampaignService.cs @@ -26,7 +26,7 @@ _apiClient = httpClient; _logger = logger; - _remoteServiceBaseUrl = $"{_settings.Value.MarketingUrl}/api/v1/campaigns/"; + _remoteServiceBaseUrl = $"{_settings.Value.MarketingUrl}/api/v1/m/campaigns/"; _httpContextAccesor = httpContextAccesor ?? throw new ArgumentNullException(nameof(httpContextAccesor)); } diff --git a/src/Web/WebMVC/Services/LocationService.cs b/src/Web/WebMVC/Services/LocationService.cs index 652484f4b..8bbdf743a 100644 --- a/src/Web/WebMVC/Services/LocationService.cs +++ b/src/Web/WebMVC/Services/LocationService.cs @@ -27,7 +27,7 @@ namespace WebMVC.Services _apiClient = httpClient; _logger = logger; - _remoteServiceBaseUrl = $"{_settings.Value.LocationsUrl}/api/v1/locations/"; + _remoteServiceBaseUrl = $"{_settings.Value.MarketingUrl}/api/v1/l/locations/"; _httpContextAccesor = httpContextAccesor ?? throw new ArgumentNullException(nameof(httpContextAccesor)); } From a34ed284458b631f2fc015dd9ff2948e0bbb6a48 Mon Sep 17 00:00:00 2001 From: eiximenis Date: Wed, 28 Feb 2018 15:40:22 +0100 Subject: [PATCH 29/45] SPA adapted to gateway --- docker-compose.override.yml | 3 +-- src/Web/WebSPA/Client/modules/campaigns/campaigns.service.ts | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 488868511..e656f753f 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -114,9 +114,8 @@ services: - ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_URLS=http://0.0.0.0:80 - IdentityUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105 #Local: You need to open your local dev-machine firewall at range 5100-5105. at range 5100-5105. - - MarketingUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5110 - - LocationsUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5109 - PurchaseUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5202 + - MarketingUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5203 - CatalogUrlHC=http://catalog.api/hc - OrderingUrlHC=http://ordering.api/hc - IdentityUrlHC=http://identity.api/hc #Local: Use ${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}, if using external IP or DNS name from browser. diff --git a/src/Web/WebSPA/Client/modules/campaigns/campaigns.service.ts b/src/Web/WebSPA/Client/modules/campaigns/campaigns.service.ts index bd1678f44..2a8973322 100644 --- a/src/Web/WebSPA/Client/modules/campaigns/campaigns.service.ts +++ b/src/Web/WebSPA/Client/modules/campaigns/campaigns.service.ts @@ -33,7 +33,7 @@ export class CampaignsService { } getCampaigns(pageIndex: number, pageSize: number): Observable { - let url = this.marketingUrl + '/api/v1/campaigns/user'; + let url = this.marketingUrl + '/api/v1/m/campaigns/user'; url = url + '?pageIndex=' + pageIndex + '&pageSize=' + pageSize; return this.service.get(url).map((response: Response) => { @@ -42,7 +42,7 @@ export class CampaignsService { } getCampaign(id: number): Observable { - let url = this.marketingUrl + '/api/v1/campaigns/' + id; + let url = this.marketingUrl + '/api/v1/m/campaigns/' + id; return this.service.get(url).map((response: Response) => { return response.json(); From 5bb67596b9f7059ee9155d99ce614047a5ce5401 Mon Sep 17 00:00:00 2001 From: eiximenis Date: Wed, 14 Mar 2018 18:25:26 +0100 Subject: [PATCH 30/45] k8s config updated --- docker-compose.yml | 12 +- k8s/conf_cloud.yml | 14 +- k8s/conf_local.yml | 37 +- k8s/deploy.ps1 | 68 ++- k8s/deployments.yaml | 440 +++++++++--------- k8s/ingress.yaml | 46 +- k8s/internalurls.yaml | 31 ++ .../configuration-mobile-marketing.json | 34 ++ k8s/ocelot/configuration-mobile-shopping.json | 142 ++++++ k8s/ocelot/configuration-web-marketing.json | 34 ++ k8s/ocelot/configuration-web-shopping.json | 142 ++++++ k8s/ocelot/configuration.json | 58 --- k8s/ocelot/deployment.yaml | 136 +++++- k8s/ocelot/service.yaml | 48 +- src/ApiGateways/ApiGw-Base/Startup.cs | 6 + .../apigw/configuration.json | 35 +- .../apigw/configuration.json | 143 +++++- 17 files changed, 1046 insertions(+), 380 deletions(-) create mode 100644 k8s/internalurls.yaml create mode 100644 k8s/ocelot/configuration-mobile-marketing.json create mode 100644 k8s/ocelot/configuration-mobile-shopping.json create mode 100644 k8s/ocelot/configuration-web-marketing.json create mode 100644 k8s/ocelot/configuration-web-shopping.json delete mode 100644 k8s/ocelot/configuration.json diff --git a/docker-compose.yml b/docker-compose.yml index f1bd68076..39a0217be 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -109,37 +109,37 @@ services: image: rabbitmq:3-management-alpine mobileshoppingapigw: - image: eshop/ocelotapigw-ms + image: eshop/ocelotapigw-ms:${TAG:-latest} build: context: . dockerfile: src/ApiGateways/ApiGw-Base/Dockerfile mobilemarketingapigw: - image: eshop/ocelotapigw-mm + image: eshop/ocelotapigw-mm:${TAG:-latest} build: context: . dockerfile: src/ApiGateways/ApiGw-Base/Dockerfile2 webshoppingapigw: - image: eshop/ocelotapigw-ws + image: eshop/ocelotapigw-ws:${TAG:-latest} build: context: . dockerfile: src/ApiGateways/ApiGw-Base/Dockerfile3 webmarketingapigw: - image: eshop/ocelotapigw-wm + image: eshop/ocelotapigw-wm:${TAG:-latest} build: context: . dockerfile: src/ApiGateways/ApiGw-Base/Dockerfile mobileshoppingagg: - image: eshop/mobileshoppingagg + image: eshop/mobileshoppingagg:${TAG:-latest} build: context: . dockerfile: src/ApiGateways/Mobile.Bff.Shopping/aggregator/Dockerfile webshoppingagg: - image: eshop/webshoppingagg + image: eshop/webshoppingagg:${TAG:-latest} build: context: . dockerfile: src/ApiGateways/Web.Bff.Shopping/aggregator/Dockerfile diff --git a/k8s/conf_cloud.yml b/k8s/conf_cloud.yml index 0f079fd3f..891de14bc 100644 --- a/k8s/conf_cloud.yml +++ b/k8s/conf_cloud.yml @@ -4,13 +4,11 @@ metadata: name: externalcfg labels: app: eshop -data: +data: # Basket.API entries - BasketBus: CONNECTION_STRING (NAME OF RABBITMQ CONTAINER OR Endpoint=sb://XXXX in case of using Azure) - BasketRedisConStr: REDIS CONNECTION STRING FOR BASKET + basket__ConnectionString: REDIS CONNECTION STRING FOR BASKET # Catalog.API entries - CatalogBus: CONNECTION_STRING (NAME OF RABBITMQ CONTAINER OR Endpoint=sb://XXXX in case of using Azure) - CatalogSqlDb: Catalog SQL SERVER CONNECTION STRING (Server=xxxx;Intial Catalog=yyy;....) + catalog__ConnectionString: Catalog SQL SERVER CONNECTION STRING (Server=xxxx;Intial Catalog=yyy;....) # Identity.API entries IdentitySqlDb: Identity SQL SERVER CONNECTION STRING (Server=xxxx;Intial Catalog=yyy;....) # Locations.API entries @@ -30,5 +28,7 @@ data: # Payment.API entries PaymentBus: CONNECTION_STRING (NAME OF RABBITMQ CONTAINER OR Endpoint=sb://XXXX in case of using Azure) # Global entries - UseAzureServiceBus: "TRUE" IF USE AZURE SB ("FALSE" FOR USING RABBITMQ) - keystore: REDIS CONNECTION STRING FOR KEYSTORE \ No newline at end of file + all_UseAzureServiceBus: "TRUE" IF USE AZURE SB ("FALSE" FOR USING RABBITMQ) + keystore: REDIS CONNECTION STRING FOR KEYSTORE + all_EventBusConnection: CONNECTION_STRING (NAME OF RABBITMQ CONTAINER OR Endpoint=sb://XXXX in case of using Azure) + all_InstrumentationKey: APPINSIGHTS KEY \ No newline at end of file diff --git a/k8s/conf_local.yml b/k8s/conf_local.yml index 9a2059e63..615754bcf 100644 --- a/k8s/conf_local.yml +++ b/k8s/conf_local.yml @@ -5,28 +5,23 @@ metadata: labels: app: eshop data: - BasketBus: rabbitmq - BasketRedisConStr: basket-data - CatalogBus: rabbitmq - CatalogSqlDb: Server=sql-data;Initial Catalog=Microsoft.eShopOnContainers.Services.CatalogDb;User Id=sa;Password=Pass@word; - CatalogAzureStorageEnabled: "False" - IdentitySqlDb: Server=sql-data;Initial Catalog=Microsoft.eShopOnContainers.Services.IdentityDb;User Id=sa;Password=Pass@word; - LocationsBus: rabbitmq - LocationsNoSqlDb: mongodb://nosql-data - LocationsNoSqlDbName: LocationsDb - MarketingBus: rabbitmq - MarketingNoSqlDb: mongodb://nosql-data - MarketingNoSqlDbName: MarketingDb - MarketingSqlDb: Server=sql-data;Initial Catalog=Microsoft.eShopOnContainers.Services.MarketingDb;User Id=sa;Password=Pass@word; - OrderingBus: rabbitmq - OrderingSqlDb: Server=sql-data;Initial Catalog=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word; - PaymentBus: rabbitmq - UseAzureServiceBus: "False" - EnableLoadTest: "False" + basket__ConnectionString: basket-data + catalog__ConnectionString: Server=sql-data;Initial Catalog=Microsoft.eShopOnContainers.Services.CatalogDb;User Id=sa;Password=Pass@word; + catalog__AzureStorageEnabled: "False" + identity__ConnectionString: Server=sql-data;Initial Catalog=Microsoft.eShopOnContainers.Services.IdentityDb;User Id=sa;Password=Pass@word; + locations__ConnectionString: mongodb://nosql-data + locations__Database: LocationsDb + marketing__MongoConnectionString: mongodb://nosql-data + marketing__MongoDatabase: MarketingDb + marketing__ConnectionString: Server=sql-data;Initial Catalog=Microsoft.eShopOnContainers.Services.MarketingDb;User Id=sa;Password=Pass@word; + ordering__ConnectionString: Server=sql-data;Initial Catalog=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word; keystore: keystore-data - GracePeriodManager_GracePeriodTime: "1" - GracePeriodManager_CheckUpdateTime: "15000" - Instrumentation_Key: "" + GracePeriodManager__GracePeriodTime: "1" + GracePeriodManager__CheckUpdateTime: "15000" + all__EventBusConnection: rabbitmq + all__InstrumentationKey: "" + all__EnableLoadTest: "False" + all__UseAzureServiceBus: "False" diff --git a/k8s/deploy.ps1 b/k8s/deploy.ps1 index 3d9c54b5c..1ac5a2770 100644 --- a/k8s/deploy.ps1 +++ b/k8s/deploy.ps1 @@ -65,7 +65,7 @@ if ($buildImages) { docker-compose -p .. -f ../docker-compose.yml build Write-Host "Pushing images to $registry/$dockerOrg..." -ForegroundColor Yellow - $services = ("basket.api", "catalog.api", "identity.api", "ordering.api", "marketing.api","payment.api","locations.api", "webmvc", "webspa", "webstatus", "ocelotapigw") + $services = ("basket.api", "catalog.api", "identity.api", "ordering.api", "marketing.api","payment.api","locations.api", "webmvc", "webspa", "webstatus", "ocelotapigw-mm", "ocelotapigw-ms", "ocelotapigw-wm", "ocelotapigw-ws", "mobileshoppingagg", "webshoppingagg") foreach ($service in $services) { $imageFqdn = if ($useDockerHub) {"$dockerOrg/${service}"} else {"$registry/$dockerOrg/${service}"} @@ -103,6 +103,7 @@ if (-not [string]::IsNullOrEmpty($dockerUser)) { Write-Host "Removing existing services & deployments.." -ForegroundColor Yellow ExecKube -cmd 'delete deployments --all' ExecKube -cmd 'delete services --all' +ExecKube -cmd 'delete configmap internalurls' ExecKube -cmd 'delete configmap urls' ExecKube -cmd 'delete configmap externalcfg' ExecKube -cmd 'delete configmap ocelot' @@ -116,47 +117,28 @@ if ($deployInfrastructure) { Write-Host 'Deploying ocelot APIGW' -ForegroundColor Yellow -ExecKube "create configmap ocelot --from-file=ocelot/configuration.json" +ExecKube "create configmap ocelot --from-file=mm=ocelot/configuration-mobile-marketing.json --from-file=ms=ocelot/configuration-mobile-shopping.json --from-file=wm=ocelot/configuration-web-marketing.json --from-file=ws=ocelot/configuration-web-shopping.json " ExecKube -cmd "apply -f ocelot/deployment.yaml" ExecKube -cmd "apply -f ocelot/service.yaml" Write-Host 'Deploying code deployments (Web APIs, Web apps, ...)' -ForegroundColor Yellow ExecKube -cmd 'create -f services.yaml' +ExecKube -cmd 'create -f internalurls.yaml' ExecKube -cmd 'create configmap urls ` - --from-literal=BasketUrl=http://basket ` - --from-literal=BasketHealthCheckUrl=http://basket/hc ` - --from-literal=CatalogUrl=http://$($externalDns)/catalog-api ` - --from-literal=CatalogHealthCheckUrl=http://catalog/hc ` - --from-literal=PicBaseUrl=http://$($externalDns)/catalog-api/api/v1/catalog/items/[0]/pic/ ` - --from-literal=Marketing_PicBaseUrl=http://$($externalDns)/marketing-api/api/v1/campaigns/[0]/pic/ ` - --from-literal=IdentityUrl=http://$($externalDns)/identity ` - --from-literal=IdentityHealthCheckUrl=http://identity/hc ` - --from-literal=OrderingUrl=http://ordering ` - --from-literal=OrderingHealthCheckUrl=http://ordering/hc ` - --from-literal=MvcClientExternalUrl=http://$($externalDns)/webmvc ` - --from-literal=WebMvcHealthCheckUrl=http://webmvc/hc ` - --from-literal=MvcClientOrderingUrl=http://ordering ` - --from-literal=MvcClientCatalogUrl=http://catalog ` - --from-literal=MvcClientBasketUrl=http://basket ` - --from-literal=MvcClientMarketingUrl=http://marketing ` - --from-literal=MvcClientLocationsUrl=http://locations ` - --from-literal=MarketingHealthCheckUrl=http://marketing/hc ` - --from-literal=WebSpaHealthCheckUrl=http://webspa/hc ` - --from-literal=SpaClientMarketingExternalUrl=http://$($externalDns)/marketing-api ` - --from-literal=SpaClientOrderingExternalUrl=http://$($externalDns)/ordering-api ` - --from-literal=SpaClientCatalogExternalUrl=http://$($externalDns)/catalog-api ` - --from-literal=SpaClientBasketExternalUrl=http://$($externalDns)/basket-api ` - --from-literal=SpaClientIdentityExternalUrl=http://$($externalDns)/identity ` - --from-literal=SpaClientLocationsUrl=http://$($externalDns)/locations-api ` - --from-literal=LocationsHealthCheckUrl=http://locations/hc ` - --from-literal=SpaClientExternalUrl=http://$($externalDns) ` - --from-literal=LocationApiClient=http://$($externalDns)/locations-api ` - --from-literal=MarketingApiClient=http://$($externalDns)/marketing-api ` - --from-literal=BasketApiClient=http://$($externalDns)/basket-api ` - --from-literal=OrderingApiClient=http://$($externalDns)/ordering-api ` - --from-literal=PaymentHealthCheckUrl=http://payment/hc' - + --from-literal=PicBaseUrl=http://$($externalDns)/webshoppingapigw/api/v1/c/catalog/items/[0]/pic/ ` + --from-literal=Marketing_PicBaseUrl=http://$($externalDns)/webmarketingapigw/api/v1/m/campaigns/[0]/pic/ ` + --from-literal=mvc_e=http://$($externalDns)/webmvc ` + --from-literal=marketingapigw_e=http://$($externalDns)/webmarketingapigw ` + --from-literal=webshoppingapigw_e=http://$($externalDns)/webshoppingapigw ` + --from-literal=mobileshoppingagg_e=http://$($externalDns)/mobileshoppingagg ` + --from-literal=webshoppingagg_e=http://$($externalDns)/webshoppingagg ` + --from-literal=identity_e=http://$($externalDns)/identity ` + --from-literal=spa_e=http://$($externalDns) ` + --from-literal=locations_e=http://$($externalDns)/locations-api ` + --from-literal=marketing_e=http://$($externalDns)/marketing-api ` + --from-literal=basket_e=http://$($externalDns)/basket-api ` + --from-literal=ordering_e=http://$($externalDns)/ordering-api ' ExecKube -cmd 'label configmap urls app=eshop' @@ -184,7 +166,14 @@ ExecKube -cmd 'set image deployments/payment payment=${registryPath}${dockerOrg} ExecKube -cmd 'set image deployments/webmvc webmvc=${registryPath}${dockerOrg}/webmvc:$imageTag' ExecKube -cmd 'set image deployments/webstatus webstatus=${registryPath}${dockerOrg}/webstatus:$imageTag' ExecKube -cmd 'set image deployments/webspa webspa=${registryPath}${dockerOrg}/webspa:$imageTag' -ExecKube -cmd 'set image deployments/ocelot ocelot=${registryPath}${dockerOrg}/ocelotapigw:$imageTag' + +ExecKube -cmd 'set image deployments/mobileshoppingagg mobileshoppingagg=${registryPath}${dockerOrg}/mobileshoppingagg:$imageTag' +ExecKube -cmd 'set image deployments/webshoppingagg webshoppingagg=${registryPath}${dockerOrg}/webshoppingagg:$imageTag' + +ExecKube -cmd 'set image deployments/apigwmm apigwmm=${registryPath}${dockerOrg}/ocelotapigw-mm:$imageTag' +ExecKube -cmd 'set image deployments/apigwms apigwms=${registryPath}${dockerOrg}/ocelotapigw-ms:$imageTag' +ExecKube -cmd 'set image deployments/apigwwm apigwwm=${registryPath}${dockerOrg}/ocelotapigw-wm:$imageTag' +ExecKube -cmd 'set image deployments/apigwws apigwws=${registryPath}${dockerOrg}/ocelotapigw-ws:$imageTag' Write-Host "Execute rollout..." -ForegroundColor Yellow ExecKube -cmd 'rollout resume deployments/basket' @@ -197,7 +186,12 @@ ExecKube -cmd 'rollout resume deployments/payment' ExecKube -cmd 'rollout resume deployments/webmvc' ExecKube -cmd 'rollout resume deployments/webstatus' ExecKube -cmd 'rollout resume deployments/webspa' -ExecKube -cmd 'rollout resume deployments/ocelot' +ExecKube -cmd 'rollout resume deployments/mobileshoppingagg' +ExecKube -cmd 'rollout resume deployments/webshoppingagg' +ExecKube -cmd 'rollout resume deployments/apigwmm' +ExecKube -cmd 'rollout resume deployments/apigwms' +ExecKube -cmd 'rollout resume deployments/apigwwm' +ExecKube -cmd 'rollout resume deployments/apigwws' Write-Host "WebSPA is exposed at http://$externalDns, WebMVC at http://$externalDns/webmvc, WebStatus at http://$externalDns/webstatus" -ForegroundColor Yellow diff --git a/k8s/deployments.yaml b/k8s/deployments.yaml index 9935b83d7..10007fe4c 100644 --- a/k8s/deployments.yaml +++ b/k8s/deployments.yaml @@ -21,32 +21,32 @@ spec: valueFrom: configMapKeyRef: name: externalcfg - key: BasketRedisConStr + key: basket__ConnectionString - name: EventBusConnection valueFrom: configMapKeyRef: name: externalcfg - key: BasketBus + key: all__EventBusConnection - name: AzureServiceBusEnabled valueFrom: configMapKeyRef: name: externalcfg - key: UseAzureServiceBus + key: all__UseAzureServiceBus - name: ApplicationInsights__InstrumentationKey valueFrom: configMapKeyRef: name: externalcfg - key: Instrumentation_Key + key: all__InstrumentationKey - name: IdentityUrl valueFrom: configMapKeyRef: name: urls - key: IdentityUrl + key: identity_e - name: UseLoadTest valueFrom: configMapKeyRef: name: externalcfg - key: EnableLoadTest + key: all__EnableLoadTest - name: OrchestratorType value: 'K8S' ports: @@ -56,15 +56,8 @@ spec: path: /hc port: 80 scheme: HTTP - initialDelaySeconds: 5 - periodSeconds: 10 - livenessProbe: - httpGet: - path: /hc - port: 80 - scheme: HTTP - initialDelaySeconds: 60 - periodSeconds: 10 + initialDelaySeconds: 300 + periodSeconds: 240 imagePullSecrets: - name: registry-key --- @@ -91,7 +84,7 @@ spec: valueFrom: configMapKeyRef: name: externalcfg - key: CatalogSqlDb + key: catalog__ConnectionString - name: PicBaseUrl valueFrom: configMapKeyRef: @@ -101,17 +94,17 @@ spec: valueFrom: configMapKeyRef: name: externalcfg - key: CatalogAzureStorageEnabled + key: catalog__AzureStorageEnabled - name: EventBusConnection valueFrom: configMapKeyRef: name: externalcfg - key: CatalogBus + key: all__EventBusConnection - name: ApplicationInsights__InstrumentationKey valueFrom: configMapKeyRef: name: externalcfg - key: Instrumentation_Key + key: all__InstrumentationKey - name: OrchestratorType value: 'K8S' ports: @@ -121,15 +114,8 @@ spec: path: /hc port: 80 scheme: HTTP - initialDelaySeconds: 5 - periodSeconds: 10 - livenessProbe: - httpGet: - path: /hc - port: 80 - scheme: HTTP - initialDelaySeconds: 60 - periodSeconds: 10 + initialDelaySeconds: 300 + periodSeconds: 240 imagePullSecrets: - name: registry-key --- @@ -156,7 +142,7 @@ spec: valueFrom: configMapKeyRef: name: externalcfg - key: IdentitySqlDb + key: identity__ConnectionString - name: DPConnectionString valueFrom: configMapKeyRef: @@ -168,37 +154,47 @@ spec: valueFrom: configMapKeyRef: name: urls - key: MvcClientExternalUrl + key: mvc_e - name: SpaClient valueFrom: configMapKeyRef: name: urls - key: SpaClientExternalUrl + key: spa_e - name: LocationApiClient valueFrom: configMapKeyRef: name: urls - key: LocationApiClient + key: locations_e - name: MarketingApiClient valueFrom: configMapKeyRef: name: urls - key: MarketingApiClient + key: marketing_e - name: BasketApiClient valueFrom: configMapKeyRef: name: urls - key: BasketApiClient + key: basket_e - name: OrderingApiClient valueFrom: configMapKeyRef: name: urls - key: OrderingApiClient + key: ordering_e + - name: MobileShoppingAggClient + valueFrom: + configMapKeyRef: + name: urls + key: mobileshoppingagg_e + - name: WebShoppingAggClient + valueFrom: + configMapKeyRef: + name: urls + key: webshoppingagg_e - name: ApplicationInsights__InstrumentationKey valueFrom: configMapKeyRef: name: externalcfg - key: Instrumentation_Key + key: all__InstrumentationKey - name: OrchestratorType value: 'K8S' ports: @@ -208,15 +204,8 @@ spec: path: /hc port: 80 scheme: HTTP - initialDelaySeconds: 5 - periodSeconds: 10 - livenessProbe: - httpGet: - path: /hc - port: 80 - scheme: HTTP - initialDelaySeconds: 60 - periodSeconds: 10 + initialDelaySeconds: 300 + periodSeconds: 240 imagePullSecrets: - name: registry-key --- @@ -243,42 +232,42 @@ spec: valueFrom: configMapKeyRef: name: externalcfg - key: OrderingSqlDb + key: ordering__ConnectionString - name: EventBusConnection valueFrom: configMapKeyRef: name: externalcfg - key: OrderingBus + key: all__EventBusConnection - name: AzureServiceBusEnabled valueFrom: configMapKeyRef: name: externalcfg - key: UseAzureServiceBus + key: all__UseAzureServiceBus - name: IdentityUrl valueFrom: configMapKeyRef: name: urls - key: IdentityUrl + key: identity_e - name: CheckUpdateTime valueFrom: configMapKeyRef: name: externalcfg - key: GracePeriodManager_CheckUpdateTime + key: GracePeriodManager__CheckUpdateTime - name: GracePeriodTime valueFrom: configMapKeyRef: name: externalcfg - key: GracePeriodManager_GracePeriodTime + key: GracePeriodManager__GracePeriodTime - name: ApplicationInsights__InstrumentationKey valueFrom: configMapKeyRef: name: externalcfg - key: Instrumentation_Key + key: all__InstrumentationKey - name: UseLoadTest valueFrom: configMapKeyRef: name: externalcfg - key: EnableLoadTest + key: all__EnableLoadTest - name: OrchestratorType value: 'K8S' ports: @@ -288,15 +277,8 @@ spec: path: /hc port: 80 scheme: HTTP - initialDelaySeconds: 5 - periodSeconds: 10 - livenessProbe: - httpGet: - path: /hc - port: 80 - scheme: HTTP - initialDelaySeconds: 60 - periodSeconds: 10 + initialDelaySeconds: 300 + periodSeconds: 240 imagePullSecrets: - name: registry-key --- @@ -323,42 +305,42 @@ spec: valueFrom: configMapKeyRef: name: externalcfg - key: LocationsNoSqlDb + key: locations__ConnectionString - name: Database valueFrom: configMapKeyRef: name: externalcfg - key: LocationsNoSqlDbName + key: locations__Database - name: AzureServiceBusEnabled valueFrom: configMapKeyRef: name: externalcfg - key: UseAzureServiceBus + key: all__UseAzureServiceBus - name: EventBusConnection valueFrom: configMapKeyRef: name: externalcfg - key: LocationsBus + key: all__EventBusConnection - name: IdentityUrl valueFrom: configMapKeyRef: - name: urls - key: IdentityUrl + name: internalurls + key: identity - name: IdentityUrlExternal valueFrom: configMapKeyRef: name: urls - key: IdentityUrl + key: identity_e - name: ApplicationInsights__InstrumentationKey valueFrom: configMapKeyRef: name: externalcfg - key: Instrumentation_Key + key: all__InstrumentationKey - name: UseLoadTest valueFrom: configMapKeyRef: name: externalcfg - key: EnableLoadTest + key: all__EnableLoadTest - name: OrchestratorType value: 'K8S' ports: @@ -368,15 +350,8 @@ spec: path: /hc port: 80 scheme: HTTP - initialDelaySeconds: 5 - periodSeconds: 10 - livenessProbe: - httpGet: - path: /hc - port: 80 - scheme: HTTP - initialDelaySeconds: 60 - periodSeconds: 10 + initialDelaySeconds: 300 + periodSeconds: 240 imagePullSecrets: - name: registry-key --- @@ -403,37 +378,37 @@ spec: valueFrom: configMapKeyRef: name: externalcfg - key: MarketingSqlDb + key: marketing__ConnectionString - name: MongoConnectionString valueFrom: configMapKeyRef: name: externalcfg - key: MarketingNoSqlDb + key: marketing__MongoConnectionString - name: MongoDatabase valueFrom: configMapKeyRef: name: externalcfg - key: MarketingNoSqlDbName + key: marketing__MongoDatabase - name: AzureServiceBusEnabled valueFrom: configMapKeyRef: name: externalcfg - key: UseAzureServiceBus + key: all__UseAzureServiceBus - name: EventBusConnection valueFrom: configMapKeyRef: name: externalcfg - key: MarketingBus + key: all__EventBusConnection - name: IdentityUrl valueFrom: configMapKeyRef: - name: urls - key: IdentityUrl + name: internalurls + key: identity - name: IdentityUrlExternal valueFrom: configMapKeyRef: name: urls - key: IdentityUrl + key: identity_e - name: PicBaseUrl valueFrom: configMapKeyRef: @@ -443,12 +418,12 @@ spec: valueFrom: configMapKeyRef: name: externalcfg - key: Instrumentation_Key + key: all__InstrumentationKey - name: UseLoadTest valueFrom: configMapKeyRef: name: externalcfg - key: EnableLoadTest + key: all__EnableLoadTest - name: OrchestratorType value: 'K8S' ports: @@ -458,15 +433,8 @@ spec: path: /hc port: 80 scheme: HTTP - initialDelaySeconds: 5 - periodSeconds: 10 - livenessProbe: - httpGet: - path: /hc - port: 80 - scheme: HTTP - initialDelaySeconds: 60 - periodSeconds: 10 + initialDelaySeconds: 300 + periodSeconds: 240 imagePullSecrets: - name: registry-key --- @@ -493,17 +461,17 @@ spec: valueFrom: configMapKeyRef: name: externalcfg - key: UseAzureServiceBus + key: all__UseAzureServiceBus - name: EventBusConnection valueFrom: configMapKeyRef: name: externalcfg - key: PaymentBus + key: all__EventBusConnection - name: ApplicationInsights__InstrumentationKey valueFrom: configMapKeyRef: name: externalcfg - key: Instrumentation_Key + key: all__InstrumentationKey - name: OrchestratorType value: 'K8S' ports: @@ -513,15 +481,8 @@ spec: path: /hc port: 80 scheme: HTTP - initialDelaySeconds: 5 - periodSeconds: 10 - livenessProbe: - httpGet: - path: /hc - port: 80 - scheme: HTTP - initialDelaySeconds: 60 - periodSeconds: 10 + initialDelaySeconds: 300 + periodSeconds: 240 imagePullSecrets: - name: registry-key --- @@ -551,81 +512,66 @@ spec: key: keystore - name: IsClusterEnv value: 'True' - - name: BasketUrl + - name: PurchaseUrl valueFrom: configMapKeyRef: - name: urls - key: MvcClientBasketUrl + name: internalurls + key: apigwws - name: CallBackUrl valueFrom: configMapKeyRef: name: urls - key: MvcClientExternalUrl - - name: LocationsUrl - valueFrom: - configMapKeyRef: - name: urls - key: MvcClientLocationsUrl - - name: CatalogUrl - valueFrom: - configMapKeyRef: - name: urls - key: MvcClientCatalogUrl + key: mvc_e - name: IdentityUrl valueFrom: configMapKeyRef: name: urls - key: IdentityUrl - - name: OrderingUrl - valueFrom: - configMapKeyRef: - name: urls - key: MvcClientOrderingUrl + key: identity_e - name: MarketingUrl valueFrom: configMapKeyRef: - name: urls - key: MvcClientMarketingUrl + name: internalurls + key: apigwwm - name: BasketUrlHC valueFrom: configMapKeyRef: - name: urls - key: BasketHealthCheckUrl + name: internalurls + key: basket__hc - name: CatalogUrlHC valueFrom: configMapKeyRef: - name: urls - key: CatalogHealthCheckUrl + name: internalurls + key: catalog__hc - name: IdentityUrlHC valueFrom: configMapKeyRef: - name: urls - key: IdentityHealthCheckUrl + name: internalurls + key: identity__hc - name: OrderingUrlHC valueFrom: configMapKeyRef: - name: urls - key: OrderingHealthCheckUrl + name: internalurls + key: ordering__hc - name: MarketingUrlHC valueFrom: configMapKeyRef: - name: urls - key: MarketingHealthCheckUrl + name: internalurls + key: marketing__hc - name: PaymentUrlHC valueFrom: configMapKeyRef: - name: urls - key: PaymentHealthCheckUrl + name: internalurls + key: payment__hc - name: ApplicationInsights__InstrumentationKey valueFrom: configMapKeyRef: name: externalcfg - key: Instrumentation_Key + key: all__InstrumentationKey - name: UseLoadTest valueFrom: configMapKeyRef: name: externalcfg - key: EnableLoadTest + key: all__EnableLoadTest - name: OrchestratorType value: 'K8S' ports: @@ -635,15 +581,8 @@ spec: path: /hc port: 80 scheme: HTTP - initialDelaySeconds: 5 - periodSeconds: 10 - livenessProbe: - httpGet: - path: /hc - port: 80 - scheme: HTTP - initialDelaySeconds: 60 - periodSeconds: 10 + initialDelaySeconds: 300 + periodSeconds: 240 imagePullSecrets: - name: registry-key --- @@ -669,53 +608,53 @@ spec: - name: BasketUrl valueFrom: configMapKeyRef: - name: urls - key: BasketHealthCheckUrl + name: internalurls + key: basket__hc - name: CatalogUrl valueFrom: configMapKeyRef: - name: urls - key: CatalogHealthCheckUrl + name: internalurls + key: catalog__hc - name: IdentityUrl valueFrom: configMapKeyRef: - name: urls - key: IdentityHealthCheckUrl + name: internalurls + key: identity__hc - name: OrderingUrl valueFrom: configMapKeyRef: - name: urls - key: OrderingHealthCheckUrl + name: internalurls + key: ordering__hc - name: LocationsUrl valueFrom: configMapKeyRef: - name: urls - key: LocationsHealthCheckUrl + name: internalurls + key: locations__hc - name: MarketingUrl valueFrom: configMapKeyRef: - name: urls - key: MarketingHealthCheckUrl + name: internalurls + key: marketing__hc - name: mvc valueFrom: configMapKeyRef: - name: urls - key: WebMvcHealthCheckUrl + name: internalurls + key: mvc__hc - name: spa valueFrom: configMapKeyRef: - name: urls - key: WebSpaHealthCheckUrl + name: internalurls + key: spa__hc - name: PaymentUrl valueFrom: configMapKeyRef: - name: urls - key: PaymentHealthCheckUrl + name: internalurls + key: payment__hc - name: ApplicationInsights__InstrumentationKey valueFrom: configMapKeyRef: name: externalcfg - key: Instrumentation_Key + key: all__InstrumentationKey - name: OrchestratorType value: 'K8S' ports: @@ -749,76 +688,61 @@ spec: key: keystore - name: IsClusterEnv value: 'True' - - name: BasketUrl + - name: PurchaseUrl valueFrom: configMapKeyRef: name: urls - key: SpaClientBasketExternalUrl + key: webshoppingapigw_e - name: CallBackUrl valueFrom: configMapKeyRef: name: urls - key: SpaClientExternalUrl - - name: CatalogUrl - valueFrom: - configMapKeyRef: - name: urls - key: SpaClientCatalogExternalUrl + key: spa_e - name: IdentityUrl valueFrom: configMapKeyRef: name: urls - key: SpaClientIdentityExternalUrl - - name: OrderingUrl - valueFrom: - configMapKeyRef: - name: urls - key: SpaClientOrderingExternalUrl + key: identity_e - name: MarketingUrl valueFrom: configMapKeyRef: name: urls - key: SpaClientMarketingExternalUrl - - name: LocationsUrl - valueFrom: - configMapKeyRef: - name: urls - key: SpaClientLocationsUrl + key: marketingapigw_e - name: BasketUrlHC valueFrom: configMapKeyRef: - name: urls - key: BasketHealthCheckUrl + name: internalurls + key: basket__hc - name: CatalogUrlHC valueFrom: configMapKeyRef: - name: urls - key: CatalogHealthCheckUrl + name: internalurls + key: catalog__hc - name: IdentityUrlHC valueFrom: configMapKeyRef: - name: urls - key: IdentityHealthCheckUrl + name: internalurls + key: identity__hc - name: OrderingUrlHC valueFrom: configMapKeyRef: - name: urls - key: OrderingHealthCheckUrl + name: internalurls + key: ordering__hc - name: MarketingUrlHC valueFrom: configMapKeyRef: - name: urls - key: MarketingHealthCheckUrl + name: internalurls + key: marketing__hc - name: PaymentUrlHC valueFrom: configMapKeyRef: - name: urls - key: PaymentHealthCheckUrl + name: internalurls + key: payment__hc - name: ApplicationInsights__InstrumentationKey valueFrom: configMapKeyRef: name: externalcfg - key: Instrumentation_Key + key: all__InstrumentationKey - name: OrchestratorType value: 'K8S' ports: @@ -828,14 +752,96 @@ spec: path: /hc port: 80 scheme: HTTP - initialDelaySeconds: 5 - periodSeconds: 10 - livenessProbe: - httpGet: - path: /hc - port: 80 - scheme: HTTP - initialDelaySeconds: 60 - periodSeconds: 10 + initialDelaySeconds: 300 + periodSeconds: 240 imagePullSecrets: - name: registry-key +--- +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: webshoppingagg +spec: + paused: true + template: + metadata: + labels: + app: eshop + component: webshoppingagg + spec: + containers: + - name: webshoppingagg + image: eshop/webshoppingagg + imagePullPolicy: Always + env: + - name: ASPNETCORE_URLS + value: http://0.0.0.0:80 + - name: urls__basket + valueFrom: + configMapKeyRef: + name: internalurls + key: basket + - name: urls__catalog + valueFrom: + configMapKeyRef: + name: internalurls + key: catalog + - name: urls__orders + valueFrom: + configMapKeyRef: + name: internalurls + key: ordering + - name: urls__identity + valueFrom: + configMapKeyRef: + name: internalurls + key: identity + ports: + - containerPort: 80 + imagePullSecrets: + - name: registry-key +--- +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: mobileshoppingagg +spec: + paused: true + template: + metadata: + labels: + app: eshop + component: mobileshoppingagg + spec: + containers: + - name: mobileshoppingagg + image: eshop/mobileshoppingagg + imagePullPolicy: Always + env: + - name: ASPNETCORE_URLS + value: http://0.0.0.0:80 + - name: urls__basket + valueFrom: + configMapKeyRef: + name: internalurls + key: basket + - name: urls__catalog + valueFrom: + configMapKeyRef: + name: internalurls + key: catalog + - name: urls__orders + valueFrom: + configMapKeyRef: + name: internalurls + key: ordering + - name: urls__identity + valueFrom: + configMapKeyRef: + name: internalurls + key: identity + ports: + - containerPort: 80 + imagePullSecrets: + - name: registry-key +--- diff --git a/k8s/ingress.yaml b/k8s/ingress.yaml index 59012bf26..b5773bb25 100644 --- a/k8s/ingress.yaml +++ b/k8s/ingress.yaml @@ -11,22 +11,10 @@ spec: rules: - http: paths: - - path: /basket-api - backend: - serviceName: ocelot - servicePort: 80 - - path: /catalog-api - backend: - serviceName: ocelot - servicePort: 80 - path: /identity backend: serviceName: identity servicePort: 80 - - path: /ordering-api - backend: - serviceName: ocelot - servicePort: 80 - path: /webmvc backend: serviceName: webmvc @@ -35,25 +23,37 @@ spec: backend: serviceName: webstatus servicePort: 80 - - path: /marketing-api + - path: /webshoppingapigw + backend: + serviceName: ocelotapigw-ws + servicePort: 80 + - path: /webmarketingapigw backend: - serviceName: ocelot + serviceName: ocelotapigw-wm servicePort: 80 - - path: /payment-api + - path: /mobilemarketingapigw + backend: + serviceName: ocelotapigw-mm + servicePort: 80 + - path: /mobileshoppingapigw backend: - serviceName: ocelot + serviceName: ocelotapigw-ms + servicePort: 80 + - path: /webshoppingagg + backend: + serviceName: webshoppingagg servicePort: 80 - - path: /locations-api + - path: /mobileshoppingagg backend: - serviceName: ocelot + serviceName: mobileshoppingagg servicePort: 80 + - path: /payment-api + backend: + serviceName: payment + servicePort: 80 - path: / backend: serviceName: webspa servicePort: 80 - - path: /ocelot - backend: - serviceName: ocelot - servicePort: 80 - + diff --git a/k8s/internalurls.yaml b/k8s/internalurls.yaml new file mode 100644 index 000000000..e42ef23ec --- /dev/null +++ b/k8s/internalurls.yaml @@ -0,0 +1,31 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: internalurls + labels: + app: eshop +data: +# Internal Services & healthchecks + basket: http://basket + basket__hc: http://basket/hc + catalog: http://catalog + catalog__hc: http://catalog/hc + identity: http://identity + identity__hc: http://identity/hc + ordering: http://ordering + ordering__hc: http://ordering/hc + marketing: http://marketing + marketing__hc: http://marketing/hc + locations: http://locations + locations__hc: http://locations/hc + payment__hc: http://payment/hc + mvc__hc: http://webmvc/hc + spa__hc: http://webspa/hc +# Aggreggators + mobileshoppingagg: http://mobileshoppingagg + webshoppingagg: http://webshoppingagg +# API GWs + apigwmm: http://ocelotapigw-mm + apigwms: http://ocelotapigw-ms + apigwwm: http://ocelotapigw-wm + apigwws: http://ocelotapigw-ws \ No newline at end of file diff --git a/k8s/ocelot/configuration-mobile-marketing.json b/k8s/ocelot/configuration-mobile-marketing.json new file mode 100644 index 000000000..666df1633 --- /dev/null +++ b/k8s/ocelot/configuration-mobile-marketing.json @@ -0,0 +1,34 @@ +{ + "ReRoutes": [ + { + "DownstreamPathTemplate": "/api/{version}/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "marketing", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/api/{version}/m/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/api/{version}/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "locations", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/api/{version}/l/{everything}", + "UpstreamHttpMethod": [] + } + + ], + "GlobalConfiguration": { + "RequestIdKey": "OcRequestId", + "AdministrationPath": "/administration" + } +} + \ No newline at end of file diff --git a/k8s/ocelot/configuration-mobile-shopping.json b/k8s/ocelot/configuration-mobile-shopping.json new file mode 100644 index 000000000..edf0714a0 --- /dev/null +++ b/k8s/ocelot/configuration-mobile-shopping.json @@ -0,0 +1,142 @@ +{ + "ReRoutes": [ + { + "DownstreamPathTemplate": "/api/{version}/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "catalog", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/api/{version}/c/{everything}", + "UpstreamHttpMethod": [ "GET" ] + }, + { + "DownstreamPathTemplate": "/api/{version}/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "basket", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/api/{version}/b/{everything}", + "UpstreamHttpMethod": [], + "AuthenticationOptions": { + "AuthenticationProviderKey": "IdentityApiKey", + "AllowedScopes": [] + } + }, + { + "DownstreamPathTemplate": "/api/{version}/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "ordering", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/api/{version}/o/{everything}", + "UpstreamHttpMethod": [], + "AuthenticationOptions": { + "AuthenticationProviderKey": "IdentityApiKey", + "AllowedScopes": [] + } + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "webshoppingagg", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/{everything}", + "UpstreamHttpMethod": [ "POST", "PUT", "GET" ], + "AuthenticationOptions": { + "AuthenticationProviderKey": "IdentityApiKey", + "AllowedScopes": [] + } + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "ordering", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/orders-api/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "basket", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/basket-api/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "catalog", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/catalog-api/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "marketing", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/marketing-api/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "payment", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/payment-api/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "locations.api", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/location-api/{everything}", + "UpstreamHttpMethod": [] + } + + ], + "GlobalConfiguration": { + "RequestIdKey": "OcRequestId", + "AdministrationPath": "/administration" + } + } + \ No newline at end of file diff --git a/k8s/ocelot/configuration-web-marketing.json b/k8s/ocelot/configuration-web-marketing.json new file mode 100644 index 000000000..666df1633 --- /dev/null +++ b/k8s/ocelot/configuration-web-marketing.json @@ -0,0 +1,34 @@ +{ + "ReRoutes": [ + { + "DownstreamPathTemplate": "/api/{version}/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "marketing", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/api/{version}/m/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/api/{version}/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "locations", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/api/{version}/l/{everything}", + "UpstreamHttpMethod": [] + } + + ], + "GlobalConfiguration": { + "RequestIdKey": "OcRequestId", + "AdministrationPath": "/administration" + } +} + \ No newline at end of file diff --git a/k8s/ocelot/configuration-web-shopping.json b/k8s/ocelot/configuration-web-shopping.json new file mode 100644 index 000000000..edf0714a0 --- /dev/null +++ b/k8s/ocelot/configuration-web-shopping.json @@ -0,0 +1,142 @@ +{ + "ReRoutes": [ + { + "DownstreamPathTemplate": "/api/{version}/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "catalog", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/api/{version}/c/{everything}", + "UpstreamHttpMethod": [ "GET" ] + }, + { + "DownstreamPathTemplate": "/api/{version}/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "basket", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/api/{version}/b/{everything}", + "UpstreamHttpMethod": [], + "AuthenticationOptions": { + "AuthenticationProviderKey": "IdentityApiKey", + "AllowedScopes": [] + } + }, + { + "DownstreamPathTemplate": "/api/{version}/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "ordering", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/api/{version}/o/{everything}", + "UpstreamHttpMethod": [], + "AuthenticationOptions": { + "AuthenticationProviderKey": "IdentityApiKey", + "AllowedScopes": [] + } + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "webshoppingagg", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/{everything}", + "UpstreamHttpMethod": [ "POST", "PUT", "GET" ], + "AuthenticationOptions": { + "AuthenticationProviderKey": "IdentityApiKey", + "AllowedScopes": [] + } + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "ordering", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/orders-api/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "basket", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/basket-api/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "catalog", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/catalog-api/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "marketing", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/marketing-api/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "payment", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/payment-api/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "locations.api", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/location-api/{everything}", + "UpstreamHttpMethod": [] + } + + ], + "GlobalConfiguration": { + "RequestIdKey": "OcRequestId", + "AdministrationPath": "/administration" + } + } + \ No newline at end of file diff --git a/k8s/ocelot/configuration.json b/k8s/ocelot/configuration.json deleted file mode 100644 index 7a94504c3..000000000 --- a/k8s/ocelot/configuration.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "ReRoutes": [ - { - "DownstreamPathTemplate": "/{everything}", - "DownstreamScheme": "http", - "DownstreamHost": "ordering", - "DownstreamPort": 80, - "UpstreamPathTemplate": "/ordering-api/{everything}", - "UpstreamHttpMethod": [] - }, - { - "DownstreamPathTemplate": "/{everything}", - "DownstreamScheme": "http", - "DownstreamHost": "basket", - "DownstreamPort": 80, - "UpstreamPathTemplate": "/basket-api/{everything}", - "UpstreamHttpMethod": [] - }, - { - "DownstreamPathTemplate": "/{everything}", - "DownstreamScheme": "http", - "DownstreamHost": "catalog", - "DownstreamPort": 80, - "UpstreamPathTemplate": "/catalog-api/{everything}", - "UpstreamHttpMethod": [] - }, - { - "DownstreamPathTemplate": "/{everything}", - "DownstreamScheme": "http", - "DownstreamHost": "marketing", - "DownstreamPort": 80, - "UpstreamPathTemplate": "/marketing-api/{everything}", - "UpstreamHttpMethod": [] - }, - { - "DownstreamPathTemplate": "/{everything}", - "DownstreamScheme": "http", - "DownstreamHost": "payment", - "DownstreamPort": 80, - "UpstreamPathTemplate": "/payment-api/{everything}", - "UpstreamHttpMethod": [] - }, - { - "DownstreamPathTemplate": "/{everything}", - "DownstreamScheme": "http", - "DownstreamHost": "locations", - "DownstreamPort": 80, - "UpstreamPathTemplate": "/location-api/{everything}", - "UpstreamHttpMethod": [] - } - - ], - "GlobalConfiguration": { - "RequestIdKey": "OcRequestId", - "AdministrationPath": "/administration" - } - } - \ No newline at end of file diff --git a/k8s/ocelot/deployment.yaml b/k8s/ocelot/deployment.yaml index 4800172e6..516f91b2f 100644 --- a/k8s/ocelot/deployment.yaml +++ b/k8s/ocelot/deployment.yaml @@ -1,19 +1,27 @@ apiVersion: extensions/v1beta1 kind: Deployment metadata: - name: ocelot + name: apigwmm spec: paused: true template: metadata: labels: app: eshop - component: ocelot + component: apigwmm spec: containers: - - name: ocelot - image: eshop/ocelotapigw + - name: apigwmm + image: eshop/ocelotapigw-mm imagePullPolicy: Always + env: + - name: PATH_BASE + value: /mobilemarketingapigw + - name: IdentityUrl + valueFrom: + configMapKeyRef: + name: internalurls + key: identity ports: - containerPort: 80 volumeMounts: @@ -24,8 +32,124 @@ spec: configMap: name: ocelot items: - - key: configuration.json + - key: mm path: configuration.json imagePullSecrets: - name: registry-key - +--- +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: apigwms +spec: + paused: true + template: + metadata: + labels: + app: eshop + component: apigwms + spec: + containers: + - name: apigwms + image: eshop/ocelotapigw-ms + imagePullPolicy: Always + env: + - name: PATH_BASE + value: /mobileshoppingapigw + - name: IdentityUrl + valueFrom: + configMapKeyRef: + name: internalurls + key: identity + ports: + - containerPort: 80 + volumeMounts: + - name: config + mountPath: /app/configuration + volumes: + - name: config + configMap: + name: ocelot + items: + - key: ms + path: configuration.json + imagePullSecrets: + - name: registry-key +--- +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: apigwwm +spec: + paused: true + template: + metadata: + labels: + app: eshop + component: apigwwm + spec: + containers: + - name: apigwwm + image: eshop/ocelotapigw-wm + imagePullPolicy: Always + env: + - name: PATH_BASE + value: /webmarketingapigw + - name: IdentityUrl + valueFrom: + configMapKeyRef: + name: internalurls + key: identity + ports: + - containerPort: 80 + volumeMounts: + - name: config + mountPath: /app/configuration + volumes: + - name: config + configMap: + name: ocelot + items: + - key: wm + path: configuration.json + imagePullSecrets: + - name: registry-key +--- +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: apigwws +spec: + paused: true + template: + metadata: + labels: + app: eshop + component: apigwws + spec: + containers: + - name: apigwws + image: eshop/ocelotapigw-ws + imagePullPolicy: Always + env: + - name: PATH_BASE + value: /webshoppingapigw + - name: IdentityUrl + valueFrom: + configMapKeyRef: + name: internalurls + key: identity + ports: + - containerPort: 80 + volumeMounts: + - name: config + mountPath: /app/configuration + volumes: + - name: config + configMap: + name: ocelot + items: + - key: ws + path: configuration.json + imagePullSecrets: + - name: registry-key \ No newline at end of file diff --git a/k8s/ocelot/service.yaml b/k8s/ocelot/service.yaml index 6b376ca78..858b54b21 100644 --- a/k8s/ocelot/service.yaml +++ b/k8s/ocelot/service.yaml @@ -3,11 +3,53 @@ kind: Service metadata: labels: app: eshop - component: ocelot - name: ocelot + component: ocelotapigw-mm + name: ocelotapigw-mm spec: ports: - port: 80 selector: app: eshop - component: ocelot + component: apigwmm +--- +apiVersion: v1 +kind: Service +metadata: + labels: + app: eshop + component: ocelotapigw-ms + name: ocelotapigw-ms +spec: + ports: + - port: 80 + selector: + app: eshop + component: apigwms +--- +apiVersion: v1 +kind: Service +metadata: + labels: + app: eshop + component: ocelotapigw-wm + name: ocelotapigw-wm +spec: + ports: + - port: 80 + selector: + app: eshop + component: apigwwm +--- +apiVersion: v1 +kind: Service +metadata: + labels: + app: eshop + component: ocelotapigw-ws + name: ocelotapigw-ws +spec: + ports: + - port: 80 + selector: + app: eshop + component: apigwws diff --git a/src/ApiGateways/ApiGw-Base/Startup.cs b/src/ApiGateways/ApiGw-Base/Startup.cs index 254849d89..f6a36b59e 100644 --- a/src/ApiGateways/ApiGw-Base/Startup.cs +++ b/src/ApiGateways/ApiGw-Base/Startup.cs @@ -70,6 +70,12 @@ namespace OcelotApiGw public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { + var pathBase = _cfg["PATH_BASE"]; + if (!string.IsNullOrEmpty(pathBase)) + { + app.UsePathBase(pathBase); + } + if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); diff --git a/src/ApiGateways/Mobile.Bff.Marketing/apigw/configuration.json b/src/ApiGateways/Mobile.Bff.Marketing/apigw/configuration.json index 22fdca1b2..85d6777e6 100644 --- a/src/ApiGateways/Mobile.Bff.Marketing/apigw/configuration.json +++ b/src/ApiGateways/Mobile.Bff.Marketing/apigw/configuration.json @@ -1 +1,34 @@ -{} \ No newline at end of file +{ + "ReRoutes": [ + { + "DownstreamPathTemplate": "/api/{version}/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "marketing.api", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/api/{version}/m/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/api/{version}/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "locations.api", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/api/{version}/l/{everything}", + "UpstreamHttpMethod": [] + } + + ], + "GlobalConfiguration": { + "RequestIdKey": "OcRequestId", + "AdministrationPath": "/administration" + } + } + \ No newline at end of file diff --git a/src/ApiGateways/Mobile.Bff.Shopping/apigw/configuration.json b/src/ApiGateways/Mobile.Bff.Shopping/apigw/configuration.json index 22fdca1b2..1de765949 100644 --- a/src/ApiGateways/Mobile.Bff.Shopping/apigw/configuration.json +++ b/src/ApiGateways/Mobile.Bff.Shopping/apigw/configuration.json @@ -1 +1,142 @@ -{} \ No newline at end of file +{ + "ReRoutes": [ + { + "DownstreamPathTemplate": "/api/{version}/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "catalog.api", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/api/{version}/c/{everything}", + "UpstreamHttpMethod": [ "GET" ] + }, + { + "DownstreamPathTemplate": "/api/{version}/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "basket.api", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/api/{version}/b/{everything}", + "UpstreamHttpMethod": [], + "AuthenticationOptions": { + "AuthenticationProviderKey": "IdentityApiKey", + "AllowedScopes": [] + } + }, + { + "DownstreamPathTemplate": "/api/{version}/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "ordering.api", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/api/{version}/o/{everything}", + "UpstreamHttpMethod": [], + "AuthenticationOptions": { + "AuthenticationProviderKey": "IdentityApiKey", + "AllowedScopes": [] + } + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "webshoppingagg", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/{everything}", + "UpstreamHttpMethod": [ "POST", "PUT", "GET" ], + "AuthenticationOptions": { + "AuthenticationProviderKey": "IdentityApiKey", + "AllowedScopes": [] + } + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "ordering.api", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/orders-api/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "basket.api", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/basket-api/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "catalog.api", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/catalog-api/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "marketing.api", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/marketing-api/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "payment.api", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/payment-api/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "locations.api", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/location-api/{everything}", + "UpstreamHttpMethod": [] + } + + ], + "GlobalConfiguration": { + "RequestIdKey": "OcRequestId", + "AdministrationPath": "/administration" + } + } + \ No newline at end of file From 72843eb6bb9e2b67d4b9fcc6859d062de7fd6649 Mon Sep 17 00:00:00 2001 From: eiximenis Date: Thu, 15 Mar 2018 15:49:24 +0100 Subject: [PATCH 31/45] Missing aggregrators services in k8s config *oops* --- k8s/services.yaml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/k8s/services.yaml b/k8s/services.yaml index 02b73448a..96d2cb8b4 100644 --- a/k8s/services.yaml +++ b/k8s/services.yaml @@ -98,6 +98,34 @@ spec: --- apiVersion: v1 kind: Service +metadata: + labels: + app: eshop + component: webshoppingagg + name: webshoppingagg +spec: + ports: + - port: 80 + selector: + app: eshop + component: webshoppingagg +--- +apiVersion: v1 +kind: Service +metadata: + labels: + app: eshop + component: mobileshoppingagg + name: mobileshoppingagg +spec: + ports: + - port: 80 + selector: + app: eshop + component: mobileshoppingagg +--- +apiVersion: v1 +kind: Service metadata: labels: app: eshop From d9fb7e713c5d35e58afc79855e9fd9a73beae882 Mon Sep 17 00:00:00 2001 From: eiximenis Date: Thu, 15 Mar 2018 16:13:23 +0100 Subject: [PATCH 32/45] Error on ocelot config for k8s --- k8s/ocelot/configuration-mobile-shopping.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k8s/ocelot/configuration-mobile-shopping.json b/k8s/ocelot/configuration-mobile-shopping.json index edf0714a0..cf3a48aff 100644 --- a/k8s/ocelot/configuration-mobile-shopping.json +++ b/k8s/ocelot/configuration-mobile-shopping.json @@ -49,7 +49,7 @@ "DownstreamScheme": "http", "DownstreamHostAndPorts": [ { - "Host": "webshoppingagg", + "Host": "mobileshoppingagg", "Port": 80 } ], From f80ee6967aa6f6514d7ee7d5ed4126fcedf319f9 Mon Sep 17 00:00:00 2001 From: eiximenis Date: Thu, 15 Mar 2018 16:14:40 +0100 Subject: [PATCH 33/45] Error on local mobile shopping apigw config file --- src/ApiGateways/Mobile.Bff.Shopping/apigw/configuration.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ApiGateways/Mobile.Bff.Shopping/apigw/configuration.json b/src/ApiGateways/Mobile.Bff.Shopping/apigw/configuration.json index 1de765949..870690ed4 100644 --- a/src/ApiGateways/Mobile.Bff.Shopping/apigw/configuration.json +++ b/src/ApiGateways/Mobile.Bff.Shopping/apigw/configuration.json @@ -49,7 +49,7 @@ "DownstreamScheme": "http", "DownstreamHostAndPorts": [ { - "Host": "webshoppingagg", + "Host": "mobileshoppingagg", "Port": 80 } ], From 51bb22366334eb6be3b4d57a7fc7c8ec58c01686 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Coben=CC=83a=20Moria=CC=81n?= Date: Mon, 19 Mar 2018 12:21:32 +0100 Subject: [PATCH 34/45] Ignored MFractor's stuff --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index a8d5986bc..6e46dd41b 100644 --- a/.gitignore +++ b/.gitignore @@ -260,3 +260,4 @@ pub/ /src/Web/WebMVC/wwwroot/lib /src/Web/WebMVC/wwwroot/css/site.min.css **/.kube/** +.mfractor From 1f27bcb5642473318af83f2a5ddd3f17e878decd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Coben=CC=83a=20Moria=CC=81n?= Date: Mon, 19 Mar 2018 12:24:37 +0100 Subject: [PATCH 35/45] WIP endpoint update --- .../eShopOnContainers.Core/GlobalSettings.cs | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/GlobalSettings.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/GlobalSettings.cs index d501a5d46..4714725af 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/GlobalSettings.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/GlobalSettings.cs @@ -4,7 +4,7 @@ { public const string AzureTag = "Azure"; public const string MockTag = "Mock"; - public const string DefaultEndpoint = "http://13.88.8.119"; + public const string DefaultEndpoint = "http://52.170.199.82"; private string _baseEndpoint; private static readonly GlobalSetting _instance = new GlobalSetting(); @@ -62,16 +62,21 @@ private void UpdateEndpoint(string baseEndpoint) { - RegisterWebsite = $"{baseEndpoint}:5105/Account/Register"; + var identityBaseEndpoint = $"{baseEndpoint}/identity"; + RegisterWebsite = $"{identityBaseEndpoint}/Account/Register"; + LogoutCallback = $"{identityBaseEndpoint}/Account/Redirecting"; + + var connectBaseEndpoint = $"{identityBaseEndpoint}/connect"; + IdentityEndpoint = $"{connectBaseEndpoint}/authorize"; + UserInfoEndpoint = $"{connectBaseEndpoint}/userinfo"; + TokenEndpoint = $"{connectBaseEndpoint}/token"; + LogoutEndpoint = $"{connectBaseEndpoint}/endsession"; + + IdentityCallback = $"{baseEndpoint}/xamarincallback"; + CatalogEndpoint = $"{baseEndpoint}:5101"; OrdersEndpoint = $"{baseEndpoint}:5102"; BasketEndpoint = $"{baseEndpoint}:5103"; - IdentityEndpoint = $"{baseEndpoint}:5105/connect/authorize"; - UserInfoEndpoint = $"{baseEndpoint}:5105/connect/userinfo"; - TokenEndpoint = $"{baseEndpoint}:5105/connect/token"; - LogoutEndpoint = $"{baseEndpoint}:5105/connect/endsession"; - IdentityCallback = $"{baseEndpoint}:5105/xamarincallback"; - LogoutCallback = $"{baseEndpoint}:5105/Account/Redirecting"; LocationEndpoint = $"{baseEndpoint}:5109"; MarketingEndpoint = $"{baseEndpoint}:5110"; } From 0f725666c0928adb611ee8c55524ccc9d8af9141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Coben=CC=83a=20Moria=CC=81n?= Date: Wed, 21 Mar 2018 12:50:08 +0100 Subject: [PATCH 36/45] Updated endpoints --- .../eShopOnContainers.Core/GlobalSettings.cs | 16 -------------- .../Services/Basket/BasketService.cs | 22 +++++++++++++------ .../Services/Catalog/CatalogService.cs | 18 ++++++++------- .../Services/Location/LocationService.cs | 4 ++-- .../Services/Marketing/CampaignService.cs | 10 +++++---- .../Services/Order/OrderService.cs | 14 +++++++----- 6 files changed, 41 insertions(+), 43 deletions(-) diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/GlobalSettings.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/GlobalSettings.cs index 4714725af..9b2b22b72 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/GlobalSettings.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/GlobalSettings.cs @@ -38,18 +38,8 @@ public string RegisterWebsite { get; set; } - public string CatalogEndpoint { get; set; } - - public string OrdersEndpoint { get; set; } - - public string BasketEndpoint { get; set; } - public string IdentityEndpoint { get; set; } - public string LocationEndpoint { get; set; } - - public string MarketingEndpoint { get; set; } - public string UserInfoEndpoint { get; set; } public string TokenEndpoint { get; set; } @@ -73,12 +63,6 @@ LogoutEndpoint = $"{connectBaseEndpoint}/endsession"; IdentityCallback = $"{baseEndpoint}/xamarincallback"; - - CatalogEndpoint = $"{baseEndpoint}:5101"; - OrdersEndpoint = $"{baseEndpoint}:5102"; - BasketEndpoint = $"{baseEndpoint}:5103"; - LocationEndpoint = $"{baseEndpoint}:5109"; - MarketingEndpoint = $"{baseEndpoint}:5110"; } } } \ No newline at end of file diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Basket/BasketService.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Basket/BasketService.cs index 54f3a03bc..b36488f24 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Basket/BasketService.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Basket/BasketService.cs @@ -11,7 +11,7 @@ namespace eShopOnContainers.Core.Services.Basket private readonly IRequestProvider _requestProvider; private readonly IFixUriService _fixUriService; - private const string ApiUrlBase = "api/v1/basket"; + private const string ApiUrlBase = "mobileshoppingapigw/api/v1/b/basket"; public BasketService(IRequestProvider requestProvider, IFixUriService fixUriService) { @@ -21,15 +21,23 @@ namespace eShopOnContainers.Core.Services.Basket public async Task GetBasketAsync(string guidUser, string token) { - var builder = new UriBuilder(GlobalSetting.Instance.BasketEndpoint) + var builder = new UriBuilder(GlobalSetting.Instance.BaseEndpoint) { Path = $"{ApiUrlBase}/{guidUser}" }; var uri = builder.ToString(); - CustomerBasket basket = - await _requestProvider.GetAsync(uri, token); + CustomerBasket basket; + + try + { + basket = await _requestProvider.GetAsync(uri, token); + } + catch (HttpRequestExceptionEx exception) when (exception.HttpCode == System.Net.HttpStatusCode.NotFound) + { + basket = null; + } _fixUriService.FixBasketItemPictureUri(basket?.Items); return basket; @@ -37,7 +45,7 @@ namespace eShopOnContainers.Core.Services.Basket public async Task UpdateBasketAsync(CustomerBasket customerBasket, string token) { - var builder = new UriBuilder(GlobalSetting.Instance.BasketEndpoint) + var builder = new UriBuilder(GlobalSetting.Instance.BaseEndpoint) { Path = ApiUrlBase }; @@ -49,7 +57,7 @@ namespace eShopOnContainers.Core.Services.Basket public async Task CheckoutAsync(BasketCheckout basketCheckout, string token) { - var builder = new UriBuilder(GlobalSetting.Instance.BasketEndpoint) + var builder = new UriBuilder(GlobalSetting.Instance.BaseEndpoint) { Path = $"{ApiUrlBase}/checkout" }; @@ -60,7 +68,7 @@ namespace eShopOnContainers.Core.Services.Basket public async Task ClearBasketAsync(string guidUser, string token) { - var builder = new UriBuilder(GlobalSetting.Instance.BasketEndpoint) + var builder = new UriBuilder(GlobalSetting.Instance.BaseEndpoint) { Path = $"{ApiUrlBase}/{guidUser}" }; diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogService.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogService.cs index 2e63e9516..dd7cfe732 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogService.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogService.cs @@ -13,6 +13,8 @@ namespace eShopOnContainers.Core.Services.Catalog { private readonly IRequestProvider _requestProvider; private readonly IFixUriService _fixUriService; + + private const string ApiUrlBase = "mobileshoppingapigw/api/v1/c/catalog"; public CatalogService(IRequestProvider requestProvider, IFixUriService fixUriService) { @@ -22,8 +24,8 @@ namespace eShopOnContainers.Core.Services.Catalog public async Task> FilterAsync(int catalogBrandId, int catalogTypeId) { - UriBuilder builder = new UriBuilder(GlobalSetting.Instance.CatalogEndpoint); - builder.Path = string.Format("api/v1/catalog/items/type/{0}/brand/{1}", catalogTypeId, catalogBrandId); + UriBuilder builder = new UriBuilder(GlobalSetting.Instance.BaseEndpoint); + builder.Path = string.Format($"{ApiUrlBase}/items/type/{0}/brand/{1}", catalogTypeId, catalogBrandId); string uri = builder.ToString(); CatalogRoot catalog = await _requestProvider.GetAsync(uri); @@ -36,8 +38,8 @@ namespace eShopOnContainers.Core.Services.Catalog public async Task> GetCatalogAsync() { - UriBuilder builder = new UriBuilder(GlobalSetting.Instance.CatalogEndpoint); - builder.Path = "api/v1/catalog/items"; + UriBuilder builder = new UriBuilder(GlobalSetting.Instance.BaseEndpoint); + builder.Path = $"{ApiUrlBase}/items"; string uri = builder.ToString(); CatalogRoot catalog = await _requestProvider.GetAsync(uri); @@ -53,8 +55,8 @@ namespace eShopOnContainers.Core.Services.Catalog public async Task> GetCatalogBrandAsync() { - UriBuilder builder = new UriBuilder(GlobalSetting.Instance.CatalogEndpoint); - builder.Path = "api/v1/catalog/catalogbrands"; + UriBuilder builder = new UriBuilder(GlobalSetting.Instance.BaseEndpoint); + builder.Path = $"{ApiUrlBase}/catalogbrands"; string uri = builder.ToString(); IEnumerable brands = await _requestProvider.GetAsync>(uri); @@ -67,8 +69,8 @@ namespace eShopOnContainers.Core.Services.Catalog public async Task> GetCatalogTypeAsync() { - UriBuilder builder = new UriBuilder(GlobalSetting.Instance.CatalogEndpoint); - builder.Path = "api/v1/catalog/catalogtypes"; + UriBuilder builder = new UriBuilder(GlobalSetting.Instance.BaseEndpoint); + builder.Path = $"{ApiUrlBase}/catalogtypes"; string uri = builder.ToString(); IEnumerable types = await _requestProvider.GetAsync>(uri); diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Location/LocationService.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Location/LocationService.cs index f20ae6339..e18d335c0 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Location/LocationService.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Location/LocationService.cs @@ -15,8 +15,8 @@ namespace eShopOnContainers.Core.Services.Location public async Task UpdateUserLocation(eShopOnContainers.Core.Models.Location.Location newLocReq, string token) { - UriBuilder builder = new UriBuilder(GlobalSetting.Instance.LocationEndpoint); - builder.Path = "api/v1/locations"; + UriBuilder builder = new UriBuilder(GlobalSetting.Instance.BaseEndpoint); + builder.Path = "/mobilemarketingapigw/api/v1/l/locations"; string uri = builder.ToString(); await _requestProvider.PostAsync(uri, newLocReq, token); } diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Marketing/CampaignService.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Marketing/CampaignService.cs index cb74f11b0..2fa5eaa9e 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Marketing/CampaignService.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Marketing/CampaignService.cs @@ -13,6 +13,8 @@ namespace eShopOnContainers.Core.Services.Marketing private readonly IRequestProvider _requestProvider; private readonly IFixUriService _fixUriService; + private const string ApiUrlBase = "mobilemarketingapigw/api/v1/m/campaigns"; + public CampaignService(IRequestProvider requestProvider, IFixUriService fixUriService) { _requestProvider = requestProvider; @@ -21,8 +23,8 @@ namespace eShopOnContainers.Core.Services.Marketing public async Task> GetAllCampaignsAsync(string token) { - UriBuilder builder = new UriBuilder(GlobalSetting.Instance.MarketingEndpoint); - builder.Path = "api/v1/campaigns/user"; + UriBuilder builder = new UriBuilder(GlobalSetting.Instance.BaseEndpoint); + builder.Path = $"{ApiUrlBase}/user"; string uri = builder.ToString(); CampaignRoot campaign = await _requestProvider.GetAsync(uri, token); @@ -38,8 +40,8 @@ namespace eShopOnContainers.Core.Services.Marketing public async Task GetCampaignByIdAsync(int campaignId, string token) { - UriBuilder builder = new UriBuilder(GlobalSetting.Instance.MarketingEndpoint); - builder.Path = $"api/v1/campaigns/{campaignId}"; + UriBuilder builder = new UriBuilder(GlobalSetting.Instance.BaseEndpoint); + builder.Path = $"{ApiUrlBase}/{campaignId}"; string uri = builder.ToString(); return await _requestProvider.GetAsync(uri, token); } diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Order/OrderService.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Order/OrderService.cs index f242971fb..0da0942ad 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Order/OrderService.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Order/OrderService.cs @@ -11,6 +11,8 @@ namespace eShopOnContainers.Core.Services.Order { private readonly IRequestProvider _requestProvider; + private const string ApiUrlBase = "mobileshoppingapigw/api/v1/o/orders"; + public OrderService(IRequestProvider requestProvider) { _requestProvider = requestProvider; @@ -23,9 +25,9 @@ namespace eShopOnContainers.Core.Services.Order public async Task> GetOrdersAsync(string token) { - UriBuilder builder = new UriBuilder(GlobalSetting.Instance.OrdersEndpoint); + UriBuilder builder = new UriBuilder(GlobalSetting.Instance.BaseEndpoint); - builder.Path = "api/v1/orders"; + builder.Path = ApiUrlBase; string uri = builder.ToString(); @@ -40,9 +42,9 @@ namespace eShopOnContainers.Core.Services.Order { try { - UriBuilder builder = new UriBuilder(GlobalSetting.Instance.OrdersEndpoint); + UriBuilder builder = new UriBuilder(GlobalSetting.Instance.BaseEndpoint); - builder.Path = string.Format("api/v1/orders/{0}", orderId); + builder.Path = string.Format($"{ApiUrlBase}/{0}", orderId); string uri = builder.ToString(); @@ -76,9 +78,9 @@ namespace eShopOnContainers.Core.Services.Order public async Task CancelOrderAsync(int orderId, string token) { - UriBuilder builder = new UriBuilder(GlobalSetting.Instance.OrdersEndpoint); + UriBuilder builder = new UriBuilder(GlobalSetting.Instance.BaseEndpoint); - builder.Path = "api/v1/orders/cancel"; + builder.Path = $"{ApiUrlBase}/cancel"; var cancelOrderCommand = new CancelOrderCommand(orderId); From 811f9a027ac75303dcf1d41623dc9192e51895e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Cobe=C3=B1a=20Mori=C3=A1n?= Date: Wed, 21 Mar 2018 15:53:52 +0100 Subject: [PATCH 37/45] Removed back-up file --- .../eShopOnContainers.Droid.csproj.bak | 429 ------------------ 1 file changed, 429 deletions(-) delete mode 100644 src/Mobile/eShopOnContainers/eShopOnContainers.Droid/eShopOnContainers.Droid.csproj.bak diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/eShopOnContainers.Droid.csproj.bak b/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/eShopOnContainers.Droid.csproj.bak deleted file mode 100644 index 8a2babd2e..000000000 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/eShopOnContainers.Droid.csproj.bak +++ /dev/null @@ -1,429 +0,0 @@ - - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {62DBB163-9CA9-4818-B48B-13233DF37C24} - {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Library - Properties - eShopOnContainers.Droid - eShopOnContainers.Droid - 512 - true - Resources\Resource.Designer.cs - Off - Properties\AndroidManifest.xml - true - v8.0 - armeabi,armeabi-v7a,x86 - - - 1G - - - - - - true - - - True - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - True - None - False - 1G - Xamarin - armeabi;armeabi-v7a;x86 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - False - SdkOnly - - - - ..\..\..\..\packages\Acr.Support.2.1.0\lib\MonoAndroid10\Acr.Support.Android.dll - True - - - ..\..\..\..\packages\AndHUD.1.2.0\lib\MonoAndroid\AndHUD.dll - True - - - ..\..\..\..\packages\Xamarin.FFImageLoading.2.2.9\lib\MonoAndroid10\FFImageLoading.dll - - - ..\..\..\..\packages\Xamarin.FFImageLoading.2.2.9\lib\MonoAndroid10\FFImageLoading.Platform.dll - - - ..\..\..\..\packages\IdentityModel.1.3.1\lib\portable-net45+wp80+win8+wpa81\IdentityModel.Portable.dll - True - - - - ..\..\..\..\packages\modernhttpclient.2.4.2\lib\MonoAndroid\ModernHttpClient.dll - True - - - - - ..\..\..\..\packages\Newtonsoft.Json.9.0.1\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll - - - ..\..\..\..\packages\modernhttpclient.2.4.2\lib\MonoAndroid\OkHttp.dll - True - - - ..\..\..\..\packages\PCLCrypto.2.0.147\lib\MonoAndroid23\PCLCrypto.dll - - - ..\..\..\..\packages\PInvoke.BCrypt.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.BCrypt.dll - - - ..\..\..\..\packages\PInvoke.Kernel32.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.Kernel32.dll - - - ..\..\..\..\packages\PInvoke.NCrypt.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.NCrypt.dll - - - ..\..\..\..\packages\PInvoke.Windows.Core.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.Windows.Core.dll - - - ..\..\..\..\packages\Plugin.CurrentActivity.1.0.1\lib\MonoAndroid10\Plugin.CurrentActivity.dll - - - ..\..\..\..\packages\Xam.Plugin.Geolocator.3.0.4\lib\MonoAndroid10\Plugin.Geolocator.dll - - - ..\..\..\..\packages\Xam.Plugin.Geolocator.3.0.4\lib\MonoAndroid10\Plugin.Geolocator.Abstractions.dll - - - ..\..\..\..\packages\Plugin.Permissions.1.1.7\lib\MonoAndroid10\Plugin.Permissions.dll - - - ..\..\..\..\packages\Plugin.Permissions.1.1.7\lib\MonoAndroid10\Plugin.Permissions.Abstractions.dll - - - ..\..\..\..\packages\Xam.Plugins.Settings.2.6.0.12-beta\lib\MonoAndroid10\Plugin.Settings.dll - True - - - ..\..\..\..\packages\Xam.Plugins.Settings.2.6.0.12-beta\lib\MonoAndroid10\Plugin.Settings.Abstractions.dll - True - - - ..\..\..\..\packages\SlideOverKit.2.1.4\lib\MonoAndroid10\SlideOverKit.dll - True - - - ..\..\..\..\packages\SlideOverKit.2.1.4\lib\MonoAndroid10\SlideOverKit.Droid.dll - True - - - ..\..\..\..\packages\Splat.1.6.2\lib\monoandroid\Splat.dll - True - - - - - - ..\..\..\..\packages\Microsoft.Net.Http.2.2.29\lib\monoandroid\System.Net.Http.Extensions.dll - True - - - ..\..\..\..\packages\Microsoft.Net.Http.2.2.29\lib\monoandroid\System.Net.Http.Primitives.dll - True - - - - - ..\..\..\..\packages\Validation.2.2.8\lib\dotnet\Validation.dll - - - - ..\..\..\..\packages\Autofac.4.5.0\lib\netstandard1.1\Autofac.dll - - - ..\..\..\..\packages\Acr.UserDialogs.6.3.8\lib\MonoAndroid10\Acr.UserDialogs.dll - - - ..\..\..\..\packages\Acr.UserDialogs.6.3.8\lib\MonoAndroid10\Acr.UserDialogs.Interface.dll - - - ..\..\..\..\packages\Xamarin.Forms.2.5.0.91635\lib\MonoAndroid10\FormsViewGroup.dll - - - ..\..\..\..\packages\Xamarin.Forms.2.5.0.91635\lib\MonoAndroid10\Xamarin.Forms.Core.dll - - - ..\..\..\..\packages\Xamarin.Forms.2.5.0.91635\lib\MonoAndroid10\Xamarin.Forms.Platform.Android.dll - - - ..\..\..\..\packages\Xamarin.Forms.2.5.0.91635\lib\MonoAndroid10\Xamarin.Forms.Platform.dll - - - ..\..\..\..\packages\Xamarin.Forms.2.5.0.91635\lib\MonoAndroid10\Xamarin.Forms.Xaml.dll - - - ..\..\..\..\packages\Xamarin.FFImageLoading.Forms.2.2.9\lib\MonoAndroid10\FFImageLoading.Forms.dll - - - ..\..\..\..\packages\Xamarin.FFImageLoading.Forms.2.2.9\lib\MonoAndroid10\FFImageLoading.Forms.Droid.dll - - - ..\..\..\..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.25.4.0.2\lib\MonoAndroid70\Xamarin.Android.Support.Animated.Vector.Drawable.dll - - - ..\..\..\..\packages\Xamarin.Android.Support.Vector.Drawable.25.4.0.2\lib\MonoAndroid70\Xamarin.Android.Support.Vector.Drawable.dll - - - ..\..\..\..\packages\Xamarin.Android.Support.v7.RecyclerView.25.4.0.2\lib\MonoAndroid70\Xamarin.Android.Support.v7.RecyclerView.dll - - - ..\..\..\..\packages\Xamarin.Android.Support.Annotations.25.4.0.2\lib\MonoAndroid70\Xamarin.Android.Support.Annotations.dll - - - ..\..\..\..\packages\Xamarin.Android.Support.Compat.25.4.0.2\lib\MonoAndroid70\Xamarin.Android.Support.Compat.dll - - - ..\..\..\..\packages\Xamarin.Android.Support.v7.CardView.25.4.0.2\lib\MonoAndroid70\Xamarin.Android.Support.v7.CardView.dll - - - ..\..\..\..\packages\Xamarin.Android.Support.Media.Compat.25.4.0.2\lib\MonoAndroid70\Xamarin.Android.Support.Media.Compat.dll - - - ..\..\..\..\packages\Xamarin.Android.Support.Core.UI.25.4.0.2\lib\MonoAndroid70\Xamarin.Android.Support.Core.UI.dll - - - ..\..\..\..\packages\Xamarin.Android.Support.Core.Utils.25.4.0.2\lib\MonoAndroid70\Xamarin.Android.Support.Core.Utils.dll - - - ..\..\..\..\packages\Xamarin.Android.Support.Fragment.25.4.0.2\lib\MonoAndroid70\Xamarin.Android.Support.Fragment.dll - - - ..\..\..\..\packages\Xamarin.Android.Support.Design.25.4.0.2\lib\MonoAndroid70\Xamarin.Android.Support.Design.dll - - - ..\..\..\..\packages\Xamarin.Android.Support.Transition.25.4.0.2\lib\MonoAndroid70\Xamarin.Android.Support.Transition.dll - - - ..\..\..\..\packages\Xamarin.Android.Support.v4.25.4.0.2\lib\MonoAndroid70\Xamarin.Android.Support.v4.dll - - - ..\..\..\..\packages\Xamarin.Android.Support.v7.Palette.25.4.0.2\lib\MonoAndroid70\Xamarin.Android.Support.v7.Palette.dll - - - ..\..\..\..\packages\Xamarin.Android.Support.v7.AppCompat.25.4.0.2\lib\MonoAndroid70\Xamarin.Android.Support.v7.AppCompat.dll - - - ..\..\..\..\packages\Xamarin.Android.Support.v7.MediaRouter.25.4.0.2\lib\MonoAndroid70\Xamarin.Android.Support.v7.MediaRouter.dll - - - - - - - - - - - - - - - - - - - - - Assets\Montserrat-Bold.ttf - - - Assets\Montserrat-Regular.ttf - - - Assets\SourceSansPro-Regular.ttf - - - - - - - - - Designer - - - Designer - - - Designer - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {ba96a12c-4ee3-46c4-bb3f-f811b554cd01} - eShopOnContainers.Core - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From 77f11330ae6977c5e13e6342ce17a205d8144e70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Cobe=C3=B1a=20Mori=C3=A1n?= Date: Wed, 21 Mar 2018 16:24:36 +0100 Subject: [PATCH 38/45] Fixed login lifecycle in UWP --- .../Views/LoginView.xaml | 28 +++++-------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/LoginView.xaml b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/LoginView.xaml index f6b9bd72c..2bccd06d6 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/LoginView.xaml +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/LoginView.xaml @@ -337,28 +337,14 @@ Grid.RowSpan="2" IsVisible="{Binding IsLogin}"> + Source="{Binding LoginUrl}" + AbsoluteLayout.LayoutBounds="0, 0, 1, 1" + AbsoluteLayout.LayoutFlags="All"> - - - - - - - - - - - - + From f910e48c37fb73f156b19bc7e54525e9fba72761 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Coben=CC=83a=20Moria=CC=81n?= Date: Wed, 21 Mar 2018 16:56:27 +0100 Subject: [PATCH 39/45] Replaced endpoint with copy --- .../eShopOnContainers/eShopOnContainers.Core/GlobalSettings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/GlobalSettings.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/GlobalSettings.cs index 9b2b22b72..4c277d81b 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/GlobalSettings.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/GlobalSettings.cs @@ -4,7 +4,7 @@ { public const string AzureTag = "Azure"; public const string MockTag = "Mock"; - public const string DefaultEndpoint = "http://52.170.199.82"; + public const string DefaultEndpoint = "INSERT YOUR ENDPOINT HERE"; private string _baseEndpoint; private static readonly GlobalSetting _instance = new GlobalSetting(); From a91850a1903aa96e47c25dfcc7af00c54c20d9bc Mon Sep 17 00:00:00 2001 From: eiximenis Date: Wed, 21 Mar 2018 18:27:53 +0100 Subject: [PATCH 40/45] XamarinCallback config in k8s --- k8s/deploy.ps1 | 3 ++- k8s/deployments.yaml | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/k8s/deploy.ps1 b/k8s/deploy.ps1 index 1ac5a2770..0739d7ef0 100644 --- a/k8s/deploy.ps1 +++ b/k8s/deploy.ps1 @@ -138,7 +138,8 @@ ExecKube -cmd 'create configmap urls ` --from-literal=locations_e=http://$($externalDns)/locations-api ` --from-literal=marketing_e=http://$($externalDns)/marketing-api ` --from-literal=basket_e=http://$($externalDns)/basket-api ` - --from-literal=ordering_e=http://$($externalDns)/ordering-api ' + --from-literal=ordering_e=http://$($externalDns)/ordering-api ` + --from-literal=xamarin_callback_e=http://$($externalDns)/xamarincallback' ExecKube -cmd 'label configmap urls app=eshop' diff --git a/k8s/deployments.yaml b/k8s/deployments.yaml index 10007fe4c..a7f2f8d37 100644 --- a/k8s/deployments.yaml +++ b/k8s/deployments.yaml @@ -189,7 +189,12 @@ spec: valueFrom: configMapKeyRef: name: urls - key: webshoppingagg_e + key: webshoppingagg_e + - name: XamarinCallback + valueFrom: + configMapKeyRef: + name: urls + key: xamarin_callback_e - name: ApplicationInsights__InstrumentationKey valueFrom: configMapKeyRef: From 9ba004187dedc0482be8c93b867cca9db90990d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Coben=CC=83a=20Moria=CC=81n?= Date: Thu, 22 Mar 2018 09:29:16 +0100 Subject: [PATCH 41/45] Clarified endpoint URI --- .../eShopOnContainers/eShopOnContainers.Core/GlobalSettings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/GlobalSettings.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/GlobalSettings.cs index 4c277d81b..492dc1ca6 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/GlobalSettings.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/GlobalSettings.cs @@ -4,7 +4,7 @@ { public const string AzureTag = "Azure"; public const string MockTag = "Mock"; - public const string DefaultEndpoint = "INSERT YOUR ENDPOINT HERE"; + public const string DefaultEndpoint = "http://YOUR_IP_OR_DNS_NAME"; private string _baseEndpoint; private static readonly GlobalSetting _instance = new GlobalSetting(); From 4791be9298f3e319887c52e64e41d7c2eadbfb6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Coben=CC=83a=20Moria=CC=81n?= Date: Fri, 23 Mar 2018 10:26:02 +0100 Subject: [PATCH 42/45] Removed string.Format()s --- .../eShopOnContainers.Core/Services/Catalog/CatalogService.cs | 2 +- .../eShopOnContainers.Core/Services/Order/OrderService.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogService.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogService.cs index dd7cfe732..2811416ad 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogService.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogService.cs @@ -25,7 +25,7 @@ namespace eShopOnContainers.Core.Services.Catalog public async Task> FilterAsync(int catalogBrandId, int catalogTypeId) { UriBuilder builder = new UriBuilder(GlobalSetting.Instance.BaseEndpoint); - builder.Path = string.Format($"{ApiUrlBase}/items/type/{0}/brand/{1}", catalogTypeId, catalogBrandId); + builder.Path = $"{ApiUrlBase}/items/type/{catalogTypeId}/brand/{catalogBrandId}"; string uri = builder.ToString(); CatalogRoot catalog = await _requestProvider.GetAsync(uri); diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Order/OrderService.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Order/OrderService.cs index 0da0942ad..fb9a0c627 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Order/OrderService.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Order/OrderService.cs @@ -44,7 +44,7 @@ namespace eShopOnContainers.Core.Services.Order { UriBuilder builder = new UriBuilder(GlobalSetting.Instance.BaseEndpoint); - builder.Path = string.Format($"{ApiUrlBase}/{0}", orderId); + builder.Path = $"{ApiUrlBase}/{orderId}"; string uri = builder.ToString(); From adf46ff83749bea845127bccc460674bb1a9d2fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Coben=CC=83a=20Moria=CC=81n?= Date: Fri, 23 Mar 2018 10:28:30 +0100 Subject: [PATCH 43/45] Clarified endpoint style --- .../eShopOnContainers/eShopOnContainers.Core/GlobalSettings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/GlobalSettings.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/GlobalSettings.cs index 492dc1ca6..e1637d7be 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/GlobalSettings.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/GlobalSettings.cs @@ -4,7 +4,7 @@ { public const string AzureTag = "Azure"; public const string MockTag = "Mock"; - public const string DefaultEndpoint = "http://YOUR_IP_OR_DNS_NAME"; + public const string DefaultEndpoint = "http://YOUR_IP_OR_DNS_NAME"; // i.e.: "http://YOUR_IP" or "http://YOUR_DNS_NAME" private string _baseEndpoint; private static readonly GlobalSetting _instance = new GlobalSetting(); From a627d1f9e24d8526cf3bebc12f75805d1c4c7059 Mon Sep 17 00:00:00 2001 From: David Britch Date: Thu, 29 Mar 2018 13:26:26 +0100 Subject: [PATCH 44/45] SettingsService now uses Application.Current.Properties dictionary. Platform specific settings code removed. --- .../Extensions/ObservableExtension.cs | 1 - .../Services/Settings/ISettingsService.cs | 9 +- .../ISettingsServiceImplementation.cs | 13 - .../Services/Settings/SettingsService.cs | 109 ++- .../Extensions/LocationExtensions.cs | 2 +- .../Services/SettingsServiceImplementation.cs | 149 --- .../eShopOnContainers.Droid.csproj | 3 +- .../eShopOnContainers.TestRunner.iOS.csproj | 454 +++++----- .../Mocks/MockSettingsService.cs | 95 +- .../Services/SettingsServiceImplementation.cs | 128 --- .../eShopOnContainers.iOS.csproj | 849 +++++++++--------- 11 files changed, 811 insertions(+), 1001 deletions(-) delete mode 100644 src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Settings/ISettingsServiceImplementation.cs delete mode 100644 src/Mobile/eShopOnContainers/eShopOnContainers.Droid/Services/SettingsServiceImplementation.cs delete mode 100644 src/Mobile/eShopOnContainers/eShopOnContainers.iOS/Services/SettingsServiceImplementation.cs diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Extensions/ObservableExtension.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Extensions/ObservableExtension.cs index ad10bd941..800f9a031 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Extensions/ObservableExtension.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Extensions/ObservableExtension.cs @@ -15,7 +15,6 @@ namespace eShopOnContainers.Core.Extensions } return collection; - } } } \ No newline at end of file diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Settings/ISettingsService.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Settings/ISettingsService.cs index 5e2732bf9..69ede7b72 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Settings/ISettingsService.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Settings/ISettingsService.cs @@ -1,4 +1,6 @@ -namespace eShopOnContainers.Core.Services.Settings +using System.Threading.Tasks; + +namespace eShopOnContainers.Core.Services.Settings { public interface ISettingsService { @@ -10,5 +12,10 @@ string Latitude { get; set; } string Longitude { get; set; } bool AllowGpsLocation { get; set; } + + bool GetValueOrDefault(string key, bool defaultValue); + string GetValueOrDefault(string key, string defaultValue); + Task AddOrUpdateValue(string key, bool value); + Task AddOrUpdateValue(string key, string value); } } diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Settings/ISettingsServiceImplementation.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Settings/ISettingsServiceImplementation.cs deleted file mode 100644 index ef9d14ed6..000000000 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Settings/ISettingsServiceImplementation.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace eShopOnContainers.Core.Services.Settings -{ - public interface ISettingsServiceImplementation - { - bool GetValueOrDefault(string key, bool defaultValue); - string GetValueOrDefault(string key, string defaultValue); - - bool AddOrUpdateValue(string key, bool value); - bool AddOrUpdateValue(string key, string value); - - void Remove(string key); - } -} diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Settings/SettingsService.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Settings/SettingsService.cs index a13f53187..ca3e03c04 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Settings/SettingsService.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Settings/SettingsService.cs @@ -1,21 +1,11 @@ -using eShopOnContainers.Core.Services.Dependency; +using System; +using System.Threading.Tasks; +using Xamarin.Forms; namespace eShopOnContainers.Core.Services.Settings { public class SettingsService : ISettingsService { - private readonly ISettingsServiceImplementation _settingsService; - - ISettingsServiceImplementation AppSettings - { - get { return _settingsService; } - } - - public SettingsService(IDependencyService dependencyService) - { - _settingsService = dependencyService.Get(); - } - #region Setting Constants private const string AccessToken = "access_token"; @@ -37,52 +27,113 @@ namespace eShopOnContainers.Core.Services.Settings #endregion + #region Settings Properties + public string AuthAccessToken { - get => AppSettings.GetValueOrDefault(AccessToken, AccessTokenDefault); - set => AppSettings.AddOrUpdateValue(AccessToken, value); + get => GetValueOrDefault(AccessToken, AccessTokenDefault); + set => AddOrUpdateValue(AccessToken, value); } public string AuthIdToken { - get => AppSettings.GetValueOrDefault(IdToken, IdTokenDefault); - set => AppSettings.AddOrUpdateValue(IdToken, value); + get => GetValueOrDefault(IdToken, IdTokenDefault); + set => AddOrUpdateValue(IdToken, value); } public bool UseMocks { - get => AppSettings.GetValueOrDefault(IdUseMocks, UseMocksDefault); - set => AppSettings.AddOrUpdateValue(IdUseMocks, value); + get => GetValueOrDefault(IdUseMocks, UseMocksDefault); + set => AddOrUpdateValue(IdUseMocks, value); } public string UrlBase { - get => AppSettings.GetValueOrDefault(IdUrlBase, UrlBaseDefault); - set => AppSettings.AddOrUpdateValue(IdUrlBase, value); + get => GetValueOrDefault(IdUrlBase, UrlBaseDefault); + set => AddOrUpdateValue(IdUrlBase, value); } public bool UseFakeLocation { - get => AppSettings.GetValueOrDefault(IdUseFakeLocation, UseFakeLocationDefault); - set => AppSettings.AddOrUpdateValue(IdUseFakeLocation, value); + get => GetValueOrDefault(IdUseFakeLocation, UseFakeLocationDefault); + set => AddOrUpdateValue(IdUseFakeLocation, value); } public string Latitude { - get => AppSettings.GetValueOrDefault(IdLatitude, FakeLatitudeDefault.ToString()); - set => AppSettings.AddOrUpdateValue(IdLatitude, value); + get => GetValueOrDefault(IdLatitude, FakeLatitudeDefault.ToString()); + set => AddOrUpdateValue(IdLatitude, value); } public string Longitude { - get => AppSettings.GetValueOrDefault(IdLongitude, FakeLongitudeDefault.ToString()); - set => AppSettings.AddOrUpdateValue(IdLongitude, value); + get => GetValueOrDefault(IdLongitude, FakeLongitudeDefault.ToString()); + set => AddOrUpdateValue(IdLongitude, value); } public bool AllowGpsLocation { - get => AppSettings.GetValueOrDefault(IdAllowGpsLocation, AllowGpsLocationDefault); - set => AppSettings.AddOrUpdateValue(IdAllowGpsLocation, value); + get => GetValueOrDefault(IdAllowGpsLocation, AllowGpsLocationDefault); + set => AddOrUpdateValue(IdAllowGpsLocation, value); } + + #endregion + + #region Public Methods + + public Task AddOrUpdateValue(string key, bool value) => AddOrUpdateValueInternal(key, value); + public Task AddOrUpdateValue(string key, string value) => AddOrUpdateValueInternal(key, value); + public bool GetValueOrDefault(string key, bool defaultValue) => GetValueOrDefaultInternal(key, defaultValue); + public string GetValueOrDefault(string key, string defaultValue) => GetValueOrDefaultInternal(key, defaultValue); + + #endregion + + #region Internal Implementation + + async Task AddOrUpdateValueInternal(string key, T value) + { + if (value == null) + { + await Remove(key); + } + + Application.Current.Properties[key] = value; + try + { + await Application.Current.SavePropertiesAsync(); + } + catch (Exception ex) + { + Console.WriteLine("Unable to save: " + key, " Message: " + ex.Message); + } + } + + T GetValueOrDefaultInternal(string key, T defaultValue = default(T)) + { + object value = null; + if (Application.Current.Properties.ContainsKey(key)) + { + value = Application.Current.Properties[key]; + } + return null != value ? (T)value : defaultValue; + } + + async Task Remove(string key) + { + try + { + if (Application.Current.Properties[key] != null) + { + Application.Current.Properties.Remove(key); + await Application.Current.SavePropertiesAsync(); + } + } + catch (Exception ex) + { + Console.WriteLine("Unable to remove: " + key, " Message: " + ex.Message); + } + } + + #endregion } } \ No newline at end of file diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/Extensions/LocationExtensions.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/Extensions/LocationExtensions.cs index 41ea2ad3e..031c186aa 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/Extensions/LocationExtensions.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/Extensions/LocationExtensions.cs @@ -32,7 +32,7 @@ namespace eShopOnContainers.Droid.Extensions { return new DateTimeOffset(Epoch.AddMilliseconds(location.Time)); } - catch (Exception e) + catch (Exception) { return new DateTimeOffset(Epoch); } diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/Services/SettingsServiceImplementation.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/Services/SettingsServiceImplementation.cs deleted file mode 100644 index 7cdce4555..000000000 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/Services/SettingsServiceImplementation.cs +++ /dev/null @@ -1,149 +0,0 @@ -using Android.App; -using Android.Content; -using Android.Preferences; -using eShopOnContainers.Core.Services.Settings; -using eShopOnContainers.Droid.Services; -using System; - -[assembly: Xamarin.Forms.Dependency(typeof(SettingsServiceImplementation))] -namespace eShopOnContainers.Droid.Services -{ - public class SettingsServiceImplementation : ISettingsServiceImplementation - { - #region Internal Implementation - - readonly object _locker = new object(); - - ISharedPreferences GetSharedPreference() - { - return PreferenceManager.GetDefaultSharedPreferences(Application.Context); - } - - bool AddOrUpdateValueInternal(string key, T value) - { - if (Application.Context == null) - return false; - - if (value == null) - { - Remove(key); - return true; - } - - var type = typeof(T); - if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) - { - type = Nullable.GetUnderlyingType(type); - } - var typeCode = Type.GetTypeCode(type); - - lock (_locker) - { - using (var sharedPrefs = GetSharedPreference()) - { - using (var editor = sharedPrefs.Edit()) - { - switch (typeCode) - { - case TypeCode.Boolean: - editor.PutBoolean(key, Convert.ToBoolean(value)); - break; - case TypeCode.String: - editor.PutString(key, Convert.ToString(value)); - break; - default: - throw new ArgumentException($"Value of type {typeCode} is not supported."); - } - editor.Commit(); - } - } - } - return true; - } - - T GetValueOrDefaultInternal(string key, T defaultValue = default(T)) - { - if (Application.Context == null) - return defaultValue; - - if (!Contains(key)) - return defaultValue; - - lock (_locker) - { - using (var sharedPrefs = GetSharedPreference()) - { - var type = typeof(T); - if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) - { - type = Nullable.GetUnderlyingType(type); - } - - object value = null; - var typeCode = Type.GetTypeCode(type); - switch (typeCode) - { - case TypeCode.Boolean: - value = sharedPrefs.GetBoolean(key, Convert.ToBoolean(defaultValue)); - break; - case TypeCode.String: - value = sharedPrefs.GetString(key, Convert.ToString(defaultValue)); - break; - default: - throw new ArgumentException($"Value of type {typeCode} is not supported."); - } - - return null != value ? (T)value : defaultValue; - } - } - } - - bool Contains(string key) - { - if (Application.Context == null) - return false; - - lock (_locker) - { - using (var sharedPrefs = GetSharedPreference()) - { - if (sharedPrefs == null) - return false; - return sharedPrefs.Contains(key); - } - } - } - - #endregion - - #region ISettingsServiceImplementation - - public bool AddOrUpdateValue(string key, bool value) => AddOrUpdateValueInternal(key, value); - - public bool AddOrUpdateValue(string key, string value) => AddOrUpdateValueInternal(key, value); - - public bool GetValueOrDefault(string key, bool defaultValue) => GetValueOrDefaultInternal(key, defaultValue); - - public string GetValueOrDefault(string key, string defaultValue) => GetValueOrDefaultInternal(key, defaultValue); - - public void Remove(string key) - { - if (Application.Context == null) - return; - - lock (_locker) - { - using (var sharedPrefs = GetSharedPreference()) - { - using (var editor = sharedPrefs.Edit()) - { - editor.Remove(key); - editor.Commit(); - } - } - } - } - - #endregion - } -} diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/eShopOnContainers.Droid.csproj b/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/eShopOnContainers.Droid.csproj index 7d699f9d2..92e2df581 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/eShopOnContainers.Droid.csproj +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/eShopOnContainers.Droid.csproj @@ -19,7 +19,7 @@ Off Properties\AndroidManifest.xml true - v8.0 + v8.1 armeabi,armeabi-v7a,x86 @@ -211,7 +211,6 @@ - diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.iOS/eShopOnContainers.TestRunner.iOS.csproj b/src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.iOS/eShopOnContainers.TestRunner.iOS.csproj index 4a83a29a8..250d836a7 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.iOS/eShopOnContainers.TestRunner.iOS.csproj +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.iOS/eShopOnContainers.TestRunner.iOS.csproj @@ -1,232 +1,232 @@  - - - - Debug - iPhoneSimulator - {B68C2B56-7581-46AE-B55D-D25DDFD3BFE3} - {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Exe - eShopOnContainers.TestRunner.iOS - Resources - eShopOnContainersTestRunneriOS - - - - - true - full - false - bin\iPhoneSimulator\Debug - DEBUG - prompt - 4 - false - x86_64 - None - True - False - False - False - False - False - True - Default - HttpClientHandler - False - - - false - none - true - bin\iPhoneSimulator\Release - prompt - 4 - None - x86_64 - false - - - true - full - false - bin\iPhone\Debug - DEBUG - prompt - 4 - false - ARMv7, ARM64 - Entitlements.plist - iPhone Developer - true - None - - - false - none - true - bin\iPhone\Release - prompt - 4 - Entitlements.plist - ARMv7, ARM64 - false - iPhone Developer - - - none - True - bin\iPhone\Ad-Hoc - prompt - 4 - False - ARMv7, ARM64 - Entitlements.plist - True - Automatic:AdHoc - iPhone Distribution - - - none - True - bin\iPhone\AppStore - prompt - 4 - False - ARMv7, ARM64 - Entitlements.plist - Automatic:AppStore - iPhone Distribution - - - - - - - - - - - - - - - - ..\..\..\..\packages\Xamarin.Forms.2.5.0.122203\lib\Xamarin.iOS10\Xamarin.Forms.Core.dll - - - ..\..\..\..\packages\Xamarin.Forms.2.5.0.122203\lib\Xamarin.iOS10\Xamarin.Forms.Platform.dll - - - ..\..\..\..\packages\Xamarin.Forms.2.5.0.122203\lib\Xamarin.iOS10\Xamarin.Forms.Platform.iOS.dll - - - ..\..\..\..\packages\Xamarin.Forms.2.5.0.122203\lib\Xamarin.iOS10\Xamarin.Forms.Xaml.dll - - - - - - ..\..\..\..\packages\xunit.runner.devices.2.3.3\lib\xamarinios10\xunit.runner.devices.dll - - - ..\..\..\..\packages\xunit.runner.devices.2.3.3\lib\xamarinios10\xunit.runner.utility.netstandard15.dll - - - ..\..\..\..\packages\xunit.abstractions.2.0.1\lib\netstandard1.0\xunit.abstractions.dll - - - ..\..\..\..\packages\xunit.assert.2.3.1\lib\netstandard1.1\xunit.assert.dll - - - ..\..\..\..\packages\xunit.extensibility.core.2.3.1\lib\netstandard1.1\xunit.core.dll - - - ..\..\..\..\packages\xunit.extensibility.execution.2.3.1\lib\netstandard1.1\xunit.execution.dotnet.dll - - - - ..\..\..\..\packages\Newtonsoft.Json.10.0.3\lib\netstandard1.3\Newtonsoft.Json.dll - - - ..\..\..\..\packages\SlideOverKit.2.1.5\lib\Xamarin.iOS10\SlideOverKit.dll - - - ..\..\..\..\packages\SlideOverKit.2.1.5\lib\Xamarin.iOS10\SlideOverKit.iOS.dll - - - ..\..\..\..\packages\IdentityModel.3.0.0\lib\netstandard2.0\IdentityModel.dll - - - ..\..\..\..\packages\Acr.Support.2.1.0\lib\Xamarin.iOS10\Acr.Support.iOS.dll - - - ..\..\..\..\packages\BTProgressHUD.1.2.0.5\lib\Xamarin.iOS10\BTProgressHUD.dll - - - ..\..\..\..\packages\Splat.2.0.0\lib\Xamarin.iOS10\Splat.dll - - - ..\..\..\..\packages\Acr.UserDialogs.6.5.1\lib\Xamarin.iOS10\Acr.UserDialogs.dll - - - ..\..\..\..\packages\Acr.UserDialogs.6.5.1\lib\Xamarin.iOS10\Acr.UserDialogs.Interface.dll - - - ..\..\..\..\packages\WebP.Touch.1.0.7\lib\Xamarin.iOS10\WebP.Touch.dll - - - ..\..\..\..\packages\Xamarin.FFImageLoading.2.3.4\lib\Xamarin.iOS10\FFImageLoading.dll - - - ..\..\..\..\packages\Xamarin.FFImageLoading.2.3.4\lib\Xamarin.iOS10\FFImageLoading.Platform.dll - - - ..\..\..\..\packages\Xamarin.FFImageLoading.Forms.2.3.4\lib\Xamarin.iOS10\FFImageLoading.Forms.dll - - - ..\..\..\..\packages\Xamarin.FFImageLoading.Forms.2.3.4\lib\Xamarin.iOS10\FFImageLoading.Forms.Touch.dll - - - ..\..\..\..\packages\PInvoke.Windows.Core.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.Windows.Core.dll - - - ..\..\..\..\packages\PInvoke.Kernel32.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.Kernel32.dll - - - ..\..\..\..\packages\PInvoke.BCrypt.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.BCrypt.dll - - - ..\..\..\..\packages\PInvoke.NCrypt.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.NCrypt.dll - - - ..\..\..\..\packages\Validation.2.2.8\lib\dotnet\Validation.dll - - - ..\..\..\..\packages\PCLCrypto.2.0.147\lib\xamarinios10\PCLCrypto.dll - - - - - - - - {FDD910BC-DF0F-483D-B7D5-C7D831855172} - eShopOnContainers.UnitTests - - - - - - + + - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + Debug + iPhoneSimulator + {B68C2B56-7581-46AE-B55D-D25DDFD3BFE3} + {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Exe + eShopOnContainers.TestRunner.iOS + Resources + eShopOnContainersTestRunneriOS + + + true - - - - - - + + true + full + false + bin\iPhoneSimulator\Debug + DEBUG + prompt + 4 + false + x86_64 + None + True + False + False + False + False + False + True + Default + HttpClientHandler + False + + + false + none + true + bin\iPhoneSimulator\Release + prompt + 4 + None + x86_64 + false + + + true + full + false + bin\iPhone\Debug + DEBUG + prompt + 4 + false + ARMv7, ARM64 + Entitlements.plist + iPhone Developer + true + None + + + false + none + true + bin\iPhone\Release + prompt + 4 + Entitlements.plist + ARMv7, ARM64 + false + iPhone Developer + + + none + True + bin\iPhone\Ad-Hoc + prompt + 4 + False + ARMv7, ARM64 + Entitlements.plist + True + Automatic:AdHoc + iPhone Distribution + + + none + True + bin\iPhone\AppStore + prompt + 4 + False + ARMv7, ARM64 + Entitlements.plist + Automatic:AppStore + iPhone Distribution + + + + + + + + + + + + + + + + ..\..\..\..\packages\Xamarin.Forms.2.5.0.122203\lib\Xamarin.iOS10\Xamarin.Forms.Core.dll + + + ..\..\..\..\packages\Xamarin.Forms.2.5.0.122203\lib\Xamarin.iOS10\Xamarin.Forms.Platform.dll + + + ..\..\..\..\packages\Xamarin.Forms.2.5.0.122203\lib\Xamarin.iOS10\Xamarin.Forms.Platform.iOS.dll + + + ..\..\..\..\packages\Xamarin.Forms.2.5.0.122203\lib\Xamarin.iOS10\Xamarin.Forms.Xaml.dll + + + + + + ..\..\..\..\packages\xunit.runner.devices.2.3.3\lib\xamarinios10\xunit.runner.devices.dll + + + ..\..\..\..\packages\xunit.runner.devices.2.3.3\lib\xamarinios10\xunit.runner.utility.netstandard15.dll + + + ..\..\..\..\packages\xunit.abstractions.2.0.1\lib\netstandard1.0\xunit.abstractions.dll + + + ..\..\..\..\packages\xunit.assert.2.3.1\lib\netstandard1.1\xunit.assert.dll + + + ..\..\..\..\packages\xunit.extensibility.core.2.3.1\lib\netstandard1.1\xunit.core.dll + + + ..\..\..\..\packages\xunit.extensibility.execution.2.3.1\lib\netstandard1.1\xunit.execution.dotnet.dll + + + ..\..\..\..\packages\Newtonsoft.Json.10.0.3\lib\netstandard1.3\Newtonsoft.Json.dll + + + ..\..\..\..\packages\SlideOverKit.2.1.5\lib\Xamarin.iOS10\SlideOverKit.dll + + + ..\..\..\..\packages\SlideOverKit.2.1.5\lib\Xamarin.iOS10\SlideOverKit.iOS.dll + + + ..\..\..\..\packages\IdentityModel.3.0.0\lib\netstandard2.0\IdentityModel.dll + + + ..\..\..\..\packages\Acr.Support.2.1.0\lib\Xamarin.iOS10\Acr.Support.iOS.dll + + + ..\..\..\..\packages\BTProgressHUD.1.2.0.5\lib\Xamarin.iOS10\BTProgressHUD.dll + + + ..\..\..\..\packages\Splat.2.0.0\lib\Xamarin.iOS10\Splat.dll + + + ..\..\..\..\packages\Acr.UserDialogs.6.5.1\lib\Xamarin.iOS10\Acr.UserDialogs.dll + + + ..\..\..\..\packages\Acr.UserDialogs.6.5.1\lib\Xamarin.iOS10\Acr.UserDialogs.Interface.dll + + + ..\..\..\..\packages\WebP.Touch.1.0.7\lib\Xamarin.iOS10\WebP.Touch.dll + + + ..\..\..\..\packages\Xamarin.FFImageLoading.2.3.4\lib\Xamarin.iOS10\FFImageLoading.dll + + + ..\..\..\..\packages\Xamarin.FFImageLoading.2.3.4\lib\Xamarin.iOS10\FFImageLoading.Platform.dll + + + ..\..\..\..\packages\Xamarin.FFImageLoading.Forms.2.3.4\lib\Xamarin.iOS10\FFImageLoading.Forms.dll + + + ..\..\..\..\packages\Xamarin.FFImageLoading.Forms.2.3.4\lib\Xamarin.iOS10\FFImageLoading.Forms.Touch.dll + + + ..\..\..\..\packages\PInvoke.Windows.Core.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.Windows.Core.dll + + + ..\..\..\..\packages\PInvoke.Kernel32.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.Kernel32.dll + + + ..\..\..\..\packages\PInvoke.BCrypt.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.BCrypt.dll + + + ..\..\..\..\packages\PInvoke.NCrypt.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.NCrypt.dll + + + ..\..\..\..\packages\Validation.2.2.8\lib\dotnet\Validation.dll + + + ..\..\..\..\packages\PCLCrypto.2.0.147\lib\xamarinios10\PCLCrypto.dll + + + + + + + + {FDD910BC-DF0F-483D-B7D5-C7D831855172} + eShopOnContainers.UnitTests + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + \ No newline at end of file diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/Mocks/MockSettingsService.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/Mocks/MockSettingsService.cs index 23e1cedc5..37bfc125f 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/Mocks/MockSettingsService.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/Mocks/MockSettingsService.cs @@ -1,65 +1,110 @@ using eShopOnContainers.Core.Services.Settings; -using System; +using System.Collections.Generic; +using System.Threading.Tasks; namespace eShopOnContainers.UnitTests.Mocks { public class MockSettingsService : ISettingsService { - string _accessTokenDefault = string.Empty; - string _idTokenDefault = string.Empty; - bool _useMocksDefault = true; - string _urlBaseDefault = "https://13.88.8.119"; - bool _useFakeLocationDefault = false; - bool _allowGpsLocationDefault = false; - double _fakeLatitudeDefault = 47.604610d; - double _fakeLongitudeDefault = -122.315752d; + IDictionary _settings = new Dictionary(); + + const string AccessToken = "access_token"; + const string IdToken = "id_token"; + const string IdUseMocks = "use_mocks"; + const string IdUrlBase = "url_base"; + const string IdUseFakeLocation = "use_fake_location"; + const string IdLatitude = "latitude"; + const string IdLongitude = "longitude"; + const string IdAllowGpsLocation = "allow_gps_location"; + readonly string AccessTokenDefault = string.Empty; + readonly string IdTokenDefault = string.Empty; + readonly bool UseMocksDefault = true; + readonly bool UseFakeLocationDefault = false; + readonly bool AllowGpsLocationDefault = false; + readonly double FakeLatitudeDefault = 47.604610d; + readonly double FakeLongitudeDefault = -122.315752d; + readonly string UrlBaseDefault = "https://13.88.8.119"; public string AuthAccessToken { - get { return _accessTokenDefault; } - set { _accessTokenDefault = value; } + get => GetValueOrDefault(AccessToken, AccessTokenDefault); + set => AddOrUpdateValue(AccessToken, value); } public string AuthIdToken { - get { return _idTokenDefault; } - set { _idTokenDefault = value; } + get => GetValueOrDefault(IdToken, IdTokenDefault); + set => AddOrUpdateValue(IdToken, value); } public bool UseMocks { - get { return _useMocksDefault; } - set { _useMocksDefault = value; } + get => GetValueOrDefault(IdUseMocks, UseMocksDefault); + set => AddOrUpdateValue(IdUseMocks, value); } public string UrlBase { - get { return _urlBaseDefault; } - set { _urlBaseDefault = value; } + get => GetValueOrDefault(IdUrlBase, UrlBaseDefault); + set => AddOrUpdateValue(IdUrlBase, value); } public bool UseFakeLocation { - get { return _useFakeLocationDefault; } - set { _useFakeLocationDefault = value; } + get => GetValueOrDefault(IdUseFakeLocation, UseFakeLocationDefault); + set => AddOrUpdateValue(IdUseFakeLocation, value); } public string Latitude { - get { return _fakeLatitudeDefault.ToString(); } - set { _fakeLatitudeDefault = Convert.ToDouble(value); } + get => GetValueOrDefault(IdLatitude, FakeLatitudeDefault.ToString()); + set => AddOrUpdateValue(IdLatitude, value); } public string Longitude { - get { return _fakeLongitudeDefault.ToString(); } - set { _fakeLongitudeDefault = Convert.ToDouble(value); } + get => GetValueOrDefault(IdLongitude, FakeLongitudeDefault.ToString()); + set => AddOrUpdateValue(IdLongitude, value); } public bool AllowGpsLocation { - get { return _allowGpsLocationDefault; } - set { _allowGpsLocationDefault = value; } + get => GetValueOrDefault(IdAllowGpsLocation, AllowGpsLocationDefault); + set => AddOrUpdateValue(IdAllowGpsLocation, value); + } + + public Task AddOrUpdateValue(string key, bool value) => AddOrUpdateValueInternal(key, value); + public Task AddOrUpdateValue(string key, string value) => AddOrUpdateValueInternal(key, value); + public bool GetValueOrDefault(string key, bool defaultValue) => GetValueOrDefaultInternal(key, defaultValue); + public string GetValueOrDefault(string key, string defaultValue) => GetValueOrDefaultInternal(key, defaultValue); + + Task AddOrUpdateValueInternal(string key, T value) + { + if (value == null) + { + Remove(key); + } + + _settings[key] = value; + return Task.Delay(10); + } + + T GetValueOrDefaultInternal(string key, T defaultValue = default(T)) + { + object value = null; + if (_settings.ContainsKey(key)) + { + value = _settings[key]; + } + return null != value ? (T)value : defaultValue; + } + + void Remove(string key) + { + if (_settings[key] != null) + { + _settings.Remove(key); + } } } } diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.iOS/Services/SettingsServiceImplementation.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.iOS/Services/SettingsServiceImplementation.cs deleted file mode 100644 index ee17b8ff7..000000000 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.iOS/Services/SettingsServiceImplementation.cs +++ /dev/null @@ -1,128 +0,0 @@ -using eShopOnContainers.Core.Services.Settings; -using eShopOnContainers.iOS.Services; -using Foundation; -using System; - -[assembly: Xamarin.Forms.Dependency(typeof(SettingsServiceImplementation))] -namespace eShopOnContainers.iOS.Services -{ - public class SettingsServiceImplementation : ISettingsServiceImplementation - { - #region Internal Implementation - - readonly object _locker = new object(); - - NSUserDefaults GetUserDefaults() => NSUserDefaults.StandardUserDefaults; - - bool AddOrUpdateValueInternal(string key, T value) - { - if (value == null) - { - Remove(key); - return true; - } - - var type = typeof(T); - if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) - { - type = Nullable.GetUnderlyingType(type); - } - var typeCode = Type.GetTypeCode(type); - - lock (_locker) - { - var defaults = GetUserDefaults(); - switch (typeCode) - { - case TypeCode.Boolean: - defaults.SetBool(Convert.ToBoolean(value), key); - break; - case TypeCode.String: - defaults.SetString(Convert.ToString(value), key); - break; - default: - throw new ArgumentException($"Value of type {typeCode} is unsupported."); - } - - try - { - defaults.Synchronize(); - } - catch (Exception ex) - { - Console.WriteLine("Unable to save: " + key, " Message: " + ex.Message); - } - } - return true; - } - - T GetValueOrDefaultInternal(string key, T defaultValue = default(T)) - { - lock (_locker) - { - var defaults = GetUserDefaults(); - - if (defaults[key] == null) - { - return defaultValue; - } - - var type = typeof(T); - if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) - { - type = Nullable.GetUnderlyingType(type); - } - - object value = null; - var typeCode = Type.GetTypeCode(type); - switch (typeCode) - { - case TypeCode.Boolean: - value = defaults.BoolForKey(key); - break; - case TypeCode.String: - value = defaults.StringForKey(key); - break; - default: - throw new ArgumentException($"Value of type {typeCode} is unsupported."); - } - - return null != value ? (T)value : defaultValue; - } - } - - #endregion - - #region ISettingsServiceImplementation - - public bool AddOrUpdateValue(string key, bool value) => AddOrUpdateValueInternal(key, value); - - public bool AddOrUpdateValue(string key, string value) => AddOrUpdateValueInternal(key, value); - - public bool GetValueOrDefault(string key, bool defaultValue) => GetValueOrDefaultInternal(key, defaultValue); - - public string GetValueOrDefault(string key, string defaultValue) => GetValueOrDefaultInternal(key, defaultValue); - - public void Remove(string key) - { - lock (_locker) - { - var defaults = GetUserDefaults(); - try - { - if (defaults[key] != null) - { - defaults.RemoveObject(key); - defaults.Synchronize(); - } - } - catch (Exception ex) - { - Console.WriteLine("Unable to remove: " + key, " Message: " + ex.Message); - } - } - } - - #endregion - } -} diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.iOS/eShopOnContainers.iOS.csproj b/src/Mobile/eShopOnContainers/eShopOnContainers.iOS/eShopOnContainers.iOS.csproj index 6ea0a4465..3d18f3a5c 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.iOS/eShopOnContainers.iOS.csproj +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.iOS/eShopOnContainers.iOS.csproj @@ -1,429 +1,428 @@  - - - Debug - iPhoneSimulator - 8.0.30703 - 2.0 - {6EEB23DC-7063-4444-9AF8-90DF24F549C0} - {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Exe - eShopOnContainers.iOS - Resources - eShopOnContainersiOS - - - true - - - true - full - false - bin\iPhoneSimulator\Debug - DEBUG - prompt - 4 - false - i386, x86_64 - None - True - False - False - False - False - False - True - Default - HttpClientHandler - False - - - none - true - bin\iPhoneSimulator\Release - prompt - 4 - None - i386, x86_64 - false - - - true - full - false - bin\iPhone\Debug - DEBUG - prompt - 4 - false - ARMv7, ARM64 - iPhone Developer - true - Entitlements.plist - None - - - none - true - bin\iPhone\Release - prompt - 4 - ARMv7, ARM64 - false - iPhone Developer - Entitlements.plist - - - none - True - bin\iPhone\Ad-Hoc - prompt - 4 - False - ARMv7, ARM64 - True - Automatic:AdHoc - iPhone Distribution - Entitlements.plist - - - none - True - bin\iPhone\AppStore - prompt - 4 - False - ARMv7, ARM64 - Automatic:AppStore - iPhone Distribution - Entitlements.plist - - - - - - - Resources\fonts\Montserrat-Bold.ttf - - - Resources\fonts\Montserrat-Regular.ttf - - - Resources\fonts\SourceSansPro-Regular.ttf - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ..\..\..\..\packages\Xamarin.Forms.2.5.0.122203\lib\Xamarin.iOS10\Xamarin.Forms.Core.dll - - - ..\..\..\..\packages\Xamarin.Forms.2.5.0.122203\lib\Xamarin.iOS10\Xamarin.Forms.Platform.dll - - - ..\..\..\..\packages\Xamarin.Forms.2.5.0.122203\lib\Xamarin.iOS10\Xamarin.Forms.Platform.iOS.dll - - - ..\..\..\..\packages\Xamarin.Forms.2.5.0.122203\lib\Xamarin.iOS10\Xamarin.Forms.Xaml.dll - - - ..\..\..\..\packages\WebP.Touch.1.0.7\lib\Xamarin.iOS10\WebP.Touch.dll - - - ..\..\..\..\packages\Xamarin.FFImageLoading.2.3.4\lib\Xamarin.iOS10\FFImageLoading.dll - - - ..\..\..\..\packages\Xamarin.FFImageLoading.2.3.4\lib\Xamarin.iOS10\FFImageLoading.Platform.dll - - - ..\..\..\..\packages\Xamarin.FFImageLoading.Forms.2.3.4\lib\Xamarin.iOS10\FFImageLoading.Forms.dll - - - ..\..\..\..\packages\Xamarin.FFImageLoading.Forms.2.3.4\lib\Xamarin.iOS10\FFImageLoading.Forms.Touch.dll - - - ..\..\..\..\packages\SlideOverKit.2.1.5\lib\Xamarin.iOS10\SlideOverKit.dll - - - ..\..\..\..\packages\SlideOverKit.2.1.5\lib\Xamarin.iOS10\SlideOverKit.iOS.dll - - - ..\..\..\..\packages\Xam.Plugins.Settings.3.1.1\lib\Xamarin.iOS10\Plugin.Settings.Abstractions.dll - - - ..\..\..\..\packages\Xam.Plugins.Settings.3.1.1\lib\Xamarin.iOS10\Plugin.Settings.dll - - - - ..\..\..\..\packages\Newtonsoft.Json.10.0.3\lib\netstandard1.3\Newtonsoft.Json.dll - - - ..\..\..\..\packages\Acr.Support.2.1.0\lib\Xamarin.iOS10\Acr.Support.iOS.dll - - - ..\..\..\..\packages\BTProgressHUD.1.2.0.5\lib\Xamarin.iOS10\BTProgressHUD.dll - - - ..\..\..\..\packages\Splat.2.0.0\lib\Xamarin.iOS10\Splat.dll - - - ..\..\..\..\packages\Acr.UserDialogs.6.5.1\lib\Xamarin.iOS10\Acr.UserDialogs.dll - - - ..\..\..\..\packages\Acr.UserDialogs.6.5.1\lib\Xamarin.iOS10\Acr.UserDialogs.Interface.dll - - - ..\..\..\..\packages\PInvoke.Windows.Core.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.Windows.Core.dll - - - ..\..\..\..\packages\PInvoke.Kernel32.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.Kernel32.dll - - - ..\..\..\..\packages\PInvoke.BCrypt.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.BCrypt.dll - - - ..\..\..\..\packages\PInvoke.NCrypt.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.NCrypt.dll - - - ..\..\..\..\packages\Validation.2.2.8\lib\dotnet\Validation.dll - - - ..\..\..\..\packages\PCLCrypto.2.0.147\lib\xamarinios10\PCLCrypto.dll - - - ..\..\..\..\packages\IdentityModel.3.0.0\lib\netstandard2.0\IdentityModel.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - false - - - false - - - false - - - false - - - false - - - false - - - false - - - false - - - false - - - false - - - false - - - false - - - false - - - false - - - false - - - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {76C5F2A7-6CD5-49EA-9F33-EC44DE6539C7} - eShopOnContainers.Core - - - - - - - - - + - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + Debug + iPhoneSimulator + 8.0.30703 + 2.0 + {6EEB23DC-7063-4444-9AF8-90DF24F549C0} + {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Exe + eShopOnContainers.iOS + Resources + eShopOnContainersiOS + + + true + true - - - + + true + full + false + bin\iPhoneSimulator\Debug + DEBUG + prompt + 4 + false + i386, x86_64 + None + True + False + False + False + False + False + True + Default + HttpClientHandler + False + + + none + true + bin\iPhoneSimulator\Release + prompt + 4 + None + i386, x86_64 + false + + + true + full + false + bin\iPhone\Debug + DEBUG + prompt + 4 + false + ARMv7, ARM64 + iPhone Developer + true + Entitlements.plist + None + + + none + true + bin\iPhone\Release + prompt + 4 + ARMv7, ARM64 + false + iPhone Developer + Entitlements.plist + + + none + True + bin\iPhone\Ad-Hoc + prompt + 4 + False + ARMv7, ARM64 + True + Automatic:AdHoc + iPhone Distribution + Entitlements.plist + + + none + True + bin\iPhone\AppStore + prompt + 4 + False + ARMv7, ARM64 + Automatic:AppStore + iPhone Distribution + Entitlements.plist + + + + + + + Resources\fonts\Montserrat-Bold.ttf + + + Resources\fonts\Montserrat-Regular.ttf + + + Resources\fonts\SourceSansPro-Regular.ttf + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ..\..\..\..\packages\Xamarin.Forms.2.5.0.122203\lib\Xamarin.iOS10\Xamarin.Forms.Core.dll + + + ..\..\..\..\packages\Xamarin.Forms.2.5.0.122203\lib\Xamarin.iOS10\Xamarin.Forms.Platform.dll + + + ..\..\..\..\packages\Xamarin.Forms.2.5.0.122203\lib\Xamarin.iOS10\Xamarin.Forms.Platform.iOS.dll + + + ..\..\..\..\packages\Xamarin.Forms.2.5.0.122203\lib\Xamarin.iOS10\Xamarin.Forms.Xaml.dll + + + ..\..\..\..\packages\WebP.Touch.1.0.7\lib\Xamarin.iOS10\WebP.Touch.dll + + + ..\..\..\..\packages\Xamarin.FFImageLoading.2.3.4\lib\Xamarin.iOS10\FFImageLoading.dll + + + ..\..\..\..\packages\Xamarin.FFImageLoading.2.3.4\lib\Xamarin.iOS10\FFImageLoading.Platform.dll + + + ..\..\..\..\packages\Xamarin.FFImageLoading.Forms.2.3.4\lib\Xamarin.iOS10\FFImageLoading.Forms.dll + + + ..\..\..\..\packages\Xamarin.FFImageLoading.Forms.2.3.4\lib\Xamarin.iOS10\FFImageLoading.Forms.Touch.dll + + + ..\..\..\..\packages\SlideOverKit.2.1.5\lib\Xamarin.iOS10\SlideOverKit.dll + + + ..\..\..\..\packages\SlideOverKit.2.1.5\lib\Xamarin.iOS10\SlideOverKit.iOS.dll + + + ..\..\..\..\packages\Xam.Plugins.Settings.3.1.1\lib\Xamarin.iOS10\Plugin.Settings.Abstractions.dll + + + ..\..\..\..\packages\Xam.Plugins.Settings.3.1.1\lib\Xamarin.iOS10\Plugin.Settings.dll + + + ..\..\..\..\packages\Newtonsoft.Json.10.0.3\lib\netstandard1.3\Newtonsoft.Json.dll + + + ..\..\..\..\packages\Acr.Support.2.1.0\lib\Xamarin.iOS10\Acr.Support.iOS.dll + + + ..\..\..\..\packages\BTProgressHUD.1.2.0.5\lib\Xamarin.iOS10\BTProgressHUD.dll + + + ..\..\..\..\packages\Splat.2.0.0\lib\Xamarin.iOS10\Splat.dll + + + ..\..\..\..\packages\Acr.UserDialogs.6.5.1\lib\Xamarin.iOS10\Acr.UserDialogs.dll + + + ..\..\..\..\packages\Acr.UserDialogs.6.5.1\lib\Xamarin.iOS10\Acr.UserDialogs.Interface.dll + + + ..\..\..\..\packages\PInvoke.Windows.Core.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.Windows.Core.dll + + + ..\..\..\..\packages\PInvoke.Kernel32.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.Kernel32.dll + + + ..\..\..\..\packages\PInvoke.BCrypt.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.BCrypt.dll + + + ..\..\..\..\packages\PInvoke.NCrypt.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.NCrypt.dll + + + ..\..\..\..\packages\Validation.2.2.8\lib\dotnet\Validation.dll + + + ..\..\..\..\packages\PCLCrypto.2.0.147\lib\xamarinios10\PCLCrypto.dll + + + ..\..\..\..\packages\IdentityModel.3.0.0\lib\netstandard2.0\IdentityModel.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + false + + + false + + + false + + + false + + + false + + + false + + + false + + + false + + + false + + + false + + + false + + + false + + + false + + + false + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {76C5F2A7-6CD5-49EA-9F33-EC44DE6539C7} + eShopOnContainers.Core + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + \ No newline at end of file From 8a32e3fe10f82c67d49d611b39b328102bdb2120 Mon Sep 17 00:00:00 2001 From: David Britch Date: Thu, 29 Mar 2018 13:42:49 +0100 Subject: [PATCH 45/45] Removed UWP SettingsServiceImplementation --- .../Services/SettingsServiceImplementation.cs | 99 ------------------- .../eShopOnContainers.Windows.csproj | 1 - 2 files changed, 100 deletions(-) delete mode 100644 src/Mobile/eShopOnContainers/eShopOnContainers.Windows/Services/SettingsServiceImplementation.cs diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Windows/Services/SettingsServiceImplementation.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Windows/Services/SettingsServiceImplementation.cs deleted file mode 100644 index e13fafd9f..000000000 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Windows/Services/SettingsServiceImplementation.cs +++ /dev/null @@ -1,99 +0,0 @@ -using eShopOnContainers.Core.Services.Settings; -using eShopOnContainers.Windows.Services; -using Windows.Storage; - -[assembly: Xamarin.Forms.Dependency(typeof(SettingsServiceImplementation))] -namespace eShopOnContainers.Windows.Services -{ - public class SettingsServiceImplementation : ISettingsServiceImplementation - { - #region Internal Implementation - - readonly object _locker = new object(); - - ApplicationDataContainer GetAppSettings() - { - return ApplicationData.Current.LocalSettings; - } - - bool AddOrUpdateValueInternal(string key, T value) - { - bool valueChanged = false; - - if (value == null) - { - Remove(key); - return true; - } - - lock (_locker) - { - var settings = GetAppSettings(); - if (settings.Values.ContainsKey(key)) - { - if (settings.Values[key] != (object)value) - { - settings.Values[key] = value; - valueChanged = true; - } - } - else - { - settings.Values[key] = value; - valueChanged = true; - } - } - - return valueChanged; - } - - T GetValueOrDefaultInternal(string key, T defaultValue = default(T)) - { - object value; - - lock (_locker) - { - var settings = GetAppSettings(); - if (settings.Values.ContainsKey(key)) - { - var tempValue = settings.Values[key]; - if (tempValue != null) - value = (T)tempValue; - else - value = defaultValue; - } - else - { - value = defaultValue; - } - } - return null != value ? (T)value : defaultValue; - } - - #endregion - - #region ISettingsServiceImplementation - - public bool AddOrUpdateValue(string key, bool value) => AddOrUpdateValueInternal(key, value); - - public bool AddOrUpdateValue(string key, string value) => AddOrUpdateValueInternal(key, value); - - public bool GetValueOrDefault(string key, bool defaultValue) => GetValueOrDefaultInternal(key, defaultValue); - - public string GetValueOrDefault(string key, string defaultValue) => GetValueOrDefaultInternal(key, defaultValue); - - public void Remove(string key) - { - lock (_locker) - { - var settings = GetAppSettings(); - if (settings.Values.ContainsKey(key)) - { - settings.Values.Remove(key); - } - } - } - - #endregion - } -} diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Windows/eShopOnContainers.Windows.csproj b/src/Mobile/eShopOnContainers/eShopOnContainers.Windows/eShopOnContainers.Windows.csproj index b879d31c6..9a1a2d108 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Windows/eShopOnContainers.Windows.csproj +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Windows/eShopOnContainers.Windows.csproj @@ -123,7 +123,6 @@ -