chore: organize

This commit is contained in:
Lapis
2026-04-05 08:14:31 -04:00
parent d831460f8f
commit c555d35d0b
49 changed files with 76 additions and 54 deletions
+1
View File
@@ -1,5 +1,6 @@
using CannedNet; using CannedNet;
using CannedNet.Services; using CannedNet.Services;
using CannedNet.Services.Infrastructure;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
var apps = new List<(WebApplication App, ServiceRegistry Service)>(); var apps = new List<(WebApplication App, ServiceRegistry Service)>();
@@ -6,10 +6,12 @@ using System.Text.Json.Serialization;
using CannedNet.Hubs; using CannedNet.Hubs;
using CannedNet.Models; using CannedNet.Models;
using Microsoft.AspNetCore.SignalR; using Microsoft.AspNetCore.SignalR;
using CannedNet.Services;
using CannedNet.Services.Infrastructure;
namespace CannedNet.Services; namespace CannedNet.Services.Controllers;
public class APIService public class APIController
{ {
public WebApplicationBuilder Initialize(string[]? args = null) => ServiceExtensions.CreateRecNetBuilder(args); public WebApplicationBuilder Initialize(string[]? args = null) => ServiceExtensions.CreateRecNetBuilder(args);
@@ -1,9 +1,11 @@
using CannedNet.Data; using CannedNet.Data;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using CannedNet.Services;
using CannedNet.Services.Infrastructure;
namespace CannedNet.Services; namespace CannedNet.Services.Controllers;
public class AccountsService public class AccountsController
{ {
public WebApplicationBuilder Initialize(string[]? args = null) => ServiceExtensions.CreateRecNetBuilder(args); public WebApplicationBuilder Initialize(string[]? args = null) => ServiceExtensions.CreateRecNetBuilder(args);
@@ -1,10 +1,12 @@
using CannedNet; using CannedNet;
using CannedNet.Data; using CannedNet.Data;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using CannedNet.Services;
using CannedNet.Services.Infrastructure;
namespace CannedNet.Services; namespace CannedNet.Services.Controllers;
public class AuthService public class AuthController
{ {
public WebApplicationBuilder Initialize(string[]? args = null) => ServiceExtensions.CreateRecNetBuilder(args); public WebApplicationBuilder Initialize(string[]? args = null) => ServiceExtensions.CreateRecNetBuilder(args);
@@ -1,6 +1,8 @@
namespace CannedNet.Services; using CannedNet.Services.Infrastructure;
public class CDNService namespace CannedNet.Services.Controllers;
public class CDNController
{ {
public WebApplicationBuilder Initialize(string[]? args = null) => ServiceExtensions.CreateRecNetBuilder(args); public WebApplicationBuilder Initialize(string[]? args = null) => ServiceExtensions.CreateRecNetBuilder(args);
@@ -1,6 +1,8 @@
namespace CannedNet.Services; using CannedNet.Services.Infrastructure;
public class ChatService namespace CannedNet.Services.Controllers;
public class ChatController
{ {
public WebApplicationBuilder Initialize(string[]? args = null) => ServiceExtensions.CreateRecNetBuilder(args); public WebApplicationBuilder Initialize(string[]? args = null) => ServiceExtensions.CreateRecNetBuilder(args);
@@ -1,6 +1,8 @@
namespace CannedNet.Services; using CannedNet.Services.Infrastructure;
public class ClubsService namespace CannedNet.Services.Controllers;
public class ClubsController
{ {
public WebApplicationBuilder Initialize(string[]? args = null) => ServiceExtensions.CreateRecNetBuilder(args); public WebApplicationBuilder Initialize(string[]? args = null) => ServiceExtensions.CreateRecNetBuilder(args);
@@ -1,6 +1,8 @@
namespace CannedNet.Services; using CannedNet.Services.Infrastructure;
public class CommerceService namespace CannedNet.Services.Controllers;
public class CommerceController
{ {
public WebApplicationBuilder Initialize(string[]? args = null) => ServiceExtensions.CreateRecNetBuilder(args); public WebApplicationBuilder Initialize(string[]? args = null) => ServiceExtensions.CreateRecNetBuilder(args);
@@ -1,6 +1,8 @@
namespace CannedNet.Services; using CannedNet.Services.Infrastructure;
public class ImageService namespace CannedNet.Services.Controllers;
public class ImageController
{ {
public WebApplicationBuilder Initialize(string[]? args = null) => ServiceExtensions.CreateRecNetBuilder(args); public WebApplicationBuilder Initialize(string[]? args = null) => ServiceExtensions.CreateRecNetBuilder(args);
@@ -2,10 +2,12 @@ using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using CannedNet.Data; using CannedNet.Data;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using CannedNet.Services;
using CannedNet.Services.Infrastructure;
namespace CannedNet.Services; namespace CannedNet.Services.Controllers;
public class MatchmakingService public class MatchmakingController
{ {
public WebApplicationBuilder Initialize(string[]? args = null) => ServiceExtensions.CreateRecNetBuilder(args); public WebApplicationBuilder Initialize(string[]? args = null) => ServiceExtensions.CreateRecNetBuilder(args);
@@ -1,8 +1,9 @@
using CannedNet.Hubs; using CannedNet.Hubs;
using CannedNet.Services.Infrastructure;
namespace CannedNet.Services; namespace CannedNet.Services.Controllers;
public class NSService public class NSController
{ {
public WebApplicationBuilder Initialize(string[]? args = null) => ServiceExtensions.CreateRecNetBuilder(args); public WebApplicationBuilder Initialize(string[]? args = null) => ServiceExtensions.CreateRecNetBuilder(args);
@@ -1,8 +1,9 @@
using CannedNet.Hubs; using CannedNet.Hubs;
using CannedNet.Services.Infrastructure;
namespace CannedNet.Services; namespace CannedNet.Services.Controllers;
public class NotifyService public class NotifyController
{ {
public WebApplicationBuilder Initialize(string[]? args = null) => ServiceExtensions.CreateRecNetBuilder(args); public WebApplicationBuilder Initialize(string[]? args = null) => ServiceExtensions.CreateRecNetBuilder(args);
@@ -1,6 +1,6 @@
using System.Text; using System.Text;
namespace CannedNet.Services; namespace CannedNet.Services.Infrastructure;
public class RequestLoggingMiddleware public class RequestLoggingMiddleware
{ {
@@ -1,7 +1,7 @@
using CannedNet.Data; using CannedNet.Data;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace CannedNet.Services; namespace CannedNet.Services.Infrastructure;
public static class ServiceExtensions public static class ServiceExtensions
{ {
@@ -0,0 +1,31 @@
using System.Net.Mime;
using CannedNet.Services.Controllers;
namespace CannedNet.Services.Infrastructure;
public class ServiceRegistry
{
public required string Name { get; init; }
public required int Port { get; init; }
public required Type ServiceType { get; init; }
public required Action<WebApplicationBuilder> ConfigureBuilder { get; init; }
public required Action<WebApplication, JwtTokenService> MapEndpoints { get; init; }
}
public static class Services
{
public static readonly List<ServiceRegistry> All =
[
new() { Name = "NS", Port = 5001, ServiceType = typeof(NSController), ConfigureBuilder = b => b.ConfigureRecNetServices(), MapEndpoints = (app, _) => new NSController().MapEndpoints(app) },
new() { Name = "API", Port = 5000, ServiceType = typeof(APIController), ConfigureBuilder = b => b.ConfigureRecNetServices(), MapEndpoints = (app, _) => new APIController().MapEndpoints(app) },
new() { Name = "Auth", Port = 5002, ServiceType = typeof(AuthController), ConfigureBuilder = b => b.ConfigureRecNetServices(), MapEndpoints = (app, jwt) => new AuthController().MapEndpoints(app) },
new() { Name = "Chat", Port = 5003, ServiceType = typeof(ChatController), ConfigureBuilder = b => b.ConfigureRecNetServices(), MapEndpoints = (app, _) => new ChatController().MapEndpoints(app) },
new() { Name = "Match", Port = 5004, ServiceType = typeof(MatchmakingController), ConfigureBuilder = b => b.ConfigureRecNetServices(), MapEndpoints = (app, _) => new MatchmakingController().MapEndpoints(app) },
new() { Name = "Accounts", Port = 5005, ServiceType = typeof(AccountsController), ConfigureBuilder = b => b.ConfigureRecNetServices(), MapEndpoints = (app, jwt) => new AccountsController().MapEndpoints(app, jwt) },
new() { Name = "Notify", Port = 5006, ServiceType = typeof(NotifyController), ConfigureBuilder = b => b.ConfigureRecNetServices(), MapEndpoints = (app, _) => new NotifyController().MapEndpoints(app) },
new() { Name = "CDN", Port = 5007, ServiceType = typeof(CDNController), ConfigureBuilder = b => b.ConfigureRecNetServices(), MapEndpoints = (app, _) => new CDNController().MapEndpoints(app) },
new() { Name = "Image", Port = 5008, ServiceType = typeof(ImageController), ConfigureBuilder = b => b.ConfigureRecNetServices(), MapEndpoints = (app, _) => new ImageController().MapEndpoints(app) },
new() { Name = "Clubs", Port = 5009, ServiceType = typeof(ClubsController), ConfigureBuilder = b => b.ConfigureRecNetServices(), MapEndpoints = (app, _) => new ClubsController().MapEndpoints(app) },
new() { Name = "Commerce", Port = 5010, ServiceType = typeof(CommerceController), ConfigureBuilder = b => b.ConfigureRecNetServices(), MapEndpoints = (app, _) => new CommerceController().MapEndpoints(app) }
];
}
-30
View File
@@ -1,30 +0,0 @@
using System.Net.Mime;
namespace CannedNet.Services;
public class ServiceRegistry
{
public required string Name { get; init; }
public required int Port { get; init; }
public required Type ServiceType { get; init; }
public required Action<WebApplicationBuilder> ConfigureBuilder { get; init; }
public required Action<WebApplication, JwtTokenService> MapEndpoints { get; init; }
}
public static class Services
{
public static readonly List<ServiceRegistry> All =
[
new() { Name = "NS", Port = 5001, ServiceType = typeof(NSService), ConfigureBuilder = b => b.ConfigureRecNetServices(), MapEndpoints = (app, _) => new NSService().MapEndpoints(app) },
new() { Name = "API", Port = 5000, ServiceType = typeof(APIService), ConfigureBuilder = b => b.ConfigureRecNetServices(), MapEndpoints = (app, _) => new APIService().MapEndpoints(app) },
new() { Name = "Auth", Port = 5002, ServiceType = typeof(AuthService), ConfigureBuilder = b => b.ConfigureRecNetServices(), MapEndpoints = (app, jwt) => new AuthService().MapEndpoints(app) },
new() { Name = "Chat", Port = 5003, ServiceType = typeof(ChatService), ConfigureBuilder = b => b.ConfigureRecNetServices(), MapEndpoints = (app, _) => new ChatService().MapEndpoints(app) },
new() { Name = "Match", Port = 5004, ServiceType = typeof(MatchmakingService), ConfigureBuilder = b => b.ConfigureRecNetServices(), MapEndpoints = (app, _) => new MatchmakingService().MapEndpoints(app) },
new() { Name = "Accounts", Port = 5005, ServiceType = typeof(AccountsService), ConfigureBuilder = b => b.ConfigureRecNetServices(), MapEndpoints = (app, jwt) => new AccountsService().MapEndpoints(app, jwt) },
new() { Name = "Notify", Port = 5006, ServiceType = typeof(NotifyService), ConfigureBuilder = b => b.ConfigureRecNetServices(), MapEndpoints = (app, _) => new NotifyService().MapEndpoints(app) },
new() { Name = "CDN", Port = 5007, ServiceType = typeof(CDNService), ConfigureBuilder = b => b.ConfigureRecNetServices(), MapEndpoints = (app, _) => new CDNService().MapEndpoints(app) },
new() { Name = "Image", Port = 5008, ServiceType = typeof(ImageService), ConfigureBuilder = b => b.ConfigureRecNetServices(), MapEndpoints = (app, _) => new ImageService().MapEndpoints(app) },
new() { Name = "Clubs", Port = 5009, ServiceType = typeof(ClubsService), ConfigureBuilder = b => b.ConfigureRecNetServices(), MapEndpoints = (app, _) => new ClubsService().MapEndpoints(app) },
new() { Name = "Commerce", Port = 5010, ServiceType = typeof(CommerceService), ConfigureBuilder = b => b.ConfigureRecNetServices(), MapEndpoints = (app, _) => new CommerceService().MapEndpoints(app) }
];
}