47 lines
1.2 KiB
C#
47 lines
1.2 KiB
C#
using Bibblan.Business.Services;
|
|
using Bibblan.Models;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Options;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
builder.Configuration.AddJsonFile($"appsettings.user.json", true, true);
|
|
|
|
var configSection = builder.Configuration.GetSection(BibblanOptions.Bibblan);
|
|
BibblanOptions config = new();
|
|
configSection.Bind(config);
|
|
// Add services to the container.
|
|
builder.Services.Configure<BibblanOptions>(configSection);
|
|
|
|
builder.Services.AddScoped<CalibreService, CalibreService>();
|
|
|
|
|
|
builder.Services.AddControllers();
|
|
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
|
|
builder.Services.AddOpenApi();
|
|
|
|
|
|
builder.Services.AddDbContext<SqliteCalibreContext>(options => options.UseSqlite($"Data Source={config.CalibreDb};Mode=ReadOnly;"));
|
|
builder.Services.AddDbContext<PostgresCalibreContext>(options => options.UseNpgsql(config.BibblanConnection));
|
|
|
|
|
|
var app = builder.Build();
|
|
|
|
app.UseDefaultFiles();
|
|
app.MapStaticAssets();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.MapOpenApi();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
app.UseAuthorization();
|
|
|
|
app.MapControllers();
|
|
|
|
app.MapFallbackToFile("/index.html");
|
|
|
|
app.Run();
|