2026-06-09 06:41:28 +03:30
|
|
|
using Microsoft.AspNetCore.Routing;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2026-06-10 01:16:37 +03:30
|
|
|
using TeamUp.SharedKernel.Modularity;
|
2026-06-09 06:41:28 +03:30
|
|
|
|
|
|
|
|
namespace TeamUp.Bootstrap;
|
|
|
|
|
|
|
|
|
|
public static class TeamUpModuleExtensions
|
|
|
|
|
{
|
|
|
|
|
/// <summary>Runs every module's <c>Register</c>. Called by BOTH hosts.</summary>
|
|
|
|
|
public static IServiceCollection AddTeamUpModules(
|
|
|
|
|
this IServiceCollection services,
|
|
|
|
|
IConfiguration configuration)
|
|
|
|
|
{
|
|
|
|
|
foreach (var module in ModuleCatalog.All)
|
|
|
|
|
{
|
|
|
|
|
module.Register(services, configuration);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return services;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>Runs every module's <c>MapEndpoints</c>. Called by the WEB host only.</summary>
|
|
|
|
|
public static IEndpointRouteBuilder MapTeamUpModules(this IEndpointRouteBuilder endpoints)
|
|
|
|
|
{
|
|
|
|
|
foreach (var module in ModuleCatalog.All)
|
|
|
|
|
{
|
|
|
|
|
module.MapEndpoints(endpoints);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return endpoints;
|
|
|
|
|
}
|
2026-06-10 01:16:37 +03:30
|
|
|
|
|
|
|
|
/// <summary>Runs <c>RegisterWorker</c> for modules with background services. WORKER host only.</summary>
|
|
|
|
|
public static IServiceCollection AddTeamUpWorkerServices(
|
|
|
|
|
this IServiceCollection services,
|
|
|
|
|
IConfiguration configuration)
|
|
|
|
|
{
|
|
|
|
|
foreach (var module in ModuleCatalog.All)
|
|
|
|
|
{
|
|
|
|
|
if (module is IWorkerModule workerModule)
|
|
|
|
|
{
|
|
|
|
|
workerModule.RegisterWorker(services, configuration);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return services;
|
|
|
|
|
}
|
2026-06-09 06:41:28 +03:30
|
|
|
}
|