Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
57 lines (43 loc) · 1.54 KB
/
Copy pathProgram.cs
File metadata and controls
57 lines (43 loc) · 1.54 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
56
57
using Bas24.CommandQuery;
using Bas24.CommandQuery.Notifications;
using Sample;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddLogging(logging =>
{
logging.ClearProviders();
logging.AddConsole(options =>
{
options.LogToStandardErrorThreshold = LogLevel.Debug;
});
logging.AddDebug();
logging.SetMinimumLevel(LogLevel.Debug); // Important!
});
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddScoped<IUserRepository, UserRepository>();
builder.Services.AddTransient<IEmailService, EmailService>();
builder.Services.AddTransient<ISmsService, SmsService>();
// Add mediator with the assembly containing handlers
builder.Services.AddCommandQuery(cq =>
{
cq.RegisterAssembly(typeof(Program).Assembly);
cq.NotificationPublisher = new MultipleNotificationPublisher();
cq.NotificationPublisherType = typeof(MultipleNotificationPublisher);
cq.AddBehavior(typeof(LoggingPipelineBehavior<,>));
cq.AddRequestPreProcessor(typeof(GenericRequestPreProcessor<>));
cq.AddRequestPostProcessor(typeof(GenericRequestPostProcessor<,>));
});
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
await app.RunAsync();