admin api packaging

This commit is contained in:
Rory&
2025-12-14 23:18:35 +01:00
parent a4527d166a
commit 4534d4dbf5
124 changed files with 2250 additions and 268 deletions

View File

@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk.Worker">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>dotnet-ConfigTest-18d89c0e-df5d-447b-8429-7d526a35ab13</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Spacebar.ConfigModel\Spacebar.ConfigModel.csproj" />
<ProjectReference Include="..\Spacebar.Db\Spacebar.Db.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,14 @@
using ConfigTest;
using Microsoft.EntityFrameworkCore;
using Spacebar.Db.Contexts;
var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddHostedService<Worker>();
builder.Services.AddDbContext<SpacebarDbContext>(options => {
options
.UseNpgsql(builder.Configuration.GetConnectionString("Spacebar"))
.EnableDetailedErrors();
}, ServiceLifetime.Singleton);
var host = builder.Build();
host.Run();

View File

@@ -0,0 +1,12 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"ConfigTest": {
"commandName": "Project",
"dotnetRunMessages": true,
"environmentVariables": {
"DOTNET_ENVIRONMENT": "Development"
}
}
}
}

View File

@@ -0,0 +1,43 @@
using System.Text.Json.Nodes;
using Spacebar.ConfigModel.Extensions;
using Spacebar.Db.Contexts;
namespace ConfigTest;
public class Worker(ILogger<Worker> logger, SpacebarDbContext db) : BackgroundService
{
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
var config = db.Configs
.OrderBy(x => x.Key)
.ToDictionary(x => x.Key, x => x.Value);
foreach (var (key, value) in config)
{
Console.WriteLine("Config Key: {0}, Value: {1}", key, value ?? "[NULL]");
}
var readConfig = config.ToNestedJsonObject();
Console.WriteLine(readConfig);
var mapped = readConfig.ToFlatKv();
foreach (var (key, value) in mapped)
{
Console.WriteLine("Mapped Key: {0}, Value: {1}", key, value ?? "[NULL]");
}
// check that they're equal
foreach (var (key, value) in config)
{
if (!mapped.ContainsKey(key))
{
Console.WriteLine("Missing Key in Mapped: {0}", key);
continue;
}
if (mapped[key] != value)
{
Console.WriteLine("Value Mismatch for Key: {0}, Original: {1}, Mapped: {2}", key, value ?? "[NULL]", mapped[key] ?? "[NULL]");
}
}
Environment.Exit(0);
}
}

View File

@@ -0,0 +1,27 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Trace", //Warning
"Microsoft.AspNetCore.Mvc": "Warning", //Warning
"Microsoft.AspNetCore.HostFiltering": "Warning", //Warning
"Microsoft.AspNetCore.Cors": "Warning", //Warning
// "Microsoft.EntityFrameworkCore": "Warning"
"Microsoft.EntityFrameworkCore.Database.Command": "Debug"
}
},
"ConnectionStrings": {
"Spacebar": "Host=127.0.0.1; Username=postgres; Database=spacebar; Port=5432; Include Error Detail=true; Maximum Pool Size=1000; Command Timeout=6000; Timeout=600;",
},
"RabbitMQ": {
"Host": "127.0.0.1",
"Port": 5673,
"Username": "guest",
"Password": "guest"
},
"SpacebarAdminApi": {
"Enforce2FA": true,
"OverrideUid": null,
"DisableAuthentication": false
}
}

View File

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