Migrate from MongoDB to Couchbase Lite for local storage; update related services and configurations
Some checks failed
Publish Container / publish (push) Failing after 3m43s

This commit is contained in:
Maddo 2026-03-17 13:53:33 +01:00
commit f976d70db8
24 changed files with 328 additions and 218 deletions

View file

@ -5,12 +5,12 @@ using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Localization;
using Microsoft.Extensions.Options;
using MongoDB.Driver;
using WorkTracker.Components;
using WorkTracker.Configuration;
using WorkTracker.Services.Auth;
using WorkTracker.Services.Festivities;
using WorkTracker.Services.Settings;
using WorkTracker.Services.Storage;
var builder = WebApplication.CreateBuilder(args);
@ -33,24 +33,12 @@ builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationSc
builder.Services.AddLocalization();
builder.Services.Configure<MongoDbOptions>(builder.Configuration.GetSection(MongoDbOptions.SectionName));
builder.Services.Configure<CouchbaseLiteOptions>(builder.Configuration.GetSection(CouchbaseLiteOptions.SectionName));
builder.Services.Configure<SingleUserOptions>(builder.Configuration.GetSection(SingleUserOptions.SectionName));
builder.Services.AddSingleton<IMongoClient>(sp =>
{
var options = sp.GetRequiredService<IOptions<MongoDbOptions>>().Value;
return new MongoClient(options.ConnectionString);
});
builder.Services.AddSingleton(sp =>
{
var options = sp.GetRequiredService<IOptions<MongoDbOptions>>().Value;
var mongoClient = sp.GetRequiredService<IMongoClient>();
return mongoClient.GetDatabase(options.DatabaseName);
});
builder.Services.AddScoped<IAppSettingsService, MongoAppSettingsService>();
builder.Services.AddSingleton<IMongoAuthService, MongoAuthService>();
builder.Services.AddSingleton<CouchbaseLiteDatabaseProvider>();
builder.Services.AddScoped<IAppSettingsService, CouchbaseLiteAppSettingsService>();
builder.Services.AddSingleton<IAuthService, CouchbaseLiteAuthService>();
builder.Services.AddSingleton<IItalianFestivitySource, ItalianFestivitySource>();
builder.Services.AddHostedService<SingleUserSeedService>();
@ -88,7 +76,7 @@ app.UseAuthorization();
app.UseAntiforgery();
app.MapPost("/login", async (HttpContext context, IMongoAuthService authService) =>
app.MapPost("/login", async (HttpContext context, IAuthService authService) =>
{
var form = await context.Request.ReadFormAsync();
var email = form["email"].ToString();