mega cleanup :D
This commit is contained in:
+23
-17
@@ -1,9 +1,8 @@
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
||||
using Svrnty.CQRS;
|
||||
using Svrnty.CQRS.Abstractions;
|
||||
using Svrnty.CQRS.FluentValidation;
|
||||
using Svrnty.CQRS.Grpc;
|
||||
using Svrnty.Sample;
|
||||
using Svrnty.Sample.Grpc.Extensions;
|
||||
using Svrnty.CQRS.MinimalApi;
|
||||
using Svrnty.CQRS.DynamicQuery;
|
||||
using Svrnty.CQRS.DynamicQuery.MinimalApi;
|
||||
@@ -19,37 +18,44 @@ builder.WebHost.ConfigureKestrel(options =>
|
||||
options.ListenLocalhost(6001, o => o.Protocols = HttpProtocols.Http1);
|
||||
});
|
||||
|
||||
builder.Services.AddCommand<AddUserCommand, int, AddUserCommandHandler, AddUserCommandValidator>();
|
||||
builder.Services.AddCommand<RemoveUserCommand, RemoveUserCommandHandler>();
|
||||
|
||||
builder.Services.AddQuery<FetchUserQuery, User, FetchUserQueryHandler>();
|
||||
|
||||
// IMPORTANT: Register dynamic query dependencies FIRST
|
||||
// (before AddSvrntyCqrs, so gRPC services can find the handlers)
|
||||
builder.Services.AddTransient<PoweredSoft.Data.Core.IAsyncQueryableService, SimpleAsyncQueryableService>();
|
||||
builder.Services.AddTransient<PoweredSoft.DynamicQuery.Core.IQueryHandlerAsync, PoweredSoft.DynamicQuery.QueryHandlerAsync>();
|
||||
|
||||
builder.Services.AddDynamicQueryWithProvider<User, UserQueryableProvider>();
|
||||
|
||||
builder.Services.AddDefaultCommandDiscovery();
|
||||
builder.Services.AddDefaultQueryDiscovery();
|
||||
// Configure CQRS with fluent API
|
||||
builder.Services.AddSvrntyCqrs(cqrs =>
|
||||
{
|
||||
// Register commands and queries with validators
|
||||
cqrs.AddCommand<AddUserCommand, int, AddUserCommandHandler, AddUserCommandValidator>();
|
||||
cqrs.AddCommand<RemoveUserCommand, RemoveUserCommandHandler>();
|
||||
cqrs.AddQuery<FetchUserQuery, User, FetchUserQueryHandler>();
|
||||
|
||||
// Enable gRPC endpoints with reflection
|
||||
cqrs.AddGrpc(grpc =>
|
||||
{
|
||||
grpc.EnableReflection();
|
||||
});
|
||||
|
||||
// Enable MinimalApi endpoints
|
||||
cqrs.AddMinimalApi();
|
||||
});
|
||||
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
builder.Services.AddGrpcCommandsAndQueries();
|
||||
app.MapGrpcCommandsAndQueries();
|
||||
app.MapGrpcReflectionService();
|
||||
// Map all configured CQRS endpoints (gRPC and MinimalApi)
|
||||
app.UseSvrntyCqrs();
|
||||
|
||||
// Map dynamic queries manually for now
|
||||
app.MapSvrntyDynamicQueries();
|
||||
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
|
||||
app.MapSvrntyCommands();
|
||||
app.MapSvrntyQueries();
|
||||
app.MapSvrntyDynamicQueries();
|
||||
|
||||
|
||||
Console.WriteLine("Auto-Generated gRPC Server with Reflection, Validation, MinimalApi and Swagger");
|
||||
Console.WriteLine("gRPC (HTTP/2): http://localhost:6000");
|
||||
|
||||
Reference in New Issue
Block a user