From 5fa869ef14fa2058a140685e4aa007cedde372cc Mon Sep 17 00:00:00 2001 From: Phong Nguyen Date: Mon, 13 Jan 2025 09:16:10 +0700 Subject: [PATCH] Remove GraphQL --- .github/workflows/.net-build-monolith.yml | 13 +- .github/workflows/docker-build-monolith.yml | 2 - .../.helm/monolith/charts/graphql/Chart.yaml | 4 - .../graphql/templates/graphql.deployment.yaml | 30 ---- .../graphql/templates/graphql.service.yaml | 15 -- .../.helm/monolith/charts/graphql/values.yaml | 0 src/Monolith/.k8s/graphql.deployment.yaml | 30 ---- src/Monolith/.k8s/graphql.service.yaml | 15 -- src/Monolith/.vscode/launch.json | 23 +-- .../ClassifiedAds.AspireAppHost.csproj | 1 - .../ClassifiedAds.AspireAppHost/Program.cs | 1 - .../ClassifiedAds.GraphQL.csproj | 20 --- .../ClassifiedAdsMutation.cs | 52 ------ .../ClassifiedAdsQuery.cs | 37 ---- src/Monolith/ClassifiedAds.GraphQL/Dockerfile | 26 --- .../DownstreamServices/ProductService.cs | 85 --------- src/Monolith/ClassifiedAds.GraphQL/Program.cs | 78 --------- .../Properties/launchSettings.json | 29 ---- .../appsettings.Development.json | 9 - .../ClassifiedAds.GraphQL/appsettings.json | 14 -- .../ClassifiedAds.IntegrationTests.csproj | 2 - .../Configuration/AppSettings.cs | 2 - .../GraphQL/ProductTests.cs | 162 ------------------ .../appsettings.json | 3 - src/Monolith/ClassifiedAds.Monolith.sln | 7 - src/Monolith/Jenkinsfile | 1 - src/Monolith/README.md | 6 +- src/Monolith/azure-pipelines.yml | 3 - src/Monolith/docker build.txt | 3 - src/Monolith/docker-compose.volumes.yml | 3 - src/Monolith/docker-compose.yml | 13 -- 31 files changed, 4 insertions(+), 685 deletions(-) delete mode 100644 src/Monolith/.helm/monolith/charts/graphql/Chart.yaml delete mode 100644 src/Monolith/.helm/monolith/charts/graphql/templates/graphql.deployment.yaml delete mode 100644 src/Monolith/.helm/monolith/charts/graphql/templates/graphql.service.yaml delete mode 100644 src/Monolith/.helm/monolith/charts/graphql/values.yaml delete mode 100644 src/Monolith/.k8s/graphql.deployment.yaml delete mode 100644 src/Monolith/.k8s/graphql.service.yaml delete mode 100644 src/Monolith/ClassifiedAds.GraphQL/ClassifiedAds.GraphQL.csproj delete mode 100644 src/Monolith/ClassifiedAds.GraphQL/ClassifiedAdsMutation.cs delete mode 100644 src/Monolith/ClassifiedAds.GraphQL/ClassifiedAdsQuery.cs delete mode 100644 src/Monolith/ClassifiedAds.GraphQL/Dockerfile delete mode 100644 src/Monolith/ClassifiedAds.GraphQL/DownstreamServices/ProductService.cs delete mode 100644 src/Monolith/ClassifiedAds.GraphQL/Program.cs delete mode 100644 src/Monolith/ClassifiedAds.GraphQL/Properties/launchSettings.json delete mode 100644 src/Monolith/ClassifiedAds.GraphQL/appsettings.Development.json delete mode 100644 src/Monolith/ClassifiedAds.GraphQL/appsettings.json delete mode 100644 src/Monolith/ClassifiedAds.IntegrationTests/GraphQL/ProductTests.cs diff --git a/.github/workflows/.net-build-monolith.yml b/.github/workflows/.net-build-monolith.yml index 5756ce595..64ed0fe1b 100644 --- a/.github/workflows/.net-build-monolith.yml +++ b/.github/workflows/.net-build-monolith.yml @@ -30,10 +30,7 @@ jobs: - name: Publish ClassifiedAds.Background run: dotnet publish ClassifiedAds.Background/*.csproj --configuration Release - - - name: Publish ClassifiedAds.GraphQL - run: dotnet publish ClassifiedAds.GraphQL/*.csproj --configuration Release - + - name: Publish ClassifiedAds.Migrator run: dotnet publish ClassifiedAds.Migrator/*.csproj --configuration Release @@ -54,12 +51,6 @@ jobs: with: name: ClassifiedAds.Background path: src/Monolith/ClassifiedAds.Background/bin/Release/net8.0/publish - - - name: Upload ClassifiedAds.GraphQL - uses: actions/upload-artifact@v4 - with: - name: ClassifiedAds.GraphQL - path: src/Monolith/ClassifiedAds.GraphQL/bin/Release/net8.0/publish - name: Upload ClassifiedAds.Migrator uses: actions/upload-artifact@v4 @@ -72,7 +63,7 @@ jobs: with: name: ClassifiedAds.WebAPI path: src/Monolith/ClassifiedAds.WebAPI/bin/Release/net8.0/publish - + - name: Upload ClassifiedAds.WebMVC uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/docker-build-monolith.yml b/.github/workflows/docker-build-monolith.yml index fb2119f85..d579f3486 100644 --- a/.github/workflows/docker-build-monolith.yml +++ b/.github/workflows/docker-build-monolith.yml @@ -43,7 +43,6 @@ jobs: docker tag classifiedads.background $REPO_NAME/classifiedads.background:$VERSION docker tag classifiedads.migrator $REPO_NAME/classifiedads.migrator:$VERSION docker tag classifiedads.webapi $REPO_NAME/classifiedads.webapi:$VERSION - docker tag classifiedads.graphql $REPO_NAME/classifiedads.graphql:$VERSION docker tag classifiedads.blazor $REPO_NAME/classifiedads.blazor:$VERSION docker tag classifiedads.identityserver $REPO_NAME/classifiedads.identityserver:$VERSION docker tag classifiedads.webmvc $REPO_NAME/classifiedads.webmvc:$VERSION @@ -51,7 +50,6 @@ jobs: docker push $REPO_NAME/classifiedads.background:$VERSION docker push $REPO_NAME/classifiedads.migrator:$VERSION docker push $REPO_NAME/classifiedads.webapi:$VERSION - docker push $REPO_NAME/classifiedads.graphql:$VERSION docker push $REPO_NAME/classifiedads.blazor:$VERSION docker push $REPO_NAME/classifiedads.identityserver:$VERSION docker push $REPO_NAME/classifiedads.webmvc:$VERSION diff --git a/src/Monolith/.helm/monolith/charts/graphql/Chart.yaml b/src/Monolith/.helm/monolith/charts/graphql/Chart.yaml deleted file mode 100644 index 2cabb8bd0..000000000 --- a/src/Monolith/.helm/monolith/charts/graphql/Chart.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v2 -name: graphql -version: 1.0.0 -type: application \ No newline at end of file diff --git a/src/Monolith/.helm/monolith/charts/graphql/templates/graphql.deployment.yaml b/src/Monolith/.helm/monolith/charts/graphql/templates/graphql.deployment.yaml deleted file mode 100644 index 4296abf89..000000000 --- a/src/Monolith/.helm/monolith/charts/graphql/templates/graphql.deployment.yaml +++ /dev/null @@ -1,30 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - labels: - app: {{ .Release.Name}}-graphql - name: {{ .Release.Name}}-graphql -spec: - replicas: 1 - selector: - matchLabels: - app: {{ .Release.Name}}-graphql - strategy: {} - template: - metadata: - labels: - app: {{ .Release.Name}}-graphql - spec: - containers: - - env: - - name: ResourceServer__Endpoint - value: http://{{ .Release.Name}}-webapi - - name: ResourceServer__PublicEndpoint - value: http://host.docker.internal:9002 - image: phongnguyend/classifiedads.graphql - name: {{ .Release.Name}}-graphql - ports: - - containerPort: 80 - resources: {} - restartPolicy: Always -status: {} diff --git a/src/Monolith/.helm/monolith/charts/graphql/templates/graphql.service.yaml b/src/Monolith/.helm/monolith/charts/graphql/templates/graphql.service.yaml deleted file mode 100644 index 2864b50b7..000000000 --- a/src/Monolith/.helm/monolith/charts/graphql/templates/graphql.service.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - labels: - app: {{ .Release.Name}}-graphql - name: {{ .Release.Name}}-graphql -spec: - ports: - - name: "80" - port: 80 - targetPort: 80 - selector: - app: {{ .Release.Name}}-graphql -status: - loadBalancer: {} diff --git a/src/Monolith/.helm/monolith/charts/graphql/values.yaml b/src/Monolith/.helm/monolith/charts/graphql/values.yaml deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/Monolith/.k8s/graphql.deployment.yaml b/src/Monolith/.k8s/graphql.deployment.yaml deleted file mode 100644 index f04ec010c..000000000 --- a/src/Monolith/.k8s/graphql.deployment.yaml +++ /dev/null @@ -1,30 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - labels: - app: graphql - name: graphql -spec: - replicas: 1 - selector: - matchLabels: - app: graphql - strategy: {} - template: - metadata: - labels: - app: graphql - spec: - containers: - - env: - - name: ResourceServer__Endpoint - value: http://webapi - - name: ResourceServer__PublicEndpoint - value: http://host.docker.internal:9002 - image: phongnguyend/classifiedads.graphql - name: graphql - ports: - - containerPort: 80 - resources: {} - restartPolicy: Always -status: {} diff --git a/src/Monolith/.k8s/graphql.service.yaml b/src/Monolith/.k8s/graphql.service.yaml deleted file mode 100644 index 455f3af54..000000000 --- a/src/Monolith/.k8s/graphql.service.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - labels: - app: graphql - name: graphql -spec: - ports: - - name: "80" - port: 80 - targetPort: 80 - selector: - app: graphql -status: - loadBalancer: {} diff --git a/src/Monolith/.vscode/launch.json b/src/Monolith/.vscode/launch.json index 5d58dd912..3979dec72 100644 --- a/src/Monolith/.vscode/launch.json +++ b/src/Monolith/.vscode/launch.json @@ -18,27 +18,6 @@ "DOTNET_ENVIRONMENT": "Development" }, }, - { - "name": "ClassifiedAds.GraphQL", - "type": "coreclr", - "request": "launch", - //"preLaunchTask": "build", - "program": "${workspaceFolder}/ClassifiedAds.GraphQL/bin/Debug/net6.0/ClassifiedAds.GraphQL.dll", - "args": [], - "cwd": "${workspaceFolder}/ClassifiedAds.GraphQL", - "stopAtEntry": false, - "serverReadyAction": { - "action": "openExternally", - "pattern": "\\bNow listening on:\\s+(https?://\\S+)" - }, - "env": { - "ASPNETCORE_ENVIRONMENT": "Development", - "ASPNETCORE_URLS": "https://localhost:44392/" - }, - "sourceFileMap": { - "/Views": "${workspaceFolder}/Views" - } - }, { "name": "ClassifiedAds.Migrator", "type": "coreclr", @@ -174,7 +153,7 @@ "compounds": [ { "name": "ClassifiedAds.Monolith", - "configurations": ["ClassifiedAds.Background", "ClassifiedAds.GraphQL", "ClassifiedAds.Migrator", "ClassifiedAds.WebAPI","ClassifiedAds.BlazorServerSide","ClassifiedAds.BlazorWebAssembly","ClassifiedAds.IdentityServer","ClassifiedAds.WebMVC"] + "configurations": ["ClassifiedAds.Background", "ClassifiedAds.Migrator", "ClassifiedAds.WebAPI","ClassifiedAds.BlazorServerSide","ClassifiedAds.BlazorWebAssembly","ClassifiedAds.IdentityServer","ClassifiedAds.WebMVC"] } ] } \ No newline at end of file diff --git a/src/Monolith/ClassifiedAds.AspireAppHost/ClassifiedAds.AspireAppHost.csproj b/src/Monolith/ClassifiedAds.AspireAppHost/ClassifiedAds.AspireAppHost.csproj index 161334e0e..98747767d 100644 --- a/src/Monolith/ClassifiedAds.AspireAppHost/ClassifiedAds.AspireAppHost.csproj +++ b/src/Monolith/ClassifiedAds.AspireAppHost/ClassifiedAds.AspireAppHost.csproj @@ -18,7 +18,6 @@ - diff --git a/src/Monolith/ClassifiedAds.AspireAppHost/Program.cs b/src/Monolith/ClassifiedAds.AspireAppHost/Program.cs index f729c6fc4..15552ec1f 100644 --- a/src/Monolith/ClassifiedAds.AspireAppHost/Program.cs +++ b/src/Monolith/ClassifiedAds.AspireAppHost/Program.cs @@ -2,7 +2,6 @@ var migrator = builder.AddProject("ClassifiedAds-Migrator"); var background = builder.AddProject("ClassifiedAds-Background"); -var graphQL = builder.AddProject("ClassifiedAds-GraphQL").WithHttpsHealthCheck("/healthz"); var webApi = builder.AddProject("ClassifiedAds-WebAPI").WithHttpsHealthCheck("/healthz"); var webMvc = builder.AddProject("ClassifiedAds-WebMVC").WithHttpsHealthCheck("/healthz"); var blazorServerSide = builder.AddProject("ClassifiedAds-BlazorServerSide").WithHttpsHealthCheck("/healthz"); diff --git a/src/Monolith/ClassifiedAds.GraphQL/ClassifiedAds.GraphQL.csproj b/src/Monolith/ClassifiedAds.GraphQL/ClassifiedAds.GraphQL.csproj deleted file mode 100644 index 13a7b8059..000000000 --- a/src/Monolith/ClassifiedAds.GraphQL/ClassifiedAds.GraphQL.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - net8.0 - Recommended - All - - - - - - - - - - - - - - diff --git a/src/Monolith/ClassifiedAds.GraphQL/ClassifiedAdsMutation.cs b/src/Monolith/ClassifiedAds.GraphQL/ClassifiedAdsMutation.cs deleted file mode 100644 index 59c3848be..000000000 --- a/src/Monolith/ClassifiedAds.GraphQL/ClassifiedAdsMutation.cs +++ /dev/null @@ -1,52 +0,0 @@ -using ClassifiedAds.Domain.Entities; -using ClassifiedAds.GraphQL.DownstreamServices; -using GraphQL; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Configuration; -using System; -using System.Net.Http; -using System.Threading.Tasks; - -namespace ClassifiedAds.GraphQL; - -public class ProductInput -{ - public string Code { get; set; } - - public string Name { get; set; } - - public string Description { get; set; } -} - -public class ClassifiedAdsMutation -{ - public static Task CreateProduct([FromServices] IConfiguration configuration, [FromServices] IHttpContextAccessor httpContext, ProductInput product) - { - var productService = GetProductService(configuration, httpContext); - var createdProduct = productService.CreateProduct(new Product - { - Code = product.Code, - Name = product.Name, - Description = product.Description - }); - return createdProduct; - } - - public static async Task DeleteProduct([FromServices] IConfiguration configuration, [FromServices] IHttpContextAccessor httpContext, [Id] string id) - { - var productService = GetProductService(configuration, httpContext); - await productService.DeleteProduct(Guid.Parse(id)); - return true; - } - - private static ProductService GetProductService(IConfiguration configuration, IHttpContextAccessor httpContext) - { - var accessToken = httpContext.HttpContext.Request.Headers["Authorization"].ToString(); - var client = new HttpClient(); - client.BaseAddress = new Uri(configuration["ResourceServer:Endpoint"]); - client.Timeout = new TimeSpan(0, 0, 30); - client.DefaultRequestHeaders.Clear(); - client.DefaultRequestHeaders.Add("Authorization", accessToken); - return new ProductService(client); - } -} diff --git a/src/Monolith/ClassifiedAds.GraphQL/ClassifiedAdsQuery.cs b/src/Monolith/ClassifiedAds.GraphQL/ClassifiedAdsQuery.cs deleted file mode 100644 index f5d2652fa..000000000 --- a/src/Monolith/ClassifiedAds.GraphQL/ClassifiedAdsQuery.cs +++ /dev/null @@ -1,37 +0,0 @@ -using ClassifiedAds.Domain.Entities; -using ClassifiedAds.GraphQL.DownstreamServices; -using GraphQL; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Configuration; -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Threading.Tasks; - -namespace ClassifiedAds.GraphQL; - -public class ClassifiedAdsQuery -{ - public static Task Product([FromServices] IConfiguration configuration, [FromServices] IHttpContextAccessor httpContext, [Id] string id) - { - var productService = GetProductService(configuration, httpContext); - return productService.GetProductById(Guid.Parse(id)); - } - - public static Task> Products([FromServices] IConfiguration configuration, [FromServices] IHttpContextAccessor httpContext) - { - var productService = GetProductService(configuration, httpContext); - return productService.GetProducts(); - } - - private static ProductService GetProductService(IConfiguration configuration, IHttpContextAccessor httpContext) - { - var accessToken = httpContext.HttpContext.Request.Headers["Authorization"].ToString(); - var client = new HttpClient(); - client.BaseAddress = new Uri(configuration["ResourceServer:Endpoint"]); - client.Timeout = new TimeSpan(0, 0, 30); - client.DefaultRequestHeaders.Clear(); - client.DefaultRequestHeaders.Add("Authorization", accessToken); - return new ProductService(client); - } -} diff --git a/src/Monolith/ClassifiedAds.GraphQL/Dockerfile b/src/Monolith/ClassifiedAds.GraphQL/Dockerfile deleted file mode 100644 index a48ac3d1f..000000000 --- a/src/Monolith/ClassifiedAds.GraphQL/Dockerfile +++ /dev/null @@ -1,26 +0,0 @@ -FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env -WORKDIR /ClassifiedAds.Monolith - -# Copy csproj and restore as distinct layers -COPY ./ClassifiedAds.Application/*.csproj ./ClassifiedAds.Application/ -COPY ./ClassifiedAds.CrossCuttingConcerns/*.csproj ./ClassifiedAds.CrossCuttingConcerns/ -COPY ./ClassifiedAds.Domain/*.csproj ./ClassifiedAds.Domain/ -COPY ./ClassifiedAds.Infrastructure/*.csproj ./ClassifiedAds.Infrastructure/ -COPY ./ClassifiedAds.Persistence/*.csproj ./ClassifiedAds.Persistence/ - -RUN dotnet restore ./ClassifiedAds.Application/ClassifiedAds.Application.csproj -RUN dotnet restore ./ClassifiedAds.Infrastructure/ClassifiedAds.Infrastructure.csproj - -COPY ./ClassifiedAds.GraphQL/*.csproj ./ClassifiedAds.GraphQL/ -RUN dotnet restore ./ClassifiedAds.GraphQL/ClassifiedAds.GraphQL.csproj - -# Copy everything else and build -COPY . ./ -RUN dotnet publish ./ClassifiedAds.GraphQL/ClassifiedAds.GraphQL.csproj -c Release -o out - -# Build runtime image -FROM mcr.microsoft.com/dotnet/aspnet:8.0 -WORKDIR /ClassifiedAds.Monolith -COPY --from=build-env /ClassifiedAds.Monolith/out . - -ENTRYPOINT ["dotnet", "ClassifiedAds.GraphQL.dll"] \ No newline at end of file diff --git a/src/Monolith/ClassifiedAds.GraphQL/DownstreamServices/ProductService.cs b/src/Monolith/ClassifiedAds.GraphQL/DownstreamServices/ProductService.cs deleted file mode 100644 index a05d84991..000000000 --- a/src/Monolith/ClassifiedAds.GraphQL/DownstreamServices/ProductService.cs +++ /dev/null @@ -1,85 +0,0 @@ -using ClassifiedAds.CrossCuttingConcerns.ExtensionMethods; -using ClassifiedAds.Domain.Entities; -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Net.Http.Headers; -using System.Threading.Tasks; - -namespace ClassifiedAds.GraphQL.DownstreamServices; - -public class ProductService -{ - private readonly HttpClient _httpClient; - - public ProductService(HttpClient httpClient) - { - _httpClient = httpClient; - } - - public async Task> GetProducts() - { - SetBearerToken(); - - var response = await _httpClient.GetAsync("api/products", HttpCompletionOption.ResponseHeadersRead); - response.EnsureSuccessStatusCode(); - var products = await response.Content.ReadAs>(); - return products; - } - - private void SetBearerToken() - { - - } - - public async Task GetProductById(Guid id) - { - SetBearerToken(); - - var response = await _httpClient.GetAsync($"api/products/{id}", HttpCompletionOption.ResponseHeadersRead); - response.EnsureSuccessStatusCode(); - var product = await response.Content.ReadAs(); - return product; - } - - public async Task CreateProduct(Product product) - { - SetBearerToken(); - - var request = new HttpRequestMessage(HttpMethod.Post, "api/products"); - request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); - - request.Content = product.AsJsonContent(); - - var response = await _httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead); - response.EnsureSuccessStatusCode(); - var createdProduct = await response.Content.ReadAs(); - return createdProduct; - } - - public async Task UpdateProduct(Guid id, Product product) - { - SetBearerToken(); - - var request = new HttpRequestMessage(HttpMethod.Put, $"api/products/{id}"); - request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); - - request.Content = product.AsJsonContent(); - - var response = await _httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead); - response.EnsureSuccessStatusCode(); - var updatedProduct = await response.Content.ReadAs(); - return updatedProduct; - } - - public async Task DeleteProduct(Guid id) - { - SetBearerToken(); - - var request = new HttpRequestMessage(HttpMethod.Delete, $"api/products/{id}"); - request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); - - var response = await _httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead); - response.EnsureSuccessStatusCode(); - } -} diff --git a/src/Monolith/ClassifiedAds.GraphQL/Program.cs b/src/Monolith/ClassifiedAds.GraphQL/Program.cs deleted file mode 100644 index 5e78b05a2..000000000 --- a/src/Monolith/ClassifiedAds.GraphQL/Program.cs +++ /dev/null @@ -1,78 +0,0 @@ -using ClassifiedAds.GraphQL; -using ClassifiedAds.Infrastructure.HealthChecks; -using ClassifiedAds.Infrastructure.HostedServices; -using ClassifiedAds.Infrastructure.Logging; -using GraphQL; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Diagnostics.HealthChecks; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Server.Kestrel.Core; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Diagnostics.HealthChecks; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; -using System; - -var builder = WebApplication.CreateBuilder(args); - -// Add services to the container. -var services = builder.Services; -var configuration = builder.Configuration; - -builder.WebHost.UseClassifiedAdsLogger(configuration => - { - return new LoggingOptions(); - }); - -// If using Kestrel: -services.Configure(options => -{ - options.AllowSynchronousIO = true; -}); - -// If using IIS: -services.Configure(options => -{ - options.AllowSynchronousIO = true; -}); - -services.AddLogging(builder => builder.AddConsole()); -services.AddHttpContextAccessor(); - -services.AddGraphQL(b => b.AddAutoSchema(s => s.WithMutation()) - .AddSystemTextJson()); - -services.AddHealthChecks() - .AddHttp(configuration["ResourceServer:Endpoint"], name: "Resource (Web API) Server", failureStatus: HealthStatus.Degraded); - -services.Configure(x => x.Interval = TimeSpan.FromMinutes(10)); -services.AddHostedService(); - -// Configure the HTTP request pipeline. -var app = builder.Build(); - -if (app.Environment.IsDevelopment()) -{ - app.UseDeveloperExceptionPage(); -} - -app.UseHealthChecks("/healthz", new HealthCheckOptions -{ - Predicate = _ => true, - ResponseWriter = HealthChecksResponseWriter.WriteReponse, - ResultStatusCodes = - { - [HealthStatus.Healthy] = StatusCodes.Status200OK, - [HealthStatus.Degraded] = StatusCodes.Status500InternalServerError, - [HealthStatus.Unhealthy] = StatusCodes.Status503ServiceUnavailable, - }, -}); - -// add http for Schema at default url /graphql -app.UseGraphQL(); - -// use graphql-playground at default url /ui/playground -app.UseGraphQLPlayground(); - -app.Run(); diff --git a/src/Monolith/ClassifiedAds.GraphQL/Properties/launchSettings.json b/src/Monolith/ClassifiedAds.GraphQL/Properties/launchSettings.json deleted file mode 100644 index ca8a43ba8..000000000 --- a/src/Monolith/ClassifiedAds.GraphQL/Properties/launchSettings.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "https://localhost:44392/", - "sslPort": 44392 - } - }, - "$schema": "http://json.schemastore.org/launchsettings.json", - "profiles": { - "IIS Express": { - "commandName": "IISExpress", - "launchUrl": "ui/playground", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "https": { - "commandName": "Project", - "launchBrowser": true, - "launchUrl": "ui/playground", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "https://localhost:44392" - } - } -} \ No newline at end of file diff --git a/src/Monolith/ClassifiedAds.GraphQL/appsettings.Development.json b/src/Monolith/ClassifiedAds.GraphQL/appsettings.Development.json deleted file mode 100644 index 8983e0fc1..000000000 --- a/src/Monolith/ClassifiedAds.GraphQL/appsettings.Development.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" - } - } -} diff --git a/src/Monolith/ClassifiedAds.GraphQL/appsettings.json b/src/Monolith/ClassifiedAds.GraphQL/appsettings.json deleted file mode 100644 index bfb9242b2..000000000 --- a/src/Monolith/ClassifiedAds.GraphQL/appsettings.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" - } - }, - "AllowedHosts": "*", - "ResourceServer": { - "Endpoint": "https://localhost:44312", - "PublicEndpoint": "https://localhost:44312" - } -} diff --git a/src/Monolith/ClassifiedAds.IntegrationTests/ClassifiedAds.IntegrationTests.csproj b/src/Monolith/ClassifiedAds.IntegrationTests/ClassifiedAds.IntegrationTests.csproj index 3552a003f..ebee73097 100644 --- a/src/Monolith/ClassifiedAds.IntegrationTests/ClassifiedAds.IntegrationTests.csproj +++ b/src/Monolith/ClassifiedAds.IntegrationTests/ClassifiedAds.IntegrationTests.csproj @@ -17,13 +17,11 @@ - all runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/src/Monolith/ClassifiedAds.IntegrationTests/Configuration/AppSettings.cs b/src/Monolith/ClassifiedAds.IntegrationTests/Configuration/AppSettings.cs index ccb40af7b..b83c9cb56 100644 --- a/src/Monolith/ClassifiedAds.IntegrationTests/Configuration/AppSettings.cs +++ b/src/Monolith/ClassifiedAds.IntegrationTests/Configuration/AppSettings.cs @@ -6,8 +6,6 @@ public class AppSettings public ResourceServer WebAPI { get; set; } - public ResourceServer GraphQL { get; set; } - public LoginOptions Login { get; set; } public string DownloadsFolder { get; set; } diff --git a/src/Monolith/ClassifiedAds.IntegrationTests/GraphQL/ProductTests.cs b/src/Monolith/ClassifiedAds.IntegrationTests/GraphQL/ProductTests.cs deleted file mode 100644 index a06e3fc27..000000000 --- a/src/Monolith/ClassifiedAds.IntegrationTests/GraphQL/ProductTests.cs +++ /dev/null @@ -1,162 +0,0 @@ -using ClassifiedAds.Domain.Entities; -using GraphQL; -using GraphQL.Client.Http; -using GraphQL.Client.Serializer.Newtonsoft; -using IdentityModel.Client; -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Net.Http.Headers; -using System.Threading.Tasks; -using Xunit; - -namespace ClassifiedAds.IntegrationTests.GraphQL; - -public class ProductTests : TestBase -{ - private readonly GraphQLHttpClient _client; - - public ProductTests() - : base() - { - _client = new GraphQLHttpClient(AppSettings.GraphQL.Endpoint, new NewtonsoftJsonSerializer()); - } - - private async Task> GetProducts() - { - var query = new GraphQLRequest - { - Query = @" - { - products - { - id - code - name - description - } - }", - }; - - var response = await _client.SendQueryAsync(query); - - return response.Data.Products; - } - - private async Task GetProductById(Guid id) - { - var query = new GraphQLRequest - { - Query = @" - query productQuery($productId: ID!) - { - product(id: $productId) - { - id - code - name - description - } - }", - Variables = new { productId = id }, - }; - var response = await _client.SendQueryAsync(query); - return response.Data.Product; - } - - private async Task CreateProduct(Product product) - { - var query = new GraphQLRequest - { - Query = @" - mutation($product: ProductInput!) - { - createProduct(product: $product) - { - id - code - name - description - } - }", - Variables = new { product = new { product.Code, product.Name, product.Description } }, - }; - var response = await _client.SendQueryAsync(query); - return response.Data.CreateProduct; - } - - private async Task DeleteProduct(Guid id) - { - var query = new GraphQLRequest - { - Query = @" - mutation($productId: ID!) - { - deleteProduct(id: $productId) - }", - Variables = new { productId = id }, - }; - - var response = await _client.SendQueryAsync(query); - } - - [Fact] - public async Task AllInOne() - { - var httpClient = new HttpClient(); - var metaDataResponse = await httpClient.GetDiscoveryDocumentAsync(new DiscoveryDocumentRequest - { - Address = AppSettings.OpenIdConnect.Authority, - Policy = { RequireHttps = AppSettings.OpenIdConnect.RequireHttpsMetadata }, - }); - - var tokenResponse = await httpClient.RequestPasswordTokenAsync(new PasswordTokenRequest - { - Address = metaDataResponse.TokenEndpoint, - ClientId = AppSettings.OpenIdConnect.ClientId, - ClientSecret = AppSettings.OpenIdConnect.ClientSecret, - UserName = AppSettings.Login.UserName, - Password = AppSettings.Login.Password, - Scope = AppSettings.Login.Scope, - }); - - var token = tokenResponse.AccessToken; - _client.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - - var product = new Product - { - Name = "Test", - Code = "TEST", - Description = "Description", - }; - - Product createdProduct = await CreateProduct(product); - Assert.True(product.Id != createdProduct.Id); - Assert.Equal(product.Name, createdProduct.Name); - Assert.Equal(product.Code, createdProduct.Code); - Assert.Equal(product.Description, createdProduct.Description); - - var products = await GetProducts(); - Assert.True(products.Count > 0); - - var refreshedProduct = await GetProductById(createdProduct.Id); - Assert.Equal(refreshedProduct.Id, createdProduct.Id); - Assert.Equal(refreshedProduct.Name, createdProduct.Name); - Assert.Equal(refreshedProduct.Code, createdProduct.Code); - Assert.Equal(refreshedProduct.Description, createdProduct.Description); - - await DeleteProduct(createdProduct.Id); - Assert.Null(await GetProductById(createdProduct.Id)); - } -} - -public class ProductResponse -{ - public List Products { get; set; } - - public Product Product { get; set; } - - public Product CreateProduct { get; set; } - - public bool? DeleteProduct { get; set; } -} diff --git a/src/Monolith/ClassifiedAds.IntegrationTests/appsettings.json b/src/Monolith/ClassifiedAds.IntegrationTests/appsettings.json index 64030ffac..a99d64cc0 100644 --- a/src/Monolith/ClassifiedAds.IntegrationTests/appsettings.json +++ b/src/Monolith/ClassifiedAds.IntegrationTests/appsettings.json @@ -8,9 +8,6 @@ "WebAPI": { "Endpoint": "https://localhost:44312" }, - "GraphQL": { - "Endpoint": "https://localhost:44392/graphql" - }, "Login": { "UserName": "phong@gmail.com", "Password": "v*7Un8b4rcN@<-RN", diff --git a/src/Monolith/ClassifiedAds.Monolith.sln b/src/Monolith/ClassifiedAds.Monolith.sln index b38f3ff3d..272ab91b0 100644 --- a/src/Monolith/ClassifiedAds.Monolith.sln +++ b/src/Monolith/ClassifiedAds.Monolith.sln @@ -25,8 +25,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClassifiedAds.Migrator", "C EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{60BC7A82-187C-43E2-8C37-DE610700A7FA}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClassifiedAds.GraphQL", "ClassifiedAds.GraphQL\ClassifiedAds.GraphQL.csproj", "{FDBA0506-A4E7-405B-918D-66A195F16C95}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClassifiedAds.Background", "ClassifiedAds.Background\ClassifiedAds.Background.csproj", "{72E42908-63F6-4981-9023-6018C66604D8}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BackEnds", "BackEnds", "{62A1AB08-A2DB-404F-B073-0F89CA780F45}" @@ -85,10 +83,6 @@ Global {95943383-5C81-45B6-8876-4789C00A9255}.Debug|Any CPU.Build.0 = Debug|Any CPU {95943383-5C81-45B6-8876-4789C00A9255}.Release|Any CPU.ActiveCfg = Release|Any CPU {95943383-5C81-45B6-8876-4789C00A9255}.Release|Any CPU.Build.0 = Release|Any CPU - {FDBA0506-A4E7-405B-918D-66A195F16C95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FDBA0506-A4E7-405B-918D-66A195F16C95}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FDBA0506-A4E7-405B-918D-66A195F16C95}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FDBA0506-A4E7-405B-918D-66A195F16C95}.Release|Any CPU.Build.0 = Release|Any CPU {72E42908-63F6-4981-9023-6018C66604D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {72E42908-63F6-4981-9023-6018C66604D8}.Debug|Any CPU.Build.0 = Debug|Any CPU {72E42908-63F6-4981-9023-6018C66604D8}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -148,7 +142,6 @@ Global {F1C3F330-D7DE-4181-8ED9-66E6C620D5CD} = {62A1AB08-A2DB-404F-B073-0F89CA780F45} {CFDF9CC8-0B83-4FF0-AC76-36AA6E8DB565} = {4B31AB94-7016-4C77-951E-84792D6EBEAC} {95943383-5C81-45B6-8876-4789C00A9255} = {62A1AB08-A2DB-404F-B073-0F89CA780F45} - {FDBA0506-A4E7-405B-918D-66A195F16C95} = {62A1AB08-A2DB-404F-B073-0F89CA780F45} {72E42908-63F6-4981-9023-6018C66604D8} = {62A1AB08-A2DB-404F-B073-0F89CA780F45} {62A1AB08-A2DB-404F-B073-0F89CA780F45} = {C6061573-0203-4860-AD42-4C6C2CF55110} {4B31AB94-7016-4C77-951E-84792D6EBEAC} = {C6061573-0203-4860-AD42-4C6C2CF55110} diff --git a/src/Monolith/Jenkinsfile b/src/Monolith/Jenkinsfile index cdedeb5fb..30ab1db7b 100644 --- a/src/Monolith/Jenkinsfile +++ b/src/Monolith/Jenkinsfile @@ -24,7 +24,6 @@ pipeline { steps { dir('src/Monolith') { sh "dotnet publish -p:Version=${VERSION} ClassifiedAds.Background/*.csproj --configuration Release" - sh "dotnet publish -p:Version=${VERSION} ClassifiedAds.GraphQL/*.csproj --configuration Release" sh "dotnet publish -p:Version=${VERSION} ClassifiedAds.Migrator/*.csproj --configuration Release" sh "dotnet publish -p:Version=${VERSION} ClassifiedAds.WebAPI/*.csproj --configuration Release" sh "dotnet publish -p:Version=${VERSION} ClassifiedAds.WebMVC/*.csproj --configuration Release" diff --git a/src/Monolith/README.md b/src/Monolith/README.md index 57f6d2cad..12a261fa5 100644 --- a/src/Monolith/README.md +++ b/src/Monolith/README.md @@ -56,7 +56,6 @@ docker tag classifiedads.background phongnguyend/classifiedads.background docker tag classifiedads.migrator phongnguyend/classifiedads.migrator docker tag classifiedads.webapi phongnguyend/classifiedads.webapi - docker tag classifiedads.graphql phongnguyend/classifiedads.graphql docker tag classifiedads.blazor phongnguyend/classifiedads.blazor docker tag classifiedads.identityserver phongnguyend/classifiedads.identityserver docker tag classifiedads.webmvc phongnguyend/classifiedads.webmvc @@ -67,7 +66,6 @@ docker push phongnguyend/classifiedads.background docker push phongnguyend/classifiedads.migrator docker push phongnguyend/classifiedads.webapi - docker push phongnguyend/classifiedads.graphql docker push phongnguyend/classifiedads.blazor docker push phongnguyend/classifiedads.identityserver docker push phongnguyend/classifiedads.webmvc @@ -117,7 +115,6 @@ dotnet publish -p:Version=1.0.0.1 -c Release ../IdentityServer/IdentityServer4/ClassifiedAds.IdentityServer/ClassifiedAds.IdentityServer.csproj -o ./publish/ClassifiedAds.IdentityServer dotnet publish -p:Version=1.0.0.1 -c Release ./ClassifiedAds.Background/ClassifiedAds.Background.csproj -o ./publish/ClassifiedAds.Background - dotnet publish -p:Version=1.0.0.1 -c Release ./ClassifiedAds.GraphQL/ClassifiedAds.GraphQL.csproj -o ./publish/ClassifiedAds.GraphQL dotnet publish -p:Version=1.0.0.1 -c Release ./ClassifiedAds.Migrator/ClassifiedAds.Migrator.csproj -o ./publish/ClassifiedAds.Migrator dotnet publish -p:Version=1.0.0.1 -c Release ./ClassifiedAds.WebAPI/ClassifiedAds.WebAPI.csproj -o ./publish/ClassifiedAds.WebAPI dotnet publish -p:Version=1.0.0.1 -c Release ./ClassifiedAds.BlazorServerSide/ClassifiedAds.BlazorServerSide.csproj -o ./publish/ClassifiedAds.BlazorServerSide @@ -128,8 +125,7 @@ - Pack ``` dotnet octo pack --version=1.0.0.1 --outFolder=./publish --overwrite --id=ClassifiedAds.IdentityServer --basePath=./publish/ClassifiedAds.IdentityServer - dotnet octo pack --version=1.0.0.1 --outFolder=./publish --overwrite --id=ClassifiedAds.Background --basePath=./publish/ClassifiedAds.Background - dotnet octo pack --version=1.0.0.1 --outFolder=./publish --overwrite --id=ClassifiedAds.GraphQL --basePath=./publish/ClassifiedAds.GraphQL + dotnet octo pack --version=1.0.0.1 --outFolder=./publish --overwrite --id=ClassifiedAds.Background --basePath=./publish/ClassifiedAds.Background dotnet octo pack --version=1.0.0.1 --outFolder=./publish --overwrite --id=ClassifiedAds.Migrator --basePath=./publish/ClassifiedAds.Migrator dotnet octo pack --version=1.0.0.1 --outFolder=./publish --overwrite --id=ClassifiedAds.WebAPI --basePath=./publish/ClassifiedAds.WebAPI dotnet octo pack --version=1.0.0.1 --outFolder=./publish --overwrite --id=ClassifiedAds.BlazorServerSide --basePath=./publish/ClassifiedAds.BlazorServerSide diff --git a/src/Monolith/azure-pipelines.yml b/src/Monolith/azure-pipelines.yml index 6e0aa53e3..6bfb820a8 100644 --- a/src/Monolith/azure-pipelines.yml +++ b/src/Monolith/azure-pipelines.yml @@ -122,7 +122,6 @@ stages: publishWebProjects: false projects: | src/Monolith/ClassifiedAds.Background/*.csproj - src/Monolith/ClassifiedAds.GraphQL/*.csproj src/Monolith/ClassifiedAds.Migrator/*.csproj src/Monolith/ClassifiedAds.WebAPI/*.csproj src/Monolith/ClassifiedAds.IdentityServer/*.csproj @@ -196,7 +195,6 @@ stages: publishWebProjects: false projects: | src/Monolith/ClassifiedAds.Background/*.csproj - src/Monolith/ClassifiedAds.GraphQL/*.csproj src/Monolith/ClassifiedAds.Migrator/*.csproj src/Monolith/ClassifiedAds.WebAPI/*.csproj src/Monolith/ClassifiedAds.IdentityServer/*.csproj @@ -211,7 +209,6 @@ stages: inputs: script: | dotnet octo pack --version=1.0.0-$(Build.BuildNumber) --outFolder=$(Build.ArtifactStagingDirectory) --overwrite --id=ClassifiedAds.Background --basePath=$(Build.ArtifactStagingDirectory)/ClassifiedAds.Background - dotnet octo pack --version=1.0.0-$(Build.BuildNumber) --outFolder=$(Build.ArtifactStagingDirectory) --overwrite --id=ClassifiedAds.GraphQL --basePath=$(Build.ArtifactStagingDirectory)/ClassifiedAds.GraphQL dotnet octo pack --version=1.0.0-$(Build.BuildNumber) --outFolder=$(Build.ArtifactStagingDirectory) --overwrite --id=ClassifiedAds.Migrator --basePath=$(Build.ArtifactStagingDirectory)/ClassifiedAds.Migrator dotnet octo pack --version=1.0.0-$(Build.BuildNumber) --outFolder=$(Build.ArtifactStagingDirectory) --overwrite --id=ClassifiedAds.WebAPI --basePath=$(Build.ArtifactStagingDirectory)/ClassifiedAds.WebAPI dotnet octo pack --version=1.0.0-$(Build.BuildNumber) --outFolder=$(Build.ArtifactStagingDirectory) --overwrite --id=ClassifiedAds.BlazorServerSide --basePath=$(Build.ArtifactStagingDirectory)/ClassifiedAds.BlazorServerSide diff --git a/src/Monolith/docker build.txt b/src/Monolith/docker build.txt index b3933beb2..a84c22d47 100644 --- a/src/Monolith/docker build.txt +++ b/src/Monolith/docker build.txt @@ -7,7 +7,6 @@ docker run -d -p 8082:80 --name classifiedads.identityserver classifiedads.ident docker build -f "ClassifiedAds.Background\Dockerfile" -t classifiedads.background . docker build -f "ClassifiedAds.Migrator\Dockerfile" -t classifiedads.migrator . docker build -f "ClassifiedAds.WebAPI\Dockerfile" -t classifiedads.webapi . -docker build -f "ClassifiedAds.GraphQL\Dockerfile" -t classifiedads.graphql . docker build -f "ClassifiedAds.BlazorServerSide\Dockerfile" -t classifiedads.blazor . docker build -f "ClassifiedAds.IdentityServer\Dockerfile" -t classifiedads.identityserver . docker build -f "ClassifiedAds.WebMVC\Dockerfile" -t classifiedads.webmvc . @@ -15,7 +14,6 @@ docker build -f "ClassifiedAds.WebMVC\Dockerfile" -t classifiedads.webmvc . docker tag classifiedads.background phongnguyend/classifiedads.background docker tag classifiedads.migrator phongnguyend/classifiedads.migrator docker tag classifiedads.webapi phongnguyend/classifiedads.webapi -docker tag classifiedads.graphql phongnguyend/classifiedads.graphql docker tag classifiedads.blazor phongnguyend/classifiedads.blazor docker tag classifiedads.identityserver phongnguyend/classifiedads.identityserver docker tag classifiedads.webmvc phongnguyend/classifiedads.webmvc @@ -23,7 +21,6 @@ docker tag classifiedads.webmvc phongnguyend/classifiedads.webmvc docker push phongnguyend/classifiedads.background docker push phongnguyend/classifiedads.migrator docker push phongnguyend/classifiedads.webapi -docker push phongnguyend/classifiedads.graphql docker push phongnguyend/classifiedads.blazor docker push phongnguyend/classifiedads.identityserver docker push phongnguyend/classifiedads.webmvc diff --git a/src/Monolith/docker-compose.volumes.yml b/src/Monolith/docker-compose.volumes.yml index 79148567e..38f0e81c5 100644 --- a/src/Monolith/docker-compose.volumes.yml +++ b/src/Monolith/docker-compose.volumes.yml @@ -20,6 +20,3 @@ services: background: volumes: - D:\\ClassifiedAds.Monolith\\Logs\\Background:/ClassifiedAds.Monolith/logs - graphql: - volumes: - - D:\\ClassifiedAds.Monolith\\Logs\\GraphQL:/ClassifiedAds.Monolith/logs diff --git a/src/Monolith/docker-compose.yml b/src/Monolith/docker-compose.yml index 1a83f1665..c5fa345f0 100644 --- a/src/Monolith/docker-compose.yml +++ b/src/Monolith/docker-compose.yml @@ -172,16 +172,3 @@ services: Notification__Sms__Twilio__FromNumber: "" Notification__Web__Provider: "Fake" Notification__Web__SignalR__Endpoint: "http://webmvc" - graphql: - image: classifiedads.graphql - build: - context: . - dockerfile: ./ClassifiedAds.GraphQL/Dockerfile - ports: - - "9006:8080" - depends_on: - - webapi - environment: - ASPNETCORE_ENVIRONMENT: ${ASPNETCORE_ENVIRONMENT} - ResourceServer__Endpoint: ${ResourceServer__Endpoint} - ResourceServer__PublicEndpoint: ${ResourceServer__PublicEndpoint}