@@ -1,10 +1,12 @@
|
||||
using Azure.Identity;
|
||||
using Api.Data;
|
||||
using Api.Services;
|
||||
using Api.Services.Contracts;
|
||||
using Api.Settings;
|
||||
using Microsoft.AspNetCore.Diagnostics;
|
||||
using Serilog;
|
||||
using System.Reflection;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
DotNetEnv.Env.Load();
|
||||
|
||||
@@ -69,7 +71,10 @@ try
|
||||
builder.Services.AddHttpClient<IRagApiClient, RagApiClient>();
|
||||
builder.Services.AddHttpClient<IMatcherAiClient, MatcherAiClient>();
|
||||
builder.Services.AddHttpClient<IJobTextExtractor, JobTextExtractor>();
|
||||
builder.Services.AddSingleton<IMatcherRepository, SqlMatcherRepository>();
|
||||
builder.Services.AddDbContext<CvMatcherDbContext>(options =>
|
||||
options.UseSqlServer(builder.Configuration.GetConnectionString("CvMatcherDb")
|
||||
?? throw new InvalidOperationException("Connection string 'CvMatcherDb' is missing.")));
|
||||
builder.Services.AddScoped<IMatcherRepository, EfMatcherRepository>();
|
||||
builder.Services.AddScoped<ICvMatcherService, CvMatcherService>();
|
||||
builder.Services.AddSingleton<IEmailService, EmailService>();
|
||||
|
||||
@@ -160,6 +165,14 @@ try
|
||||
app.MapControllers();
|
||||
app.MapGet("/health", () => Results.Ok(new { status = "ok", service = "cv-matcher-api", version = appVersion, timeUtc = DateTimeOffset.UtcNow }));
|
||||
|
||||
|
||||
Log.Information("Running EfCore DbMigrations if any");
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var db = scope.ServiceProvider.GetRequiredService<CvMatcherDbContext>();
|
||||
db.Database.Migrate();
|
||||
}
|
||||
|
||||
Log.Information("{Service} startup complete", "cv-matcher-api");
|
||||
app.Run();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user