Project Init
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
46
colaflow-api/src/ColaFlow.API/Extensions/ModuleExtensions.cs
Normal file
46
colaflow-api/src/ColaFlow.API/Extensions/ModuleExtensions.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using FluentValidation;
|
||||
using MediatR;
|
||||
using ColaFlow.Modules.ProjectManagement.Application.Behaviors;
|
||||
using ColaFlow.Modules.ProjectManagement.Application.Commands.CreateProject;
|
||||
using ColaFlow.Modules.ProjectManagement.Domain.Repositories;
|
||||
using ColaFlow.Modules.ProjectManagement.Infrastructure.Persistence;
|
||||
using ColaFlow.Modules.ProjectManagement.Infrastructure.Repositories;
|
||||
|
||||
namespace ColaFlow.API.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for registering modules
|
||||
/// </summary>
|
||||
public static class ModuleExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Register ProjectManagement Module
|
||||
/// </summary>
|
||||
public static IServiceCollection AddProjectManagementModule(
|
||||
this IServiceCollection services,
|
||||
IConfiguration configuration)
|
||||
{
|
||||
// Register DbContext
|
||||
var connectionString = configuration.GetConnectionString("PMDatabase");
|
||||
services.AddDbContext<PMDbContext>(options =>
|
||||
options.UseNpgsql(connectionString));
|
||||
|
||||
// Register repositories
|
||||
services.AddScoped<IProjectRepository, ProjectRepository>();
|
||||
services.AddScoped<IUnitOfWork, UnitOfWork>();
|
||||
|
||||
// Register MediatR handlers from Application assembly
|
||||
services.AddMediatR(typeof(CreateProjectCommand).Assembly);
|
||||
|
||||
// Register FluentValidation validators
|
||||
services.AddValidatorsFromAssembly(typeof(CreateProjectCommand).Assembly);
|
||||
|
||||
// Register pipeline behaviors
|
||||
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehavior<,>));
|
||||
|
||||
Console.WriteLine("[ProjectManagement] Module registered");
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user