51 lines
1.2 KiB
C#
51 lines
1.2 KiB
C#
using FinancialApi;
|
|
using FinancialApi.Infrastructure;
|
|
using FinancialApi.ServiceDefaults;
|
|
using JasperFx.CodeGeneration;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Wolverine;
|
|
using Wolverine.EntityFrameworkCore;
|
|
using Wolverine.Sqlite;
|
|
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
builder.Services.AddDbContext<AccountDbContext>(options =>
|
|
options.UseSqlite("Data Source=demo.db"));
|
|
|
|
// Add services to the container.
|
|
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
|
|
builder.Services.AddOpenApi();
|
|
|
|
builder.AddServiceDefaults();
|
|
|
|
builder.Host.UseWolverine(opts =>
|
|
{
|
|
opts.PersistMessagesWithSqlite("Data Source=demo.db");
|
|
opts.UseEntityFrameworkCoreTransactions();
|
|
});
|
|
|
|
var app = builder.Build();
|
|
|
|
using (var scope = app.Services.CreateScope())
|
|
{
|
|
var db = scope.ServiceProvider.GetRequiredService<AccountDbContext>();
|
|
await db.Database.MigrateAsync();
|
|
}
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.MapOpenApi();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
app.MapPost("/accounts/apply-fee", async (ApplyFeeCommand cmd, IMessageBus bus) =>
|
|
{
|
|
await bus.InvokeAsync(cmd);
|
|
return Results.Accepted();
|
|
});
|
|
|
|
app.Run();
|