Switched to database scheme seperation from MoonCores SingleDb. Updated mooncore versions. Updating to correct Async naming
This commit is contained in:
@@ -13,7 +13,7 @@ namespace Moonlight.ApiServer.Startup;
|
||||
|
||||
public partial class Startup
|
||||
{
|
||||
private Task RegisterAuth()
|
||||
private Task RegisterAuthAsync()
|
||||
{
|
||||
WebApplicationBuilder.Services
|
||||
.AddAuthentication(options => { options.DefaultScheme = "MainScheme"; })
|
||||
@@ -62,7 +62,7 @@ public partial class Startup
|
||||
.RequestServices
|
||||
.GetRequiredService<ApiKeyAuthService>();
|
||||
|
||||
var result = await apiKeyAuthService.Validate(context.Principal);
|
||||
var result = await apiKeyAuthService.ValidateAsync(context.Principal);
|
||||
|
||||
if (!result)
|
||||
context.Fail("API key has been deleted");
|
||||
@@ -120,7 +120,7 @@ public partial class Startup
|
||||
.RequestServices
|
||||
.GetRequiredService<UserAuthService>();
|
||||
|
||||
var result = await userSyncService.Sync(context.Principal);
|
||||
var result = await userSyncService.SyncAsync(context.Principal);
|
||||
|
||||
if (!result)
|
||||
context.Principal = new();
|
||||
@@ -135,7 +135,7 @@ public partial class Startup
|
||||
.RequestServices
|
||||
.GetRequiredService<UserAuthService>();
|
||||
|
||||
var result = await userSyncService.Validate(context.Principal);
|
||||
var result = await userSyncService.ValidateAsync(context.Principal);
|
||||
|
||||
if (!result)
|
||||
context.RejectPrincipal();
|
||||
@@ -178,7 +178,7 @@ public partial class Startup
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task UseAuth()
|
||||
private Task UseAuthAsync()
|
||||
{
|
||||
WebApplication.UseAuthentication();
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Moonlight.ApiServer.Startup;
|
||||
|
||||
public partial class Startup
|
||||
{
|
||||
private Task RegisterBase()
|
||||
private Task RegisterBaseAsync()
|
||||
{
|
||||
WebApplicationBuilder.Services.AutoAddServices<Startup>();
|
||||
WebApplicationBuilder.Services.AddHttpClient();
|
||||
@@ -29,7 +29,7 @@ public partial class Startup
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task UseBase()
|
||||
private Task UseBaseAsync()
|
||||
{
|
||||
WebApplication.UseRouting();
|
||||
WebApplication.UseExceptionHandler();
|
||||
@@ -37,7 +37,7 @@ public partial class Startup
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task MapBase()
|
||||
private Task MapBaseAsync()
|
||||
{
|
||||
WebApplication.MapControllers();
|
||||
|
||||
@@ -47,7 +47,7 @@ public partial class Startup
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task ConfigureKestrel()
|
||||
private Task ConfigureKestrelAsync()
|
||||
{
|
||||
WebApplicationBuilder.WebHost.ConfigureKestrel(kestrelOptions =>
|
||||
{
|
||||
|
||||
@@ -8,11 +8,11 @@ namespace Moonlight.ApiServer.Startup;
|
||||
|
||||
public partial class Startup
|
||||
{
|
||||
private async Task SetupAppConfiguration()
|
||||
private async Task SetupAppConfigurationAsync()
|
||||
{
|
||||
var configPath = Path.Combine("storage", "config.yml");
|
||||
|
||||
await YamlDefaultGenerator.Generate<AppConfiguration>(configPath);
|
||||
await YamlDefaultGenerator.GenerateAsync<AppConfiguration>(configPath);
|
||||
|
||||
// Configure configuration (wow)
|
||||
var configurationBuilder = new ConfigurationBuilder();
|
||||
@@ -27,7 +27,7 @@ public partial class Startup
|
||||
configurationRoot.Bind(Configuration);
|
||||
}
|
||||
|
||||
private Task RegisterAppConfiguration()
|
||||
private Task RegisterAppConfigurationAsync()
|
||||
{
|
||||
WebApplicationBuilder.Services.AddSingleton(Configuration);
|
||||
return Task.CompletedTask;
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Moonlight.ApiServer.Startup;
|
||||
|
||||
public partial class Startup
|
||||
{
|
||||
private Task RegisterDatabase()
|
||||
private Task RegisterDatabaseAsync()
|
||||
{
|
||||
WebApplicationBuilder.Services.AddDatabaseMappings();
|
||||
WebApplicationBuilder.Services.AddServiceCollectionAccessor();
|
||||
@@ -16,9 +16,9 @@ public partial class Startup
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private async Task PrepareDatabase()
|
||||
private async Task PrepareDatabaseAsync()
|
||||
{
|
||||
await WebApplication.Services.EnsureDatabaseMigrated();
|
||||
await WebApplication.Services.EnsureDatabaseMigratedAsync();
|
||||
|
||||
WebApplication.Services.GenerateDatabaseMappings();
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Moonlight.ApiServer.Startup;
|
||||
|
||||
public partial class Startup
|
||||
{
|
||||
private Task RegisterHangfire()
|
||||
private Task RegisterHangfireAsync()
|
||||
{
|
||||
WebApplicationBuilder.Services.AddHangfire((provider, configuration) =>
|
||||
{
|
||||
@@ -38,7 +38,7 @@ public partial class Startup
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task UseHangfire()
|
||||
private Task UseHangfireAsync()
|
||||
{
|
||||
if (WebApplication.Environment.IsDevelopment())
|
||||
WebApplication.UseHangfireDashboard();
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Moonlight.ApiServer.Startup;
|
||||
|
||||
public partial class Startup
|
||||
{
|
||||
private Task SetupLogging()
|
||||
private Task SetupLoggingAsync()
|
||||
{
|
||||
var loggerFactory = new LoggerFactory();
|
||||
loggerFactory.AddAnsiConsole();
|
||||
@@ -16,7 +16,7 @@ public partial class Startup
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private async Task RegisterLogging()
|
||||
private async Task RegisterLoggingAsync()
|
||||
{
|
||||
// Configure application logging
|
||||
WebApplicationBuilder.Logging.ClearProviders();
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Moonlight.ApiServer.Startup;
|
||||
|
||||
public partial class Startup
|
||||
{
|
||||
private Task PrintVersion()
|
||||
private Task PrintVersionAsync()
|
||||
{
|
||||
// Fancy start console output... yes very fancy :>
|
||||
var rainbow = new Crayon.Rainbow(0.5);
|
||||
@@ -25,7 +25,7 @@ public partial class Startup
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task CreateStorage()
|
||||
private Task CreateStorageAsync()
|
||||
{
|
||||
Directory.CreateDirectory("storage");
|
||||
Directory.CreateDirectory(Path.Combine("storage", "logs"));
|
||||
@@ -33,7 +33,7 @@ public partial class Startup
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task RegisterCors()
|
||||
private Task RegisterCorsAsync()
|
||||
{
|
||||
var allowedOrigins = Configuration.Kestrel.AllowedOrigins;
|
||||
|
||||
@@ -64,7 +64,7 @@ public partial class Startup
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task UseCors()
|
||||
private Task UseCorsAsync()
|
||||
{
|
||||
WebApplication.UseCors();
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ public partial class Startup
|
||||
private IServiceProvider PluginLoadServiceProvider;
|
||||
private IPluginStartup[] PluginStartups;
|
||||
|
||||
private Task InitializePlugins()
|
||||
private Task InitializePluginsAsync()
|
||||
{
|
||||
// Create service provider for starting up
|
||||
var serviceCollection = new ServiceCollection();
|
||||
@@ -28,13 +28,13 @@ public partial class Startup
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private async Task HookPluginBuild()
|
||||
private async Task HookPluginBuildAsync()
|
||||
{
|
||||
foreach (var pluginAppStartup in PluginStartups)
|
||||
{
|
||||
try
|
||||
{
|
||||
await pluginAppStartup.BuildApplication(PluginLoadServiceProvider, WebApplicationBuilder);
|
||||
await pluginAppStartup.BuildApplicationAsync(PluginLoadServiceProvider, WebApplicationBuilder);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -47,13 +47,13 @@ public partial class Startup
|
||||
}
|
||||
}
|
||||
|
||||
private async Task HookPluginConfigure()
|
||||
private async Task HookPluginConfigureAsync()
|
||||
{
|
||||
foreach (var pluginAppStartup in PluginStartups)
|
||||
{
|
||||
try
|
||||
{
|
||||
await pluginAppStartup.ConfigureApplication(PluginLoadServiceProvider, WebApplication);
|
||||
await pluginAppStartup.ConfigureApplicationAsync(PluginLoadServiceProvider, WebApplication);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -66,13 +66,13 @@ public partial class Startup
|
||||
}
|
||||
}
|
||||
|
||||
private async Task HookPluginEndpoints()
|
||||
private async Task HookPluginEndpointsAsync()
|
||||
{
|
||||
foreach (var pluginEndpointStartup in PluginStartups)
|
||||
{
|
||||
try
|
||||
{
|
||||
await pluginEndpointStartup.ConfigureEndpoints(PluginLoadServiceProvider, WebApplication);
|
||||
await pluginEndpointStartup.ConfigureEndpointsAsync(PluginLoadServiceProvider, WebApplication);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Moonlight.ApiServer.Startup;
|
||||
|
||||
public partial class Startup
|
||||
{
|
||||
public Task RegisterSignalR()
|
||||
public Task RegisterSignalRAsync()
|
||||
{
|
||||
var signalRBuilder = WebApplicationBuilder.Services.AddSignalR();
|
||||
|
||||
@@ -16,7 +16,7 @@ public partial class Startup
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task MapSignalR()
|
||||
public Task MapSignalRAsync()
|
||||
{
|
||||
WebApplication.MapHub<DiagnoseHub>("/api/admin/system/diagnose/ws");
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ public partial class Startup
|
||||
public WebApplication WebApplication { get; private set; }
|
||||
public WebApplicationBuilder WebApplicationBuilder { get; private set; }
|
||||
|
||||
public Task Initialize(string[] args, IPluginStartup[]? plugins = null)
|
||||
public Task InitializeAsync(string[] args, IPluginStartup[]? plugins = null)
|
||||
{
|
||||
Args = args;
|
||||
PluginStartups = plugins ?? [];
|
||||
@@ -27,43 +27,43 @@ public partial class Startup
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public async Task AddMoonlight(WebApplicationBuilder builder)
|
||||
public async Task AddMoonlightAsync(WebApplicationBuilder builder)
|
||||
{
|
||||
WebApplicationBuilder = builder;
|
||||
|
||||
await PrintVersion();
|
||||
await PrintVersionAsync();
|
||||
|
||||
await CreateStorage();
|
||||
await SetupAppConfiguration();
|
||||
await SetupLogging();
|
||||
await InitializePlugins();
|
||||
await CreateStorageAsync();
|
||||
await SetupAppConfigurationAsync();
|
||||
await SetupLoggingAsync();
|
||||
await InitializePluginsAsync();
|
||||
|
||||
await ConfigureKestrel();
|
||||
await RegisterAppConfiguration();
|
||||
await RegisterLogging();
|
||||
await RegisterBase();
|
||||
await RegisterDatabase();
|
||||
await RegisterAuth();
|
||||
await RegisterCors();
|
||||
await RegisterHangfire();
|
||||
await RegisterSignalR();
|
||||
await HookPluginBuild();
|
||||
await ConfigureKestrelAsync();
|
||||
await RegisterAppConfigurationAsync();
|
||||
await RegisterLoggingAsync();
|
||||
await RegisterBaseAsync();
|
||||
await RegisterDatabaseAsync();
|
||||
await RegisterAuthAsync();
|
||||
await RegisterCorsAsync();
|
||||
await RegisterHangfireAsync();
|
||||
await RegisterSignalRAsync();
|
||||
await HookPluginBuildAsync();
|
||||
}
|
||||
|
||||
public async Task AddMoonlight(WebApplication application)
|
||||
public async Task AddMoonlightAsync(WebApplication application)
|
||||
{
|
||||
WebApplication = application;
|
||||
|
||||
await PrepareDatabase();
|
||||
await PrepareDatabaseAsync();
|
||||
|
||||
await UseCors();
|
||||
await UseBase();
|
||||
await UseAuth();
|
||||
await UseHangfire();
|
||||
await HookPluginConfigure();
|
||||
await UseCorsAsync();
|
||||
await UseBaseAsync();
|
||||
await UseAuthAsync();
|
||||
await UseHangfireAsync();
|
||||
await HookPluginConfigureAsync();
|
||||
|
||||
await MapBase();
|
||||
await MapSignalR();
|
||||
await HookPluginEndpoints();
|
||||
await MapBaseAsync();
|
||||
await MapSignalRAsync();
|
||||
await HookPluginEndpointsAsync();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user