diff --git a/src/Server/StellarChat.Server.Api/Extensions.cs b/src/Server/StellarChat.Server.Api/Extensions.cs new file mode 100644 index 0000000..16595cc --- /dev/null +++ b/src/Server/StellarChat.Server.Api/Extensions.cs @@ -0,0 +1,30 @@ +using Mapster; +using MapsterMapper; +using System.Reflection; +using StellarChat.Shared.Infrastructure; + +namespace StellarChat.Server.Api; + +internal static class Extensions +{ + public static void AddInfrastructure(this WebApplicationBuilder builder) + { + builder.AddSharedInfrastructure(); + + builder.Services.AddMappings(); + } + + public static WebApplication UseInfrastructure(this WebApplication app) + => app.UseSharedInfrastructure(); + + public static IServiceCollection AddMappings(this IServiceCollection services) + { + var config = TypeAdapterConfig.GlobalSettings; + config.Scan(Assembly.GetExecutingAssembly()); + + services.AddSingleton(config); + services.AddScoped(); + + return services; + } +} diff --git a/src/Server/StellarChat.Server.Api/Program.cs b/src/Server/StellarChat.Server.Api/Program.cs index 769cd76..24f9b1a 100644 --- a/src/Server/StellarChat.Server.Api/Program.cs +++ b/src/Server/StellarChat.Server.Api/Program.cs @@ -1,11 +1,11 @@ -using StellarChat.Shared.Infrastructure; +using StellarChat.Server.Api; var builder = WebApplication.CreateBuilder(args); -builder.AddSharedInfrastructure(); +builder.AddInfrastructure(); var app = builder.Build(); -app.UseSharedInfrastructure(); +app.UseInfrastructure(); app.Run(); diff --git a/src/Server/StellarChat.Server.Api/StellarChat.Server.Api.csproj b/src/Server/StellarChat.Server.Api/StellarChat.Server.Api.csproj index 919d4e3..256f610 100644 --- a/src/Server/StellarChat.Server.Api/StellarChat.Server.Api.csproj +++ b/src/Server/StellarChat.Server.Api/StellarChat.Server.Api.csproj @@ -9,6 +9,8 @@ + +