mirror of
https://github.com/9ParsonsB/Pulsar.git
synced 2025-07-01 16:33:43 -04:00
Add initial API & Configuration
This commit is contained in:
51
Pulsar/Features/EventsHub.cs
Normal file
51
Pulsar/Features/EventsHub.cs
Normal file
@ -0,0 +1,51 @@
|
||||
namespace Pulsar.Features;
|
||||
|
||||
using Observatory.Framework.Files;
|
||||
using Observatory.Framework.Files.Journal;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
|
||||
public class EventsHub : Hub<IEventHub>
|
||||
{
|
||||
public async Task StatusUpdated(Observatory.Framework.Files.Status status) => await Clients.All.StatusUpdated(status);
|
||||
|
||||
public async Task OutfittingUpdated(OutfittingFile outfitting) => await Clients.All.OutfittingUpdated(outfitting);
|
||||
|
||||
public async Task ShipyardUpdated(ShipyardFile shipyard) => await Clients.All.ShipyardUpdated(shipyard);
|
||||
|
||||
public async Task NavRouteUpdated(NavRouteFile navRoute) => await Clients.All.NavRouteUpdated(navRoute);
|
||||
|
||||
public async Task MarketUpdated(MarketFile market) => await Clients.All.MarketUpdated(market);
|
||||
|
||||
public async Task JournalUpdated(IReadOnlyCollection<JournalBase> journals) => await Clients.All.JournalUpdated(journals);
|
||||
|
||||
public async Task ModuleInfoUpdated(ModuleInfoFile moduleInfo) => await Clients.All.ModuleInfoUpdated(moduleInfo);
|
||||
|
||||
public async Task FleetCarrierUpdated(FCMaterialsFile fleetCarrier) => await Clients.All.FleetCarrierUpdated(fleetCarrier);
|
||||
|
||||
public async Task CargoUpdated(CargoFile cargo) => await Clients.All.CargoUpdated(cargo);
|
||||
|
||||
public async Task BackpackUpdated(BackpackFile backpack) => await Clients.All.BackpackUpdated(backpack);
|
||||
}
|
||||
|
||||
public interface IEventHub
|
||||
{
|
||||
Task StatusUpdated(Observatory.Framework.Files.Status status);
|
||||
|
||||
Task OutfittingUpdated(OutfittingFile outfitting);
|
||||
|
||||
Task ShipyardUpdated(ShipyardFile shipyard);
|
||||
|
||||
Task NavRouteUpdated(NavRouteFile navRoute);
|
||||
|
||||
Task MarketUpdated(MarketFile market);
|
||||
|
||||
Task JournalUpdated(IReadOnlyCollection<JournalBase> journals);
|
||||
|
||||
Task ModuleInfoUpdated(ModuleInfoFile moduleInfo);
|
||||
|
||||
Task FleetCarrierUpdated(FCMaterialsFile fleetCarrier);
|
||||
|
||||
Task CargoUpdated(CargoFile cargo);
|
||||
|
||||
Task BackpackUpdated(BackpackFile backpack);
|
||||
}
|
12
Pulsar/Features/Status/StatusController.cs
Normal file
12
Pulsar/Features/Status/StatusController.cs
Normal file
@ -0,0 +1,12 @@
|
||||
namespace Pulsar.Features.Status;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/status")]
|
||||
public class StatusController : Controller
|
||||
{
|
||||
[HttpGet]
|
||||
public IActionResult Get()
|
||||
{
|
||||
return Ok();
|
||||
}
|
||||
}
|
@ -3,4 +3,5 @@ global using Pulsar.Utils;
|
||||
global using System.Text;
|
||||
global using System.Text.Json;
|
||||
global using System.Text.Json.Nodes;
|
||||
global using System.Text.Json.Serialization;
|
||||
global using System.Text.Json.Serialization;
|
||||
global using Microsoft.AspNetCore.Mvc;
|
||||
|
@ -1,21 +1,18 @@
|
||||
if (args.Length > 0 && File.Exists(args[0]))
|
||||
{
|
||||
var fileInfo = new FileInfo(args[0]);
|
||||
if (fileInfo.Extension is ".eop" or ".zip")
|
||||
File.Copy(fileInfo.FullName, Path.Join(AppDomain.CurrentDomain.BaseDirectory, "plugins", fileInfo.Name));
|
||||
}
|
||||
using Lamar.Microsoft.DependencyInjection;
|
||||
|
||||
try
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Services.AddLamar();
|
||||
builder.Services.AddControllers();
|
||||
builder.Services.AddSignalR();
|
||||
builder.Services.AddDbContext<PulsarContext>();
|
||||
builder.Services.Configure<PulsarConfiguration>(builder.Configuration.GetSection(nameof(Pulsar)));
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
await app.RunAsync();
|
||||
|
||||
public class PulsarConfiguration
|
||||
{
|
||||
WebApplicationBuilder builder = WebApplication.CreateSlimBuilder(args);
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
SettingsManager.Load();
|
||||
|
||||
await app.RunAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LoggingUtils.LogError(ex, "");
|
||||
public string JournalDirectory { get; set; }
|
||||
}
|
@ -12,5 +12,13 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ObservatoryFramework\ObservatoryFramework.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Lamar" Version="13.0.3" />
|
||||
<PackageReference Include="Lamar.Microsoft.DependencyInjection" Version="13.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.4" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.4" />
|
||||
<PackageReference Include="Scrutor" Version="4.2.2" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
8
Pulsar/PulsarContext.cs
Normal file
8
Pulsar/PulsarContext.cs
Normal file
@ -0,0 +1,8 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
/// <summary>
|
||||
/// An in-memory database context for Pulsar.
|
||||
/// </summary>
|
||||
public class PulsarContext : DbContext
|
||||
{
|
||||
}
|
@ -3,7 +3,7 @@ using Observatory.Framework.Files.Journal.Exploration;
|
||||
|
||||
namespace Pulsar.Utils;
|
||||
|
||||
public class JournalReader
|
||||
public static class JournalReader
|
||||
{
|
||||
public static TJournal ObservatoryDeserializer<TJournal>(string json) where TJournal : JournalBase
|
||||
{
|
||||
|
@ -1,14 +0,0 @@
|
||||
namespace Pulsar.Utils;
|
||||
|
||||
internal static class SettingsManager
|
||||
{
|
||||
internal static void Save()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
internal static void Load()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
6
Pulsar/appSettings.json
Normal file
6
Pulsar/appSettings.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"Pulsar": {
|
||||
// C:\Users\User Name\Saved Games\Frontier Developments\Elite Dangerous\
|
||||
"JournalDirectory": "/home/minijack/Games/lutris/elite-dangerous/drive_c/users/minijack/Saved Games/Frontier Developments/Elite Dangerous/",
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user