56 lines
1.6 KiB
C#
56 lines
1.6 KiB
C#
using Asentrafin.Api.Data;
|
|
using Asentrafin.Api.Configuration;
|
|
using Asentrafin.Api.Services.Plaid;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add services to the container.
|
|
|
|
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection")
|
|
?? throw new InvalidOperationException("Connection string 'DefaultConnection' was not found.");
|
|
|
|
builder.Services.AddDbContextPool<AppDbContext>(options =>
|
|
options.UseNpgsql(connectionString));
|
|
|
|
builder.Services.Configure<PlaidOptions>(builder.Configuration.GetSection("Plaid"));
|
|
builder.Services.AddHttpClient<IPlaidClient, PlaidClient>((serviceProvider, client) =>
|
|
{
|
|
var options = serviceProvider.GetRequiredService<Microsoft.Extensions.Options.IOptions<PlaidOptions>>().Value;
|
|
client.BaseAddress = new Uri(options.BaseUrl);
|
|
});
|
|
builder.Services.AddScoped<IPlaidIngestionService, PlaidIngestionService>();
|
|
|
|
builder.Services.AddControllers();
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
builder.Services.AddSwaggerGen(options =>
|
|
{
|
|
options.SwaggerDoc("v1", new()
|
|
{
|
|
Title = "Asentrafin API",
|
|
Version = "v1",
|
|
Description = "REST API for Asentrafin"
|
|
});
|
|
});
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.UseSwagger();
|
|
app.UseSwaggerUI(options =>
|
|
{
|
|
options.RoutePrefix = "swagger";
|
|
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Asentrafin API v1");
|
|
});
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
app.UseAuthorization();
|
|
|
|
app.MapControllers();
|
|
|
|
app.Run();
|