using Microsoft.AspNetCore.Server.Kestrel.Core; using Svrnty.CQRS; using Svrnty.CQRS.Abstractions; using Svrnty.CQRS.FluentValidation; using Svrnty.Sample; using Svrnty.Sample.Grpc.Extensions; using Svrnty.CQRS.MinimalApi; using Svrnty.CQRS.DynamicQuery; using Svrnty.CQRS.DynamicQuery.MinimalApi; var builder = WebApplication.CreateBuilder(args); // Configure Kestrel to support both HTTP/1.1 (for REST APIs) and HTTP/2 (for gRPC) builder.WebHost.ConfigureKestrel(options => { // Port 6000: HTTP/2 for gRPC options.ListenLocalhost(6000, o => o.Protocols = HttpProtocols.Http2); // Port 6001: HTTP/1.1 for REST API options.ListenLocalhost(6001, o => o.Protocols = HttpProtocols.Http1); }); builder.Services.AddCommand(); builder.Services.AddCommand(); builder.Services.AddQuery(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddDynamicQueryWithProvider(); builder.Services.AddDefaultCommandDiscovery(); builder.Services.AddDefaultQueryDiscovery(); builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); var app = builder.Build(); builder.Services.AddGrpcCommandsAndQueries(); app.MapGrpcCommandsAndQueries(); app.MapGrpcReflectionService(); 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"); Console.WriteLine("HTTP API (HTTP/1.1): http://localhost:6001/api/command/* and http://localhost:6001/api/query/*"); Console.WriteLine("Swagger UI: http://localhost:6001/swagger"); app.Run();