Reformat all code as per my preferred formatting.

This commit is contained in:
2026-07-17 17:14:44 +02:00
parent 29d179a23a
commit 249a166d07
13 changed files with 181 additions and 169 deletions
@@ -19,8 +19,7 @@ builder.Services.AddProblemDetails();
var connectionString = "Data Source=demo.db";
builder.Services.AddDbContext<AccountDbContext>(options =>
options.UseSqlite(connectionString));
builder.Services.AddDbContext<AccountDbContext>(options => options.UseSqlite(connectionString));
builder.Services.AddScoped<IAccountQuery, AccountQuery>();
builder.Services.AddScoped<IReversalQuery, ReversalQuery>();
@@ -33,13 +32,14 @@ builder.Services.AddOpenApi();
builder.AddServiceDefaults();
builder.Host.UseWolverine(opts =>
{
opts.Discovery.IncludeAssembly(typeof(DemoEventStore).Assembly);
opts.Discovery.IncludeAssembly(typeof(ApplyFeeHandler).Assembly);
opts.PersistMessagesWithSqlite(connectionString);
opts.UseEntityFrameworkCoreTransactions();
opts.Policies.AutoApplyTransactions();
});
{
opts.Discovery.IncludeAssembly(typeof(DemoEventStore).Assembly);
opts.Discovery.IncludeAssembly(typeof(ApplyFeeHandler).Assembly);
opts.PersistMessagesWithSqlite(connectionString);
opts.UseEntityFrameworkCoreTransactions();
opts.Policies.AutoApplyTransactions();
}
);
builder.Host.UseResourceSetupOnStartup();
var app = builder.Build();
@@ -60,32 +60,44 @@ if (app.Environment.IsDevelopment())
app.UseHttpsRedirection();
app.MapPost("/accounts/apply-fee", async (ApplyFeeCommand cmd, IMessageBus bus) =>
{
await bus.InvokeAsync(cmd);
return Results.Accepted();
});
app.MapPost("/accounts/transfer", async (TransferFundsCommand cmd, IMessageBus bus) =>
{
await bus.InvokeAsync(cmd);
return Results.Accepted();
});
app.MapPost("/journal/reverse", async (ReverseJournalCommand cmd, IMessageBus bus) =>
{
await bus.InvokeAsync(cmd);
return Results.Accepted();
});
app.MapGet("/events", (IEventTracker tracker) =>
{
if (tracker is DemoEventStore store)
app.MapPost(
"/accounts/apply-fee",
async (ApplyFeeCommand cmd, IMessageBus bus) =>
{
return Results.Ok(store.CapturedEvents);
await bus.InvokeAsync(cmd);
return Results.Accepted();
}
);
return Results.NotFound();
});
app.MapPost(
"/accounts/transfer",
async (TransferFundsCommand cmd, IMessageBus bus) =>
{
await bus.InvokeAsync(cmd);
return Results.Accepted();
}
);
app.MapPost(
"/journal/reverse",
async (ReverseJournalCommand cmd, IMessageBus bus) =>
{
await bus.InvokeAsync(cmd);
return Results.Accepted();
}
);
app.MapGet(
"/events",
(IEventTracker tracker) =>
{
if (tracker is DemoEventStore store)
{
return Results.Ok(store.CapturedEvents);
}
return Results.NotFound();
}
);
app.Run();