From 8f4d7285dce0fab0ee8d7c42239d3fba46890265 Mon Sep 17 00:00:00 2001 From: Dave Skender <8432125+DaveSkender@users.noreply.github.com> Date: Wed, 21 Aug 2024 20:32:49 -0400 Subject: [PATCH] feat: Response compression (#355) --- Client/src/app/app.component.html | 11 +++--- Client/src/app/app.component.scss | 2 +- Client/src/app/chart/chart.component.html | 7 ++-- Client/src/index.html | 8 ++-- Client/src/styles/_base-elements.scss | 6 +-- Client/src/styles/_themed-parts.scss | 9 ----- Server/.editorconfig | 1 + Server/WebApi/Program.cs | 47 +++++++++++++++++------ 8 files changed, 52 insertions(+), 39 deletions(-) diff --git a/Client/src/app/app.component.html b/Client/src/app/app.component.html index 74a84ea3..c6be80f2 100644 --- a/Client/src/app/app.component.html +++ b/Client/src/app/app.component.html @@ -1,16 +1,15 @@ -
+

- + stock chart

demo of - - - Stock Indicators for .NET - + + Stock Indicators for .NET +

diff --git a/Client/src/app/app.component.scss b/Client/src/app/app.component.scss index 91e81f28..cbdc8490 100644 --- a/Client/src/app/app.component.scss +++ b/Client/src/app/app.component.scss @@ -6,6 +6,7 @@ width: 100%; max-width: 1024px; + min-height: 100vh; margin: 0; margin-right: auto; margin-left: auto; @@ -17,7 +18,6 @@ top: -56px; right: 8px; height: 100%; - min-height: 100vh; button { opacity: 0.6; diff --git a/Client/src/app/chart/chart.component.html b/Client/src/app/chart/chart.component.html index a9f2e5c6..5b8addf4 100644 --- a/Client/src/app/chart/chart.component.html +++ b/Client/src/app/chart/chart.component.html @@ -1,10 +1,9 @@
-
-

loading

-

LOADING

+
+

loading

+

LOADING

-
diff --git a/Client/src/index.html b/Client/src/index.html index 8da8fd30..8e50aa51 100644 --- a/Client/src/index.html +++ b/Client/src/index.html @@ -57,13 +57,13 @@ "@type": "Website", "name": "Stock Indicators for .NET (demo)", "description": "A stock chart to demonstrate the Stock Indicators for .NET NuGet package. Transform price quotes into trading insights.", - "url": "https://charts.stockindicators.dev/", + "url": "https://charts.stockindicators.dev", "image": "https://charts.stockindicators.dev/assets/icons/android-chrome-256x256.png", "author": { "@type": "Organization", - "name": "Skender Co.", - "url": "https://skenderco.com", - "logo": "https://skenderco.com/assets/logo.svg" + "name": "FacioQuo", + "url": "https://facioquo.com", + "logo": "https://facioquo.com/assets/logo.svg" } } diff --git a/Client/src/styles/_base-elements.scss b/Client/src/styles/_base-elements.scss index 1d429e5a..d3751b25 100644 --- a/Client/src/styles/_base-elements.scss +++ b/Client/src/styles/_base-elements.scss @@ -54,9 +54,9 @@ mat-dialog-content { padding-top: 1rem !important; box-shadow: - 0 0 3px 0 rgba(0, 0, 0, 0.20), - 0 0 5px 0 rgba(0, 0, 0, 0.14), - 0 0 8px 0 rgba(0, 0, 0, 0.12); + 0 0 3px 0 rgb(0 0 0 / 20%), + 0 0 5px 0 rgb(0 0 0 / 14%), + 0 0 8px 0 rgb(0 0 0 / 12%); } mat-dialog-actions { diff --git a/Client/src/styles/_themed-parts.scss b/Client/src/styles/_themed-parts.scss index 0f90528d..022fe80e 100644 --- a/Client/src/styles/_themed-parts.scss +++ b/Client/src/styles/_themed-parts.scss @@ -18,9 +18,6 @@ .main-toolbar, .mat-toolbar-single-row { - display: flex; - justify-content: left; - max-width: $maxwidth; margin-left: auto; margin-right: auto; @@ -29,12 +26,6 @@ background-color: transparent; line-height: unset !important; - .toolbar-content { - display: flex; - flex-direction: column; - align-items: left; - } - h1 { font-family: Rubik, Roboto, Arial, Helvetica, sans-serif; font-size: 1.4em; diff --git a/Server/.editorconfig b/Server/.editorconfig index 1e675f2f..ead54450 100644 --- a/Server/.editorconfig +++ b/Server/.editorconfig @@ -61,6 +61,7 @@ dotnet_naming_style.pascal_case.capitalization = pascal_case dotnet_code_quality_unused_parameters = all:suggestion dotnet_sort_system_directives_first = true +dotnet_separate_import_directive_groups = false dotnet_style_operator_placement_when_wrapping = beginning_of_line dotnet_style_predefined_type_for_locals_parameters_members = true:silent diff --git a/Server/WebApi/Program.cs b/Server/WebApi/Program.cs index 3127f6e4..b326a73c 100644 --- a/Server/WebApi/Program.cs +++ b/Server/WebApi/Program.cs @@ -1,6 +1,7 @@ // STARTUP CONFIGURATION -using Microsoft.Net.Http.Headers; +using System.IO.Compression; +using Microsoft.AspNetCore.ResponseCompression; using WebApi.Services; WebApplicationBuilder builder = WebApplication.CreateBuilder(args); @@ -8,10 +9,10 @@ IServiceCollection services = builder.Services; ConfigurationManager configuration = builder.Configuration; -// add framework services +// Add framework services services.AddControllers(); -// get CORS origins from appsettings +// Get CORS origins from appsettings // reminder: production origins defined in cloud host settings » API » CORS // so these are really only for localhost / development IConfigurationSection corsOrigins = configuration.GetSection("CorsOrigins"); @@ -21,10 +22,10 @@ if (!string.IsNullOrEmpty(allowedOrigin)) { - origins.Add(item: allowedOrigin); + origins.Add(allowedOrigin); } -// setup CORS for website +// Setup CORS for website services.AddCors(options => { options.AddPolicy("CorsPolicy", cors => { @@ -38,23 +39,45 @@ Console.WriteLine($"CORS Origin: {allowedOrigin}"); -// register services +// Register services services.AddHostedService(); services.AddTransient(); -// build application +// Add response compression services +services.AddResponseCompression(options => { + options.EnableForHttps = true; + options.Providers.Add(); + options.Providers.Add(); +}); + +// Configure compression options +services.Configure(options => { + options.Level = CompressionLevel.Fastest; +}); + +services.Configure(options => { + options.Level = CompressionLevel.Fastest; +}); + +// Build application WebApplication app = builder.Build(); -// configure the HTTP request pipeline -_ = app.Environment.IsDevelopment() - ? app.UseDeveloperExceptionPage() - : app.UseHsts(); +// Configure the HTTP request pipeline +if (app.Environment.IsDevelopment()) +{ + app.UseDeveloperExceptionPage(); +} +else +{ + app.UseHsts(); +} app.UseHttpsRedirection(); app.UseRouting(); app.UseCors("CorsPolicy"); app.UseResponseCaching(); +app.UseResponseCompression(); -// controller endpoints +// Controller endpoints app.MapControllers(); app.Run();