* Fixed registration issues
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
This commit is contained in:
@@ -1,21 +1,43 @@
|
||||
using System.Reflection;
|
||||
using HeartBeatClients;
|
||||
using FaKrosnoEfDataModel;
|
||||
using HeartBeatClients.Core;
|
||||
using HeartBeatClients.Models;
|
||||
using HeartBeatClients.Services;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Services.Vault;
|
||||
using SytelineSaAppEfDataModel;
|
||||
using MappingProfile = FaKrosnoEfDataModel.MappingProfile;
|
||||
|
||||
IHost? host = null;
|
||||
|
||||
try
|
||||
{
|
||||
var builder = Host.CreateDefaultBuilder(args)
|
||||
.ConfigureServices((context, services) =>
|
||||
.ConfigureAppConfiguration((_, config) =>
|
||||
{
|
||||
// Register dependencies here if needed
|
||||
config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
|
||||
})
|
||||
.ConfigureServices((_, services) =>
|
||||
{
|
||||
var vaultUrl = Environment.GetEnvironmentVariable("VAULT_URL") ?? "http://vault:8200";
|
||||
var vaultToken = Environment.GetEnvironmentVariable("VAULT_TOKEN") ?? "dev-only-token";
|
||||
var vaultService = new VaultService(vaultUrl, vaultToken);
|
||||
|
||||
var sytelineConnection = vaultService.GetSecretAsync("database/syteline_prod", "connection_string").GetAwaiter().GetResult();
|
||||
var faKrosnoConnection = vaultService.GetSecretAsync("database/fakrosno", "connection_string").GetAwaiter().GetResult();
|
||||
|
||||
services.AddDbContext<SytelineSaAppDbContext>(options => options.UseSqlServer(sytelineConnection));
|
||||
services.AddDbContext<FaKrosnoDbContext>(options => options.UseSqlServer(faKrosnoConnection));
|
||||
|
||||
services.AddAutoMapper(typeof(MappingProfile), typeof(SytelineSaAppEfDataModel.MappingProfile));
|
||||
services.AddSingleton<IVaultService>(vaultService);
|
||||
services.AddScoped<IEmailGeneratorService, EmailGeneratorService>();
|
||||
services.AddScoped<IHeartBeatDecisionService, HeartBeatDecisionService>();
|
||||
services.AddScoped<IApp, App>();
|
||||
});
|
||||
|
||||
host = builder.Build();
|
||||
|
||||
Reference in New Issue
Block a user