Skip to content

Commit

Permalink
Merge pull request #724 from mixcore/features/cleanup
Browse files Browse the repository at this point in the history
Clean code
  • Loading branch information
nhathoang989 authored Dec 30, 2023
2 parents d59510b + 8a4536d commit 27acb12
Show file tree
Hide file tree
Showing 149 changed files with 4,642 additions and 4,806 deletions.
54 changes: 47 additions & 7 deletions src/applications/mixcore.gateway/Program.cs
Original file line number Diff line number Diff line change
@@ -1,33 +1,65 @@

using Microsoft.Extensions.DependencyInjection.Extensions;
using Mix.Constant.Constants;
using Mix.Heart.Services;
using Mix.Shared.Services;
using Ocelot.DependencyInjection;
using Ocelot.Middleware;
using System.Reflection;
using System.Text.Encodings.Web;
using System.Text.Unicode;

var builder = WebApplication.CreateBuilder(args);

bool isInit = true;
if (Directory.Exists("../mixcore/mixcontent/shared"))
{
isInit = false;
MixFileHelper.CopyFolder("../mixcore/mixcontent/shared", MixFolders.MixContentSharedFolder);
}

var builder = WebApplication.CreateBuilder(args);
builder.AddServiceDefaults();
builder.WebHost.UseContentRoot(Directory.GetCurrentDirectory());
builder.Configuration.SetBasePath(builder.Environment.ContentRootPath)
.AddJsonFile("appsettings.json", true, true)
.AddJsonFile("ocelot.json", true, true)
.AddJsonFile("appsettings.json", true, false)
.AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json", true, true)
.AddJsonFile("ocelot.json", true, false)
.AddJsonFile($"ocelot.{builder.Environment.EnvironmentName}.json", true, true)
.AddEnvironmentVariables();
builder.Services.AddOutputCache();
builder.Services.AddControllers();
builder.Services.TryAddSingleton<MixEndpointService>();
builder.Services.AddOcelot(builder.Configuration);
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
if (isInit)
{
builder.Services.AddCors(options =>
{
options.AddDefaultPolicy(builder =>
{
builder.AllowAnyOrigin();
builder.AllowAnyHeader();
builder.AllowAnyMethod();
});
});
}
else
{
builder.Services.AddMixCors();
}
builder.Services.AddSwaggerGen();

var app = builder.Build();

Configure(app, builder.Environment);
Configure(app, builder.Environment, isInit);

app.UseOutputCache();
app.MapDefaultEndpoints();
app.Run();

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
static void Configure(WebApplication app, IWebHostEnvironment env)
static void Configure(WebApplication app, IWebHostEnvironment env, bool isInit)
{
if (!env.IsDevelopment())
{
Expand All @@ -36,7 +68,14 @@ static void Configure(WebApplication app, IWebHostEnvironment env)
}
//app.UseResponseCompression();
app.UseRouting();

if (isInit)
{
app.UseCors();
}
else
{
app.UseMixCors();
}
// ref: app.UseMixAuth();
app.UseAuthentication();
app.UseAuthorization();
Expand All @@ -45,4 +84,5 @@ static void Configure(WebApplication app, IWebHostEnvironment env)
app.UseSwaggerUI();
app.MapControllers();
app.UseOcelot().Wait();
}
}

5 changes: 3 additions & 2 deletions src/applications/mixcore.gateway/mixcore.gateway.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization>
Expand All @@ -12,7 +13,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" />
<PackageReference Include="Ocelot" Version="21.0.0" />
<PackageReference Include="Ocelot.Cache.CacheManager" Version="21.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.5.0" />
Expand All @@ -21,6 +21,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\platform\mix.library\mix.library.csproj" />
<ProjectReference Include="..\mixcore.host.aspire\mixcore.host.aspire.ServiceDefaults\mixcore.host.aspire.ServiceDefaults.csproj" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="8.0.0-preview.1.23557.2" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.7.0-alpha.1" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.7.0" />
<PackageReference Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" Version="1.7.0-rc.1" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.7.0-alpha.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.6.0-beta.2" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.7.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.7.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="1.6.0-beta.2" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.6.0-beta.2" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.7.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.5.1" />
</ItemGroup>

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Sat Sep 09 2023 14:08:55 GMT+0700 (Indochina Time) */qr-code .qr-output canvas {
/* Sat Dec 30 2023 10:43:01 GMT+0700 (Indochina Time) */qr-code .qr-output canvas {
max-width: 100%; }

fb-login {
Expand Down Expand Up @@ -33,9 +33,6 @@ mix-module-data-table .preview-container {
max-height: 4em;
overflow: hidden; }

qr-code .qr-output canvas {
max-width: 100%; }

#dlg-preview-popup .modal-body img {
display: block;
margin: 0 auto;
Expand All @@ -45,6 +42,9 @@ qr-code .qr-output canvas {
#dlg-preview-popup pre {
overflow: visible; }

qr-code .qr-output canvas {
max-width: 100%; }

/* PROPORTIONALLY resize the canvas to the intended viewing size */
/* canvas{width:300px; height:380px;} */
upload-croppie .cr-boundary {
Expand Down

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/applications/mixcore/wwwroot/mix-app/css/portal.min.css

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading

0 comments on commit 27acb12

Please sign in to comment.