diff --git a/api/src/BcGov.Malt.Web/Program.cs b/api/src/BcGov.Malt.Web/Program.cs index 72526935..131a5139 100644 --- a/api/src/BcGov.Malt.Web/Program.cs +++ b/api/src/BcGov.Malt.Web/Program.cs @@ -3,7 +3,6 @@ using System.Diagnostics; using System.Linq; using System.Net.Http; -using System.Reflection; using System.Threading.Tasks; using BcGov.Malt.Web.Models.Configuration; using BcGov.Malt.Web.Services; @@ -58,29 +57,17 @@ public static async Task Main(string[] args) /// /// Creates the host builder. /// - public static IHostBuilder CreateHostBuilder(string[] args) + private static IHostBuilder CreateHostBuilder(string[] args) { var builder = Host.CreateDefaultBuilder(args) .UseSerilog(ConfigureSerilogLogging) - .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup(); }) - .ConfigureAppConfiguration((hostingContext, config) => - { - // Added before AddUserSecrets to let user secrets override environment variables. - config.AddEnvironmentVariables(); - - var env = hostingContext.HostingEnvironment; - if (env.IsDevelopment()) - { - var appAssembly = Assembly.Load(new AssemblyName(env.ApplicationName)); - config.AddUserSecrets(appAssembly, optional: true); - } - }); + .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup(); }); - return builder; + return builder; } private static ILogger GetProgramLogger(string[] args) - { + { // configure the program logger in the same way as CreateDefaultBuilder does string environmentName = GetEnvironmentName(); @@ -124,7 +111,7 @@ static string GetEnvironmentName() return logger; } - + private static void ConfigureSerilogLogging(HostBuilderContext hostingContext, LoggerConfiguration loggerConfiguration) { loggerConfiguration @@ -152,14 +139,15 @@ private static void ConfigureSerilogLogging(HostBuilderContext hostingContext, L messageHandler: new HttpClientHandler { ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => true - }, + }); #pragma warning restore CA2000 // Dispose objects before losing scope - renderTemplate: false); } } private static async Task GetAccessTokensAsync(ILogger logger, IServiceProvider services) { + // use a logger with context + logger = logger.ForContext(); try { @@ -190,7 +178,7 @@ private static async Task GetAccessTokensAsync(ILogger logger, IServiceProvider { logger.Error("Error fetching {ErrorCount} of total {AccessTokenCount} access tokens, process took {ElapsedMilliseconds} milliseconds", exceptionCount, - results.Count, + results.Count, milliseconds); } diff --git a/maltd-frontend/package.json b/maltd-frontend/package.json index bb49148d..41124b55 100644 --- a/maltd-frontend/package.json +++ b/maltd-frontend/package.json @@ -33,7 +33,8 @@ "lint": "eslint .", "lint:fix": "eslint --fix .", "ci-test": "cross-env CI=true jest --env=jsdom --testResultsProcessor=jest-sonar-reporter --update-snapshot --runInBand --coverage", - "cy:run": "cypress run" + "cy:run": "cypress run", + "format-staged": "pretty-quick --staged" }, "jest": { "setupFilesAfterEnv": [ @@ -108,7 +109,7 @@ }, "husky": { "hooks": { - "pre-commit": "pretty-quick --staged", + "pre-commit": "npm run format-staged", "pre-push": "npx eslint ." } }