Database migration, repository, controller and service

This commit is contained in:
Nickk888 committed 2026-10-09 16:32:38 +02:00
1 parent 07e4e6b381
commit 4fb8768807
17 files changed
+368 -44

No files matched your search

+27 -6
View File
@@ -1,28 +1,49 @@
using Microsoft.EntityFrameworkCore;
using PaperlessAI.Context;
using PaperlessAI.Repositories;
using PaperlessAI.Services;
using Serilog;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
// Services
builder.Services.AddScoped<PaperlessDocumentService>();
// Repositories
builder.Services.AddScoped<PaperlessDocumentRepository>();
// Other
builder.Services.AddControllers();
// Database
builder.Services.AddDbContextPool<MyDbContext>(options =>
{
options.UseMySql(
builder.Configuration.GetConnectionString("MariaDbConnectionString"),
ServerVersion.Parse("12.0.2-mariadb")
);
)
.LogTo(Console.WriteLine, LogLevel.Information)
.EnableSensitiveDataLogging()
.EnableDetailedErrors();
});
// Logging
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.Console()
.WriteTo.File(
Path.Combine(AppContext.BaseDirectory, "logs", "log-.txt"),
rollingInterval: RollingInterval.Day,
retainedFileCountLimit: 30)
.CreateLogger();
builder.Host.UseSerilog();
// App
var app = builder.Build();
// Configure the HTTP request pipeline.
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();