55 lines
1.3 KiB
C#
55 lines
1.3 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using PaperlessAI.Context;
|
|
using PaperlessAI.Jobs;
|
|
using PaperlessAI.Repositories;
|
|
using PaperlessAI.Services;
|
|
using Serilog;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Services
|
|
builder.Services.AddScoped<PaperlessDocumentService>();
|
|
builder.Services.AddSingleton<DocumentProcessingService>();
|
|
|
|
// 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();
|
|
|
|
// Jobs
|
|
builder.Services.AddHostedService<CheckDocumentsToProcessJob>();
|
|
|
|
// App
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
app.UseHttpsRedirection();
|
|
app.UseAuthorization();
|
|
app.MapControllers();
|
|
app.Run();
|