Added base structure

This commit is contained in:
Masu-Baumgartner
2024-08-30 09:15:06 +02:00
parent d5bf1a5e15
commit c4a4fbd221
15 changed files with 782 additions and 0 deletions

425
.gitignore vendored Normal file
View File

@@ -0,0 +1,425 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.tlog
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
*.vbp
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
*.dsw
*.dsp
# Visual Studio 6 technical files
*.ncb
*.aps
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# Visual Studio History (VSHistory) files
.vshistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd
# VS Code files for those working on multiple tools
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# Local History for Visual Studio Code
.history/
# Windows Installer files from build outputs
*.cab
*.msi
*.msix
*.msm
*.msp
# JetBrains Rider
*.sln.iml
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Moonlight
MoonlightServers/ApiServer/storage/**
/.idea/.idea.MoonlightServers/.idea

View File

@@ -0,0 +1,8 @@
using Moonlight.ApiServer.App.Helpers.Database;
namespace MoonlightServers.ApiServer.Database;
public class ServersContext : DatabaseContext
{
public override string Prefix => "Servers";
}

View File

@@ -0,0 +1,51 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
<ItemGroup Label="Moonlight Dependencies">
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.7"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.7">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MoonCore" Version="1.5.3" />
<PackageReference Include="MoonCore.Extended" Version="1.0.2" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.2" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.6.2" />
</ItemGroup>
<ItemGroup Label="Shared references">
<ProjectReference Include="..\MoonlightServers.DaemonShared\MoonlightServers.DaemonShared.csproj" />
<ProjectReference Include="..\MoonlightServers.Shared\MoonlightServers.Shared.csproj" />
</ItemGroup>
<ItemGroup Label="Reference moonlight builds">
<Reference Include="Moonlight.ApiServer">
<HintPath>..\..\Moonlight\Moonlight\ApiServer\bin\Debug\net8.0\Moonlight.ApiServer.dll</HintPath>
</Reference>
<Reference Include="Moonlight.Shared">
<HintPath>..\..\Moonlight\Moonlight\Shared\bin\Debug\net8.0\Moonlight.Shared.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Folder Include="Database\Entities\" />
<Folder Include="Database\Migrations\" />
<Folder Include="Helpers\" />
<Folder Include="Http\Controllers\" />
<Folder Include="Http\Hubs\" />
<Folder Include="Http\Middleware\" />
<Folder Include="Implementations\" />
<Folder Include="Models\" />
<Folder Include="Services\" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,34 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using MoonCore.Extended.Helpers;
using Moonlight.ApiServer.App.PluginApi;
using MoonlightServers.ApiServer.Database;
namespace MoonlightServers.ApiServer;
public class MoonlightServersPlugin : MoonlightPlugin
{
public MoonlightServersPlugin(ILogger logger, PluginService pluginService) : base(logger, pluginService)
{
}
public override Task OnLoaded()
{
return Task.CompletedTask;
}
public override Task OnAppBuilding(WebApplicationBuilder builder, DatabaseHelper databaseHelper)
{
// Register database
builder.Services.AddDbContext<ServersContext>();
databaseHelper.AddDbContext<ServersContext>();
return Task.CompletedTask;
}
public override Task OnAppConfiguring(WebApplication app)
{
return Task.CompletedTask;
}
}

View File

@@ -0,0 +1,27 @@
using Moonlight.Client.App.Interfaces;
using Moonlight.Client.App.Models;
namespace MoonlightServers.Client.Implementations;
public class ServersSidebarProvider : ISidebarItemProvider
{
public SidebarItem[] GetItems()
{
return [new ()
{
Name = "Servers",
Target = "/servers",
Icon = "bi bi-hdd-rack",
Priority = 5
},
new()
{
Name = "Servers",
Target = "/admin/servers",
Priority = 5,
Icon = "bi bi-hdd-rack",
Group = "Admin",
Permission = "admin.servers.get"
}];
}
}

View File

@@ -0,0 +1,42 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<SupportedPlatform Include="browser"/>
</ItemGroup>
<ItemGroup Label="Moonlight Dependencies">
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.7" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0"/>
<PackageReference Include="MoonCore" Version="1.5.3" />
<PackageReference Include="MoonCore.Blazor" Version="1.2.1" />
</ItemGroup>
<ItemGroup Label="Shared references">
<ProjectReference Include="..\MoonlightServers.Shared\MoonlightServers.Shared.csproj" />
</ItemGroup>
<ItemGroup Label="Reference moonlight builds">
<Reference Include="Moonlight.Client">
<HintPath>..\..\Moonlight\Moonlight\Client\bin\Debug\net8.0\Moonlight.Client.dll</HintPath>
</Reference>
<Reference Include="Moonlight.Shared">
<HintPath>..\..\Moonlight\Moonlight\Shared\bin\Debug\net8.0\Moonlight.Shared.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Folder Include="Helpers\" />
<Folder Include="Models\" />
<Folder Include="Services\" />
<Folder Include="UI\Components\" />
<Folder Include="UI\Views\" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,31 @@
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.Logging;
using Moonlight.Client.App.Interfaces;
using Moonlight.Client.App.PluginApi;
using MoonlightServers.Client.Implementations;
namespace MoonlightServers.Client;
public class MoonlightServersClientPlugin : MoonlightClientPlugin
{
public MoonlightServersClientPlugin(ILogger logger, PluginService pluginService) : base(logger, pluginService)
{
}
public override Task OnLoaded()
{
PluginService.RegisterImplementation<ISidebarItemProvider, ServersSidebarProvider>();
return Task.CompletedTask;
}
public override Task OnAppBuilding(WebAssemblyHostBuilder builder)
{
return Task.CompletedTask;
}
public override Task OnAppConfiguring(WebAssemblyHost app)
{
return Task.CompletedTask;
}
}

View File

@@ -0,0 +1,15 @@
@using System.Net.Http
@using System.Net.Http.Json
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.AspNetCore.Components.WebAssembly.Http
@using Microsoft.JSInterop
@using MoonCore.Services
@using MoonCore.Helpers
@using Moonlight.Client
@using Moonlight.Client.App.UI
@using Moonlight.Client.App.UI.Components
@using Moonlight.Client.App.UI.Layouts
@using Moonlight.Client.App.Attributes

View File

@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.6"/>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MoonlightServers.DaemonShared\MoonlightServers.DaemonShared.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,44 @@
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
var summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
app.MapGet("/weatherforecast", () =>
{
var forecast = Enumerable.Range(1, 5).Select(index =>
new WeatherForecast
(
DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
Random.Shared.Next(-20, 55),
summaries[Random.Shared.Next(summaries.Length)]
))
.ToArray();
return forecast;
})
.WithName("GetWeatherForecast")
.WithOpenApi();
app.Run();
record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
{
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
}

View File

@@ -0,0 +1,14 @@
{
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5167",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

View File

@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Folder Include="Http\Requests\" />
<Folder Include="Http\Responses\" />
<Folder Include="Models\" />
</ItemGroup>
</Project>

40
MoonlightServers.sln Normal file
View File

@@ -0,0 +1,40 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoonlightServers.Shared", "MoonlightServers.Shared\MoonlightServers.Shared.csproj", "{E16B0418-F865-41A6-A532-A2FF15651894}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoonlightServers.ApiServer", "MoonlightServers.ApiServer\MoonlightServers.ApiServer.csproj", "{74EB54DC-0136-4A02-A888-EB69B4905631}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoonlightServers.Client", "MoonlightServers.Client\MoonlightServers.Client.csproj", "{0D44004B-087F-4F4E-9346-9D079E40755E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoonlightServers.Daemon", "MoonlightServers.Daemon\MoonlightServers.Daemon.csproj", "{84E74090-85F3-4CCF-BD12-E533BDB869D8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoonlightServers.DaemonShared", "MoonlightServers.DaemonShared\MoonlightServers.DaemonShared.csproj", "{FCA17F9E-3734-4E94-8C6C-997012EBAB88}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E16B0418-F865-41A6-A532-A2FF15651894}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E16B0418-F865-41A6-A532-A2FF15651894}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E16B0418-F865-41A6-A532-A2FF15651894}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E16B0418-F865-41A6-A532-A2FF15651894}.Release|Any CPU.Build.0 = Release|Any CPU
{74EB54DC-0136-4A02-A888-EB69B4905631}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{74EB54DC-0136-4A02-A888-EB69B4905631}.Debug|Any CPU.Build.0 = Debug|Any CPU
{74EB54DC-0136-4A02-A888-EB69B4905631}.Release|Any CPU.ActiveCfg = Release|Any CPU
{74EB54DC-0136-4A02-A888-EB69B4905631}.Release|Any CPU.Build.0 = Release|Any CPU
{0D44004B-087F-4F4E-9346-9D079E40755E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0D44004B-087F-4F4E-9346-9D079E40755E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0D44004B-087F-4F4E-9346-9D079E40755E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0D44004B-087F-4F4E-9346-9D079E40755E}.Release|Any CPU.Build.0 = Release|Any CPU
{84E74090-85F3-4CCF-BD12-E533BDB869D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{84E74090-85F3-4CCF-BD12-E533BDB869D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{84E74090-85F3-4CCF-BD12-E533BDB869D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{84E74090-85F3-4CCF-BD12-E533BDB869D8}.Release|Any CPU.Build.0 = Release|Any CPU
{FCA17F9E-3734-4E94-8C6C-997012EBAB88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FCA17F9E-3734-4E94-8C6C-997012EBAB88}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FCA17F9E-3734-4E94-8C6C-997012EBAB88}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FCA17F9E-3734-4E94-8C6C-997012EBAB88}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal