From 099536880bfbc1ac9c92fa06c63836cf697a3b76 Mon Sep 17 00:00:00 2001 From: Tobias Tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Thu, 22 Apr 2021 22:50:16 +0200 Subject: [PATCH] Align Server Template with WebAPI Template (#3573) --- templates/Server/content/Program.cs | 8 +------- templates/Server/content/Startup.cs | 20 +++++++++---------- .../content/appsettings.Development.json | 9 +++++++++ templates/Server/content/appsettings.json | 10 ++++++++++ 4 files changed, 30 insertions(+), 17 deletions(-) create mode 100644 templates/Server/content/appsettings.Development.json create mode 100644 templates/Server/content/appsettings.json diff --git a/templates/Server/content/Program.cs b/templates/Server/content/Program.cs index f002ca1137b..66f7a67ac35 100644 --- a/templates/Server/content/Program.cs +++ b/templates/Server/content/Program.cs @@ -1,11 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; +using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; namespace HotChocolate.Server.Template { diff --git a/templates/Server/content/Startup.cs b/templates/Server/content/Startup.cs index 3dadaf98e82..851ed600d1d 100644 --- a/templates/Server/content/Startup.cs +++ b/templates/Server/content/Startup.cs @@ -1,11 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using HotChocolate.AspNetCore; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; @@ -13,14 +8,19 @@ namespace HotChocolate.Server.Template { 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. - // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { // If you need dependency injection with your query object add your query type as a services. // services.AddSingleton(); services - .AddRouting() .AddGraphQLServer() .AddQueryType(); } @@ -38,8 +38,8 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) app.UseEndpoints(endpoints => { // By default the GraphQL server is mapped to /graphql - // This route also provides you with our GraphQL IDE. In order to configure the - // the GraphQL IDE use endpoints.MapGraphQL().WithToolOptions(...). + // This route also provides you with our GraphQL IDE. + // In order to configure the GraphQL IDE use endpoints.MapGraphQL().WithToolOptions(...). endpoints.MapGraphQL(); }); } diff --git a/templates/Server/content/appsettings.Development.json b/templates/Server/content/appsettings.Development.json new file mode 100644 index 00000000000..8983e0fc1c5 --- /dev/null +++ b/templates/Server/content/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/templates/Server/content/appsettings.json b/templates/Server/content/appsettings.json new file mode 100644 index 00000000000..d9d9a9bff6f --- /dev/null +++ b/templates/Server/content/appsettings.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "AllowedHosts": "*" +}