Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
Aragas committed May 26, 2024
1 parent f12b4af commit 226ec32
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions src/BUTR.Site.NexusMods.Server/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.Unicode;
using Serilog;

namespace BUTR.Site.NexusMods.Server;

Expand Down Expand Up @@ -94,7 +95,7 @@ public Startup(IConfiguration configuration)

public void ConfigureServices(IServiceCollection services)
{
Console.WriteLine("Test1");
Log.Warning("Test1");
var assemblyName = typeof(Startup).Assembly.GetName();
var userAgent = $"{assemblyName.Name ?? "ERROR"} v{assemblyName.Version?.ToString() ?? "ERROR"} (github.com/BUTR)";

Expand All @@ -108,7 +109,7 @@ public void ConfigureServices(IServiceCollection services)
var steamAPISection = _configuration.GetSection(SteamAPISectionName);
var depotDownloaderSection = _configuration.GetSection(DepotDownloaderSectionName);

Console.WriteLine("Test2");
Log.Warning("Test2");
services.AddOptions<JsonSerializerOptions>().Configure(opt => Configure(opt));
services.AddValidatedOptions<ConnectionStringsOptions, ConnectionStringsOptionsValidator>().Bind(connectionStringSection);
services.AddValidatedOptionsWithHttp<CrashReporterOptions, CrashReporterOptionsValidator>().Bind(crashReporterSection);
Expand All @@ -120,7 +121,7 @@ public void ConfigureServices(IServiceCollection services)
services.AddValidatedOptions<SteamAPIOptions, SteamAPIOptionsValidator>().Bind(steamAPISection);
services.AddValidatedOptions<SteamDepotDownloaderOptions, SteamDepotDownloaderOptionsValidator>().Bind(depotDownloaderSection);

Console.WriteLine("Test3");
Log.Warning("Test3");
services.AddHttpClient(string.Empty).ConfigureHttpClient((_, client) =>
{
client.DefaultRequestHeaders.Add("User-Agent", userAgent);
Expand Down Expand Up @@ -190,7 +191,7 @@ public void ConfigureServices(IServiceCollection services)
client.DefaultRequestHeaders.Add("User-Agent", userAgent);
}).AddPolicyHandler(GetRetryPolicy());

Console.WriteLine("Test4");
Log.Warning("Test4");
services.AddQuartz(opt =>
{
opt.AddJobListener<IQuartzEventProviderService>(sp => sp.GetRequiredService<IQuartzEventProviderService>());
Expand Down Expand Up @@ -234,22 +235,22 @@ public void ConfigureServices(IServiceCollection services)
services.AddMemoryCache();


Console.WriteLine("Test5");
Log.Warning("Test5");
var types = typeof(Startup).Assembly.GetTypes().Where(x => x is { IsAbstract: false, BaseType: { IsGenericType: true } }).ToList();
foreach (var type in types.Where(x => x.BaseType!.GetGenericTypeDefinition() == typeof(BaseEntityConfigurationWithTenant<>)))
services.TryAddEnumerable(ServiceDescriptor.Scoped(typeof(IEntityConfiguration), type));
foreach (var type in types.Where(x => x.BaseType!.GetGenericTypeDefinition() == typeof(BaseEntityConfiguration<>)))
services.TryAddEnumerable(ServiceDescriptor.Scoped(typeof(IEntityConfiguration), type));

Console.WriteLine("Tes6");
Log.Warning("Tes6");
services.AddDbContext<BaseAppDbContext>(ServiceLifetime.Scoped);
services.AddDbContextFactory<AppDbContextRead>(lifetime: ServiceLifetime.Scoped);
services.AddDbContextFactory<AppDbContextWrite>(lifetime: ServiceLifetime.Scoped);

Console.WriteLine("Test7");
Log.Warning("Test7");
services.AddNexusModsDefaultServices();

Console.WriteLine("Test8");
Log.Warning("Test8");
services.TryAddEnumerable(ServiceDescriptor.Singleton<IHttpMessageHandlerBuilderFilter, SyncLoggingHttpMessageHandlerBuilderFilter>());

services.AddAuthentication(ButrNexusModsAuthSchemeConstants.AuthScheme).AddNexusMods(options =>
Expand All @@ -258,16 +259,16 @@ public void ConfigureServices(IServiceCollection services)
options.EncryptionKey = opts?.EncryptionKey ?? string.Empty;
});

Console.WriteLine("Test9");
Log.Warning("Test9");
services.AddStreamingMultipartResult();

services.AddHttpContextAccessor();
Console.WriteLine("Test10");
Log.Warning("Test10");
services.AddRouting(opt =>
{
opt.ConstraintMap["slugify"] = typeof(SlugifyParameterTransformer);
});
Console.WriteLine("Test11");
Log.Warning("Test11");
services.AddControllersWithAPIResult(opt =>
{
opt.Conventions.Add(new SlugifyActionConvention());
Expand All @@ -277,7 +278,7 @@ public void ConfigureServices(IServiceCollection services)
opt.ValueProviderFactories.Add(new ClaimsValueProviderFactory());
}).AddJsonOptions(opt => Configure(opt.JsonSerializerOptions));
Console.WriteLine("Test12");
Log.Warning("Test12");
services.AddResponseCompression(opt =>
{
opt.Providers.Add<BrotliCompressionProvider>();
Expand All @@ -292,7 +293,7 @@ public void ConfigureServices(IServiceCollection services)
options.Level = CompressionLevel.SmallestSize;
});

Console.WriteLine("Test13");
Log.Warning("Test13");
services.AddSwaggerGen(opt =>
{
opt.SwaggerDoc("v1", new OpenApiInfo
Expand Down Expand Up @@ -345,18 +346,18 @@ public void ConfigureServices(IServiceCollection services)
.Where(File.Exists)
.ToList();
foreach (var xmlFilePath in xmlFilePaths)
opt.IncludeXmlComments(xmlFilePath, true);
opt.IncludeXmlComments(xmlFilePath);
});

Console.WriteLine("Test14");
Log.Warning("Test14");
services.Configure<ForwardedHeadersOptions>(options =>
{
options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
});

services.AddResponseCaching();

Console.WriteLine("Test15");
Log.Warning("Test15");
services.AddCors(options =>
{
options.AddPolicy("Development", builder => builder
Expand All @@ -366,7 +367,7 @@ public void ConfigureServices(IServiceCollection services)
);
});

Console.WriteLine("Test16");
Log.Warning("Test16");
services.AddDistributedPostgreSqlCache(options =>
{
var opts = connectionStringSection.Get<ConnectionStringsOptions>();
Expand Down

0 comments on commit 226ec32

Please sign in to comment.