Files
hrynco-notification-service/HrynCo.NotificationService.Api/Program.cs
T
Anatolii Grynchuk 4ea57b2068 feat: introduce AppSettings per application
- AppSettings class in Api and Worker with SectionName constant
- appsettings.json: replaced ConnectionStrings section with App section
- Program.cs: bind AppSettings at startup, register as singleton
- Connection string now sourced from AppSettings.ConnectionString

Ref: IT-628

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-02 00:30:19 +03:00

28 lines
844 B
C#

using HrynCo.NotificationService.Api;
using HrynCo.NotificationService.DAL.EF;
using HrynCo.NotificationService.Services;
using Serilog;
var builder = WebApplication.CreateBuilder(args);
builder.Host.UseSerilog((context, lc) =>
lc.ReadFrom.Configuration(context.Configuration));
var appSettings = builder.Configuration
.GetSection(AppSettings.SectionName)
.Get<AppSettings>() ?? throw new InvalidOperationException("App settings are not configured.");
builder.Services.AddSingleton(appSettings);
builder.Services.AddOpenApi();
builder.Services.AddControllers();
builder.Services.AddNotificationDataAccess(appSettings.ConnectionString);
builder.Services.AddNotificationServices();
var app = builder.Build();
if (app.Environment.IsDevelopment())
app.MapOpenApi();
app.UseHttpsRedirection();
app.MapControllers();
app.Run();