mirror of
https://github.com/meysamhadeli/booking-microservices.git
synced 2026-04-26 07:24:09 +08:00
39 lines
1.2 KiB
C#
39 lines
1.2 KiB
C#
using BuildingBlocks.Core;
|
|
using BuildingBlocks.EFCore;
|
|
using BuildingBlocks.Mapster;
|
|
using BuildingBlocks.Mongo;
|
|
using BuildingBlocks.Web;
|
|
using FluentValidation;
|
|
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Passenger.Data;
|
|
using Passenger.GrpcServer.Services;
|
|
|
|
namespace Passenger.Extensions.Infrastructure;
|
|
|
|
public static class InfrastructureExtensions
|
|
{
|
|
public static WebApplicationBuilder AddPassengerModules(this WebApplicationBuilder builder)
|
|
{
|
|
builder.Services.AddScoped<IEventMapper, PassengerEventMapper>();
|
|
builder.AddMinimalEndpoints(assemblies: typeof(PassengerRoot).Assembly);
|
|
builder.Services.AddValidatorsFromAssembly(typeof(PassengerRoot).Assembly);
|
|
builder.Services.AddCustomMapster(typeof(PassengerRoot).Assembly);
|
|
builder.AddCustomDbContext<PassengerDbContext>(nameof(Passenger));
|
|
builder.AddMongoDbContext<PassengerReadDbContext>();
|
|
|
|
builder.Services.AddCustomMediatR();
|
|
|
|
return builder;
|
|
}
|
|
|
|
|
|
public static WebApplication UsePassengerModules(this WebApplication app)
|
|
{
|
|
app.UseMigration<PassengerDbContext>();
|
|
app.MapGrpcService<PassengerGrpcServices>();
|
|
|
|
return app;
|
|
}
|
|
}
|