-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
55 lines (40 loc) · 1.79 KB
/
Program.cs
File metadata and controls
55 lines (40 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using EventSourcingMedium.API.Models;
using EventSourcingMedium.API.Services.EventStreaming;
using EventSourcingMedium.API.Services.PostInformationServices.CommandService;
using EventSourcingMedium.API.Services.PostInformationServices.QueryService;
using EventStore.Client;
using EventStore.ClientAPI;
using Microsoft.EntityFrameworkCore;
using System.Reflection;
var builder = WebApplication.CreateBuilder(args);
var connectionString = builder.Configuration.GetConnectionString("DbConnection");
builder.Services.AddDbContextPool<AppDbContext>(db => db.UseSqlServer(connectionString));
builder.Services.AddScoped<IPostInformationCommandService, PostInformationCommandService>();
builder.Services.AddScoped<IPostInformationQueryService, PostInformationQueryService>();
builder.Services.AddScoped<IEventStoreService, EventStoreService>();
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
//var eventConnectionString = EventStoreConnection.Create(
// connectionString: EventStoreDB.ConnectionString);
//eventConnectionString.ConnectAsync().GetAwaiter().GetResult();
//builder.Services.AddSingleton(eventConnectionString);
var client = EventStoreClientSettings.Create(EventStoreDB.ConnectionString);
builder.Services.AddSingleton(client);
builder.Services.AddMediatR(cfg =>
{
cfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly());
});
// Add services to the container.
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddControllers();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.MapControllers();
app.Run();