More server code

This commit is contained in:
Timothy Baldridge 2021-11-27 13:15:07 -07:00
parent 779e178bfe
commit 6af400369d
2 changed files with 10 additions and 1 deletions

View File

@ -21,4 +21,5 @@ public class AppSettings
public string AuthoredFilesFolder { get; set; }
public string MetricsFolder { get; set; }
public string TarLogPath { get; set; }
public string GitHubKey { get; set; }
}

View File

@ -63,7 +63,15 @@ public class Startup
services.AddSingleton<AuthorFiles>();
services.AddSingleton<AuthorKeys>();
services.AddSingleton<Client>();
services.AddSingleton(s => new GitHubClient(new ProductHeaderValue("wabbajack")));
services.AddSingleton(s =>
{
var settings = s.GetService<AppSettings>()!;
if (string.IsNullOrWhiteSpace(settings.GitHubKey))
return new GitHubClient(new ProductHeaderValue("wabbajack"));
var creds = new Credentials(settings.GitHubKey);
return new GitHubClient(new ProductHeaderValue("wabbajack")) {Credentials = creds};
});
services.AddDTOSerializer();
services.AddDTOConverters();
services.AddResponseCompression(options =>